Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2020 Intel Corporation
3 : : */
4 : :
5 : : /*
6 : : * 82540EM Gigabit Ethernet Controller
7 : : * 82540EP Gigabit Ethernet Controller
8 : : * 82545EM Gigabit Ethernet Controller (Copper)
9 : : * 82545EM Gigabit Ethernet Controller (Fiber)
10 : : * 82545GM Gigabit Ethernet Controller
11 : : * 82546EB Gigabit Ethernet Controller (Copper)
12 : : * 82546EB Gigabit Ethernet Controller (Fiber)
13 : : * 82546GB Gigabit Ethernet Controller
14 : : */
15 : :
16 : : #include "e1000_api.h"
17 : :
18 : : STATIC s32 e1000_init_phy_params_82540(struct e1000_hw *hw);
19 : : STATIC s32 e1000_init_nvm_params_82540(struct e1000_hw *hw);
20 : : STATIC s32 e1000_init_mac_params_82540(struct e1000_hw *hw);
21 : : STATIC s32 e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw);
22 : : STATIC void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw);
23 : : STATIC s32 e1000_init_hw_82540(struct e1000_hw *hw);
24 : : STATIC s32 e1000_reset_hw_82540(struct e1000_hw *hw);
25 : : STATIC s32 e1000_set_phy_mode_82540(struct e1000_hw *hw);
26 : : STATIC s32 e1000_set_vco_speed_82540(struct e1000_hw *hw);
27 : : STATIC s32 e1000_setup_copper_link_82540(struct e1000_hw *hw);
28 : : STATIC s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw);
29 : : STATIC void e1000_power_down_phy_copper_82540(struct e1000_hw *hw);
30 : : STATIC s32 e1000_read_mac_addr_82540(struct e1000_hw *hw);
31 : :
32 : : /**
33 : : * e1000_init_phy_params_82540 - Init PHY func ptrs.
34 : : * @hw: pointer to the HW structure
35 : : **/
36 : 0 : STATIC s32 e1000_init_phy_params_82540(struct e1000_hw *hw)
37 : : {
38 : : struct e1000_phy_info *phy = &hw->phy;
39 : : s32 ret_val;
40 : :
41 : 0 : phy->addr = 1;
42 : 0 : phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
43 : 0 : phy->reset_delay_us = 10000;
44 : 0 : phy->type = e1000_phy_m88;
45 : :
46 : : /* Function Pointers */
47 : 0 : phy->ops.check_polarity = e1000_check_polarity_m88;
48 : 0 : phy->ops.commit = e1000_phy_sw_reset_generic;
49 : 0 : phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
50 : 0 : phy->ops.get_cable_length = e1000_get_cable_length_m88;
51 : 0 : phy->ops.get_cfg_done = e1000_get_cfg_done_generic;
52 : 0 : phy->ops.read_reg = e1000_read_phy_reg_m88;
53 : 0 : phy->ops.reset = e1000_phy_hw_reset_generic;
54 : 0 : phy->ops.write_reg = e1000_write_phy_reg_m88;
55 : 0 : phy->ops.get_info = e1000_get_phy_info_m88;
56 : 0 : phy->ops.power_up = e1000_power_up_phy_copper;
57 : 0 : phy->ops.power_down = e1000_power_down_phy_copper_82540;
58 : :
59 : 0 : ret_val = e1000_get_phy_id(hw);
60 [ # # ]: 0 : if (ret_val)
61 : 0 : goto out;
62 : :
63 : : /* Verify phy id */
64 [ # # ]: 0 : switch (hw->mac.type) {
65 : 0 : case e1000_82540:
66 : : case e1000_82545:
67 : : case e1000_82545_rev_3:
68 : : case e1000_82546:
69 : : case e1000_82546_rev_3:
70 [ # # ]: 0 : if (phy->id == M88E1011_I_PHY_ID)
71 : : break;
72 : : /* Fall Through */
73 : : default:
74 : : ret_val = -E1000_ERR_PHY;
75 : 0 : goto out;
76 : : break;
77 : : }
78 : :
79 : 0 : out:
80 : 0 : return ret_val;
81 : : }
82 : :
83 : : /**
84 : : * e1000_init_nvm_params_82540 - Init NVM func ptrs.
85 : : * @hw: pointer to the HW structure
86 : : **/
87 : 0 : STATIC s32 e1000_init_nvm_params_82540(struct e1000_hw *hw)
88 : : {
89 : : struct e1000_nvm_info *nvm = &hw->nvm;
90 : 0 : u32 eecd = E1000_READ_REG(hw, E1000_EECD);
91 : :
92 : 0 : DEBUGFUNC("e1000_init_nvm_params_82540");
93 : :
94 : 0 : nvm->type = e1000_nvm_eeprom_microwire;
95 : 0 : nvm->delay_usec = 50;
96 : 0 : nvm->opcode_bits = 3;
97 [ # # # ]: 0 : switch (nvm->override) {
98 : 0 : case e1000_nvm_override_microwire_large:
99 : 0 : nvm->address_bits = 8;
100 : 0 : nvm->word_size = 256;
101 : 0 : break;
102 : 0 : case e1000_nvm_override_microwire_small:
103 : 0 : nvm->address_bits = 6;
104 : 0 : nvm->word_size = 64;
105 : 0 : break;
106 : 0 : default:
107 [ # # ]: 0 : nvm->address_bits = eecd & E1000_EECD_SIZE ? 8 : 6;
108 [ # # ]: 0 : nvm->word_size = eecd & E1000_EECD_SIZE ? 256 : 64;
109 : 0 : break;
110 : : }
111 : :
112 : : /* Function Pointers */
113 : 0 : nvm->ops.acquire = e1000_acquire_nvm_generic;
114 : 0 : nvm->ops.read = e1000_read_nvm_microwire;
115 : 0 : nvm->ops.release = e1000_release_nvm_generic;
116 : 0 : nvm->ops.update = e1000_update_nvm_checksum_generic;
117 : 0 : nvm->ops.valid_led_default = e1000_valid_led_default_generic;
118 : 0 : nvm->ops.validate = e1000_validate_nvm_checksum_generic;
119 : 0 : nvm->ops.write = e1000_write_nvm_microwire;
120 : :
121 : 0 : return E1000_SUCCESS;
122 : : }
123 : :
124 : : /**
125 : : * e1000_init_mac_params_82540 - Init MAC func ptrs.
126 : : * @hw: pointer to the HW structure
127 : : **/
128 : 0 : STATIC s32 e1000_init_mac_params_82540(struct e1000_hw *hw)
129 : : {
130 : : struct e1000_mac_info *mac = &hw->mac;
131 : : s32 ret_val = E1000_SUCCESS;
132 : :
133 : 0 : DEBUGFUNC("e1000_init_mac_params_82540");
134 : :
135 : : /* Set media type */
136 [ # # # ]: 0 : switch (hw->device_id) {
137 : 0 : case E1000_DEV_ID_82545EM_FIBER:
138 : : case E1000_DEV_ID_82545GM_FIBER:
139 : : case E1000_DEV_ID_82546EB_FIBER:
140 : : case E1000_DEV_ID_82546GB_FIBER:
141 : 0 : hw->phy.media_type = e1000_media_type_fiber;
142 : 0 : break;
143 : 0 : case E1000_DEV_ID_82545GM_SERDES:
144 : : case E1000_DEV_ID_82546GB_SERDES:
145 : 0 : hw->phy.media_type = e1000_media_type_internal_serdes;
146 : 0 : break;
147 : 0 : default:
148 : 0 : hw->phy.media_type = e1000_media_type_copper;
149 : 0 : break;
150 : : }
151 : :
152 : : /* Set mta register count */
153 : 0 : mac->mta_reg_count = 128;
154 : : /* Set rar entry count */
155 : 0 : mac->rar_entry_count = E1000_RAR_ENTRIES;
156 : :
157 : : /* Function pointers */
158 : :
159 : : /* bus type/speed/width */
160 : 0 : mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
161 : : /* function id */
162 : 0 : mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
163 : : /* reset */
164 : 0 : mac->ops.reset_hw = e1000_reset_hw_82540;
165 : : /* hw initialization */
166 : 0 : mac->ops.init_hw = e1000_init_hw_82540;
167 : : /* link setup */
168 : 0 : mac->ops.setup_link = e1000_setup_link_generic;
169 : : /* physical interface setup */
170 : 0 : mac->ops.setup_physical_interface =
171 : 0 : (hw->phy.media_type == e1000_media_type_copper)
172 : : ? e1000_setup_copper_link_82540
173 [ # # ]: 0 : : e1000_setup_fiber_serdes_link_82540;
174 : : /* check for link */
175 [ # # # # ]: 0 : switch (hw->phy.media_type) {
176 : 0 : case e1000_media_type_copper:
177 : 0 : mac->ops.check_for_link = e1000_check_for_copper_link_generic;
178 : 0 : break;
179 : 0 : case e1000_media_type_fiber:
180 : 0 : mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
181 : 0 : break;
182 : 0 : case e1000_media_type_internal_serdes:
183 : 0 : mac->ops.check_for_link = e1000_check_for_serdes_link_generic;
184 : 0 : break;
185 : 0 : default:
186 : : ret_val = -E1000_ERR_CONFIG;
187 : 0 : goto out;
188 : : break;
189 : : }
190 : : /* link info */
191 : 0 : mac->ops.get_link_up_info =
192 : : (hw->phy.media_type == e1000_media_type_copper)
193 : : ? e1000_get_speed_and_duplex_copper_generic
194 [ # # ]: 0 : : e1000_get_speed_and_duplex_fiber_serdes_generic;
195 : : /* multicast address update */
196 : 0 : mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
197 : : /* writing VFTA */
198 : 0 : mac->ops.write_vfta = e1000_write_vfta_generic;
199 : : /* clearing VFTA */
200 : 0 : mac->ops.clear_vfta = e1000_clear_vfta_generic;
201 : : /* read mac address */
202 : 0 : mac->ops.read_mac_addr = e1000_read_mac_addr_82540;
203 : : /* ID LED init */
204 : 0 : mac->ops.id_led_init = e1000_id_led_init_generic;
205 : : /* setup LED */
206 : 0 : mac->ops.setup_led = e1000_setup_led_generic;
207 : : /* cleanup LED */
208 : 0 : mac->ops.cleanup_led = e1000_cleanup_led_generic;
209 : : /* turn on/off LED */
210 : 0 : mac->ops.led_on = e1000_led_on_generic;
211 : 0 : mac->ops.led_off = e1000_led_off_generic;
212 : : /* clear hardware counters */
213 : 0 : mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82540;
214 : :
215 : 0 : out:
216 : 0 : return ret_val;
217 : : }
218 : :
219 : : /**
220 : : * e1000_init_function_pointers_82540 - Init func ptrs.
221 : : * @hw: pointer to the HW structure
222 : : *
223 : : * Called to initialize all function pointers and parameters.
224 : : **/
225 : 0 : void e1000_init_function_pointers_82540(struct e1000_hw *hw)
226 : : {
227 : 0 : DEBUGFUNC("e1000_init_function_pointers_82540");
228 : :
229 : 0 : hw->mac.ops.init_params = e1000_init_mac_params_82540;
230 : 0 : hw->nvm.ops.init_params = e1000_init_nvm_params_82540;
231 : 0 : hw->phy.ops.init_params = e1000_init_phy_params_82540;
232 : 0 : }
233 : :
234 : : /**
235 : : * e1000_reset_hw_82540 - Reset hardware
236 : : * @hw: pointer to the HW structure
237 : : *
238 : : * This resets the hardware into a known state.
239 : : **/
240 : 0 : STATIC s32 e1000_reset_hw_82540(struct e1000_hw *hw)
241 : : {
242 : : u32 ctrl, manc;
243 : : s32 ret_val = E1000_SUCCESS;
244 : :
245 : 0 : DEBUGFUNC("e1000_reset_hw_82540");
246 : :
247 : 0 : DEBUGOUT("Masking off all interrupts\n");
248 : 0 : E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
249 : :
250 : 0 : E1000_WRITE_REG(hw, E1000_RCTL, 0);
251 : 0 : E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
252 : 0 : E1000_WRITE_FLUSH(hw);
253 : :
254 : : /*
255 : : * Delay to allow any outstanding PCI transactions to complete
256 : : * before resetting the device.
257 : : */
258 : 0 : msec_delay(10);
259 : :
260 : 0 : ctrl = E1000_READ_REG(hw, E1000_CTRL);
261 : :
262 : 0 : DEBUGOUT("Issuing a global reset to 82540/82545/82546 MAC\n");
263 [ # # ]: 0 : switch (hw->mac.type) {
264 : 0 : case e1000_82545_rev_3:
265 : : case e1000_82546_rev_3:
266 : 0 : E1000_WRITE_REG(hw, E1000_CTRL_DUP, ctrl | E1000_CTRL_RST);
267 : : break;
268 : 0 : default:
269 : : /*
270 : : * These controllers can't ack the 64-bit write when
271 : : * issuing the reset, so we use IO-mapping as a
272 : : * workaround to issue the reset.
273 : : */
274 : 0 : E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
275 : : break;
276 : : }
277 : :
278 : : /* Wait for EEPROM reload */
279 : 0 : msec_delay(5);
280 : :
281 : : /* Disable HW ARPs on ASF enabled adapters */
282 : 0 : manc = E1000_READ_REG(hw, E1000_MANC);
283 : 0 : manc &= ~E1000_MANC_ARP_EN;
284 : 0 : E1000_WRITE_REG(hw, E1000_MANC, manc);
285 : :
286 : 0 : E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
287 : 0 : E1000_READ_REG(hw, E1000_ICR);
288 : :
289 : 0 : return ret_val;
290 : : }
291 : :
292 : : /**
293 : : * e1000_init_hw_82540 - Initialize hardware
294 : : * @hw: pointer to the HW structure
295 : : *
296 : : * This inits the hardware readying it for operation.
297 : : **/
298 : 0 : STATIC s32 e1000_init_hw_82540(struct e1000_hw *hw)
299 : : {
300 : : struct e1000_mac_info *mac = &hw->mac;
301 : : u32 txdctl, ctrl_ext;
302 : : s32 ret_val;
303 : : u16 i;
304 : :
305 : 0 : DEBUGFUNC("e1000_init_hw_82540");
306 : :
307 : : /* Initialize identification LED */
308 : 0 : ret_val = mac->ops.id_led_init(hw);
309 [ # # ]: 0 : if (ret_val) {
310 : 0 : DEBUGOUT("Error initializing identification LED\n");
311 : : /* This is not fatal and we should not stop init due to this */
312 : : }
313 : :
314 : : /* Disabling VLAN filtering */
315 : 0 : DEBUGOUT("Initializing the IEEE VLAN\n");
316 [ # # ]: 0 : if (mac->type < e1000_82545_rev_3)
317 : 0 : E1000_WRITE_REG(hw, E1000_VET, 0);
318 : :
319 : 0 : mac->ops.clear_vfta(hw);
320 : :
321 : : /* Setup the receive address. */
322 : 0 : e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
323 : :
324 : : /* Zero out the Multicast HASH table */
325 : 0 : DEBUGOUT("Zeroing the MTA\n");
326 [ # # ]: 0 : for (i = 0; i < mac->mta_reg_count; i++) {
327 : 0 : E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
328 : : /*
329 : : * Avoid back to back register writes by adding the register
330 : : * read (flush). This is to protect against some strange
331 : : * bridge configurations that may issue Memory Write Block
332 : : * (MWB) to our register space. The *_rev_3 hardware at
333 : : * least doesn't respond correctly to every other dword in an
334 : : * MWB to our register space.
335 : : */
336 : 0 : E1000_WRITE_FLUSH(hw);
337 : : }
338 : :
339 [ # # ]: 0 : if (mac->type < e1000_82545_rev_3)
340 : 0 : e1000_pcix_mmrbc_workaround_generic(hw);
341 : :
342 : : /* Setup link and flow control */
343 : 0 : ret_val = mac->ops.setup_link(hw);
344 : :
345 : 0 : txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
346 : 0 : txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
347 : : E1000_TXDCTL_FULL_TX_DESC_WB;
348 : 0 : E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
349 : :
350 : : /*
351 : : * Clear all of the statistics registers (clear on read). It is
352 : : * important that we do this after we have tried to establish link
353 : : * because the symbol error count will increment wildly if there
354 : : * is no link.
355 : : */
356 : 0 : e1000_clear_hw_cntrs_82540(hw);
357 : :
358 [ # # ]: 0 : if ((hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER) ||
359 : : (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3)) {
360 : 0 : ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
361 : : /*
362 : : * Relaxed ordering must be disabled to avoid a parity
363 : : * error crash in a PCI slot.
364 : : */
365 : 0 : ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
366 : 0 : E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
367 : : }
368 : :
369 : 0 : return ret_val;
370 : : }
371 : :
372 : : /**
373 : : * e1000_setup_copper_link_82540 - Configure copper link settings
374 : : * @hw: pointer to the HW structure
375 : : *
376 : : * Calls the appropriate function to configure the link for auto-neg or forced
377 : : * speed and duplex. Then we check for link, once link is established calls
378 : : * to configure collision distance and flow control are called. If link is
379 : : * not established, we return -E1000_ERR_PHY (-2).
380 : : **/
381 : 0 : STATIC s32 e1000_setup_copper_link_82540(struct e1000_hw *hw)
382 : : {
383 : : u32 ctrl;
384 : : s32 ret_val;
385 : : u16 data;
386 : :
387 : 0 : DEBUGFUNC("e1000_setup_copper_link_82540");
388 : :
389 : 0 : ctrl = E1000_READ_REG(hw, E1000_CTRL);
390 : : ctrl |= E1000_CTRL_SLU;
391 : 0 : ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
392 : 0 : E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
393 : :
394 : 0 : ret_val = e1000_set_phy_mode_82540(hw);
395 [ # # ]: 0 : if (ret_val)
396 : 0 : goto out;
397 : :
398 [ # # ]: 0 : if (hw->mac.type == e1000_82545_rev_3 ||
399 : : hw->mac.type == e1000_82546_rev_3) {
400 : 0 : ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL,
401 : : &data);
402 [ # # ]: 0 : if (ret_val)
403 : 0 : goto out;
404 : 0 : data |= 0x00000008;
405 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL,
406 : : data);
407 [ # # ]: 0 : if (ret_val)
408 : 0 : goto out;
409 : : }
410 : :
411 : 0 : ret_val = e1000_copper_link_setup_m88(hw);
412 [ # # ]: 0 : if (ret_val)
413 : 0 : goto out;
414 : :
415 : 0 : ret_val = e1000_setup_copper_link_generic(hw);
416 : :
417 : 0 : out:
418 : 0 : return ret_val;
419 : : }
420 : :
421 : : /**
422 : : * e1000_setup_fiber_serdes_link_82540 - Setup link for fiber/serdes
423 : : * @hw: pointer to the HW structure
424 : : *
425 : : * Set the output amplitude to the value in the EEPROM and adjust the VCO
426 : : * speed to improve Bit Error Rate (BER) performance. Configures collision
427 : : * distance and flow control for fiber and serdes links. Upon successful
428 : : * setup, poll for link.
429 : : **/
430 : 0 : STATIC s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw)
431 : : {
432 : : struct e1000_mac_info *mac = &hw->mac;
433 : : s32 ret_val = E1000_SUCCESS;
434 : :
435 : 0 : DEBUGFUNC("e1000_setup_fiber_serdes_link_82540");
436 : :
437 [ # # ]: 0 : switch (mac->type) {
438 : 0 : case e1000_82545_rev_3:
439 : : case e1000_82546_rev_3:
440 [ # # ]: 0 : if (hw->phy.media_type == e1000_media_type_internal_serdes) {
441 : : /*
442 : : * If we're on serdes media, adjust the output
443 : : * amplitude to value set in the EEPROM.
444 : : */
445 : 0 : ret_val = e1000_adjust_serdes_amplitude_82540(hw);
446 [ # # ]: 0 : if (ret_val)
447 : 0 : goto out;
448 : : }
449 : : /* Adjust VCO speed to improve BER performance */
450 : 0 : ret_val = e1000_set_vco_speed_82540(hw);
451 [ # # ]: 0 : if (ret_val)
452 : 0 : goto out;
453 : : default:
454 : : break;
455 : : }
456 : :
457 : 0 : ret_val = e1000_setup_fiber_serdes_link_generic(hw);
458 : :
459 : 0 : out:
460 : 0 : return ret_val;
461 : : }
462 : :
463 : : /**
464 : : * e1000_adjust_serdes_amplitude_82540 - Adjust amplitude based on EEPROM
465 : : * @hw: pointer to the HW structure
466 : : *
467 : : * Adjust the SERDES output amplitude based on the EEPROM settings.
468 : : **/
469 : 0 : STATIC s32 e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw)
470 : : {
471 : : s32 ret_val;
472 : : u16 nvm_data;
473 : :
474 : 0 : DEBUGFUNC("e1000_adjust_serdes_amplitude_82540");
475 : :
476 : 0 : ret_val = hw->nvm.ops.read(hw, NVM_SERDES_AMPLITUDE, 1, &nvm_data);
477 [ # # ]: 0 : if (ret_val)
478 : 0 : goto out;
479 : :
480 [ # # ]: 0 : if (nvm_data != NVM_RESERVED_WORD) {
481 : : /* Adjust serdes output amplitude only. */
482 : 0 : nvm_data &= NVM_SERDES_AMPLITUDE_MASK;
483 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_EXT_CTRL,
484 : : nvm_data);
485 [ # # ]: 0 : if (ret_val)
486 : 0 : goto out;
487 : : }
488 : :
489 : 0 : out:
490 : 0 : return ret_val;
491 : : }
492 : :
493 : : /**
494 : : * e1000_set_vco_speed_82540 - Set VCO speed for better performance
495 : : * @hw: pointer to the HW structure
496 : : *
497 : : * Set the VCO speed to improve Bit Error Rate (BER) performance.
498 : : **/
499 : 0 : STATIC s32 e1000_set_vco_speed_82540(struct e1000_hw *hw)
500 : : {
501 : : s32 ret_val;
502 : 0 : u16 default_page = 0;
503 : : u16 phy_data;
504 : :
505 : 0 : DEBUGFUNC("e1000_set_vco_speed_82540");
506 : :
507 : : /* Set PHY register 30, page 5, bit 8 to 0 */
508 : :
509 : 0 : ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_PAGE_SELECT,
510 : : &default_page);
511 [ # # ]: 0 : if (ret_val)
512 : 0 : goto out;
513 : :
514 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0005);
515 [ # # ]: 0 : if (ret_val)
516 : 0 : goto out;
517 : :
518 : 0 : ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
519 [ # # ]: 0 : if (ret_val)
520 : 0 : goto out;
521 : :
522 : 0 : phy_data &= ~M88E1000_PHY_VCO_REG_BIT8;
523 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
524 [ # # ]: 0 : if (ret_val)
525 : 0 : goto out;
526 : :
527 : : /* Set PHY register 30, page 4, bit 11 to 1 */
528 : :
529 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0004);
530 [ # # ]: 0 : if (ret_val)
531 : 0 : goto out;
532 : :
533 : 0 : ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
534 [ # # ]: 0 : if (ret_val)
535 : 0 : goto out;
536 : :
537 : 0 : phy_data |= M88E1000_PHY_VCO_REG_BIT11;
538 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
539 [ # # ]: 0 : if (ret_val)
540 : 0 : goto out;
541 : :
542 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
543 : : default_page);
544 : :
545 : 0 : out:
546 : 0 : return ret_val;
547 : : }
548 : :
549 : : /**
550 : : * e1000_set_phy_mode_82540 - Set PHY to class A mode
551 : : * @hw: pointer to the HW structure
552 : : *
553 : : * Sets the PHY to class A mode and assumes the following operations will
554 : : * follow to enable the new class mode:
555 : : * 1. Do a PHY soft reset.
556 : : * 2. Restart auto-negotiation or force link.
557 : : **/
558 : 0 : STATIC s32 e1000_set_phy_mode_82540(struct e1000_hw *hw)
559 : : {
560 : : s32 ret_val = E1000_SUCCESS;
561 : : u16 nvm_data;
562 : :
563 : 0 : DEBUGFUNC("e1000_set_phy_mode_82540");
564 : :
565 [ # # ]: 0 : if (hw->mac.type != e1000_82545_rev_3)
566 : 0 : goto out;
567 : :
568 : 0 : ret_val = hw->nvm.ops.read(hw, NVM_PHY_CLASS_WORD, 1, &nvm_data);
569 [ # # ]: 0 : if (ret_val) {
570 : : ret_val = -E1000_ERR_PHY;
571 : 0 : goto out;
572 : : }
573 : :
574 [ # # ]: 0 : if ((nvm_data != NVM_RESERVED_WORD) && (nvm_data & NVM_PHY_CLASS_A)) {
575 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
576 : : 0x000B);
577 [ # # ]: 0 : if (ret_val) {
578 : : ret_val = -E1000_ERR_PHY;
579 : 0 : goto out;
580 : : }
581 : 0 : ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL,
582 : : 0x8104);
583 [ # # ]: 0 : if (ret_val) {
584 : : ret_val = -E1000_ERR_PHY;
585 : 0 : goto out;
586 : : }
587 : :
588 : : }
589 : :
590 : 0 : out:
591 : 0 : return ret_val;
592 : : }
593 : :
594 : : /**
595 : : * e1000_power_down_phy_copper_82540 - Remove link in case of PHY power down
596 : : * @hw: pointer to the HW structure
597 : : *
598 : : * In the case of a PHY power down to save power, or to turn off link during a
599 : : * driver unload, or wake on lan is not enabled, remove the link.
600 : : **/
601 : 0 : STATIC void e1000_power_down_phy_copper_82540(struct e1000_hw *hw)
602 : : {
603 : : /* If the management interface is not enabled, then power down */
604 [ # # ]: 0 : if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_SMBUS_EN))
605 : 0 : e1000_power_down_phy_copper(hw);
606 : :
607 : 0 : return;
608 : : }
609 : :
610 : : /**
611 : : * e1000_clear_hw_cntrs_82540 - Clear device specific hardware counters
612 : : * @hw: pointer to the HW structure
613 : : *
614 : : * Clears the hardware counters by reading the counter registers.
615 : : **/
616 : 0 : STATIC void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw)
617 : : {
618 : 0 : DEBUGFUNC("e1000_clear_hw_cntrs_82540");
619 : :
620 : 0 : e1000_clear_hw_cntrs_base_generic(hw);
621 : :
622 : 0 : E1000_READ_REG(hw, E1000_PRC64);
623 : 0 : E1000_READ_REG(hw, E1000_PRC127);
624 : 0 : E1000_READ_REG(hw, E1000_PRC255);
625 : 0 : E1000_READ_REG(hw, E1000_PRC511);
626 : 0 : E1000_READ_REG(hw, E1000_PRC1023);
627 : 0 : E1000_READ_REG(hw, E1000_PRC1522);
628 : 0 : E1000_READ_REG(hw, E1000_PTC64);
629 : 0 : E1000_READ_REG(hw, E1000_PTC127);
630 : 0 : E1000_READ_REG(hw, E1000_PTC255);
631 : 0 : E1000_READ_REG(hw, E1000_PTC511);
632 : 0 : E1000_READ_REG(hw, E1000_PTC1023);
633 : 0 : E1000_READ_REG(hw, E1000_PTC1522);
634 : :
635 : 0 : E1000_READ_REG(hw, E1000_ALGNERRC);
636 : 0 : E1000_READ_REG(hw, E1000_RXERRC);
637 : 0 : E1000_READ_REG(hw, E1000_TNCRS);
638 : 0 : E1000_READ_REG(hw, E1000_CEXTERR);
639 : 0 : E1000_READ_REG(hw, E1000_TSCTC);
640 : 0 : E1000_READ_REG(hw, E1000_TSCTFC);
641 : :
642 : 0 : E1000_READ_REG(hw, E1000_MGTPRC);
643 : 0 : E1000_READ_REG(hw, E1000_MGTPDC);
644 : 0 : E1000_READ_REG(hw, E1000_MGTPTC);
645 : 0 : }
646 : :
647 : : /**
648 : : * e1000_read_mac_addr_82540 - Read device MAC address
649 : : * @hw: pointer to the HW structure
650 : : *
651 : : * Reads the device MAC address from the EEPROM and stores the value.
652 : : * Since devices with two ports use the same EEPROM, we increment the
653 : : * last bit in the MAC address for the second port.
654 : : *
655 : : * This version is being used over generic because of customer issues
656 : : * with VmWare and Virtual Box when using generic. It seems in
657 : : * the emulated 82545, RAR[0] does NOT have a valid address after a
658 : : * reset, this older method works and using this breaks nothing for
659 : : * these legacy adapters.
660 : : **/
661 : 0 : s32 e1000_read_mac_addr_82540(struct e1000_hw *hw)
662 : : {
663 : : s32 ret_val = E1000_SUCCESS;
664 : : u16 offset, nvm_data, i;
665 : :
666 : 0 : DEBUGFUNC("e1000_read_mac_addr");
667 : :
668 [ # # ]: 0 : for (i = 0; i < ETH_ADDR_LEN; i += 2) {
669 : 0 : offset = i >> 1;
670 : 0 : ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
671 [ # # ]: 0 : if (ret_val) {
672 : 0 : DEBUGOUT("NVM Read Error\n");
673 : 0 : goto out;
674 : : }
675 : 0 : hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
676 : 0 : hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
677 : : }
678 : :
679 : : /* Flip last bit of mac address if we're on second port */
680 [ # # ]: 0 : if (hw->bus.func == E1000_FUNC_1)
681 : 0 : hw->mac.perm_addr[5] ^= 1;
682 : :
683 [ # # ]: 0 : for (i = 0; i < ETH_ADDR_LEN; i++)
684 : 0 : hw->mac.addr[i] = hw->mac.perm_addr[i];
685 : :
686 : 0 : out:
687 : 0 : return ret_val;
688 : : }
|