blob: ff2d806eaef71bc2a7a861a8971c228cd6856e2a [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanbf670442013-01-01 16:00:01 +00004 Copyright(c) 1999 - 2013 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
Bruce Allane921eb12012-11-28 09:28:37 +000029/* 80003ES2LAN Gigabit Ethernet Controller (Copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -070030 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
31 */
32
Auke Kokbc7f75f2007-09-17 12:30:59 -070033#include "e1000.h"
34
Bruce Allane921eb12012-11-28 09:28:37 +000035/* A table for the GG82563 cable length where the range is defined
Auke Kokbc7f75f2007-09-17 12:30:59 -070036 * with a lower bound at "index" and the upper bound at
37 * "index + 5".
38 */
Bruce Allan64806412010-12-11 05:53:42 +000039static const u16 e1000_gg82563_cable_length_table[] = {
Bruce Allan04e115c2013-02-20 04:06:22 +000040 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF
41};
Bruce Allanfc830b72013-02-20 04:06:11 +000042
Bruce Allaneb656d42009-12-01 15:47:02 +000043#define GG82563_CABLE_LENGTH_TABLE_SIZE \
44 ARRAY_SIZE(e1000_gg82563_cable_length_table)
Auke Kokbc7f75f2007-09-17 12:30:59 -070045
46static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
47static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
48static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
49static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
50static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
51static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
52static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
Bruce Allan1f96012d2013-01-05 03:06:54 +000053static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
54 u16 *data);
55static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
56 u16 data);
Bruce Allan17f208d2009-12-01 15:47:22 +000057static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070058
59/**
60 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
61 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070062 **/
63static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
64{
65 struct e1000_phy_info *phy = &hw->phy;
66 s32 ret_val;
67
Jeff Kirsher318a94d2008-03-28 09:15:16 -070068 if (hw->phy.media_type != e1000_media_type_copper) {
Bruce Allane80bd1d2013-05-01 01:19:46 +000069 phy->type = e1000_phy_none;
Auke Kokbc7f75f2007-09-17 12:30:59 -070070 return 0;
Bruce Allan17f208d2009-12-01 15:47:22 +000071 } else {
72 phy->ops.power_up = e1000_power_up_phy_copper;
73 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -070074 }
75
Bruce Allane80bd1d2013-05-01 01:19:46 +000076 phy->addr = 1;
77 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
78 phy->reset_delay_us = 100;
79 phy->type = e1000_phy_gg82563;
Auke Kokbc7f75f2007-09-17 12:30:59 -070080
81 /* This can only be done after all function pointers are setup. */
82 ret_val = e1000e_get_phy_id(hw);
83
84 /* Verify phy id */
85 if (phy->id != GG82563_E_PHY_ID)
86 return -E1000_ERR_PHY;
87
88 return ret_val;
89}
90
91/**
92 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
93 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070094 **/
95static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
96{
97 struct e1000_nvm_info *nvm = &hw->nvm;
98 u32 eecd = er32(EECD);
99 u16 size;
100
Bruce Allane80bd1d2013-05-01 01:19:46 +0000101 nvm->opcode_bits = 8;
102 nvm->delay_usec = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700103 switch (nvm->override) {
104 case e1000_nvm_override_spi_large:
Bruce Allane80bd1d2013-05-01 01:19:46 +0000105 nvm->page_size = 32;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700106 nvm->address_bits = 16;
107 break;
108 case e1000_nvm_override_spi_small:
Bruce Allane80bd1d2013-05-01 01:19:46 +0000109 nvm->page_size = 8;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700110 nvm->address_bits = 8;
111 break;
112 default:
Bruce Allane80bd1d2013-05-01 01:19:46 +0000113 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700114 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
115 break;
116 }
117
Bruce Allanad680762008-03-28 09:15:03 -0700118 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700119
120 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
Bruce Allanf0ff4392013-02-20 04:05:39 +0000121 E1000_EECD_SIZE_EX_SHIFT);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700122
Bruce Allane921eb12012-11-28 09:28:37 +0000123 /* Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700124 * for setting word_size.
125 */
126 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700127
128 /* EEPROM access above 16k is unsupported */
129 if (size > 14)
130 size = 14;
Bruce Allane80bd1d2013-05-01 01:19:46 +0000131 nvm->word_size = 1 << size;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700132
133 return 0;
134}
135
136/**
137 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
138 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700139 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000140static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700141{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700142 struct e1000_mac_info *mac = &hw->mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700143
Bruce Allane68782e2012-01-31 06:37:43 +0000144 /* Set media type and media-dependent function pointers */
Bruce Allanec34c172012-02-01 10:53:05 +0000145 switch (hw->adapter->pdev->device) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700146 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700147 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allane68782e2012-01-31 06:37:43 +0000148 mac->ops.check_for_link = e1000e_check_for_serdes_link;
149 mac->ops.setup_physical_interface =
150 e1000e_setup_fiber_serdes_link;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700151 break;
152 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700153 hw->phy.media_type = e1000_media_type_copper;
Bruce Allane68782e2012-01-31 06:37:43 +0000154 mac->ops.check_for_link = e1000e_check_for_copper_link;
155 mac->ops.setup_physical_interface =
156 e1000_setup_copper_link_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700157 break;
158 }
159
160 /* Set mta register count */
161 mac->mta_reg_count = 128;
162 /* Set rar entry count */
163 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allana65a4a02010-05-10 15:01:51 +0000164 /* FWSM register */
165 mac->has_fwsm = true;
166 /* ARC supported; valid only if manageability features are enabled. */
Bruce Allan04499ec2012-04-13 00:08:31 +0000167 mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
Bruce Allanf464ba82010-01-07 16:31:35 +0000168 /* Adaptive IFS not supported */
169 mac->adaptive_ifs = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700170
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000171 /* set lan id for port to determine which phy lock to use */
172 hw->mac.ops.set_lan_id(hw);
173
Auke Kokbc7f75f2007-09-17 12:30:59 -0700174 return 0;
175}
176
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700177static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700178{
179 struct e1000_hw *hw = &adapter->hw;
180 s32 rc;
181
Bruce Allanec34c172012-02-01 10:53:05 +0000182 rc = e1000_init_mac_params_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700183 if (rc)
184 return rc;
185
186 rc = e1000_init_nvm_params_80003es2lan(hw);
187 if (rc)
188 return rc;
189
190 rc = e1000_init_phy_params_80003es2lan(hw);
191 if (rc)
192 return rc;
193
194 return 0;
195}
196
197/**
198 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
199 * @hw: pointer to the HW structure
200 *
Bruce Allanfe401672009-11-20 23:26:05 +0000201 * A wrapper to acquire access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700202 **/
203static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
204{
205 u16 mask;
206
207 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700208 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
209}
210
211/**
212 * e1000_release_phy_80003es2lan - Release rights to access PHY
213 * @hw: pointer to the HW structure
214 *
Bruce Allanfe401672009-11-20 23:26:05 +0000215 * A wrapper to release access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700216 **/
217static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
218{
219 u16 mask;
220
221 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800222 e1000_release_swfw_sync_80003es2lan(hw, mask);
223}
224
225/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000226 * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800227 * @hw: pointer to the HW structure
228 *
229 * Acquire the semaphore to access the Kumeran interface.
230 *
231 **/
232static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
233{
234 u16 mask;
235
236 mask = E1000_SWFW_CSR_SM;
237
238 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
239}
240
241/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000242 * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800243 * @hw: pointer to the HW structure
244 *
245 * Release the semaphore used to access the Kumeran interface
246 **/
247static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
248{
249 u16 mask;
250
251 mask = E1000_SWFW_CSR_SM;
David Graham2d9498f2008-04-23 11:09:14 -0700252
Auke Kokbc7f75f2007-09-17 12:30:59 -0700253 e1000_release_swfw_sync_80003es2lan(hw, mask);
254}
255
256/**
257 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
258 * @hw: pointer to the HW structure
259 *
Bruce Allanfe401672009-11-20 23:26:05 +0000260 * Acquire the semaphore to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700261 **/
262static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
263{
264 s32 ret_val;
265
266 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
267 if (ret_val)
268 return ret_val;
269
270 ret_val = e1000e_acquire_nvm(hw);
271
272 if (ret_val)
273 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
274
275 return ret_val;
276}
277
278/**
279 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
280 * @hw: pointer to the HW structure
281 *
Bruce Allanfe401672009-11-20 23:26:05 +0000282 * Release the semaphore used to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700283 **/
284static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
285{
286 e1000e_release_nvm(hw);
287 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
288}
289
290/**
291 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
292 * @hw: pointer to the HW structure
293 * @mask: specifies which semaphore to acquire
294 *
295 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
296 * will also specify which port we're acquiring the lock for.
297 **/
298static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
299{
300 u32 swfw_sync;
301 u32 swmask = mask;
302 u32 fwmask = mask << 16;
303 s32 i = 0;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800304 s32 timeout = 50;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700305
306 while (i < timeout) {
307 if (e1000e_get_hw_semaphore(hw))
308 return -E1000_ERR_SWFW_SYNC;
309
310 swfw_sync = er32(SW_FW_SYNC);
311 if (!(swfw_sync & (fwmask | swmask)))
312 break;
313
Bruce Allane921eb12012-11-28 09:28:37 +0000314 /* Firmware currently using resource (fwmask)
Bruce Allanad680762008-03-28 09:15:03 -0700315 * or other software thread using resource (swmask)
316 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700317 e1000e_put_hw_semaphore(hw);
318 mdelay(5);
319 i++;
320 }
321
322 if (i == timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000323 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700324 return -E1000_ERR_SWFW_SYNC;
325 }
326
327 swfw_sync |= swmask;
328 ew32(SW_FW_SYNC, swfw_sync);
329
330 e1000e_put_hw_semaphore(hw);
331
332 return 0;
333}
334
335/**
336 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
337 * @hw: pointer to the HW structure
338 * @mask: specifies which semaphore to acquire
339 *
340 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
341 * will also specify which port we're releasing the lock for.
342 **/
343static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
344{
345 u32 swfw_sync;
346
Bruce Allan184125a2010-12-11 05:53:37 +0000347 while (e1000e_get_hw_semaphore(hw) != 0)
348 ; /* Empty */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700349
350 swfw_sync = er32(SW_FW_SYNC);
351 swfw_sync &= ~mask;
352 ew32(SW_FW_SYNC, swfw_sync);
353
354 e1000e_put_hw_semaphore(hw);
355}
356
357/**
358 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
359 * @hw: pointer to the HW structure
360 * @offset: offset of the register to read
361 * @data: pointer to the data returned from the operation
362 *
Bruce Allanfe401672009-11-20 23:26:05 +0000363 * Read the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700364 **/
365static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
366 u32 offset, u16 *data)
367{
368 s32 ret_val;
369 u32 page_select;
370 u16 temp;
371
David Graham2d9498f2008-04-23 11:09:14 -0700372 ret_val = e1000_acquire_phy_80003es2lan(hw);
373 if (ret_val)
374 return ret_val;
375
Auke Kokbc7f75f2007-09-17 12:30:59 -0700376 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700377 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700378 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700379 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000380 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700381 * registers 30 and 31
382 */
383 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700384 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700385
386 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700387 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
388 if (ret_val) {
389 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700390 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700391 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700392
Bruce Allanb4d8e212012-02-17 03:17:55 +0000393 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000394 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000395 * before the device has completed the "Page Select" MDI
396 * transaction. So we wait 200us after each MDI command...
397 */
Bruce Allance43a212013-02-20 04:06:32 +0000398 usleep_range(200, 400);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700399
Bruce Allan3421eec2009-12-08 07:28:20 +0000400 /* ...and verify the command was successful. */
401 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700402
Bruce Allan3421eec2009-12-08 07:28:20 +0000403 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
Bruce Allan3421eec2009-12-08 07:28:20 +0000404 e1000_release_phy_80003es2lan(hw);
Bruce Allan7eb61d82012-02-08 02:55:03 +0000405 return -E1000_ERR_PHY;
Bruce Allan3421eec2009-12-08 07:28:20 +0000406 }
407
Bruce Allance43a212013-02-20 04:06:32 +0000408 usleep_range(200, 400);
Bruce Allan3421eec2009-12-08 07:28:20 +0000409
410 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000411 MAX_PHY_REG_ADDRESS & offset,
412 data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000413
Bruce Allance43a212013-02-20 04:06:32 +0000414 usleep_range(200, 400);
Bruce Allan3421eec2009-12-08 07:28:20 +0000415 } else {
416 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000417 MAX_PHY_REG_ADDRESS & offset,
418 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700419 }
420
David Graham2d9498f2008-04-23 11:09:14 -0700421 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700422
423 return ret_val;
424}
425
426/**
427 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
428 * @hw: pointer to the HW structure
429 * @offset: offset of the register to read
430 * @data: value to write to the register
431 *
Bruce Allanfe401672009-11-20 23:26:05 +0000432 * Write to the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700433 **/
434static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
435 u32 offset, u16 data)
436{
437 s32 ret_val;
438 u32 page_select;
439 u16 temp;
440
David Graham2d9498f2008-04-23 11:09:14 -0700441 ret_val = e1000_acquire_phy_80003es2lan(hw);
442 if (ret_val)
443 return ret_val;
444
Auke Kokbc7f75f2007-09-17 12:30:59 -0700445 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700446 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700447 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700448 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000449 /* 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 Allanb4d8e212012-02-17 03:17:55 +0000462 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000463 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000464 * before the device has completed the "Page Select" MDI
465 * transaction. So we wait 200us after each MDI command...
466 */
Bruce Allance43a212013-02-20 04:06:32 +0000467 usleep_range(200, 400);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700468
Bruce Allan3421eec2009-12-08 07:28:20 +0000469 /* ...and verify the command was successful. */
470 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700471
Bruce Allan3421eec2009-12-08 07:28:20 +0000472 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
473 e1000_release_phy_80003es2lan(hw);
474 return -E1000_ERR_PHY;
475 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700476
Bruce Allance43a212013-02-20 04:06:32 +0000477 usleep_range(200, 400);
Bruce Allan3421eec2009-12-08 07:28:20 +0000478
479 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000480 MAX_PHY_REG_ADDRESS &
481 offset, data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000482
Bruce Allance43a212013-02-20 04:06:32 +0000483 usleep_range(200, 400);
Bruce Allan3421eec2009-12-08 07:28:20 +0000484 } else {
485 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000486 MAX_PHY_REG_ADDRESS &
487 offset, data);
David Graham2d9498f2008-04-23 11:09:14 -0700488 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700489
David Graham2d9498f2008-04-23 11:09:14 -0700490 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700491
492 return ret_val;
493}
494
495/**
496 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
497 * @hw: pointer to the HW structure
498 * @offset: offset of the register to read
499 * @words: number of words to write
500 * @data: buffer of data to write to the NVM
501 *
Bruce Allanfe401672009-11-20 23:26:05 +0000502 * Write "words" of data to the ESB2 NVM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700503 **/
504static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
505 u16 words, u16 *data)
506{
507 return e1000e_write_nvm_spi(hw, offset, words, data);
508}
509
510/**
511 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
512 * @hw: pointer to the HW structure
513 *
514 * Wait a specific amount of time for manageability processes to complete.
515 * This is a function pointer entry point called by the phy module.
516 **/
517static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
518{
519 s32 timeout = PHY_CFG_TIMEOUT;
520 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
521
522 if (hw->bus.func == 1)
523 mask = E1000_NVM_CFG_DONE_PORT_1;
524
525 while (timeout) {
526 if (er32(EEMNGCTL) & mask)
527 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000528 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700529 timeout--;
530 }
531 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000532 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700533 return -E1000_ERR_RESET;
534 }
535
536 return 0;
537}
538
539/**
540 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
541 * @hw: pointer to the HW structure
542 *
543 * Force the speed and duplex settings onto the PHY. This is a
544 * function pointer entry point called by the phy module.
545 **/
546static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
547{
548 s32 ret_val;
549 u16 phy_data;
550 bool link;
551
Bruce Allane921eb12012-11-28 09:28:37 +0000552 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
Auke Kokbc7f75f2007-09-17 12:30:59 -0700553 * forced whenever speed and duplex are forced.
554 */
555 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
556 if (ret_val)
557 return ret_val;
558
559 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
560 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
561 if (ret_val)
562 return ret_val;
563
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000564 e_dbg("GG82563 PSCR: %X\n", phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700565
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000566 ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700567 if (ret_val)
568 return ret_val;
569
570 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
571
572 /* Reset the phy to commit changes. */
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000573 phy_data |= BMCR_RESET;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700574
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000575 ret_val = e1e_wphy(hw, MII_BMCR, phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700576 if (ret_val)
577 return ret_val;
578
579 udelay(1);
580
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700581 if (hw->phy.autoneg_wait_to_complete) {
Bruce Allan434f1392011-12-16 00:46:54 +0000582 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700583
584 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000585 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700586 if (ret_val)
587 return ret_val;
588
589 if (!link) {
Bruce Allane921eb12012-11-28 09:28:37 +0000590 /* We didn't get link.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700591 * Reset the DSP and cross our fingers.
592 */
593 ret_val = e1000e_phy_reset_dsp(hw);
594 if (ret_val)
595 return ret_val;
596 }
597
598 /* Try once more */
599 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000600 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700601 if (ret_val)
602 return ret_val;
603 }
604
605 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
606 if (ret_val)
607 return ret_val;
608
Bruce Allane921eb12012-11-28 09:28:37 +0000609 /* Resetting the phy means we need to verify the TX_CLK corresponds
Auke Kokbc7f75f2007-09-17 12:30:59 -0700610 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
611 */
612 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
613 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
614 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
615 else
616 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
617
Bruce Allane921eb12012-11-28 09:28:37 +0000618 /* In addition, we must re-enable CRS on Tx for both half and full
Auke Kokbc7f75f2007-09-17 12:30:59 -0700619 * duplex.
620 */
621 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
622 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
623
624 return ret_val;
625}
626
627/**
628 * e1000_get_cable_length_80003es2lan - Set approximate cable length
629 * @hw: pointer to the HW structure
630 *
631 * Find the approximate cable length as measured by the GG82563 PHY.
632 * This is a function pointer entry point called by the phy module.
633 **/
634static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
635{
636 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan70806a72013-01-05 05:08:37 +0000637 s32 ret_val;
Bruce Allana708dd82009-11-20 23:28:37 +0000638 u16 phy_data, index;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700639
640 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
641 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000642 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700643
644 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
Bruce Allaneb656d42009-12-01 15:47:02 +0000645
Bruce Allan5015e532012-02-08 02:55:56 +0000646 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
647 return -E1000_ERR_PHY;
Bruce Allaneb656d42009-12-01 15:47:02 +0000648
Auke Kokbc7f75f2007-09-17 12:30:59 -0700649 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
Bruce Allaneb656d42009-12-01 15:47:02 +0000650 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700651
652 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
653
Bruce Allan5015e532012-02-08 02:55:56 +0000654 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700655}
656
657/**
658 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
659 * @hw: pointer to the HW structure
660 * @speed: pointer to speed buffer
661 * @duplex: pointer to duplex buffer
662 *
663 * Retrieve the current speed and duplex configuration.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700664 **/
665static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
666 u16 *duplex)
667{
668 s32 ret_val;
669
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700670 if (hw->phy.media_type == e1000_media_type_copper) {
Bruce Allan17e813e2013-02-20 04:06:01 +0000671 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800672 hw->phy.ops.cfg_on_link_up(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700673 } else {
674 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +0000675 speed,
676 duplex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700677 }
678
679 return ret_val;
680}
681
682/**
683 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
684 * @hw: pointer to the HW structure
685 *
686 * Perform a global reset to the ESB2 controller.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700687 **/
688static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
689{
Bruce Allandd93f952011-01-06 14:29:48 +0000690 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700691 s32 ret_val;
Matthew Vick1c1093a2012-03-16 09:02:58 +0000692 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700693
Bruce Allane921eb12012-11-28 09:28:37 +0000694 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700695 * on the last TLP read/write transaction when MAC is reset.
696 */
697 ret_val = e1000e_disable_pcie_master(hw);
698 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000699 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700700
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000701 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700702 ew32(IMC, 0xffffffff);
703
704 ew32(RCTL, 0);
705 ew32(TCTL, E1000_TCTL_PSP);
706 e1e_flush();
707
Bruce Allan1bba4382011-03-19 00:27:20 +0000708 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700709
710 ctrl = er32(CTRL);
711
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800712 ret_val = e1000_acquire_phy_80003es2lan(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000713 if (ret_val)
714 return ret_val;
715
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000716 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700717 ew32(CTRL, ctrl | E1000_CTRL_RST);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800718 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700719
Matthew Vick1c1093a2012-03-16 09:02:58 +0000720 /* Disable IBIST slave mode (far-end loopback) */
David Ertman918a4302013-12-14 07:30:39 +0000721 ret_val =
722 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
723 &kum_reg_data);
724 if (ret_val)
725 return ret_val;
Matthew Vick1c1093a2012-03-16 09:02:58 +0000726 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
727 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
728 kum_reg_data);
729
Auke Kokbc7f75f2007-09-17 12:30:59 -0700730 ret_val = e1000e_get_auto_rd_done(hw);
731 if (ret_val)
732 /* We don't want to continue accessing MAC registers. */
733 return ret_val;
734
735 /* Clear any pending interrupt events. */
736 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +0000737 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700738
Bruce Allan7eb61d82012-02-08 02:55:03 +0000739 return e1000_check_alt_mac_addr_generic(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700740}
741
742/**
743 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
744 * @hw: pointer to the HW structure
745 *
746 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700747 **/
748static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
749{
750 struct e1000_mac_info *mac = &hw->mac;
751 u32 reg_data;
752 s32 ret_val;
Bruce Alland9b24132011-05-13 07:19:42 +0000753 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700754 u16 i;
755
756 e1000_initialize_hw_bits_80003es2lan(hw);
757
758 /* Initialize identification LED */
Bruce Alland1964eb2012-02-22 09:02:21 +0000759 ret_val = mac->ops.id_led_init(hw);
Bruce Allan33550ce2013-02-20 04:06:16 +0000760 /* An error is not fatal and we should not stop init due to this */
Bruce Allande39b752009-11-20 23:27:59 +0000761 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000762 e_dbg("Error initializing identification LED\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700763
764 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000765 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +0000766 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700767
768 /* Setup the receive address. */
769 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
770
771 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000772 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700773 for (i = 0; i < mac->mta_reg_count; i++)
774 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
775
776 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +0000777 ret_val = mac->ops.setup_link(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000778 if (ret_val)
779 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700780
Bruce Alland9b24132011-05-13 07:19:42 +0000781 /* Disable IBIST slave mode (far-end loopback) */
782 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
783 &kum_reg_data);
784 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
785 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
786 kum_reg_data);
787
Auke Kokbc7f75f2007-09-17 12:30:59 -0700788 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700789 reg_data = er32(TXDCTL(0));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000790 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
791 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700792 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700793
794 /* ...for both queues. */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700795 reg_data = er32(TXDCTL(1));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000796 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
797 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700798 ew32(TXDCTL(1), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700799
800 /* Enable retransmit on late collisions */
801 reg_data = er32(TCTL);
802 reg_data |= E1000_TCTL_RTLC;
803 ew32(TCTL, reg_data);
804
805 /* Configure Gigabit Carry Extend Padding */
806 reg_data = er32(TCTL_EXT);
807 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
808 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
809 ew32(TCTL_EXT, reg_data);
810
811 /* Configure Transmit Inter-Packet Gap */
812 reg_data = er32(TIPG);
813 reg_data &= ~E1000_TIPG_IPGT_MASK;
814 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
815 ew32(TIPG, reg_data);
816
817 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
818 reg_data &= ~0x00100000;
819 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
820
Bruce Allan3421eec2009-12-08 07:28:20 +0000821 /* default to true to enable the MDIC W/A */
822 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
823
Bruce Allanf0ff4392013-02-20 04:05:39 +0000824 ret_val =
825 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
826 E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
Bruce Allan3421eec2009-12-08 07:28:20 +0000827 if (!ret_val) {
828 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
Bruce Allan17e813e2013-02-20 04:06:01 +0000829 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
Bruce Allan3421eec2009-12-08 07:28:20 +0000830 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
831 }
832
Bruce Allane921eb12012-11-28 09:28:37 +0000833 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -0700834 * important that we do this after we have tried to establish link
835 * because the symbol error count will increment wildly if there
836 * is no link.
837 */
838 e1000_clear_hw_cntrs_80003es2lan(hw);
839
840 return ret_val;
841}
842
843/**
844 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
845 * @hw: pointer to the HW structure
846 *
847 * Initializes required hardware-dependent bits needed for normal operation.
848 **/
849static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
850{
851 u32 reg;
852
853 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700854 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700855 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700856 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700857
858 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700859 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700860 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700861 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700862
863 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700864 reg = er32(TARC(0));
Bruce Allane80bd1d2013-05-01 01:19:46 +0000865 reg &= ~(0xF << 27); /* 30:27 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700866 if (hw->phy.media_type != e1000_media_type_copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700867 reg &= ~(1 << 20);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700868 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700869
870 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700871 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700872 if (er32(TCTL) & E1000_TCTL_MULR)
873 reg &= ~(1 << 28);
874 else
875 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700876 ew32(TARC(1), reg);
Matthew Vickf6bd5572012-04-25 08:01:05 +0000877
Bruce Allane921eb12012-11-28 09:28:37 +0000878 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +0000879 * IPv6 headers can hang the Rx.
880 */
881 reg = er32(RFCTL);
882 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
883 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700884}
885
886/**
887 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
888 * @hw: pointer to the HW structure
889 *
890 * Setup some GG82563 PHY registers for obtaining link
891 **/
892static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
893{
894 struct e1000_phy_info *phy = &hw->phy;
895 s32 ret_val;
Bruce Allan17e813e2013-02-20 04:06:01 +0000896 u32 reg;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800897 u16 data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700898
David Graham2d9498f2008-04-23 11:09:14 -0700899 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700900 if (ret_val)
901 return ret_val;
902
903 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
904 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
905 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
906
David Graham2d9498f2008-04-23 11:09:14 -0700907 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700908 if (ret_val)
909 return ret_val;
910
Bruce Allane921eb12012-11-28 09:28:37 +0000911 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700912 * MDI/MDI-X = 0 (default)
913 * 0 - Auto for all speeds
914 * 1 - MDI mode
915 * 2 - MDI-X mode
916 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
917 */
918 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
919 if (ret_val)
920 return ret_val;
921
922 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
923
924 switch (phy->mdix) {
925 case 1:
926 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
927 break;
928 case 2:
929 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
930 break;
931 case 0:
932 default:
933 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
934 break;
935 }
936
Bruce Allane921eb12012-11-28 09:28:37 +0000937 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700938 * disable_polarity_correction = 0 (default)
939 * Automatic Correction for Reversed Cable Polarity
940 * 0 - Disabled
941 * 1 - Enabled
942 */
943 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
944 if (phy->disable_polarity_correction)
945 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
946
947 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
948 if (ret_val)
949 return ret_val;
950
951 /* SW Reset the PHY so all changes take effect */
Bruce Allan6b598e12013-01-23 06:50:05 +0000952 ret_val = hw->phy.ops.commit(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700953 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000954 e_dbg("Error Resetting the PHY\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700955 return ret_val;
956 }
957
Bruce Allanad680762008-03-28 09:15:03 -0700958 /* Bypass Rx and Tx FIFO's */
Bruce Allan17e813e2013-02-20 04:06:01 +0000959 reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
960 data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
961 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
962 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700963 if (ret_val)
964 return ret_val;
965
Bruce Allan17e813e2013-02-20 04:06:01 +0000966 reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
967 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
David Graham2d9498f2008-04-23 11:09:14 -0700968 if (ret_val)
969 return ret_val;
970 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
Bruce Allan17e813e2013-02-20 04:06:01 +0000971 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
David Graham2d9498f2008-04-23 11:09:14 -0700972 if (ret_val)
973 return ret_val;
974
Auke Kokbc7f75f2007-09-17 12:30:59 -0700975 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
976 if (ret_val)
977 return ret_val;
978
979 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
980 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
981 if (ret_val)
982 return ret_val;
983
Bruce Allan17e813e2013-02-20 04:06:01 +0000984 reg = er32(CTRL_EXT);
985 reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
986 ew32(CTRL_EXT, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700987
988 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
989 if (ret_val)
990 return ret_val;
991
Bruce Allane921eb12012-11-28 09:28:37 +0000992 /* Do not init these registers when the HW is in IAMT mode, since the
Auke Kokbc7f75f2007-09-17 12:30:59 -0700993 * firmware will have already initialized them. We only initialize
994 * them if the HW is not in IAMT mode.
995 */
Bruce Allan48768322012-02-22 09:02:32 +0000996 if (!hw->mac.ops.check_mng_mode(hw)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700997 /* Enable Electrical Idle on the PHY */
998 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
999 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
1000 if (ret_val)
1001 return ret_val;
1002
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001003 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1004 if (ret_val)
1005 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001006
1007 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1008 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1009 if (ret_val)
1010 return ret_val;
1011 }
1012
Bruce Allane921eb12012-11-28 09:28:37 +00001013 /* Workaround: Disable padding in Kumeran interface in the MAC
Auke Kokbc7f75f2007-09-17 12:30:59 -07001014 * and in the PHY to avoid CRC errors.
1015 */
1016 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1017 if (ret_val)
1018 return ret_val;
1019
1020 data |= GG82563_ICR_DIS_PADDING;
1021 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1022 if (ret_val)
1023 return ret_val;
1024
1025 return 0;
1026}
1027
1028/**
1029 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1030 * @hw: pointer to the HW structure
1031 *
1032 * Essentially a wrapper for setting up all things "copper" related.
1033 * This is a function pointer entry point called by the mac module.
1034 **/
1035static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1036{
1037 u32 ctrl;
1038 s32 ret_val;
1039 u16 reg_data;
1040
1041 ctrl = er32(CTRL);
1042 ctrl |= E1000_CTRL_SLU;
1043 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1044 ew32(CTRL, ctrl);
1045
Bruce Allane921eb12012-11-28 09:28:37 +00001046 /* Set the mac to wait the maximum time between each
Auke Kokbc7f75f2007-09-17 12:30:59 -07001047 * iteration and increase the max iterations when
Bruce Allanad680762008-03-28 09:15:03 -07001048 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1049 */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001050 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001051 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001052 if (ret_val)
1053 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001054 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001055 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001056 if (ret_val)
1057 return ret_val;
1058 reg_data |= 0x3F;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001059 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001060 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001061 if (ret_val)
1062 return ret_val;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001063 ret_val =
1064 e1000_read_kmrn_reg_80003es2lan(hw,
1065 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1066 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001067 if (ret_val)
1068 return ret_val;
1069 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001070 ret_val =
1071 e1000_write_kmrn_reg_80003es2lan(hw,
1072 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1073 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001074 if (ret_val)
1075 return ret_val;
1076
1077 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1078 if (ret_val)
1079 return ret_val;
1080
Bruce Allan8649f432012-02-08 02:54:58 +00001081 return e1000e_setup_copper_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001082}
1083
1084/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001085 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1086 * @hw: pointer to the HW structure
1087 * @duplex: current duplex setting
1088 *
1089 * Configure the KMRN interface by applying last minute quirks for
1090 * 10/100 operation.
1091 **/
1092static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1093{
1094 s32 ret_val = 0;
1095 u16 speed;
1096 u16 duplex;
1097
1098 if (hw->phy.media_type == e1000_media_type_copper) {
1099 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
Bruce Allanf0ff4392013-02-20 04:05:39 +00001100 &duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001101 if (ret_val)
1102 return ret_val;
1103
1104 if (speed == SPEED_1000)
1105 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1106 else
1107 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1108 }
1109
1110 return ret_val;
1111}
1112
1113/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001114 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1115 * @hw: pointer to the HW structure
1116 * @duplex: current duplex setting
1117 *
1118 * Configure the KMRN interface by applying last minute quirks for
1119 * 10/100 operation.
1120 **/
1121static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1122{
1123 s32 ret_val;
1124 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001125 u32 i = 0;
1126 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001127
1128 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001129 ret_val =
1130 e1000_write_kmrn_reg_80003es2lan(hw,
1131 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1132 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001133 if (ret_val)
1134 return ret_val;
1135
1136 /* Configure Transmit Inter-Packet Gap */
1137 tipg = er32(TIPG);
1138 tipg &= ~E1000_TIPG_IPGT_MASK;
1139 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1140 ew32(TIPG, tipg);
1141
David Graham2d9498f2008-04-23 11:09:14 -07001142 do {
1143 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1144 if (ret_val)
1145 return ret_val;
1146
1147 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1148 if (ret_val)
1149 return ret_val;
1150 i++;
1151 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001152
1153 if (duplex == HALF_DUPLEX)
1154 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1155 else
1156 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1157
Bruce Allan520d6f22012-02-08 02:54:53 +00001158 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001159}
1160
1161/**
1162 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1163 * @hw: pointer to the HW structure
1164 *
1165 * Configure the KMRN interface by applying last minute quirks for
1166 * gigabit operation.
1167 **/
1168static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1169{
1170 s32 ret_val;
David Graham2d9498f2008-04-23 11:09:14 -07001171 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001172 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001173 u32 i = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001174
1175 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001176 ret_val =
1177 e1000_write_kmrn_reg_80003es2lan(hw,
1178 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1179 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001180 if (ret_val)
1181 return ret_val;
1182
1183 /* Configure Transmit Inter-Packet Gap */
1184 tipg = er32(TIPG);
1185 tipg &= ~E1000_TIPG_IPGT_MASK;
1186 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1187 ew32(TIPG, tipg);
1188
David Graham2d9498f2008-04-23 11:09:14 -07001189 do {
1190 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1191 if (ret_val)
1192 return ret_val;
1193
1194 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1195 if (ret_val)
1196 return ret_val;
1197 i++;
1198 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001199
1200 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001201
Bruce Allan7eb61d82012-02-08 02:55:03 +00001202 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001203}
1204
1205/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001206 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1207 * @hw: pointer to the HW structure
1208 * @offset: register offset to be read
1209 * @data: pointer to the read data
1210 *
1211 * Acquire semaphore, then read the PHY register at offset
1212 * using the kumeran interface. The information retrieved is stored in data.
1213 * Release the semaphore before exiting.
1214 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001215static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1216 u16 *data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001217{
1218 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001219 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001220
1221 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1222 if (ret_val)
1223 return ret_val;
1224
1225 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001226 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001227 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001228 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001229
1230 udelay(2);
1231
1232 kmrnctrlsta = er32(KMRNCTRLSTA);
1233 *data = (u16)kmrnctrlsta;
1234
1235 e1000_release_mac_csr_80003es2lan(hw);
1236
1237 return ret_val;
1238}
1239
1240/**
1241 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1242 * @hw: pointer to the HW structure
1243 * @offset: register offset to write to
1244 * @data: data to write at register offset
1245 *
1246 * Acquire semaphore, then write the data to PHY register
1247 * at the offset using the kumeran interface. Release semaphore
1248 * before exiting.
1249 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001250static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1251 u16 data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001252{
1253 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001254 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001255
1256 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1257 if (ret_val)
1258 return ret_val;
1259
1260 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001261 E1000_KMRNCTRLSTA_OFFSET) | data;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001262 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001263 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001264
1265 udelay(2);
1266
1267 e1000_release_mac_csr_80003es2lan(hw);
1268
1269 return ret_val;
1270}
1271
1272/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001273 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1274 * @hw: pointer to the HW structure
1275 **/
1276static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1277{
Bruce Allan70806a72013-01-05 05:08:37 +00001278 s32 ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001279
Bruce Allane921eb12012-11-28 09:28:37 +00001280 /* If there's an alternate MAC address place it in RAR0
Bruce Allan608f8a02010-01-13 02:04:58 +00001281 * so that it will override the Si installed default perm
1282 * address.
1283 */
1284 ret_val = e1000_check_alt_mac_addr_generic(hw);
1285 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001286 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001287
Bruce Allan5015e532012-02-08 02:55:56 +00001288 return e1000_read_mac_addr_generic(hw);
Bruce Allan608f8a02010-01-13 02:04:58 +00001289}
1290
1291/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001292 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1293 * @hw: pointer to the HW structure
1294 *
1295 * In the case of a PHY power down to save power, or to turn off link during a
1296 * driver unload, or wake on lan is not enabled, remove the link.
1297 **/
1298static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1299{
1300 /* If the management interface is not enabled, then power down */
1301 if (!(hw->mac.ops.check_mng_mode(hw) ||
1302 hw->phy.ops.check_reset_block(hw)))
1303 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001304}
1305
1306/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001307 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1308 * @hw: pointer to the HW structure
1309 *
1310 * Clears the hardware counters by reading the counter registers.
1311 **/
1312static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1313{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001314 e1000e_clear_hw_cntrs_base(hw);
1315
Bruce Allan99673d92009-11-20 23:27:21 +00001316 er32(PRC64);
1317 er32(PRC127);
1318 er32(PRC255);
1319 er32(PRC511);
1320 er32(PRC1023);
1321 er32(PRC1522);
1322 er32(PTC64);
1323 er32(PTC127);
1324 er32(PTC255);
1325 er32(PTC511);
1326 er32(PTC1023);
1327 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001328
Bruce Allan99673d92009-11-20 23:27:21 +00001329 er32(ALGNERRC);
1330 er32(RXERRC);
1331 er32(TNCRS);
1332 er32(CEXTERR);
1333 er32(TSCTC);
1334 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001335
Bruce Allan99673d92009-11-20 23:27:21 +00001336 er32(MGTPRC);
1337 er32(MGTPDC);
1338 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001339
Bruce Allan99673d92009-11-20 23:27:21 +00001340 er32(IAC);
1341 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001342
Bruce Allan99673d92009-11-20 23:27:21 +00001343 er32(ICRXPTC);
1344 er32(ICRXATC);
1345 er32(ICTXPTC);
1346 er32(ICTXATC);
1347 er32(ICTXQEC);
1348 er32(ICTXQMTC);
1349 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001350}
1351
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001352static const struct e1000_mac_operations es2_mac_ops = {
Bruce Allan608f8a02010-01-13 02:04:58 +00001353 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
Bruce Alland1964eb2012-02-22 09:02:21 +00001354 .id_led_init = e1000e_id_led_init_generic,
Bruce Allandbf80dc2011-04-16 00:34:40 +00001355 .blink_led = e1000e_blink_led_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001356 .check_mng_mode = e1000e_check_mng_mode_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001357 /* check_for_link dependent on media type */
1358 .cleanup_led = e1000e_cleanup_led_generic,
1359 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1360 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001361 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001362 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1363 .led_on = e1000e_led_on_generic,
1364 .led_off = e1000e_led_off_generic,
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07001365 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001366 .write_vfta = e1000_write_vfta_generic,
1367 .clear_vfta = e1000_clear_vfta_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001368 .reset_hw = e1000_reset_hw_80003es2lan,
1369 .init_hw = e1000_init_hw_80003es2lan,
Bruce Allan1a46b402012-02-22 09:02:26 +00001370 .setup_link = e1000e_setup_link_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001371 /* setup_physical_interface dependent on media type */
Bruce Allana4f58f52009-06-02 11:29:18 +00001372 .setup_led = e1000e_setup_led_generic,
Bruce Allan57cde762012-02-22 09:02:58 +00001373 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00001374 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001375};
1376
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001377static const struct e1000_phy_operations es2_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001378 .acquire = e1000_acquire_phy_80003es2lan,
Bruce Allan94e5b652009-12-02 17:02:14 +00001379 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001380 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan55c5f552013-01-12 07:28:24 +00001381 .commit = e1000e_phy_sw_reset,
1382 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1383 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1384 .get_cable_length = e1000_get_cable_length_80003es2lan,
1385 .get_info = e1000e_get_phy_info_m88,
1386 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
Bruce Allan94d81862009-11-20 23:25:26 +00001387 .release = e1000_release_phy_80003es2lan,
Bruce Allan55c5f552013-01-12 07:28:24 +00001388 .reset = e1000e_phy_hw_reset_generic,
1389 .set_d0_lplu_state = NULL,
1390 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1391 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
1392 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001393};
1394
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001395static const struct e1000_nvm_operations es2_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001396 .acquire = e1000_acquire_nvm_80003es2lan,
1397 .read = e1000e_read_nvm_eerd,
1398 .release = e1000_release_nvm_80003es2lan,
Bruce Allane85e3632012-02-22 09:03:14 +00001399 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001400 .update = e1000e_update_nvm_checksum_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001401 .valid_led_default = e1000e_valid_led_default,
Bruce Allan94d81862009-11-20 23:25:26 +00001402 .validate = e1000e_validate_nvm_checksum_generic,
1403 .write = e1000_write_nvm_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001404};
1405
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001406const struct e1000_info e1000_es2_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001407 .mac = e1000_80003es2lan,
1408 .flags = FLAG_HAS_HW_VLAN_FILTER
1409 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001410 | FLAG_HAS_WOL
1411 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07001412 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001413 | FLAG_RX_NEEDS_RESTART /* errata */
1414 | FLAG_TARC_SET_BIT_ZERO /* errata */
1415 | FLAG_APME_CHECK_PORT_B
Bruce Allan6a92f732011-12-16 00:46:12 +00001416 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001417 .flags2 = FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001418 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001419 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001420 .get_variants = e1000_get_variants_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001421 .mac_ops = &es2_mac_ops,
1422 .phy_ops = &es2_phy_ops,
1423 .nvm_ops = &es2_nvm_ops,
1424};