1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 FILE_LICENCE ( GPL2_ONLY
);
32 * Shared functions for accessing and configuring the MAC
38 static int32_t e1000_swfw_sync_acquire(struct e1000_hw
*hw
, uint16_t mask
);
39 static void e1000_swfw_sync_release(struct e1000_hw
*hw
, uint16_t mask
);
40 static int32_t e1000_read_kmrn_reg(struct e1000_hw
*hw
, uint32_t reg_addr
, uint16_t *data
);
41 static int32_t e1000_write_kmrn_reg(struct e1000_hw
*hw
, uint32_t reg_addr
, uint16_t data
);
42 static int32_t e1000_get_software_semaphore(struct e1000_hw
*hw
);
43 static void e1000_release_software_semaphore(struct e1000_hw
*hw
);
45 static uint8_t e1000_arc_subsystem_valid(struct e1000_hw
*hw
);
46 static int32_t e1000_check_downshift(struct e1000_hw
*hw
);
47 static int32_t e1000_check_polarity(struct e1000_hw
*hw
, e1000_rev_polarity
*polarity
);
48 static void e1000_clear_hw_cntrs(struct e1000_hw
*hw
);
49 static void e1000_clear_vfta(struct e1000_hw
*hw
);
50 static int32_t e1000_commit_shadow_ram(struct e1000_hw
*hw
);
51 static int32_t e1000_config_dsp_after_link_change(struct e1000_hw
*hw
, boolean_t link_up
);
52 static int32_t e1000_config_fc_after_link_up(struct e1000_hw
*hw
);
53 static int32_t e1000_detect_gig_phy(struct e1000_hw
*hw
);
54 static int32_t e1000_erase_ich8_4k_segment(struct e1000_hw
*hw
, uint32_t bank
);
55 static int32_t e1000_get_auto_rd_done(struct e1000_hw
*hw
);
56 static int32_t e1000_get_cable_length(struct e1000_hw
*hw
, uint16_t *min_length
, uint16_t *max_length
);
57 static int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw
*hw
);
58 static int32_t e1000_get_phy_cfg_done(struct e1000_hw
*hw
);
59 static int32_t e1000_get_software_flag(struct e1000_hw
*hw
);
60 static int32_t e1000_ich8_cycle_init(struct e1000_hw
*hw
);
61 static int32_t e1000_ich8_flash_cycle(struct e1000_hw
*hw
, uint32_t timeout
);
62 static int32_t e1000_id_led_init(struct e1000_hw
*hw
);
63 static int32_t e1000_init_lcd_from_nvm_config_region(struct e1000_hw
*hw
, uint32_t cnf_base_addr
, uint32_t cnf_size
);
64 static int32_t e1000_init_lcd_from_nvm(struct e1000_hw
*hw
);
65 static void e1000_init_rx_addrs(struct e1000_hw
*hw
);
66 static void e1000_initialize_hardware_bits(struct e1000_hw
*hw
);
67 static boolean_t
e1000_is_onboard_nvm_eeprom(struct e1000_hw
*hw
);
68 static int32_t e1000_kumeran_lock_loss_workaround(struct e1000_hw
*hw
);
69 static int32_t e1000_mng_enable_host_if(struct e1000_hw
*hw
);
70 static int32_t e1000_mng_host_if_write(struct e1000_hw
*hw
, uint8_t *buffer
, uint16_t length
, uint16_t offset
, uint8_t *sum
);
71 static int32_t e1000_mng_write_cmd_header(struct e1000_hw
* hw
, struct e1000_host_mng_command_header
* hdr
);
72 static int32_t e1000_mng_write_commit(struct e1000_hw
*hw
);
73 static int32_t e1000_phy_ife_get_info(struct e1000_hw
*hw
, struct e1000_phy_info
*phy_info
);
74 static int32_t e1000_phy_igp_get_info(struct e1000_hw
*hw
, struct e1000_phy_info
*phy_info
);
75 static int32_t e1000_read_eeprom_eerd(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
, uint16_t *data
);
76 static int32_t e1000_write_eeprom_eewr(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
, uint16_t *data
);
77 static int32_t e1000_poll_eerd_eewr_done(struct e1000_hw
*hw
, int eerd
);
78 static int32_t e1000_phy_m88_get_info(struct e1000_hw
*hw
, struct e1000_phy_info
*phy_info
);
79 static void e1000_put_hw_eeprom_semaphore(struct e1000_hw
*hw
);
80 static int32_t e1000_read_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t *data
);
81 static int32_t e1000_verify_write_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t byte
);
82 static int32_t e1000_write_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t byte
);
83 static int32_t e1000_read_ich8_word(struct e1000_hw
*hw
, uint32_t index
, uint16_t *data
);
84 static int32_t e1000_read_ich8_data(struct e1000_hw
*hw
, uint32_t index
, uint32_t size
, uint16_t *data
);
85 static int32_t e1000_write_ich8_data(struct e1000_hw
*hw
, uint32_t index
, uint32_t size
, uint16_t data
);
86 static int32_t e1000_read_eeprom_ich8(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
, uint16_t *data
);
87 static int32_t e1000_write_eeprom_ich8(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
, uint16_t *data
);
88 static void e1000_release_software_flag(struct e1000_hw
*hw
);
89 static int32_t e1000_set_d3_lplu_state(struct e1000_hw
*hw
, boolean_t active
);
90 static int32_t e1000_set_d0_lplu_state(struct e1000_hw
*hw
, boolean_t active
);
91 static int32_t e1000_set_pci_ex_no_snoop(struct e1000_hw
*hw
, uint32_t no_snoop
);
92 static void e1000_set_pci_express_master_disable(struct e1000_hw
*hw
);
93 static int32_t e1000_wait_autoneg(struct e1000_hw
*hw
);
94 static void e1000_write_reg_io(struct e1000_hw
*hw
, uint32_t offset
, uint32_t value
);
95 static int32_t e1000_set_phy_type(struct e1000_hw
*hw
);
96 static void e1000_phy_init_script(struct e1000_hw
*hw
);
97 static int32_t e1000_setup_copper_link(struct e1000_hw
*hw
);
98 static int32_t e1000_setup_fiber_serdes_link(struct e1000_hw
*hw
);
99 static int32_t e1000_adjust_serdes_amplitude(struct e1000_hw
*hw
);
100 static int32_t e1000_phy_force_speed_duplex(struct e1000_hw
*hw
);
101 static int32_t e1000_config_mac_to_phy(struct e1000_hw
*hw
);
102 static void e1000_raise_mdi_clk(struct e1000_hw
*hw
, uint32_t *ctrl
);
103 static void e1000_lower_mdi_clk(struct e1000_hw
*hw
, uint32_t *ctrl
);
104 static void e1000_shift_out_mdi_bits(struct e1000_hw
*hw
, uint32_t data
,
106 static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw
*hw
);
107 static int32_t e1000_phy_reset_dsp(struct e1000_hw
*hw
);
108 static int32_t e1000_write_eeprom_spi(struct e1000_hw
*hw
, uint16_t offset
,
109 uint16_t words
, uint16_t *data
);
110 static int32_t e1000_write_eeprom_microwire(struct e1000_hw
*hw
,
111 uint16_t offset
, uint16_t words
,
113 static int32_t e1000_spi_eeprom_ready(struct e1000_hw
*hw
);
114 static void e1000_raise_ee_clk(struct e1000_hw
*hw
, uint32_t *eecd
);
115 static void e1000_lower_ee_clk(struct e1000_hw
*hw
, uint32_t *eecd
);
116 static void e1000_shift_out_ee_bits(struct e1000_hw
*hw
, uint16_t data
,
118 static int32_t e1000_write_phy_reg_ex(struct e1000_hw
*hw
, uint32_t reg_addr
,
120 static int32_t e1000_read_phy_reg_ex(struct e1000_hw
*hw
,uint32_t reg_addr
,
122 static uint16_t e1000_shift_in_ee_bits(struct e1000_hw
*hw
, uint16_t count
);
123 static int32_t e1000_acquire_eeprom(struct e1000_hw
*hw
);
124 static void e1000_release_eeprom(struct e1000_hw
*hw
);
125 static void e1000_standby_eeprom(struct e1000_hw
*hw
);
126 static int32_t e1000_set_vco_speed(struct e1000_hw
*hw
);
127 static int32_t e1000_polarity_reversal_workaround(struct e1000_hw
*hw
);
128 static int32_t e1000_set_phy_mode(struct e1000_hw
*hw
);
129 static int32_t e1000_host_if_read_cookie(struct e1000_hw
*hw
, uint8_t *buffer
);
130 static uint8_t e1000_calculate_mng_checksum(char *buffer
, uint32_t length
);
131 static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw
*hw
,
133 static int32_t e1000_configure_kmrn_for_1000(struct e1000_hw
*hw
);
135 /* IGP cable length table */
137 uint16_t e1000_igp_cable_length_table
[IGP01E1000_AGC_LENGTH_TABLE_SIZE
] =
138 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
139 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
140 25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
141 40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
142 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
143 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
144 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
145 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
148 uint16_t e1000_igp_2_cable_length_table
[IGP02E1000_AGC_LENGTH_TABLE_SIZE
] =
149 { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
150 0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
151 6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
152 21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
153 40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
154 60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
155 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
156 104, 109, 114, 118, 121, 124};
158 /******************************************************************************
159 * Set the phy type member in the hw struct.
161 * hw - Struct containing variables accessed by shared code
162 *****************************************************************************/
164 e1000_set_phy_type(struct e1000_hw
*hw
)
166 DEBUGFUNC("e1000_set_phy_type");
168 if (hw
->mac_type
== e1000_undefined
)
169 return -E1000_ERR_PHY_TYPE
;
171 switch (hw
->phy_id
) {
172 case M88E1000_E_PHY_ID
:
173 case M88E1000_I_PHY_ID
:
174 case M88E1011_I_PHY_ID
:
175 case M88E1111_I_PHY_ID
:
176 hw
->phy_type
= e1000_phy_m88
;
178 case IGP01E1000_I_PHY_ID
:
179 if (hw
->mac_type
== e1000_82541
||
180 hw
->mac_type
== e1000_82541_rev_2
||
181 hw
->mac_type
== e1000_82547
||
182 hw
->mac_type
== e1000_82547_rev_2
) {
183 hw
->phy_type
= e1000_phy_igp
;
186 case IGP03E1000_E_PHY_ID
:
187 hw
->phy_type
= e1000_phy_igp_3
;
190 case IFE_PLUS_E_PHY_ID
:
192 hw
->phy_type
= e1000_phy_ife
;
194 case GG82563_E_PHY_ID
:
195 if (hw
->mac_type
== e1000_80003es2lan
) {
196 hw
->phy_type
= e1000_phy_gg82563
;
201 /* Should never have loaded on this device */
202 hw
->phy_type
= e1000_phy_undefined
;
203 return -E1000_ERR_PHY_TYPE
;
206 return E1000_SUCCESS
;
209 /******************************************************************************
210 * IGP phy init script - initializes the GbE PHY
212 * hw - Struct containing variables accessed by shared code
213 *****************************************************************************/
215 e1000_phy_init_script(struct e1000_hw
*hw
)
218 uint16_t phy_saved_data
;
220 DEBUGFUNC("e1000_phy_init_script");
222 if (hw
->phy_init_script
) {
225 /* Save off the current value of register 0x2F5B to be restored at
226 * the end of this routine. */
227 ret_val
= e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
229 /* Disabled the PHY transmitter */
230 e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
234 e1000_write_phy_reg(hw
,0x0000,0x0140);
238 switch (hw
->mac_type
) {
241 e1000_write_phy_reg(hw
, 0x1F95, 0x0001);
243 e1000_write_phy_reg(hw
, 0x1F71, 0xBD21);
245 e1000_write_phy_reg(hw
, 0x1F79, 0x0018);
247 e1000_write_phy_reg(hw
, 0x1F30, 0x1600);
249 e1000_write_phy_reg(hw
, 0x1F31, 0x0014);
251 e1000_write_phy_reg(hw
, 0x1F32, 0x161C);
253 e1000_write_phy_reg(hw
, 0x1F94, 0x0003);
255 e1000_write_phy_reg(hw
, 0x1F96, 0x003F);
257 e1000_write_phy_reg(hw
, 0x2010, 0x0008);
260 case e1000_82541_rev_2
:
261 case e1000_82547_rev_2
:
262 e1000_write_phy_reg(hw
, 0x1F73, 0x0099);
268 e1000_write_phy_reg(hw
, 0x0000, 0x3300);
272 /* Now enable the transmitter */
273 e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
275 if (hw
->mac_type
== e1000_82547
) {
276 uint16_t fused
, fine
, coarse
;
278 /* Move to analog registers page */
279 e1000_read_phy_reg(hw
, IGP01E1000_ANALOG_SPARE_FUSE_STATUS
, &fused
);
281 if (!(fused
& IGP01E1000_ANALOG_SPARE_FUSE_ENABLED
)) {
282 e1000_read_phy_reg(hw
, IGP01E1000_ANALOG_FUSE_STATUS
, &fused
);
284 fine
= fused
& IGP01E1000_ANALOG_FUSE_FINE_MASK
;
285 coarse
= fused
& IGP01E1000_ANALOG_FUSE_COARSE_MASK
;
287 if (coarse
> IGP01E1000_ANALOG_FUSE_COARSE_THRESH
) {
288 coarse
-= IGP01E1000_ANALOG_FUSE_COARSE_10
;
289 fine
-= IGP01E1000_ANALOG_FUSE_FINE_1
;
290 } else if (coarse
== IGP01E1000_ANALOG_FUSE_COARSE_THRESH
)
291 fine
-= IGP01E1000_ANALOG_FUSE_FINE_10
;
293 fused
= (fused
& IGP01E1000_ANALOG_FUSE_POLY_MASK
) |
294 (fine
& IGP01E1000_ANALOG_FUSE_FINE_MASK
) |
295 (coarse
& IGP01E1000_ANALOG_FUSE_COARSE_MASK
);
297 e1000_write_phy_reg(hw
, IGP01E1000_ANALOG_FUSE_CONTROL
, fused
);
298 e1000_write_phy_reg(hw
, IGP01E1000_ANALOG_FUSE_BYPASS
,
299 IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL
);
305 /******************************************************************************
306 * Set the mac type member in the hw struct.
308 * hw - Struct containing variables accessed by shared code
309 *****************************************************************************/
311 e1000_set_mac_type(struct e1000_hw
*hw
)
313 DEBUGFUNC("e1000_set_mac_type");
315 switch (hw
->device_id
) {
316 case E1000_DEV_ID_82542
:
317 switch (hw
->revision_id
) {
318 case E1000_82542_2_0_REV_ID
:
319 hw
->mac_type
= e1000_82542_rev2_0
;
321 case E1000_82542_2_1_REV_ID
:
322 hw
->mac_type
= e1000_82542_rev2_1
;
325 /* Invalid 82542 revision ID */
326 return -E1000_ERR_MAC_TYPE
;
329 case E1000_DEV_ID_82543GC_FIBER
:
330 case E1000_DEV_ID_82543GC_COPPER
:
331 hw
->mac_type
= e1000_82543
;
333 case E1000_DEV_ID_82544EI_COPPER
:
334 case E1000_DEV_ID_82544EI_FIBER
:
335 case E1000_DEV_ID_82544GC_COPPER
:
336 case E1000_DEV_ID_82544GC_LOM
:
337 hw
->mac_type
= e1000_82544
;
339 case E1000_DEV_ID_82540EM
:
340 case E1000_DEV_ID_82540EM_LOM
:
341 case E1000_DEV_ID_82540EP
:
342 case E1000_DEV_ID_82540EP_LOM
:
343 case E1000_DEV_ID_82540EP_LP
:
344 hw
->mac_type
= e1000_82540
;
346 case E1000_DEV_ID_82545EM_COPPER
:
347 case E1000_DEV_ID_82545EM_FIBER
:
348 hw
->mac_type
= e1000_82545
;
350 case E1000_DEV_ID_82545GM_COPPER
:
351 case E1000_DEV_ID_82545GM_FIBER
:
352 case E1000_DEV_ID_82545GM_SERDES
:
353 hw
->mac_type
= e1000_82545_rev_3
;
355 case E1000_DEV_ID_82546EB_COPPER
:
356 case E1000_DEV_ID_82546EB_FIBER
:
357 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
358 hw
->mac_type
= e1000_82546
;
360 case E1000_DEV_ID_82546GB_COPPER
:
361 case E1000_DEV_ID_82546GB_FIBER
:
362 case E1000_DEV_ID_82546GB_SERDES
:
363 case E1000_DEV_ID_82546GB_PCIE
:
364 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
365 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
366 hw
->mac_type
= e1000_82546_rev_3
;
368 case E1000_DEV_ID_82541EI
:
369 case E1000_DEV_ID_82541EI_MOBILE
:
370 case E1000_DEV_ID_82541ER_LOM
:
371 hw
->mac_type
= e1000_82541
;
373 case E1000_DEV_ID_82541ER
:
374 case E1000_DEV_ID_82541GI
:
375 case E1000_DEV_ID_82541GI_LF
:
376 case E1000_DEV_ID_82541GI_MOBILE
:
377 hw
->mac_type
= e1000_82541_rev_2
;
379 case E1000_DEV_ID_82547EI
:
380 case E1000_DEV_ID_82547EI_MOBILE
:
381 hw
->mac_type
= e1000_82547
;
383 case E1000_DEV_ID_82547GI
:
384 hw
->mac_type
= e1000_82547_rev_2
;
386 case E1000_DEV_ID_82571EB_COPPER
:
387 case E1000_DEV_ID_82571EB_FIBER
:
388 case E1000_DEV_ID_82571EB_SERDES
:
389 case E1000_DEV_ID_82571EB_SERDES_DUAL
:
390 case E1000_DEV_ID_82571EB_SERDES_QUAD
:
391 case E1000_DEV_ID_82571EB_QUAD_COPPER
:
392 case E1000_DEV_ID_82571EB_QUAD_FIBER
:
393 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE
:
394 hw
->mac_type
= e1000_82571
;
396 case E1000_DEV_ID_82572EI_COPPER
:
397 case E1000_DEV_ID_82572EI_FIBER
:
398 case E1000_DEV_ID_82572EI_SERDES
:
399 case E1000_DEV_ID_82572EI
:
400 hw
->mac_type
= e1000_82572
;
402 case E1000_DEV_ID_82573E
:
403 case E1000_DEV_ID_82573E_IAMT
:
404 case E1000_DEV_ID_82573L
:
405 hw
->mac_type
= e1000_82573
;
407 case E1000_DEV_ID_80003ES2LAN_COPPER_SPT
:
408 case E1000_DEV_ID_80003ES2LAN_SERDES_SPT
:
409 case E1000_DEV_ID_80003ES2LAN_COPPER_DPT
:
410 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT
:
411 hw
->mac_type
= e1000_80003es2lan
;
413 case E1000_DEV_ID_ICH8_IGP_M_AMT
:
414 case E1000_DEV_ID_ICH8_IGP_AMT
:
415 case E1000_DEV_ID_ICH8_IGP_C
:
416 case E1000_DEV_ID_ICH8_IFE
:
417 case E1000_DEV_ID_ICH8_IFE_GT
:
418 case E1000_DEV_ID_ICH8_IFE_G
:
419 case E1000_DEV_ID_ICH8_IGP_M
:
420 hw
->mac_type
= e1000_ich8lan
;
422 case E1000_DEV_ID_82576
:
423 hw
->mac_type
= e1000_82576
;
426 /* Should never have loaded on this device */
427 return -E1000_ERR_MAC_TYPE
;
430 switch (hw
->mac_type
) {
433 hw
->swfwhw_semaphore_present
= TRUE
;
434 hw
->asf_firmware_present
= TRUE
;
436 case e1000_80003es2lan
:
437 hw
->swfw_sync_present
= TRUE
;
442 hw
->eeprom_semaphore_present
= TRUE
;
446 case e1000_82541_rev_2
:
447 case e1000_82547_rev_2
:
448 hw
->asf_firmware_present
= TRUE
;
454 /* The 82543 chip does not count tx_carrier_errors properly in
457 if (hw
->mac_type
== e1000_82543
)
458 hw
->bad_tx_carr_stats_fd
= TRUE
;
460 /* capable of receiving management packets to the host */
461 if (hw
->mac_type
>= e1000_82571
)
462 hw
->has_manc2h
= TRUE
;
464 /* In rare occasions, ESB2 systems would end up started without
465 * the RX unit being turned on.
467 if (hw
->mac_type
== e1000_80003es2lan
)
468 hw
->rx_needs_kicking
= TRUE
;
470 if (hw
->mac_type
> e1000_82544
)
471 hw
->has_smbus
= TRUE
;
473 return E1000_SUCCESS
;
476 /*****************************************************************************
477 * Set media type and TBI compatibility.
479 * hw - Struct containing variables accessed by shared code
480 * **************************************************************************/
482 e1000_set_media_type(struct e1000_hw
*hw
)
486 DEBUGFUNC("e1000_set_media_type");
488 if (hw
->mac_type
!= e1000_82543
) {
489 /* tbi_compatibility is only valid on 82543 */
490 hw
->tbi_compatibility_en
= FALSE
;
493 switch (hw
->device_id
) {
494 case E1000_DEV_ID_82545GM_SERDES
:
495 case E1000_DEV_ID_82546GB_SERDES
:
496 case E1000_DEV_ID_82571EB_SERDES
:
497 case E1000_DEV_ID_82571EB_SERDES_DUAL
:
498 case E1000_DEV_ID_82571EB_SERDES_QUAD
:
499 case E1000_DEV_ID_82572EI_SERDES
:
500 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT
:
501 hw
->media_type
= e1000_media_type_internal_serdes
;
504 switch (hw
->mac_type
) {
505 case e1000_82542_rev2_0
:
506 case e1000_82542_rev2_1
:
507 hw
->media_type
= e1000_media_type_fiber
;
512 /* The STATUS_TBIMODE bit is reserved or reused for the this
515 hw
->media_type
= e1000_media_type_copper
;
518 status
= E1000_READ_REG(hw
, STATUS
);
519 if (status
& E1000_STATUS_TBIMODE
) {
520 hw
->media_type
= e1000_media_type_fiber
;
521 /* tbi_compatibility not valid on fiber */
522 hw
->tbi_compatibility_en
= FALSE
;
524 hw
->media_type
= e1000_media_type_copper
;
531 /******************************************************************************
532 * Reset the transmit and receive units; mask and clear all interrupts.
534 * hw - Struct containing variables accessed by shared code
535 *****************************************************************************/
537 e1000_reset_hw(struct e1000_hw
*hw
)
545 uint32_t extcnf_ctrl
;
548 DEBUGFUNC("e1000_reset_hw");
550 /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
551 if (hw
->mac_type
== e1000_82542_rev2_0
) {
552 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
553 e1000_pci_clear_mwi(hw
);
556 if (hw
->bus_type
== e1000_bus_type_pci_express
) {
557 /* Prevent the PCI-E bus from sticking if there is no TLP connection
558 * on the last TLP read/write transaction when MAC is reset.
560 if (e1000_disable_pciex_master(hw
) != E1000_SUCCESS
) {
561 DEBUGOUT("PCI-E Master disable polling has failed.\n");
565 /* Clear interrupt mask to stop board from generating interrupts */
566 DEBUGOUT("Masking off all interrupts\n");
567 E1000_WRITE_REG(hw
, IMC
, 0xffffffff);
569 /* Disable the Transmit and Receive units. Then delay to allow
570 * any pending transactions to complete before we hit the MAC with
573 E1000_WRITE_REG(hw
, RCTL
, 0);
574 E1000_WRITE_REG(hw
, TCTL
, E1000_TCTL_PSP
);
575 E1000_WRITE_FLUSH(hw
);
577 /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
578 hw
->tbi_compatibility_on
= FALSE
;
580 /* Delay to allow any outstanding PCI transactions to complete before
581 * resetting the device
585 ctrl
= E1000_READ_REG(hw
, CTRL
);
587 /* Must reset the PHY before resetting the MAC */
588 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
589 E1000_WRITE_REG(hw
, CTRL
, (ctrl
| E1000_CTRL_PHY_RST
));
593 /* Must acquire the MDIO ownership before MAC reset.
594 * Ownership defaults to firmware after a reset. */
595 if (hw
->mac_type
== e1000_82573
) {
598 extcnf_ctrl
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
599 extcnf_ctrl
|= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
;
602 E1000_WRITE_REG(hw
, EXTCNF_CTRL
, extcnf_ctrl
);
603 extcnf_ctrl
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
605 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
)
608 extcnf_ctrl
|= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
;
615 /* Workaround for ICH8 bit corruption issue in FIFO memory */
616 if (hw
->mac_type
== e1000_ich8lan
) {
617 /* Set Tx and Rx buffer allocation to 8k apiece. */
618 E1000_WRITE_REG(hw
, PBA
, E1000_PBA_8K
);
619 /* Set Packet Buffer Size to 16k. */
620 E1000_WRITE_REG(hw
, PBS
, E1000_PBS_16K
);
623 /* Issue a global reset to the MAC. This will reset the chip's
624 * transmit, receive, DMA, and link units. It will not effect
625 * the current PCI configuration. The global reset bit is self-
626 * clearing, and should clear within a microsecond.
628 DEBUGOUT("Issuing a global reset to MAC\n");
630 switch (hw
->mac_type
) {
636 case e1000_82541_rev_2
:
637 /* These controllers can't ack the 64-bit write when issuing the
638 * reset, so use IO-mapping as a workaround to issue the reset */
639 E1000_WRITE_REG_IO(hw
, CTRL
, (ctrl
| E1000_CTRL_RST
));
641 case e1000_82545_rev_3
:
642 case e1000_82546_rev_3
:
643 /* Reset is performed on a shadow of the control register */
644 E1000_WRITE_REG(hw
, CTRL_DUP
, (ctrl
| E1000_CTRL_RST
));
647 if (!hw
->phy_reset_disable
&&
648 e1000_check_phy_reset_block(hw
) == E1000_SUCCESS
) {
649 /* e1000_ich8lan PHY HW reset requires MAC CORE reset
650 * at the same time to make sure the interface between
651 * MAC and the external PHY is reset.
653 ctrl
|= E1000_CTRL_PHY_RST
;
656 e1000_get_software_flag(hw
);
657 E1000_WRITE_REG(hw
, CTRL
, (ctrl
| E1000_CTRL_RST
));
661 E1000_WRITE_REG(hw
, CTRL
, (ctrl
| E1000_CTRL_RST
));
665 /* After MAC reset, force reload of EEPROM to restore power-on settings to
666 * device. Later controllers reload the EEPROM automatically, so just wait
667 * for reload to complete.
669 switch (hw
->mac_type
) {
670 case e1000_82542_rev2_0
:
671 case e1000_82542_rev2_1
:
674 /* Wait for reset to complete */
676 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
677 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
678 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
679 E1000_WRITE_FLUSH(hw
);
680 /* Wait for EEPROM reload */
684 case e1000_82541_rev_2
:
686 case e1000_82547_rev_2
:
687 /* Wait for EEPROM reload */
691 if (e1000_is_onboard_nvm_eeprom(hw
) == FALSE
) {
693 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
694 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
695 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
696 E1000_WRITE_FLUSH(hw
);
700 /* Auto read done will delay 5ms or poll based on mac type */
701 ret_val
= e1000_get_auto_rd_done(hw
);
707 /* Disable HW ARPs on ASF enabled adapters */
708 if (hw
->mac_type
>= e1000_82540
&& hw
->mac_type
<= e1000_82547_rev_2
) {
709 manc
= E1000_READ_REG(hw
, MANC
);
710 manc
&= ~(E1000_MANC_ARP_EN
);
711 E1000_WRITE_REG(hw
, MANC
, manc
);
714 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
715 e1000_phy_init_script(hw
);
717 /* Configure activity LED after PHY reset */
718 led_ctrl
= E1000_READ_REG(hw
, LEDCTL
);
719 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
720 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
721 E1000_WRITE_REG(hw
, LEDCTL
, led_ctrl
);
724 /* Clear interrupt mask to stop board from generating interrupts */
725 DEBUGOUT("Masking off all interrupts\n");
726 E1000_WRITE_REG(hw
, IMC
, 0xffffffff);
728 /* Clear any pending interrupt events. */
729 icr
= E1000_READ_REG(hw
, ICR
);
731 if (hw
->mac_type
== e1000_82571
&& hw
->laa_is_present
== TRUE
) {
733 * Hold a copy of the LAA in RAR[14] This is done so that
734 * between the time RAR[0] gets clobbered and the time it
735 * gets fixed, the actual LAA is in one of the RARs and no
736 * incoming packets directed to this port are dropped.
737 * Eventually the LAA will be in RAR[0] and RAR[14].
739 e1000_rar_set(hw
, hw
->mac_addr
, E1000_RAR_ENTRIES
- 1);
742 /* If MWI was previously enabled, reenable it. */
743 if (hw
->mac_type
== e1000_82542_rev2_0
) {
744 if (hw
->pci_cmd_word
& PCI_COMMAND_INVALIDATE
)
745 e1000_pci_set_mwi(hw
);
748 if (hw
->mac_type
== e1000_ich8lan
) {
749 uint32_t kab
= E1000_READ_REG(hw
, KABGTXD
);
750 kab
|= E1000_KABGTXD_BGSQLBIAS
;
751 E1000_WRITE_REG(hw
, KABGTXD
, kab
);
754 return E1000_SUCCESS
;
757 /******************************************************************************
759 * Initialize a number of hardware-dependent bits
761 * hw: Struct containing variables accessed by shared code
763 * This function contains hardware limitation workarounds for PCI-E adapters
765 *****************************************************************************/
767 e1000_initialize_hardware_bits(struct e1000_hw
*hw
)
769 if ((hw
->mac_type
>= e1000_82571
&& hw
->mac_type
< e1000_82576
) &&
770 (!hw
->initialize_hw_bits_disable
)) {
771 /* Settings common to all PCI-express silicon */
772 uint32_t reg_ctrl
, reg_ctrl_ext
;
773 uint32_t reg_tarc0
, reg_tarc1
;
775 uint32_t reg_txdctl
, reg_txdctl1
;
777 /* link autonegotiation/sync workarounds */
778 reg_tarc0
= E1000_READ_REG(hw
, TARC0
);
779 reg_tarc0
&= ~((1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
781 /* Enable not-done TX descriptor counting */
782 reg_txdctl
= E1000_READ_REG(hw
, TXDCTL
);
783 reg_txdctl
|= E1000_TXDCTL_COUNT_DESC
;
784 E1000_WRITE_REG(hw
, TXDCTL
, reg_txdctl
);
785 reg_txdctl1
= E1000_READ_REG(hw
, TXDCTL1
);
786 reg_txdctl1
|= E1000_TXDCTL_COUNT_DESC
;
787 E1000_WRITE_REG(hw
, TXDCTL1
, reg_txdctl1
);
789 switch (hw
->mac_type
) {
792 /* Clear PHY TX compatible mode bits */
793 reg_tarc1
= E1000_READ_REG(hw
, TARC1
);
794 reg_tarc1
&= ~((1 << 30)|(1 << 29));
796 /* link autonegotiation/sync workarounds */
797 reg_tarc0
|= ((1 << 26)|(1 << 25)|(1 << 24)|(1 << 23));
799 /* TX ring control fixes */
800 reg_tarc1
|= ((1 << 26)|(1 << 25)|(1 << 24));
802 /* Multiple read bit is reversed polarity */
803 reg_tctl
= E1000_READ_REG(hw
, TCTL
);
804 if (reg_tctl
& E1000_TCTL_MULR
)
805 reg_tarc1
&= ~(1 << 28);
807 reg_tarc1
|= (1 << 28);
809 E1000_WRITE_REG(hw
, TARC1
, reg_tarc1
);
812 reg_ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
813 reg_ctrl_ext
&= ~(1 << 23);
814 reg_ctrl_ext
|= (1 << 22);
816 /* TX byte count fix */
817 reg_ctrl
= E1000_READ_REG(hw
, CTRL
);
818 reg_ctrl
&= ~(1 << 29);
820 E1000_WRITE_REG(hw
, CTRL_EXT
, reg_ctrl_ext
);
821 E1000_WRITE_REG(hw
, CTRL
, reg_ctrl
);
823 case e1000_80003es2lan
:
824 /* improve small packet performace for fiber/serdes */
825 if ((hw
->media_type
== e1000_media_type_fiber
) ||
826 (hw
->media_type
== e1000_media_type_internal_serdes
)) {
827 reg_tarc0
&= ~(1 << 20);
830 /* Multiple read bit is reversed polarity */
831 reg_tctl
= E1000_READ_REG(hw
, TCTL
);
832 reg_tarc1
= E1000_READ_REG(hw
, TARC1
);
833 if (reg_tctl
& E1000_TCTL_MULR
)
834 reg_tarc1
&= ~(1 << 28);
836 reg_tarc1
|= (1 << 28);
838 E1000_WRITE_REG(hw
, TARC1
, reg_tarc1
);
841 /* Reduce concurrent DMA requests to 3 from 4 */
842 if ((hw
->revision_id
< 3) ||
843 ((hw
->device_id
!= E1000_DEV_ID_ICH8_IGP_M_AMT
) &&
844 (hw
->device_id
!= E1000_DEV_ID_ICH8_IGP_M
)))
845 reg_tarc0
|= ((1 << 29)|(1 << 28));
847 reg_ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
848 reg_ctrl_ext
|= (1 << 22);
849 E1000_WRITE_REG(hw
, CTRL_EXT
, reg_ctrl_ext
);
851 /* workaround TX hang with TSO=on */
852 reg_tarc0
|= ((1 << 27)|(1 << 26)|(1 << 24)|(1 << 23));
854 /* Multiple read bit is reversed polarity */
855 reg_tctl
= E1000_READ_REG(hw
, TCTL
);
856 reg_tarc1
= E1000_READ_REG(hw
, TARC1
);
857 if (reg_tctl
& E1000_TCTL_MULR
)
858 reg_tarc1
&= ~(1 << 28);
860 reg_tarc1
|= (1 << 28);
862 /* workaround TX hang with TSO=on */
863 reg_tarc1
|= ((1 << 30)|(1 << 26)|(1 << 24));
865 E1000_WRITE_REG(hw
, TARC1
, reg_tarc1
);
871 E1000_WRITE_REG(hw
, TARC0
, reg_tarc0
);
875 /******************************************************************************
876 * Performs basic configuration of the adapter.
878 * hw - Struct containing variables accessed by shared code
880 * Assumes that the controller has previously been reset and is in a
881 * post-reset uninitialized state. Initializes the receive address registers,
882 * multicast table, and VLAN filter table. Calls routines to setup link
883 * configuration and flow control settings. Clears all on-chip counters. Leaves
884 * the transmit and receive units disabled and uninitialized.
885 *****************************************************************************/
887 e1000_init_hw(struct e1000_hw
*hw
)
892 uint16_t pcix_cmd_word
;
893 uint16_t pcix_stat_hi_word
;
900 DEBUGFUNC("e1000_init_hw");
902 /* force full DMA clock frequency for 10/100 on ICH8 A0-B0 */
903 if ((hw
->mac_type
== e1000_ich8lan
) &&
904 ((hw
->revision_id
< 3) ||
905 ((hw
->device_id
!= E1000_DEV_ID_ICH8_IGP_M_AMT
) &&
906 (hw
->device_id
!= E1000_DEV_ID_ICH8_IGP_M
)))) {
907 reg_data
= E1000_READ_REG(hw
, STATUS
);
908 reg_data
&= ~0x80000000;
909 E1000_WRITE_REG(hw
, STATUS
, reg_data
);
912 /* Initialize Identification LED */
913 ret_val
= e1000_id_led_init(hw
);
915 DEBUGOUT("Error Initializing Identification LED\n");
919 /* Set the media type and TBI compatibility */
920 e1000_set_media_type(hw
);
922 /* Must be called after e1000_set_media_type because media_type is used */
923 e1000_initialize_hardware_bits(hw
);
925 /* Disabling VLAN filtering. */
926 DEBUGOUT("Initializing the IEEE VLAN\n");
927 switch (hw
->mac_type
) {
929 /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */
932 /* There is no need to clear vfta on 82576 if VLANs are not used.
933 * - Intel® 82576 Gigabit Ethernet Controller Datasheet r2.41
934 * Section 8.10.19 Table Array - VFTA
936 * Setting VET may also be unnecessary, however the documentation
937 * isn't specific on this point. The value used here is as advised in
938 * - Intel® 82576 Gigabit Ethernet Controller Datasheet r2.41
939 * Section 8.2.7 VLAN Ether Type - VET
941 E1000_WRITE_REG(hw
, VET
, ETHERNET_IEEE_VLAN_TYPE
);
944 if (hw
->mac_type
< e1000_82545_rev_3
)
945 E1000_WRITE_REG(hw
, VET
, 0);
946 e1000_clear_vfta(hw
);
950 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
951 if (hw
->mac_type
== e1000_82542_rev2_0
) {
952 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
953 e1000_pci_clear_mwi(hw
);
954 E1000_WRITE_REG(hw
, RCTL
, E1000_RCTL_RST
);
955 E1000_WRITE_FLUSH(hw
);
959 /* Setup the receive address. This involves initializing all of the Receive
960 * Address Registers (RARs 0 - 15).
962 e1000_init_rx_addrs(hw
);
964 /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
965 if (hw
->mac_type
== e1000_82542_rev2_0
) {
966 E1000_WRITE_REG(hw
, RCTL
, 0);
967 E1000_WRITE_FLUSH(hw
);
969 if (hw
->pci_cmd_word
& PCI_COMMAND_INVALIDATE
)
970 e1000_pci_set_mwi(hw
);
973 /* Zero out the Multicast HASH table */
974 DEBUGOUT("Zeroing the MTA\n");
975 mta_size
= E1000_MC_TBL_SIZE
;
976 if (hw
->mac_type
== e1000_ich8lan
)
977 mta_size
= E1000_MC_TBL_SIZE_ICH8LAN
;
978 for (i
= 0; i
< mta_size
; i
++) {
979 E1000_WRITE_REG_ARRAY(hw
, MTA
, i
, 0);
980 /* use write flush to prevent Memory Write Block (MWB) from
981 * occuring when accessing our register space */
982 E1000_WRITE_FLUSH(hw
);
985 /* Set the PCI priority bit correctly in the CTRL register. This
986 * determines if the adapter gives priority to receives, or if it
987 * gives equal priority to transmits and receives. Valid only on
988 * 82542 and 82543 silicon.
990 if (hw
->dma_fairness
&& hw
->mac_type
<= e1000_82543
) {
991 ctrl
= E1000_READ_REG(hw
, CTRL
);
992 E1000_WRITE_REG(hw
, CTRL
, ctrl
| E1000_CTRL_PRIOR
);
995 switch (hw
->mac_type
) {
996 case e1000_82545_rev_3
:
997 case e1000_82546_rev_3
:
1000 /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
1001 if (hw
->bus_type
== e1000_bus_type_pcix
) {
1002 e1000_read_pci_cfg(hw
, PCIX_COMMAND_REGISTER
, &pcix_cmd_word
);
1003 e1000_read_pci_cfg(hw
, PCIX_STATUS_REGISTER_HI
,
1004 &pcix_stat_hi_word
);
1005 cmd_mmrbc
= (pcix_cmd_word
& PCIX_COMMAND_MMRBC_MASK
) >>
1006 PCIX_COMMAND_MMRBC_SHIFT
;
1007 stat_mmrbc
= (pcix_stat_hi_word
& PCIX_STATUS_HI_MMRBC_MASK
) >>
1008 PCIX_STATUS_HI_MMRBC_SHIFT
;
1009 if (stat_mmrbc
== PCIX_STATUS_HI_MMRBC_4K
)
1010 stat_mmrbc
= PCIX_STATUS_HI_MMRBC_2K
;
1011 if (cmd_mmrbc
> stat_mmrbc
) {
1012 pcix_cmd_word
&= ~PCIX_COMMAND_MMRBC_MASK
;
1013 pcix_cmd_word
|= stat_mmrbc
<< PCIX_COMMAND_MMRBC_SHIFT
;
1014 e1000_write_pci_cfg(hw
, PCIX_COMMAND_REGISTER
,
1021 /* More time needed for PHY to initialize */
1022 if (hw
->mac_type
== e1000_ich8lan
)
1025 /* Call a subroutine to configure the link and setup flow control. */
1026 ret_val
= e1000_setup_link(hw
);
1028 /* Set the transmit descriptor write-back policy */
1029 if (hw
->mac_type
> e1000_82544
) {
1030 ctrl
= E1000_READ_REG(hw
, TXDCTL
);
1031 ctrl
= (ctrl
& ~E1000_TXDCTL_WTHRESH
) | E1000_TXDCTL_FULL_TX_DESC_WB
;
1032 E1000_WRITE_REG(hw
, TXDCTL
, ctrl
);
1035 if (hw
->mac_type
== e1000_82573
) {
1036 e1000_enable_tx_pkt_filtering(hw
);
1039 switch (hw
->mac_type
) {
1042 case e1000_80003es2lan
:
1043 /* Enable retransmit on late collisions */
1044 reg_data
= E1000_READ_REG(hw
, TCTL
);
1045 reg_data
|= E1000_TCTL_RTLC
;
1046 E1000_WRITE_REG(hw
, TCTL
, reg_data
);
1048 /* Configure Gigabit Carry Extend Padding */
1049 reg_data
= E1000_READ_REG(hw
, TCTL_EXT
);
1050 reg_data
&= ~E1000_TCTL_EXT_GCEX_MASK
;
1051 reg_data
|= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX
;
1052 E1000_WRITE_REG(hw
, TCTL_EXT
, reg_data
);
1054 /* Configure Transmit Inter-Packet Gap */
1055 reg_data
= E1000_READ_REG(hw
, TIPG
);
1056 reg_data
&= ~E1000_TIPG_IPGT_MASK
;
1057 reg_data
|= DEFAULT_80003ES2LAN_TIPG_IPGT_1000
;
1058 E1000_WRITE_REG(hw
, TIPG
, reg_data
);
1060 reg_data
= E1000_READ_REG_ARRAY(hw
, FFLT
, 0x0001);
1061 reg_data
&= ~0x00100000;
1062 E1000_WRITE_REG_ARRAY(hw
, FFLT
, 0x0001, reg_data
);
1067 ctrl
= E1000_READ_REG(hw
, TXDCTL1
);
1068 ctrl
= (ctrl
& ~E1000_TXDCTL_WTHRESH
) | E1000_TXDCTL_FULL_TX_DESC_WB
;
1069 E1000_WRITE_REG(hw
, TXDCTL1
, ctrl
);
1074 if (hw
->mac_type
== e1000_82573
) {
1075 uint32_t gcr
= E1000_READ_REG(hw
, GCR
);
1076 gcr
|= E1000_GCR_L1_ACT_WITHOUT_L0S_RX
;
1077 E1000_WRITE_REG(hw
, GCR
, gcr
);
1080 /* Clear all of the statistics registers (clear on read). It is
1081 * important that we do this after we have tried to establish link
1082 * because the symbol error count will increment wildly if there
1085 e1000_clear_hw_cntrs(hw
);
1087 /* ICH8 No-snoop bits are opposite polarity.
1088 * Set to snoop by default after reset. */
1089 if (hw
->mac_type
== e1000_ich8lan
)
1090 e1000_set_pci_ex_no_snoop(hw
, PCI_EX_82566_SNOOP_ALL
);
1092 if (hw
->device_id
== E1000_DEV_ID_82546GB_QUAD_COPPER
||
1093 hw
->device_id
== E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
) {
1094 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
1095 /* Relaxed ordering must be disabled to avoid a parity
1096 * error crash in a PCI slot. */
1097 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
1098 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
1104 /******************************************************************************
1105 * Adjust SERDES output amplitude based on EEPROM setting.
1107 * hw - Struct containing variables accessed by shared code.
1108 *****************************************************************************/
1110 e1000_adjust_serdes_amplitude(struct e1000_hw
*hw
)
1112 uint16_t eeprom_data
;
1115 DEBUGFUNC("e1000_adjust_serdes_amplitude");
1117 if (hw
->media_type
!= e1000_media_type_internal_serdes
)
1118 return E1000_SUCCESS
;
1120 switch (hw
->mac_type
) {
1121 case e1000_82545_rev_3
:
1122 case e1000_82546_rev_3
:
1125 return E1000_SUCCESS
;
1128 ret_val
= e1000_read_eeprom(hw
, EEPROM_SERDES_AMPLITUDE
, 1, &eeprom_data
);
1133 if (eeprom_data
!= EEPROM_RESERVED_WORD
) {
1134 /* Adjust SERDES output amplitude only. */
1135 eeprom_data
&= EEPROM_SERDES_AMPLITUDE_MASK
;
1136 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_EXT_CTRL
, eeprom_data
);
1141 return E1000_SUCCESS
;
1144 /******************************************************************************
1145 * Configures flow control and link settings.
1147 * hw - Struct containing variables accessed by shared code
1149 * Determines which flow control settings to use. Calls the apropriate media-
1150 * specific link configuration function. Configures the flow control settings.
1151 * Assuming the adapter has a valid link partner, a valid link should be
1152 * established. Assumes the hardware has previously been reset and the
1153 * transmitter and receiver are not enabled.
1154 *****************************************************************************/
1156 e1000_setup_link(struct e1000_hw
*hw
)
1160 uint16_t eeprom_data
;
1162 DEBUGFUNC("e1000_setup_link");
1164 /* In the case of the phy reset being blocked, we already have a link.
1165 * We do not have to set it up again. */
1166 if (e1000_check_phy_reset_block(hw
))
1167 return E1000_SUCCESS
;
1169 /* Read and store word 0x0F of the EEPROM. This word contains bits
1170 * that determine the hardware's default PAUSE (flow control) mode,
1171 * a bit that determines whether the HW defaults to enabling or
1172 * disabling auto-negotiation, and the direction of the
1173 * SW defined pins. If there is no SW over-ride of the flow
1174 * control setting, then the variable hw->fc will
1175 * be initialized based on a value in the EEPROM.
1177 if (hw
->fc
== E1000_FC_DEFAULT
) {
1178 switch (hw
->mac_type
) {
1181 hw
->fc
= E1000_FC_FULL
;
1184 ret_val
= e1000_read_eeprom(hw
, EEPROM_INIT_CONTROL2_REG
,
1187 DEBUGOUT("EEPROM Read Error\n");
1188 return -E1000_ERR_EEPROM
;
1190 if ((eeprom_data
& EEPROM_WORD0F_PAUSE_MASK
) == 0)
1191 hw
->fc
= E1000_FC_NONE
;
1192 else if ((eeprom_data
& EEPROM_WORD0F_PAUSE_MASK
) ==
1193 EEPROM_WORD0F_ASM_DIR
)
1194 hw
->fc
= E1000_FC_TX_PAUSE
;
1196 hw
->fc
= E1000_FC_FULL
;
1201 /* We want to save off the original Flow Control configuration just
1202 * in case we get disconnected and then reconnected into a different
1203 * hub or switch with different Flow Control capabilities.
1205 if (hw
->mac_type
== e1000_82542_rev2_0
)
1206 hw
->fc
&= (~E1000_FC_TX_PAUSE
);
1208 if ((hw
->mac_type
< e1000_82543
) && (hw
->report_tx_early
== 1))
1209 hw
->fc
&= (~E1000_FC_RX_PAUSE
);
1211 hw
->original_fc
= hw
->fc
;
1213 DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw
->fc
);
1215 /* Take the 4 bits from EEPROM word 0x0F that determine the initial
1216 * polarity value for the SW controlled pins, and setup the
1217 * Extended Device Control reg with that info.
1218 * This is needed because one of the SW controlled pins is used for
1219 * signal detection. So this should be done before e1000_setup_pcs_link()
1220 * or e1000_phy_setup() is called.
1222 if (hw
->mac_type
== e1000_82543
) {
1223 ret_val
= e1000_read_eeprom(hw
, EEPROM_INIT_CONTROL2_REG
,
1226 DEBUGOUT("EEPROM Read Error\n");
1227 return -E1000_ERR_EEPROM
;
1229 ctrl_ext
= ((eeprom_data
& EEPROM_WORD0F_SWPDIO_EXT
) <<
1231 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
1234 /* Call the necessary subroutine to configure the link. */
1235 ret_val
= (hw
->media_type
== e1000_media_type_copper
) ?
1236 e1000_setup_copper_link(hw
) :
1237 e1000_setup_fiber_serdes_link(hw
);
1239 /* Initialize the flow control address, type, and PAUSE timer
1240 * registers to their default values. This is done even if flow
1241 * control is disabled, because it does not hurt anything to
1242 * initialize these registers.
1244 DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
1246 /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */
1247 if (hw
->mac_type
!= e1000_ich8lan
) {
1248 E1000_WRITE_REG(hw
, FCT
, FLOW_CONTROL_TYPE
);
1249 E1000_WRITE_REG(hw
, FCAH
, FLOW_CONTROL_ADDRESS_HIGH
);
1250 E1000_WRITE_REG(hw
, FCAL
, FLOW_CONTROL_ADDRESS_LOW
);
1253 E1000_WRITE_REG(hw
, FCTTV
, hw
->fc_pause_time
);
1255 /* Set the flow control receive threshold registers. Normally,
1256 * these registers will be set to a default threshold that may be
1257 * adjusted later by the driver's runtime code. However, if the
1258 * ability to transmit pause frames in not enabled, then these
1259 * registers will be set to 0.
1261 if (!(hw
->fc
& E1000_FC_TX_PAUSE
)) {
1262 E1000_WRITE_REG(hw
, FCRTL
, 0);
1263 E1000_WRITE_REG(hw
, FCRTH
, 0);
1265 /* We need to set up the Receive Threshold high and low water marks
1266 * as well as (optionally) enabling the transmission of XON frames.
1268 if (hw
->fc_send_xon
) {
1269 E1000_WRITE_REG(hw
, FCRTL
, (hw
->fc_low_water
| E1000_FCRTL_XONE
));
1270 E1000_WRITE_REG(hw
, FCRTH
, hw
->fc_high_water
);
1272 E1000_WRITE_REG(hw
, FCRTL
, hw
->fc_low_water
);
1273 E1000_WRITE_REG(hw
, FCRTH
, hw
->fc_high_water
);
1279 /******************************************************************************
1280 * Sets up link for a fiber based or serdes based adapter
1282 * hw - Struct containing variables accessed by shared code
1284 * Manipulates Physical Coding Sublayer functions in order to configure
1285 * link. Assumes the hardware has been previously reset and the transmitter
1286 * and receiver are not enabled.
1287 *****************************************************************************/
1289 e1000_setup_fiber_serdes_link(struct e1000_hw
*hw
)
1295 uint32_t signal
= 0;
1298 DEBUGFUNC("e1000_setup_fiber_serdes_link");
1300 /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
1301 * until explicitly turned off or a power cycle is performed. A read to
1302 * the register does not indicate its status. Therefore, we ensure
1303 * loopback mode is disabled during initialization.
1305 if (hw
->mac_type
== e1000_82571
|| hw
->mac_type
== e1000_82572
)
1306 E1000_WRITE_REG(hw
, SCTL
, E1000_DISABLE_SERDES_LOOPBACK
);
1308 /* On adapters with a MAC newer than 82544, SWDP 1 will be
1309 * set when the optics detect a signal. On older adapters, it will be
1310 * cleared when there is a signal. This applies to fiber media only.
1311 * If we're on serdes media, adjust the output amplitude to value
1312 * set in the EEPROM.
1314 ctrl
= E1000_READ_REG(hw
, CTRL
);
1315 if (hw
->media_type
== e1000_media_type_fiber
)
1316 signal
= (hw
->mac_type
> e1000_82544
) ? E1000_CTRL_SWDPIN1
: 0;
1318 ret_val
= e1000_adjust_serdes_amplitude(hw
);
1322 /* Take the link out of reset */
1323 ctrl
&= ~(E1000_CTRL_LRST
);
1325 /* Adjust VCO speed to improve BER performance */
1326 ret_val
= e1000_set_vco_speed(hw
);
1330 e1000_config_collision_dist(hw
);
1332 /* Check for a software override of the flow control settings, and setup
1333 * the device accordingly. If auto-negotiation is enabled, then software
1334 * will have to set the "PAUSE" bits to the correct value in the Tranmsit
1335 * Config Word Register (TXCW) and re-start auto-negotiation. However, if
1336 * auto-negotiation is disabled, then software will have to manually
1337 * configure the two flow control enable bits in the CTRL register.
1339 * The possible values of the "fc" parameter are:
1340 * 0: Flow control is completely disabled
1341 * 1: Rx flow control is enabled (we can receive pause frames, but
1342 * not send pause frames).
1343 * 2: Tx flow control is enabled (we can send pause frames but we do
1344 * not support receiving pause frames).
1345 * 3: Both Rx and TX flow control (symmetric) are enabled.
1349 /* Flow control is completely disabled by a software over-ride. */
1350 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
);
1352 case E1000_FC_RX_PAUSE
:
1353 /* RX Flow control is enabled and TX Flow control is disabled by a
1354 * software over-ride. Since there really isn't a way to advertise
1355 * that we are capable of RX Pause ONLY, we will advertise that we
1356 * support both symmetric and asymmetric RX PAUSE. Later, we will
1357 * disable the adapter's ability to send PAUSE frames.
1359 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_PAUSE_MASK
);
1361 case E1000_FC_TX_PAUSE
:
1362 /* TX Flow control is enabled, and RX Flow control is disabled, by a
1363 * software over-ride.
1365 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_ASM_DIR
);
1368 /* Flow control (both RX and TX) is enabled by a software over-ride. */
1369 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_PAUSE_MASK
);
1372 DEBUGOUT("Flow control param set incorrectly\n");
1373 return -E1000_ERR_CONFIG
;
1377 /* Since auto-negotiation is enabled, take the link out of reset (the link
1378 * will be in reset, because we previously reset the chip). This will
1379 * restart auto-negotiation. If auto-neogtiation is successful then the
1380 * link-up status bit will be set and the flow control enable bits (RFCE
1381 * and TFCE) will be set according to their negotiated value.
1383 DEBUGOUT("Auto-negotiation enabled\n");
1385 E1000_WRITE_REG(hw
, TXCW
, txcw
);
1386 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
1387 E1000_WRITE_FLUSH(hw
);
1392 /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
1393 * indication in the Device Status Register. Time-out if a link isn't
1394 * seen in 500 milliseconds seconds (Auto-negotiation should complete in
1395 * less than 500 milliseconds even if the other end is doing it in SW).
1396 * For internal serdes, we just assume a signal is present, then poll.
1398 if (hw
->media_type
== e1000_media_type_internal_serdes
||
1399 (E1000_READ_REG(hw
, CTRL
) & E1000_CTRL_SWDPIN1
) == signal
) {
1400 DEBUGOUT("Looking for Link\n");
1401 for (i
= 0; i
< (LINK_UP_TIMEOUT
/ 10); i
++) {
1403 status
= E1000_READ_REG(hw
, STATUS
);
1404 if (status
& E1000_STATUS_LU
) break;
1406 if (i
== (LINK_UP_TIMEOUT
/ 10)) {
1407 DEBUGOUT("Never got a valid link from auto-neg!!!\n");
1408 hw
->autoneg_failed
= 1;
1409 /* AutoNeg failed to achieve a link, so we'll call
1410 * e1000_check_for_link. This routine will force the link up if
1411 * we detect a signal. This will allow us to communicate with
1412 * non-autonegotiating link partners.
1414 ret_val
= e1000_check_for_link(hw
);
1416 DEBUGOUT("Error while checking for link\n");
1419 hw
->autoneg_failed
= 0;
1421 hw
->autoneg_failed
= 0;
1422 DEBUGOUT("Valid Link Found\n");
1425 DEBUGOUT("No Signal Detected\n");
1427 return E1000_SUCCESS
;
1430 /******************************************************************************
1431 * Make sure we have a valid PHY and change PHY mode before link setup.
1433 * hw - Struct containing variables accessed by shared code
1434 ******************************************************************************/
1436 e1000_copper_link_preconfig(struct e1000_hw
*hw
)
1442 DEBUGFUNC("e1000_copper_link_preconfig");
1444 ctrl
= E1000_READ_REG(hw
, CTRL
);
1445 /* With 82543, we need to force speed and duplex on the MAC equal to what
1446 * the PHY speed and duplex configuration is. In addition, we need to
1447 * perform a hardware reset on the PHY to take it out of reset.
1449 if (hw
->mac_type
> e1000_82543
) {
1450 ctrl
|= E1000_CTRL_SLU
;
1451 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1452 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
1454 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
| E1000_CTRL_SLU
);
1455 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
1456 ret_val
= e1000_phy_hw_reset(hw
);
1461 /* Make sure we have a valid PHY */
1462 ret_val
= e1000_detect_gig_phy(hw
);
1464 DEBUGOUT("Error, did not detect valid phy.\n");
1467 DEBUGOUT1("Phy ID = %#08x \n", hw
->phy_id
);
1469 /* Set PHY to class A mode (if necessary) */
1470 ret_val
= e1000_set_phy_mode(hw
);
1474 if ((hw
->mac_type
== e1000_82545_rev_3
) ||
1475 (hw
->mac_type
== e1000_82546_rev_3
)) {
1476 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1477 phy_data
|= 0x00000008;
1478 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1481 if (hw
->mac_type
<= e1000_82543
||
1482 hw
->mac_type
== e1000_82541
|| hw
->mac_type
== e1000_82547
||
1483 hw
->mac_type
== e1000_82541_rev_2
|| hw
->mac_type
== e1000_82547_rev_2
)
1484 hw
->phy_reset_disable
= FALSE
;
1486 return E1000_SUCCESS
;
1490 /********************************************************************
1491 * Copper link setup for e1000_phy_igp series.
1493 * hw - Struct containing variables accessed by shared code
1494 *********************************************************************/
1496 e1000_copper_link_igp_setup(struct e1000_hw
*hw
)
1502 DEBUGFUNC("e1000_copper_link_igp_setup");
1504 if (hw
->phy_reset_disable
)
1505 return E1000_SUCCESS
;
1507 ret_val
= e1000_phy_reset(hw
);
1509 DEBUGOUT("Error Resetting the PHY\n");
1514 * Wait 100ms for MAC to configure PHY from NVM settings, to avoid
1515 * timeout issues when LFS is enabled.
1519 if (hw
->mac_type
!= e1000_ich8lan
&& hw
->mac_type
!= e1000_82576
) {
1520 /* Configure activity LED after PHY reset */
1521 led_ctrl
= E1000_READ_REG(hw
, LEDCTL
);
1522 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
1523 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
1524 E1000_WRITE_REG(hw
, LEDCTL
, led_ctrl
);
1527 /* The NVM settings will configure LPLU in D3 for IGP2 and IGP3 PHYs */
1528 if (hw
->phy_type
== e1000_phy_igp
) {
1529 /* disable lplu d3 during driver init */
1530 ret_val
= e1000_set_d3_lplu_state(hw
, FALSE
);
1532 DEBUGOUT("Error Disabling LPLU D3\n");
1537 /* disable lplu d0 during driver init */
1538 ret_val
= e1000_set_d0_lplu_state(hw
, FALSE
);
1540 DEBUGOUT("Error Disabling LPLU D0\n");
1543 /* Configure mdi-mdix settings */
1544 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, &phy_data
);
1548 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
1549 hw
->dsp_config_state
= e1000_dsp_config_disabled
;
1550 /* Force MDI for earlier revs of the IGP PHY */
1551 phy_data
&= ~(IGP01E1000_PSCR_AUTO_MDIX
| IGP01E1000_PSCR_FORCE_MDI_MDIX
);
1555 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
1556 phy_data
&= ~IGP01E1000_PSCR_AUTO_MDIX
;
1560 phy_data
&= ~IGP01E1000_PSCR_FORCE_MDI_MDIX
;
1563 phy_data
|= IGP01E1000_PSCR_FORCE_MDI_MDIX
;
1567 phy_data
|= IGP01E1000_PSCR_AUTO_MDIX
;
1571 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, phy_data
);
1575 /* set auto-master slave resolution settings */
1577 e1000_ms_type phy_ms_setting
= hw
->master_slave
;
1579 if (hw
->ffe_config_state
== e1000_ffe_config_active
)
1580 hw
->ffe_config_state
= e1000_ffe_config_enabled
;
1582 if (hw
->dsp_config_state
== e1000_dsp_config_activated
)
1583 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
1585 /* when autonegotiation advertisment is only 1000Mbps then we
1586 * should disable SmartSpeed and enable Auto MasterSlave
1587 * resolution as hardware default. */
1588 if (hw
->autoneg_advertised
== ADVERTISE_1000_FULL
) {
1589 /* Disable SmartSpeed */
1590 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1594 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1595 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1599 /* Set auto Master/Slave resolution process */
1600 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &phy_data
);
1603 phy_data
&= ~CR_1000T_MS_ENABLE
;
1604 ret_val
= e1000_write_phy_reg(hw
, PHY_1000T_CTRL
, phy_data
);
1609 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &phy_data
);
1613 /* load defaults for future use */
1614 hw
->original_master_slave
= (phy_data
& CR_1000T_MS_ENABLE
) ?
1615 ((phy_data
& CR_1000T_MS_VALUE
) ?
1616 e1000_ms_force_master
:
1617 e1000_ms_force_slave
) :
1620 switch (phy_ms_setting
) {
1621 case e1000_ms_force_master
:
1622 phy_data
|= (CR_1000T_MS_ENABLE
| CR_1000T_MS_VALUE
);
1624 case e1000_ms_force_slave
:
1625 phy_data
|= CR_1000T_MS_ENABLE
;
1626 phy_data
&= ~(CR_1000T_MS_VALUE
);
1629 phy_data
&= ~CR_1000T_MS_ENABLE
;
1633 ret_val
= e1000_write_phy_reg(hw
, PHY_1000T_CTRL
, phy_data
);
1638 return E1000_SUCCESS
;
1641 /********************************************************************
1642 * Copper link setup for e1000_phy_gg82563 series.
1644 * hw - Struct containing variables accessed by shared code
1645 *********************************************************************/
1647 e1000_copper_link_ggp_setup(struct e1000_hw
*hw
)
1653 DEBUGFUNC("e1000_copper_link_ggp_setup");
1655 if (!hw
->phy_reset_disable
) {
1657 /* Enable CRS on TX for half-duplex operation. */
1658 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_MAC_SPEC_CTRL
,
1663 phy_data
|= GG82563_MSCR_ASSERT_CRS_ON_TX
;
1664 /* Use 25MHz for both link down and 1000BASE-T for Tx clock */
1665 phy_data
|= GG82563_MSCR_TX_CLK_1000MBPS_25MHZ
;
1667 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_MAC_SPEC_CTRL
,
1673 * MDI/MDI-X = 0 (default)
1674 * 0 - Auto for all speeds
1677 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1679 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_SPEC_CTRL
, &phy_data
);
1683 phy_data
&= ~GG82563_PSCR_CROSSOVER_MODE_MASK
;
1687 phy_data
|= GG82563_PSCR_CROSSOVER_MODE_MDI
;
1690 phy_data
|= GG82563_PSCR_CROSSOVER_MODE_MDIX
;
1694 phy_data
|= GG82563_PSCR_CROSSOVER_MODE_AUTO
;
1699 * disable_polarity_correction = 0 (default)
1700 * Automatic Correction for Reversed Cable Polarity
1704 phy_data
&= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE
;
1705 if (hw
->disable_polarity_correction
== 1)
1706 phy_data
|= GG82563_PSCR_POLARITY_REVERSAL_DISABLE
;
1707 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_SPEC_CTRL
, phy_data
);
1712 /* SW Reset the PHY so all changes take effect */
1713 ret_val
= e1000_phy_reset(hw
);
1715 DEBUGOUT("Error Resetting the PHY\n");
1718 } /* phy_reset_disable */
1720 if (hw
->mac_type
== e1000_80003es2lan
) {
1721 /* Bypass RX and TX FIFO's */
1722 ret_val
= e1000_write_kmrn_reg(hw
, E1000_KUMCTRLSTA_OFFSET_FIFO_CTRL
,
1723 E1000_KUMCTRLSTA_FIFO_CTRL_RX_BYPASS
|
1724 E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS
);
1728 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_SPEC_CTRL_2
, &phy_data
);
1732 phy_data
&= ~GG82563_PSCR2_REVERSE_AUTO_NEG
;
1733 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_SPEC_CTRL_2
, phy_data
);
1738 reg_data
= E1000_READ_REG(hw
, CTRL_EXT
);
1739 reg_data
&= ~(E1000_CTRL_EXT_LINK_MODE_MASK
);
1740 E1000_WRITE_REG(hw
, CTRL_EXT
, reg_data
);
1742 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_PWR_MGMT_CTRL
,
1747 /* Do not init these registers when the HW is in IAMT mode, since the
1748 * firmware will have already initialized them. We only initialize
1749 * them if the HW is not in IAMT mode.
1751 if (e1000_check_mng_mode(hw
) == FALSE
) {
1752 /* Enable Electrical Idle on the PHY */
1753 phy_data
|= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE
;
1754 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_PWR_MGMT_CTRL
,
1759 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
,
1764 phy_data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
1765 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
,
1772 /* Workaround: Disable padding in Kumeran interface in the MAC
1773 * and in the PHY to avoid CRC errors.
1775 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_INBAND_CTRL
,
1779 phy_data
|= GG82563_ICR_DIS_PADDING
;
1780 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_INBAND_CTRL
,
1786 return E1000_SUCCESS
;
1789 /********************************************************************
1790 * Copper link setup for e1000_phy_m88 series.
1792 * hw - Struct containing variables accessed by shared code
1793 *********************************************************************/
1795 e1000_copper_link_mgp_setup(struct e1000_hw
*hw
)
1800 DEBUGFUNC("e1000_copper_link_mgp_setup");
1802 if (hw
->phy_reset_disable
)
1803 return E1000_SUCCESS
;
1805 /* Enable CRS on TX. This must be set for half-duplex operation. */
1806 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1810 phy_data
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
1813 * MDI/MDI-X = 0 (default)
1814 * 0 - Auto for all speeds
1817 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1819 phy_data
&= ~M88E1000_PSCR_AUTO_X_MODE
;
1823 phy_data
|= M88E1000_PSCR_MDI_MANUAL_MODE
;
1826 phy_data
|= M88E1000_PSCR_MDIX_MANUAL_MODE
;
1829 phy_data
|= M88E1000_PSCR_AUTO_X_1000T
;
1833 phy_data
|= M88E1000_PSCR_AUTO_X_MODE
;
1838 * disable_polarity_correction = 0 (default)
1839 * Automatic Correction for Reversed Cable Polarity
1843 phy_data
&= ~M88E1000_PSCR_POLARITY_REVERSAL
;
1844 if (hw
->disable_polarity_correction
== 1)
1845 phy_data
|= M88E1000_PSCR_POLARITY_REVERSAL
;
1846 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1850 if (hw
->phy_revision
< M88E1011_I_REV_4
) {
1851 /* Force TX_CLK in the Extended PHY Specific Control Register
1854 ret_val
= e1000_read_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_data
);
1858 phy_data
|= M88E1000_EPSCR_TX_CLK_25
;
1860 if ((hw
->phy_revision
== E1000_REVISION_2
) &&
1861 (hw
->phy_id
== M88E1111_I_PHY_ID
)) {
1862 /* Vidalia Phy, set the downshift counter to 5x */
1863 phy_data
&= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK
);
1864 phy_data
|= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X
;
1865 ret_val
= e1000_write_phy_reg(hw
,
1866 M88E1000_EXT_PHY_SPEC_CTRL
, phy_data
);
1870 /* Configure Master and Slave downshift values */
1871 phy_data
&= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK
|
1872 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK
);
1873 phy_data
|= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X
|
1874 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X
);
1875 ret_val
= e1000_write_phy_reg(hw
,
1876 M88E1000_EXT_PHY_SPEC_CTRL
, phy_data
);
1882 /* SW Reset the PHY so all changes take effect */
1883 ret_val
= e1000_phy_reset(hw
);
1885 DEBUGOUT("Error Resetting the PHY\n");
1889 return E1000_SUCCESS
;
1892 /********************************************************************
1893 * Setup auto-negotiation and flow control advertisements,
1894 * and then perform auto-negotiation.
1896 * hw - Struct containing variables accessed by shared code
1897 *********************************************************************/
1899 e1000_copper_link_autoneg(struct e1000_hw
*hw
)
1904 DEBUGFUNC("e1000_copper_link_autoneg");
1906 /* Perform some bounds checking on the hw->autoneg_advertised
1907 * parameter. If this variable is zero, then set it to the default.
1909 hw
->autoneg_advertised
&= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
1911 /* If autoneg_advertised is zero, we assume it was not defaulted
1912 * by the calling code so we set to advertise full capability.
1914 if (hw
->autoneg_advertised
== 0)
1915 hw
->autoneg_advertised
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
1917 /* IFE phy only supports 10/100 */
1918 if (hw
->phy_type
== e1000_phy_ife
)
1919 hw
->autoneg_advertised
&= AUTONEG_ADVERTISE_10_100_ALL
;
1921 DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
1922 ret_val
= e1000_phy_setup_autoneg(hw
);
1924 DEBUGOUT("Error Setting up Auto-Negotiation\n");
1927 DEBUGOUT("Restarting Auto-Neg\n");
1929 /* Restart auto-negotiation by setting the Auto Neg Enable bit and
1930 * the Auto Neg Restart bit in the PHY control register.
1932 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_data
);
1936 phy_data
|= (MII_CR_AUTO_NEG_EN
| MII_CR_RESTART_AUTO_NEG
);
1937 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, phy_data
);
1941 /* Does the user want to wait for Auto-Neg to complete here, or
1942 * check at a later time (for example, callback routine).
1944 if (hw
->wait_autoneg_complete
) {
1945 ret_val
= e1000_wait_autoneg(hw
);
1947 DEBUGOUT("Error while waiting for autoneg to complete\n");
1952 hw
->get_link_status
= TRUE
;
1954 return E1000_SUCCESS
;
1957 /******************************************************************************
1958 * Config the MAC and the PHY after link is up.
1959 * 1) Set up the MAC to the current PHY speed/duplex
1960 * if we are on 82543. If we
1961 * are on newer silicon, we only need to configure
1962 * collision distance in the Transmit Control Register.
1963 * 2) Set up flow control on the MAC to that established with
1965 * 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1967 * hw - Struct containing variables accessed by shared code
1968 ******************************************************************************/
1970 e1000_copper_link_postconfig(struct e1000_hw
*hw
)
1973 DEBUGFUNC("e1000_copper_link_postconfig");
1975 if (hw
->mac_type
>= e1000_82544
) {
1976 e1000_config_collision_dist(hw
);
1978 ret_val
= e1000_config_mac_to_phy(hw
);
1980 DEBUGOUT("Error configuring MAC to PHY settings\n");
1984 ret_val
= e1000_config_fc_after_link_up(hw
);
1986 DEBUGOUT("Error Configuring Flow Control\n");
1990 /* Config DSP to improve Giga link quality */
1991 if (hw
->phy_type
== e1000_phy_igp
) {
1992 ret_val
= e1000_config_dsp_after_link_change(hw
, TRUE
);
1994 DEBUGOUT("Error Configuring DSP after link up\n");
1999 return E1000_SUCCESS
;
2002 /******************************************************************************
2003 * Detects which PHY is present and setup the speed and duplex
2005 * hw - Struct containing variables accessed by shared code
2006 ******************************************************************************/
2008 e1000_setup_copper_link(struct e1000_hw
*hw
)
2015 DEBUGFUNC("e1000_setup_copper_link");
2017 switch (hw
->mac_type
) {
2018 case e1000_80003es2lan
:
2020 /* Set the mac to wait the maximum time between each
2021 * iteration and increase the max iterations when
2022 * polling the phy; this fixes erroneous timeouts at 10Mbps. */
2023 ret_val
= e1000_write_kmrn_reg(hw
, GG82563_REG(0x34, 4), 0xFFFF);
2026 ret_val
= e1000_read_kmrn_reg(hw
, GG82563_REG(0x34, 9), ®_data
);
2030 ret_val
= e1000_write_kmrn_reg(hw
, GG82563_REG(0x34, 9), reg_data
);
2037 /* Check if it is a valid PHY and set PHY mode if necessary. */
2038 ret_val
= e1000_copper_link_preconfig(hw
);
2042 switch (hw
->mac_type
) {
2043 case e1000_80003es2lan
:
2044 /* Kumeran registers are written-only */
2045 reg_data
= E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT
;
2046 reg_data
|= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING
;
2047 ret_val
= e1000_write_kmrn_reg(hw
, E1000_KUMCTRLSTA_OFFSET_INB_CTRL
,
2056 if (hw
->phy_type
== e1000_phy_igp
||
2057 hw
->phy_type
== e1000_phy_igp_3
||
2058 hw
->phy_type
== e1000_phy_igp_2
) {
2059 ret_val
= e1000_copper_link_igp_setup(hw
);
2062 } else if (hw
->phy_type
== e1000_phy_m88
) {
2063 ret_val
= e1000_copper_link_mgp_setup(hw
);
2066 } else if (hw
->phy_type
== e1000_phy_gg82563
) {
2067 ret_val
= e1000_copper_link_ggp_setup(hw
);
2073 /* Setup autoneg and flow control advertisement
2074 * and perform autonegotiation */
2075 ret_val
= e1000_copper_link_autoneg(hw
);
2079 /* PHY will be set to 10H, 10F, 100H,or 100F
2080 * depending on value from forced_speed_duplex. */
2081 DEBUGOUT("Forcing speed and duplex\n");
2082 ret_val
= e1000_phy_force_speed_duplex(hw
);
2084 DEBUGOUT("Error Forcing Speed and Duplex\n");
2089 /* Check link status. Wait up to 100 microseconds for link to become
2092 for (i
= 0; i
< 10; i
++) {
2093 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2096 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2100 if (phy_data
& MII_SR_LINK_STATUS
) {
2101 /* Config the MAC and PHY after link is up */
2102 ret_val
= e1000_copper_link_postconfig(hw
);
2106 DEBUGOUT("Valid link established!!!\n");
2107 return E1000_SUCCESS
;
2112 DEBUGOUT("Unable to establish link!!!\n");
2113 return E1000_SUCCESS
;
2116 /******************************************************************************
2117 * Configure the MAC-to-PHY interface for 10/100Mbps
2119 * hw - Struct containing variables accessed by shared code
2120 ******************************************************************************/
2122 e1000_configure_kmrn_for_10_100(struct e1000_hw
*hw
, uint16_t duplex
)
2124 int32_t ret_val
= E1000_SUCCESS
;
2128 DEBUGFUNC("e1000_configure_kmrn_for_10_100");
2130 reg_data
= E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT
;
2131 ret_val
= e1000_write_kmrn_reg(hw
, E1000_KUMCTRLSTA_OFFSET_HD_CTRL
,
2136 /* Configure Transmit Inter-Packet Gap */
2137 tipg
= E1000_READ_REG(hw
, TIPG
);
2138 tipg
&= ~E1000_TIPG_IPGT_MASK
;
2139 tipg
|= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100
;
2140 E1000_WRITE_REG(hw
, TIPG
, tipg
);
2142 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data
);
2147 if (duplex
== HALF_DUPLEX
)
2148 reg_data
|= GG82563_KMCR_PASS_FALSE_CARRIER
;
2150 reg_data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
2152 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
, reg_data
);
2158 e1000_configure_kmrn_for_1000(struct e1000_hw
*hw
)
2160 int32_t ret_val
= E1000_SUCCESS
;
2164 DEBUGFUNC("e1000_configure_kmrn_for_1000");
2166 reg_data
= E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT
;
2167 ret_val
= e1000_write_kmrn_reg(hw
, E1000_KUMCTRLSTA_OFFSET_HD_CTRL
,
2172 /* Configure Transmit Inter-Packet Gap */
2173 tipg
= E1000_READ_REG(hw
, TIPG
);
2174 tipg
&= ~E1000_TIPG_IPGT_MASK
;
2175 tipg
|= DEFAULT_80003ES2LAN_TIPG_IPGT_1000
;
2176 E1000_WRITE_REG(hw
, TIPG
, tipg
);
2178 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data
);
2183 reg_data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
2184 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_KMRN_MODE_CTRL
, reg_data
);
2189 /******************************************************************************
2190 * Configures PHY autoneg and flow control advertisement settings
2192 * hw - Struct containing variables accessed by shared code
2193 ******************************************************************************/
2195 e1000_phy_setup_autoneg(struct e1000_hw
*hw
)
2198 uint16_t mii_autoneg_adv_reg
;
2199 uint16_t mii_1000t_ctrl_reg
;
2201 DEBUGFUNC("e1000_phy_setup_autoneg");
2203 /* Read the MII Auto-Neg Advertisement Register (Address 4). */
2204 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_ADV
, &mii_autoneg_adv_reg
);
2208 if (hw
->phy_type
!= e1000_phy_ife
) {
2209 /* Read the MII 1000Base-T Control Register (Address 9). */
2210 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &mii_1000t_ctrl_reg
);
2214 mii_1000t_ctrl_reg
=0;
2216 /* Need to parse both autoneg_advertised and fc and set up
2217 * the appropriate PHY registers. First we will parse for
2218 * autoneg_advertised software override. Since we can advertise
2219 * a plethora of combinations, we need to check each bit
2223 /* First we clear all the 10/100 mb speed bits in the Auto-Neg
2224 * Advertisement Register (Address 4) and the 1000 mb speed bits in
2225 * the 1000Base-T Control Register (Address 9).
2227 mii_autoneg_adv_reg
&= ~REG4_SPEED_MASK
;
2228 mii_1000t_ctrl_reg
&= ~REG9_SPEED_MASK
;
2230 DEBUGOUT1("autoneg_advertised %x\n", hw
->autoneg_advertised
);
2232 /* Do we want to advertise 10 Mb Half Duplex? */
2233 if (hw
->autoneg_advertised
& ADVERTISE_10_HALF
) {
2234 DEBUGOUT("Advertise 10mb Half duplex\n");
2235 mii_autoneg_adv_reg
|= NWAY_AR_10T_HD_CAPS
;
2238 /* Do we want to advertise 10 Mb Full Duplex? */
2239 if (hw
->autoneg_advertised
& ADVERTISE_10_FULL
) {
2240 DEBUGOUT("Advertise 10mb Full duplex\n");
2241 mii_autoneg_adv_reg
|= NWAY_AR_10T_FD_CAPS
;
2244 /* Do we want to advertise 100 Mb Half Duplex? */
2245 if (hw
->autoneg_advertised
& ADVERTISE_100_HALF
) {
2246 DEBUGOUT("Advertise 100mb Half duplex\n");
2247 mii_autoneg_adv_reg
|= NWAY_AR_100TX_HD_CAPS
;
2250 /* Do we want to advertise 100 Mb Full Duplex? */
2251 if (hw
->autoneg_advertised
& ADVERTISE_100_FULL
) {
2252 DEBUGOUT("Advertise 100mb Full duplex\n");
2253 mii_autoneg_adv_reg
|= NWAY_AR_100TX_FD_CAPS
;
2256 /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
2257 if (hw
->autoneg_advertised
& ADVERTISE_1000_HALF
) {
2258 DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
2261 /* Do we want to advertise 1000 Mb Full Duplex? */
2262 if (hw
->autoneg_advertised
& ADVERTISE_1000_FULL
) {
2263 DEBUGOUT("Advertise 1000mb Full duplex\n");
2264 mii_1000t_ctrl_reg
|= CR_1000T_FD_CAPS
;
2265 if (hw
->phy_type
== e1000_phy_ife
) {
2266 DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n");
2270 /* Check for a software override of the flow control settings, and
2271 * setup the PHY advertisement registers accordingly. If
2272 * auto-negotiation is enabled, then software will have to set the
2273 * "PAUSE" bits to the correct value in the Auto-Negotiation
2274 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
2276 * The possible values of the "fc" parameter are:
2277 * 0: Flow control is completely disabled
2278 * 1: Rx flow control is enabled (we can receive pause frames
2279 * but not send pause frames).
2280 * 2: Tx flow control is enabled (we can send pause frames
2281 * but we do not support receiving pause frames).
2282 * 3: Both Rx and TX flow control (symmetric) are enabled.
2283 * other: No software override. The flow control configuration
2284 * in the EEPROM is used.
2287 case E1000_FC_NONE
: /* 0 */
2288 /* Flow control (RX & TX) is completely disabled by a
2289 * software over-ride.
2291 mii_autoneg_adv_reg
&= ~(NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
2293 case E1000_FC_RX_PAUSE
: /* 1 */
2294 /* RX Flow control is enabled, and TX Flow control is
2295 * disabled, by a software over-ride.
2297 /* Since there really isn't a way to advertise that we are
2298 * capable of RX Pause ONLY, we will advertise that we
2299 * support both symmetric and asymmetric RX PAUSE. Later
2300 * (in e1000_config_fc_after_link_up) we will disable the
2301 *hw's ability to send PAUSE frames.
2303 mii_autoneg_adv_reg
|= (NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
2305 case E1000_FC_TX_PAUSE
: /* 2 */
2306 /* TX Flow control is enabled, and RX Flow control is
2307 * disabled, by a software over-ride.
2309 mii_autoneg_adv_reg
|= NWAY_AR_ASM_DIR
;
2310 mii_autoneg_adv_reg
&= ~NWAY_AR_PAUSE
;
2312 case E1000_FC_FULL
: /* 3 */
2313 /* Flow control (both RX and TX) is enabled by a software
2316 mii_autoneg_adv_reg
|= (NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
2319 DEBUGOUT("Flow control param set incorrectly\n");
2320 return -E1000_ERR_CONFIG
;
2323 ret_val
= e1000_write_phy_reg(hw
, PHY_AUTONEG_ADV
, mii_autoneg_adv_reg
);
2327 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg
);
2329 if (hw
->phy_type
!= e1000_phy_ife
) {
2330 ret_val
= e1000_write_phy_reg(hw
, PHY_1000T_CTRL
, mii_1000t_ctrl_reg
);
2335 return E1000_SUCCESS
;
2338 /******************************************************************************
2339 * Force PHY speed and duplex settings to hw->forced_speed_duplex
2341 * hw - Struct containing variables accessed by shared code
2342 ******************************************************************************/
2344 e1000_phy_force_speed_duplex(struct e1000_hw
*hw
)
2348 uint16_t mii_ctrl_reg
;
2349 uint16_t mii_status_reg
;
2353 DEBUGFUNC("e1000_phy_force_speed_duplex");
2355 /* Turn off Flow control if we are forcing speed and duplex. */
2356 hw
->fc
= E1000_FC_NONE
;
2358 DEBUGOUT1("hw->fc = %d\n", hw
->fc
);
2360 /* Read the Device Control Register. */
2361 ctrl
= E1000_READ_REG(hw
, CTRL
);
2363 /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
2364 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
2365 ctrl
&= ~(DEVICE_SPEED_MASK
);
2367 /* Clear the Auto Speed Detect Enable bit. */
2368 ctrl
&= ~E1000_CTRL_ASDE
;
2370 /* Read the MII Control Register. */
2371 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &mii_ctrl_reg
);
2375 /* We need to disable autoneg in order to force link and duplex. */
2377 mii_ctrl_reg
&= ~MII_CR_AUTO_NEG_EN
;
2379 /* Are we forcing Full or Half Duplex? */
2380 if (hw
->forced_speed_duplex
== e1000_100_full
||
2381 hw
->forced_speed_duplex
== e1000_10_full
) {
2382 /* We want to force full duplex so we SET the full duplex bits in the
2383 * Device and MII Control Registers.
2385 ctrl
|= E1000_CTRL_FD
;
2386 mii_ctrl_reg
|= MII_CR_FULL_DUPLEX
;
2387 DEBUGOUT("Full Duplex\n");
2389 /* We want to force half duplex so we CLEAR the full duplex bits in
2390 * the Device and MII Control Registers.
2392 ctrl
&= ~E1000_CTRL_FD
;
2393 mii_ctrl_reg
&= ~MII_CR_FULL_DUPLEX
;
2394 DEBUGOUT("Half Duplex\n");
2397 /* Are we forcing 100Mbps??? */
2398 if (hw
->forced_speed_duplex
== e1000_100_full
||
2399 hw
->forced_speed_duplex
== e1000_100_half
) {
2400 /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
2401 ctrl
|= E1000_CTRL_SPD_100
;
2402 mii_ctrl_reg
|= MII_CR_SPEED_100
;
2403 mii_ctrl_reg
&= ~(MII_CR_SPEED_1000
| MII_CR_SPEED_10
);
2404 DEBUGOUT("Forcing 100mb ");
2406 /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
2407 ctrl
&= ~(E1000_CTRL_SPD_1000
| E1000_CTRL_SPD_100
);
2408 mii_ctrl_reg
|= MII_CR_SPEED_10
;
2409 mii_ctrl_reg
&= ~(MII_CR_SPEED_1000
| MII_CR_SPEED_100
);
2410 DEBUGOUT("Forcing 10mb ");
2413 e1000_config_collision_dist(hw
);
2415 /* Write the configured values back to the Device Control Reg. */
2416 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
2418 if ((hw
->phy_type
== e1000_phy_m88
) ||
2419 (hw
->phy_type
== e1000_phy_gg82563
)) {
2420 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
2424 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
2425 * forced whenever speed are duplex are forced.
2427 phy_data
&= ~M88E1000_PSCR_AUTO_X_MODE
;
2428 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
2432 DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data
);
2434 /* Need to reset the PHY or these changes will be ignored */
2435 mii_ctrl_reg
|= MII_CR_RESET
;
2437 /* Disable MDI-X support for 10/100 */
2438 } else if (hw
->phy_type
== e1000_phy_ife
) {
2439 ret_val
= e1000_read_phy_reg(hw
, IFE_PHY_MDIX_CONTROL
, &phy_data
);
2443 phy_data
&= ~IFE_PMC_AUTO_MDIX
;
2444 phy_data
&= ~IFE_PMC_FORCE_MDIX
;
2446 ret_val
= e1000_write_phy_reg(hw
, IFE_PHY_MDIX_CONTROL
, phy_data
);
2451 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
2452 * forced whenever speed or duplex are forced.
2454 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, &phy_data
);
2458 phy_data
&= ~IGP01E1000_PSCR_AUTO_MDIX
;
2459 phy_data
&= ~IGP01E1000_PSCR_FORCE_MDI_MDIX
;
2461 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, phy_data
);
2466 /* Write back the modified PHY MII control register. */
2467 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, mii_ctrl_reg
);
2473 /* The wait_autoneg_complete flag may be a little misleading here.
2474 * Since we are forcing speed and duplex, Auto-Neg is not enabled.
2475 * But we do want to delay for a period while forcing only so we
2476 * don't generate false No Link messages. So we will wait here
2477 * only if the user has set wait_autoneg_complete to 1, which is
2480 if (hw
->wait_autoneg_complete
) {
2481 /* We will wait for autoneg to complete. */
2482 DEBUGOUT("Waiting for forced speed/duplex link.\n");
2485 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
2486 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
2487 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2490 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2494 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2498 if (mii_status_reg
& MII_SR_LINK_STATUS
) break;
2502 ((hw
->phy_type
== e1000_phy_m88
) ||
2503 (hw
->phy_type
== e1000_phy_gg82563
))) {
2504 /* We didn't get link. Reset the DSP and wait again for link. */
2505 ret_val
= e1000_phy_reset_dsp(hw
);
2507 DEBUGOUT("Error Resetting PHY DSP\n");
2511 /* This loop will early-out if the link condition has been met. */
2512 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
2513 if (mii_status_reg
& MII_SR_LINK_STATUS
) break;
2515 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2518 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2522 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2528 if (hw
->phy_type
== e1000_phy_m88
) {
2529 /* Because we reset the PHY above, we need to re-force TX_CLK in the
2530 * Extended PHY Specific Control Register to 25MHz clock. This value
2531 * defaults back to a 2.5MHz clock when the PHY is reset.
2533 ret_val
= e1000_read_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_data
);
2537 phy_data
|= M88E1000_EPSCR_TX_CLK_25
;
2538 ret_val
= e1000_write_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
, phy_data
);
2542 /* In addition, because of the s/w reset above, we need to enable CRS on
2543 * TX. This must be set for both full and half duplex operation.
2545 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
2549 phy_data
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
2550 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
2554 if ((hw
->mac_type
== e1000_82544
|| hw
->mac_type
== e1000_82543
) &&
2555 (!hw
->autoneg
) && (hw
->forced_speed_duplex
== e1000_10_full
||
2556 hw
->forced_speed_duplex
== e1000_10_half
)) {
2557 ret_val
= e1000_polarity_reversal_workaround(hw
);
2561 } else if (hw
->phy_type
== e1000_phy_gg82563
) {
2562 /* The TX_CLK of the Extended PHY Specific Control Register defaults
2563 * to 2.5MHz on a reset. We need to re-force it back to 25MHz, if
2564 * we're not in a forced 10/duplex configuration. */
2565 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_MAC_SPEC_CTRL
, &phy_data
);
2569 phy_data
&= ~GG82563_MSCR_TX_CLK_MASK
;
2570 if ((hw
->forced_speed_duplex
== e1000_10_full
) ||
2571 (hw
->forced_speed_duplex
== e1000_10_half
))
2572 phy_data
|= GG82563_MSCR_TX_CLK_10MBPS_2_5MHZ
;
2574 phy_data
|= GG82563_MSCR_TX_CLK_100MBPS_25MHZ
;
2576 /* Also due to the reset, we need to enable CRS on Tx. */
2577 phy_data
|= GG82563_MSCR_ASSERT_CRS_ON_TX
;
2579 ret_val
= e1000_write_phy_reg(hw
, GG82563_PHY_MAC_SPEC_CTRL
, phy_data
);
2583 return E1000_SUCCESS
;
2586 /******************************************************************************
2587 * Sets the collision distance in the Transmit Control register
2589 * hw - Struct containing variables accessed by shared code
2591 * Link should have been established previously. Reads the speed and duplex
2592 * information from the Device Status register.
2593 ******************************************************************************/
2595 e1000_config_collision_dist(struct e1000_hw
*hw
)
2597 uint32_t tctl
, coll_dist
;
2599 DEBUGFUNC("e1000_config_collision_dist");
2601 if (hw
->mac_type
< e1000_82543
)
2602 coll_dist
= E1000_COLLISION_DISTANCE_82542
;
2604 coll_dist
= E1000_COLLISION_DISTANCE
;
2606 tctl
= E1000_READ_REG(hw
, TCTL
);
2608 tctl
&= ~E1000_TCTL_COLD
;
2609 tctl
|= coll_dist
<< E1000_COLD_SHIFT
;
2611 E1000_WRITE_REG(hw
, TCTL
, tctl
);
2612 E1000_WRITE_FLUSH(hw
);
2615 /******************************************************************************
2616 * Sets MAC speed and duplex settings to reflect the those in the PHY
2618 * hw - Struct containing variables accessed by shared code
2619 * mii_reg - data to write to the MII control register
2621 * The contents of the PHY register containing the needed information need to
2623 ******************************************************************************/
2625 e1000_config_mac_to_phy(struct e1000_hw
*hw
)
2631 DEBUGFUNC("e1000_config_mac_to_phy");
2633 /* 82544 or newer MAC, Auto Speed Detection takes care of
2634 * MAC speed/duplex configuration.*/
2635 if (hw
->mac_type
>= e1000_82544
)
2636 return E1000_SUCCESS
;
2638 /* Read the Device Control Register and set the bits to Force Speed
2641 ctrl
= E1000_READ_REG(hw
, CTRL
);
2642 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
2643 ctrl
&= ~(E1000_CTRL_SPD_SEL
| E1000_CTRL_ILOS
);
2645 /* Set up duplex in the Device Control and Transmit Control
2646 * registers depending on negotiated values.
2648 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
2652 if (phy_data
& M88E1000_PSSR_DPLX
)
2653 ctrl
|= E1000_CTRL_FD
;
2655 ctrl
&= ~E1000_CTRL_FD
;
2657 e1000_config_collision_dist(hw
);
2659 /* Set up speed in the Device Control register depending on
2660 * negotiated values.
2662 if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_1000MBS
)
2663 ctrl
|= E1000_CTRL_SPD_1000
;
2664 else if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_100MBS
)
2665 ctrl
|= E1000_CTRL_SPD_100
;
2667 /* Write the configured values back to the Device Control Reg. */
2668 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
2669 return E1000_SUCCESS
;
2672 /******************************************************************************
2673 * Forces the MAC's flow control settings.
2675 * hw - Struct containing variables accessed by shared code
2677 * Sets the TFCE and RFCE bits in the device control register to reflect
2678 * the adapter settings. TFCE and RFCE need to be explicitly set by
2679 * software when a Copper PHY is used because autonegotiation is managed
2680 * by the PHY rather than the MAC. Software must also configure these
2681 * bits when link is forced on a fiber connection.
2682 *****************************************************************************/
2684 e1000_force_mac_fc(struct e1000_hw
*hw
)
2688 DEBUGFUNC("e1000_force_mac_fc");
2690 /* Get the current configuration of the Device Control Register */
2691 ctrl
= E1000_READ_REG(hw
, CTRL
);
2693 /* Because we didn't get link via the internal auto-negotiation
2694 * mechanism (we either forced link or we got link via PHY
2695 * auto-neg), we have to manually enable/disable transmit an
2696 * receive flow control.
2698 * The "Case" statement below enables/disable flow control
2699 * according to the "hw->fc" parameter.
2701 * The possible values of the "fc" parameter are:
2702 * 0: Flow control is completely disabled
2703 * 1: Rx flow control is enabled (we can receive pause
2704 * frames but not send pause frames).
2705 * 2: Tx flow control is enabled (we can send pause frames
2706 * frames but we do not receive pause frames).
2707 * 3: Both Rx and TX flow control (symmetric) is enabled.
2708 * other: No other values should be possible at this point.
2713 ctrl
&= (~(E1000_CTRL_TFCE
| E1000_CTRL_RFCE
));
2715 case E1000_FC_RX_PAUSE
:
2716 ctrl
&= (~E1000_CTRL_TFCE
);
2717 ctrl
|= E1000_CTRL_RFCE
;
2719 case E1000_FC_TX_PAUSE
:
2720 ctrl
&= (~E1000_CTRL_RFCE
);
2721 ctrl
|= E1000_CTRL_TFCE
;
2724 ctrl
|= (E1000_CTRL_TFCE
| E1000_CTRL_RFCE
);
2727 DEBUGOUT("Flow control param set incorrectly\n");
2728 return -E1000_ERR_CONFIG
;
2731 /* Disable TX Flow Control for 82542 (rev 2.0) */
2732 if (hw
->mac_type
== e1000_82542_rev2_0
)
2733 ctrl
&= (~E1000_CTRL_TFCE
);
2735 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
2736 return E1000_SUCCESS
;
2739 /******************************************************************************
2740 * Configures flow control settings after link is established
2742 * hw - Struct containing variables accessed by shared code
2744 * Should be called immediately after a valid link has been established.
2745 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
2746 * and autonegotiation is enabled, the MAC flow control settings will be set
2747 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
2748 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
2749 *****************************************************************************/
2751 e1000_config_fc_after_link_up(struct e1000_hw
*hw
)
2754 uint16_t mii_status_reg
;
2755 uint16_t mii_nway_adv_reg
;
2756 uint16_t mii_nway_lp_ability_reg
;
2760 DEBUGFUNC("e1000_config_fc_after_link_up");
2762 /* Check for the case where we have fiber media and auto-neg failed
2763 * so we had to force link. In this case, we need to force the
2764 * configuration of the MAC to match the "fc" parameter.
2766 if (((hw
->media_type
== e1000_media_type_fiber
) && (hw
->autoneg_failed
)) ||
2767 ((hw
->media_type
== e1000_media_type_internal_serdes
) &&
2768 (hw
->autoneg_failed
)) ||
2769 ((hw
->media_type
== e1000_media_type_copper
) && (!hw
->autoneg
))) {
2770 ret_val
= e1000_force_mac_fc(hw
);
2772 DEBUGOUT("Error forcing flow control settings\n");
2777 /* Check for the case where we have copper media and auto-neg is
2778 * enabled. In this case, we need to check and see if Auto-Neg
2779 * has completed, and if so, how the PHY and link partner has
2780 * flow control configured.
2782 if ((hw
->media_type
== e1000_media_type_copper
) && hw
->autoneg
) {
2783 /* Read the MII Status Register and check to see if AutoNeg
2784 * has completed. We read this twice because this reg has
2785 * some "sticky" (latched) bits.
2787 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2790 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2794 if (mii_status_reg
& MII_SR_AUTONEG_COMPLETE
) {
2795 /* The AutoNeg process has completed, so we now need to
2796 * read both the Auto Negotiation Advertisement Register
2797 * (Address 4) and the Auto_Negotiation Base Page Ability
2798 * Register (Address 5) to determine how flow control was
2801 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_ADV
,
2805 ret_val
= e1000_read_phy_reg(hw
, PHY_LP_ABILITY
,
2806 &mii_nway_lp_ability_reg
);
2810 /* Two bits in the Auto Negotiation Advertisement Register
2811 * (Address 4) and two bits in the Auto Negotiation Base
2812 * Page Ability Register (Address 5) determine flow control
2813 * for both the PHY and the link partner. The following
2814 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
2815 * 1999, describes these PAUSE resolution bits and how flow
2816 * control is determined based upon these settings.
2817 * NOTE: DC = Don't Care
2819 * LOCAL DEVICE | LINK PARTNER
2820 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
2821 *-------|---------|-------|---------|--------------------
2822 * 0 | 0 | DC | DC | E1000_FC_NONE
2823 * 0 | 1 | 0 | DC | E1000_FC_NONE
2824 * 0 | 1 | 1 | 0 | E1000_FC_NONE
2825 * 0 | 1 | 1 | 1 | E1000_FC_TX_PAUSE
2826 * 1 | 0 | 0 | DC | E1000_FC_NONE
2827 * 1 | DC | 1 | DC | E1000_FC_FULL
2828 * 1 | 1 | 0 | 0 | E1000_FC_NONE
2829 * 1 | 1 | 0 | 1 | E1000_FC_RX_PAUSE
2832 /* Are both PAUSE bits set to 1? If so, this implies
2833 * Symmetric Flow Control is enabled at both ends. The
2834 * ASM_DIR bits are irrelevant per the spec.
2836 * For Symmetric Flow Control:
2838 * LOCAL DEVICE | LINK PARTNER
2839 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2840 *-------|---------|-------|---------|--------------------
2841 * 1 | DC | 1 | DC | E1000_FC_FULL
2844 if ((mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2845 (mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
)) {
2846 /* Now we need to check if the user selected RX ONLY
2847 * of pause frames. In this case, we had to advertise
2848 * FULL flow control because we could not advertise RX
2849 * ONLY. Hence, we must now check to see if we need to
2850 * turn OFF the TRANSMISSION of PAUSE frames.
2852 if (hw
->original_fc
== E1000_FC_FULL
) {
2853 hw
->fc
= E1000_FC_FULL
;
2854 DEBUGOUT("Flow Control = FULL.\n");
2856 hw
->fc
= E1000_FC_RX_PAUSE
;
2857 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2860 /* For receiving PAUSE frames ONLY.
2862 * LOCAL DEVICE | LINK PARTNER
2863 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2864 *-------|---------|-------|---------|--------------------
2865 * 0 | 1 | 1 | 1 | E1000_FC_TX_PAUSE
2868 else if (!(mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2869 (mii_nway_adv_reg
& NWAY_AR_ASM_DIR
) &&
2870 (mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
) &&
2871 (mii_nway_lp_ability_reg
& NWAY_LPAR_ASM_DIR
)) {
2872 hw
->fc
= E1000_FC_TX_PAUSE
;
2873 DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
2875 /* For transmitting PAUSE frames ONLY.
2877 * LOCAL DEVICE | LINK PARTNER
2878 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2879 *-------|---------|-------|---------|--------------------
2880 * 1 | 1 | 0 | 1 | E1000_FC_RX_PAUSE
2883 else if ((mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2884 (mii_nway_adv_reg
& NWAY_AR_ASM_DIR
) &&
2885 !(mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
) &&
2886 (mii_nway_lp_ability_reg
& NWAY_LPAR_ASM_DIR
)) {
2887 hw
->fc
= E1000_FC_RX_PAUSE
;
2888 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2890 /* Per the IEEE spec, at this point flow control should be
2891 * disabled. However, we want to consider that we could
2892 * be connected to a legacy switch that doesn't advertise
2893 * desired flow control, but can be forced on the link
2894 * partner. So if we advertised no flow control, that is
2895 * what we will resolve to. If we advertised some kind of
2896 * receive capability (Rx Pause Only or Full Flow Control)
2897 * and the link partner advertised none, we will configure
2898 * ourselves to enable Rx Flow Control only. We can do
2899 * this safely for two reasons: If the link partner really
2900 * didn't want flow control enabled, and we enable Rx, no
2901 * harm done since we won't be receiving any PAUSE frames
2902 * anyway. If the intent on the link partner was to have
2903 * flow control enabled, then by us enabling RX only, we
2904 * can at least receive pause frames and process them.
2905 * This is a good idea because in most cases, since we are
2906 * predominantly a server NIC, more times than not we will
2907 * be asked to delay transmission of packets than asking
2908 * our link partner to pause transmission of frames.
2910 else if ((hw
->original_fc
== E1000_FC_NONE
||
2911 hw
->original_fc
== E1000_FC_TX_PAUSE
) ||
2912 hw
->fc_strict_ieee
) {
2913 hw
->fc
= E1000_FC_NONE
;
2914 DEBUGOUT("Flow Control = NONE.\n");
2916 hw
->fc
= E1000_FC_RX_PAUSE
;
2917 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2920 /* Now we need to do one last check... If we auto-
2921 * negotiated to HALF DUPLEX, flow control should not be
2922 * enabled per IEEE 802.3 spec.
2924 ret_val
= e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
2926 DEBUGOUT("Error getting link speed and duplex\n");
2930 if (duplex
== HALF_DUPLEX
)
2931 hw
->fc
= E1000_FC_NONE
;
2933 /* Now we call a subroutine to actually force the MAC
2934 * controller to use the correct flow control settings.
2936 ret_val
= e1000_force_mac_fc(hw
);
2938 DEBUGOUT("Error forcing flow control settings\n");
2942 DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
2945 return E1000_SUCCESS
;
2948 /******************************************************************************
2949 * Checks to see if the link status of the hardware has changed.
2951 * hw - Struct containing variables accessed by shared code
2953 * Called by any function that needs to check the link status of the adapter.
2954 *****************************************************************************/
2956 e1000_check_for_link(struct e1000_hw
*hw
)
2963 uint32_t signal
= 0;
2967 DEBUGFUNC("e1000_check_for_link");
2969 ctrl
= E1000_READ_REG(hw
, CTRL
);
2970 status
= E1000_READ_REG(hw
, STATUS
);
2972 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
2973 * set when the optics detect a signal. On older adapters, it will be
2974 * cleared when there is a signal. This applies to fiber media only.
2976 if ((hw
->media_type
== e1000_media_type_fiber
) ||
2977 (hw
->media_type
== e1000_media_type_internal_serdes
)) {
2978 rxcw
= E1000_READ_REG(hw
, RXCW
);
2980 if (hw
->media_type
== e1000_media_type_fiber
) {
2981 signal
= (hw
->mac_type
> e1000_82544
) ? E1000_CTRL_SWDPIN1
: 0;
2982 if (status
& E1000_STATUS_LU
)
2983 hw
->get_link_status
= FALSE
;
2987 /* If we have a copper PHY then we only want to go out to the PHY
2988 * registers to see if Auto-Neg has completed and/or if our link
2989 * status has changed. The get_link_status flag will be set if we
2990 * receive a Link Status Change interrupt or we have Rx Sequence
2993 if ((hw
->media_type
== e1000_media_type_copper
) && hw
->get_link_status
) {
2994 /* First we want to see if the MII Status Register reports
2995 * link. If so, then we want to get the current speed/duplex
2997 * Read the register twice since the link bit is sticky.
2999 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3002 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3006 if (phy_data
& MII_SR_LINK_STATUS
) {
3007 hw
->get_link_status
= FALSE
;
3008 /* Check if there was DownShift, must be checked immediately after
3010 e1000_check_downshift(hw
);
3012 /* If we are on 82544 or 82543 silicon and speed/duplex
3013 * are forced to 10H or 10F, then we will implement the polarity
3014 * reversal workaround. We disable interrupts first, and upon
3015 * returning, place the devices interrupt state to its previous
3016 * value except for the link status change interrupt which will
3017 * happen due to the execution of this workaround.
3020 if ((hw
->mac_type
== e1000_82544
|| hw
->mac_type
== e1000_82543
) &&
3022 (hw
->forced_speed_duplex
== e1000_10_full
||
3023 hw
->forced_speed_duplex
== e1000_10_half
)) {
3024 E1000_WRITE_REG(hw
, IMC
, 0xffffffff);
3025 ret_val
= e1000_polarity_reversal_workaround(hw
);
3026 icr
= E1000_READ_REG(hw
, ICR
);
3027 E1000_WRITE_REG(hw
, ICS
, (icr
& ~E1000_ICS_LSC
));
3028 E1000_WRITE_REG(hw
, IMS
, IMS_ENABLE_MASK
);
3032 /* No link detected */
3033 e1000_config_dsp_after_link_change(hw
, FALSE
);
3037 /* If we are forcing speed/duplex, then we simply return since
3038 * we have already determined whether we have link or not.
3040 if (!hw
->autoneg
) return -E1000_ERR_CONFIG
;
3042 /* optimize the dsp settings for the igp phy */
3043 e1000_config_dsp_after_link_change(hw
, TRUE
);
3045 /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
3046 * have Si on board that is 82544 or newer, Auto
3047 * Speed Detection takes care of MAC speed/duplex
3048 * configuration. So we only need to configure Collision
3049 * Distance in the MAC. Otherwise, we need to force
3050 * speed/duplex on the MAC to the current PHY speed/duplex
3053 if (hw
->mac_type
>= e1000_82544
)
3054 e1000_config_collision_dist(hw
);
3056 ret_val
= e1000_config_mac_to_phy(hw
);
3058 DEBUGOUT("Error configuring MAC to PHY settings\n");
3063 /* Configure Flow Control now that Auto-Neg has completed. First, we
3064 * need to restore the desired flow control settings because we may
3065 * have had to re-autoneg with a different link partner.
3067 ret_val
= e1000_config_fc_after_link_up(hw
);
3069 DEBUGOUT("Error configuring flow control\n");
3073 /* At this point we know that we are on copper and we have
3074 * auto-negotiated link. These are conditions for checking the link
3075 * partner capability register. We use the link speed to determine if
3076 * TBI compatibility needs to be turned on or off. If the link is not
3077 * at gigabit speed, then TBI compatibility is not needed. If we are
3078 * at gigabit speed, we turn on TBI compatibility.
3080 if (hw
->tbi_compatibility_en
) {
3081 uint16_t speed
, duplex
;
3082 ret_val
= e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
3084 DEBUGOUT("Error getting link speed and duplex\n");
3087 if (speed
!= SPEED_1000
) {
3088 /* If link speed is not set to gigabit speed, we do not need
3089 * to enable TBI compatibility.
3091 if (hw
->tbi_compatibility_on
) {
3092 /* If we previously were in the mode, turn it off. */
3093 rctl
= E1000_READ_REG(hw
, RCTL
);
3094 rctl
&= ~E1000_RCTL_SBP
;
3095 E1000_WRITE_REG(hw
, RCTL
, rctl
);
3096 hw
->tbi_compatibility_on
= FALSE
;
3099 /* If TBI compatibility is was previously off, turn it on. For
3100 * compatibility with a TBI link partner, we will store bad
3101 * packets. Some frames have an additional byte on the end and
3102 * will look like CRC errors to to the hardware.
3104 if (!hw
->tbi_compatibility_on
) {
3105 hw
->tbi_compatibility_on
= TRUE
;
3106 rctl
= E1000_READ_REG(hw
, RCTL
);
3107 rctl
|= E1000_RCTL_SBP
;
3108 E1000_WRITE_REG(hw
, RCTL
, rctl
);
3113 /* If we don't have link (auto-negotiation failed or link partner cannot
3114 * auto-negotiate), the cable is plugged in (we have signal), and our
3115 * link partner is not trying to auto-negotiate with us (we are receiving
3116 * idles or data), we need to force link up. We also need to give
3117 * auto-negotiation time to complete, in case the cable was just plugged
3118 * in. The autoneg_failed flag does this.
3120 else if ((((hw
->media_type
== e1000_media_type_fiber
) &&
3121 ((ctrl
& E1000_CTRL_SWDPIN1
) == signal
)) ||
3122 (hw
->media_type
== e1000_media_type_internal_serdes
)) &&
3123 (!(status
& E1000_STATUS_LU
)) &&
3124 (!(rxcw
& E1000_RXCW_C
))) {
3125 if (hw
->autoneg_failed
== 0) {
3126 hw
->autoneg_failed
= 1;
3129 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
3131 /* Disable auto-negotiation in the TXCW register */
3132 E1000_WRITE_REG(hw
, TXCW
, (hw
->txcw
& ~E1000_TXCW_ANE
));
3134 /* Force link-up and also force full-duplex. */
3135 ctrl
= E1000_READ_REG(hw
, CTRL
);
3136 ctrl
|= (E1000_CTRL_SLU
| E1000_CTRL_FD
);
3137 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
3139 /* Configure Flow Control after forcing link up. */
3140 ret_val
= e1000_config_fc_after_link_up(hw
);
3142 DEBUGOUT("Error configuring flow control\n");
3146 /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
3147 * auto-negotiation in the TXCW register and disable forced link in the
3148 * Device Control register in an attempt to auto-negotiate with our link
3151 else if (((hw
->media_type
== e1000_media_type_fiber
) ||
3152 (hw
->media_type
== e1000_media_type_internal_serdes
)) &&
3153 (ctrl
& E1000_CTRL_SLU
) && (rxcw
& E1000_RXCW_C
)) {
3154 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
3155 E1000_WRITE_REG(hw
, TXCW
, hw
->txcw
);
3156 E1000_WRITE_REG(hw
, CTRL
, (ctrl
& ~E1000_CTRL_SLU
));
3158 hw
->serdes_link_down
= FALSE
;
3160 /* If we force link for non-auto-negotiation switch, check link status
3161 * based on MAC synchronization for internal serdes media type.
3163 else if ((hw
->media_type
== e1000_media_type_internal_serdes
) &&
3164 !(E1000_TXCW_ANE
& E1000_READ_REG(hw
, TXCW
))) {
3165 /* SYNCH bit and IV bit are sticky. */
3167 if (E1000_RXCW_SYNCH
& E1000_READ_REG(hw
, RXCW
)) {
3168 if (!(rxcw
& E1000_RXCW_IV
)) {
3169 hw
->serdes_link_down
= FALSE
;
3170 DEBUGOUT("SERDES: Link is up.\n");
3173 hw
->serdes_link_down
= TRUE
;
3174 DEBUGOUT("SERDES: Link is down.\n");
3177 if ((hw
->media_type
== e1000_media_type_internal_serdes
) &&
3178 (E1000_TXCW_ANE
& E1000_READ_REG(hw
, TXCW
))) {
3179 hw
->serdes_link_down
= !(E1000_STATUS_LU
& E1000_READ_REG(hw
, STATUS
));
3181 return E1000_SUCCESS
;
3184 /******************************************************************************
3185 * Detects the current speed and duplex settings of the hardware.
3187 * hw - Struct containing variables accessed by shared code
3188 * speed - Speed of the connection
3189 * duplex - Duplex setting of the connection
3190 *****************************************************************************/
3192 e1000_get_speed_and_duplex(struct e1000_hw
*hw
,
3200 DEBUGFUNC("e1000_get_speed_and_duplex");
3202 if (hw
->mac_type
>= e1000_82543
) {
3203 status
= E1000_READ_REG(hw
, STATUS
);
3204 if (status
& E1000_STATUS_SPEED_1000
) {
3205 *speed
= SPEED_1000
;
3206 DEBUGOUT("1000 Mbs, ");
3207 } else if (status
& E1000_STATUS_SPEED_100
) {
3209 DEBUGOUT("100 Mbs, ");
3212 DEBUGOUT("10 Mbs, ");
3215 if (status
& E1000_STATUS_FD
) {
3216 *duplex
= FULL_DUPLEX
;
3217 DEBUGOUT("Full Duplex\n");
3219 *duplex
= HALF_DUPLEX
;
3220 DEBUGOUT(" Half Duplex\n");
3223 DEBUGOUT("1000 Mbs, Full Duplex\n");
3224 *speed
= SPEED_1000
;
3225 *duplex
= FULL_DUPLEX
;
3228 /* IGP01 PHY may advertise full duplex operation after speed downgrade even
3229 * if it is operating at half duplex. Here we set the duplex settings to
3230 * match the duplex in the link partner's capabilities.
3232 if (hw
->phy_type
== e1000_phy_igp
&& hw
->speed_downgraded
) {
3233 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_EXP
, &phy_data
);
3237 if (!(phy_data
& NWAY_ER_LP_NWAY_CAPS
))
3238 *duplex
= HALF_DUPLEX
;
3240 ret_val
= e1000_read_phy_reg(hw
, PHY_LP_ABILITY
, &phy_data
);
3243 if ((*speed
== SPEED_100
&& !(phy_data
& NWAY_LPAR_100TX_FD_CAPS
)) ||
3244 (*speed
== SPEED_10
&& !(phy_data
& NWAY_LPAR_10T_FD_CAPS
)))
3245 *duplex
= HALF_DUPLEX
;
3249 if ((hw
->mac_type
== e1000_80003es2lan
) &&
3250 (hw
->media_type
== e1000_media_type_copper
)) {
3251 if (*speed
== SPEED_1000
)
3252 ret_val
= e1000_configure_kmrn_for_1000(hw
);
3254 ret_val
= e1000_configure_kmrn_for_10_100(hw
, *duplex
);
3259 if ((hw
->phy_type
== e1000_phy_igp_3
) && (*speed
== SPEED_1000
)) {
3260 ret_val
= e1000_kumeran_lock_loss_workaround(hw
);
3265 return E1000_SUCCESS
;
3268 /******************************************************************************
3269 * Blocks until autoneg completes or times out (~4.5 seconds)
3271 * hw - Struct containing variables accessed by shared code
3272 ******************************************************************************/
3274 e1000_wait_autoneg(struct e1000_hw
*hw
)
3280 DEBUGFUNC("e1000_wait_autoneg");
3281 DEBUGOUT("Waiting for Auto-Neg to complete.\n");
3283 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
3284 for (i
= PHY_AUTO_NEG_TIME
; i
> 0; i
--) {
3285 /* Read the MII Status Register and wait for Auto-Neg
3286 * Complete bit to be set.
3288 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3291 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3294 if (phy_data
& MII_SR_AUTONEG_COMPLETE
) {
3295 return E1000_SUCCESS
;
3299 return E1000_SUCCESS
;
3302 /******************************************************************************
3303 * Raises the Management Data Clock
3305 * hw - Struct containing variables accessed by shared code
3306 * ctrl - Device control register's current value
3307 ******************************************************************************/
3309 e1000_raise_mdi_clk(struct e1000_hw
*hw
,
3312 /* Raise the clock input to the Management Data Clock (by setting the MDC
3313 * bit), and then delay 10 microseconds.
3315 E1000_WRITE_REG(hw
, CTRL
, (*ctrl
| E1000_CTRL_MDC
));
3316 E1000_WRITE_FLUSH(hw
);
3320 /******************************************************************************
3321 * Lowers the Management Data Clock
3323 * hw - Struct containing variables accessed by shared code
3324 * ctrl - Device control register's current value
3325 ******************************************************************************/
3327 e1000_lower_mdi_clk(struct e1000_hw
*hw
,
3330 /* Lower the clock input to the Management Data Clock (by clearing the MDC
3331 * bit), and then delay 10 microseconds.
3333 E1000_WRITE_REG(hw
, CTRL
, (*ctrl
& ~E1000_CTRL_MDC
));
3334 E1000_WRITE_FLUSH(hw
);
3338 /******************************************************************************
3339 * Shifts data bits out to the PHY
3341 * hw - Struct containing variables accessed by shared code
3342 * data - Data to send out to the PHY
3343 * count - Number of bits to shift out
3345 * Bits are shifted out in MSB to LSB order.
3346 ******************************************************************************/
3348 e1000_shift_out_mdi_bits(struct e1000_hw
*hw
,
3355 /* We need to shift "count" number of bits out to the PHY. So, the value
3356 * in the "data" parameter will be shifted out to the PHY one bit at a
3357 * time. In order to do this, "data" must be broken down into bits.
3360 mask
<<= (count
- 1);
3362 ctrl
= E1000_READ_REG(hw
, CTRL
);
3364 /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
3365 ctrl
|= (E1000_CTRL_MDIO_DIR
| E1000_CTRL_MDC_DIR
);
3368 /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
3369 * then raising and lowering the Management Data Clock. A "0" is
3370 * shifted out to the PHY by setting the MDIO bit to "0" and then
3371 * raising and lowering the clock.
3374 ctrl
|= E1000_CTRL_MDIO
;
3376 ctrl
&= ~E1000_CTRL_MDIO
;
3378 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
3379 E1000_WRITE_FLUSH(hw
);
3383 e1000_raise_mdi_clk(hw
, &ctrl
);
3384 e1000_lower_mdi_clk(hw
, &ctrl
);
3390 /******************************************************************************
3391 * Shifts data bits in from the PHY
3393 * hw - Struct containing variables accessed by shared code
3395 * Bits are shifted in in MSB to LSB order.
3396 ******************************************************************************/
3398 e1000_shift_in_mdi_bits(struct e1000_hw
*hw
)
3404 /* In order to read a register from the PHY, we need to shift in a total
3405 * of 18 bits from the PHY. The first two bit (turnaround) times are used
3406 * to avoid contention on the MDIO pin when a read operation is performed.
3407 * These two bits are ignored by us and thrown away. Bits are "shifted in"
3408 * by raising the input to the Management Data Clock (setting the MDC bit),
3409 * and then reading the value of the MDIO bit.
3411 ctrl
= E1000_READ_REG(hw
, CTRL
);
3413 /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
3414 ctrl
&= ~E1000_CTRL_MDIO_DIR
;
3415 ctrl
&= ~E1000_CTRL_MDIO
;
3417 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
3418 E1000_WRITE_FLUSH(hw
);
3420 /* Raise and Lower the clock before reading in the data. This accounts for
3421 * the turnaround bits. The first clock occurred when we clocked out the
3422 * last bit of the Register Address.
3424 e1000_raise_mdi_clk(hw
, &ctrl
);
3425 e1000_lower_mdi_clk(hw
, &ctrl
);
3427 for (data
= 0, i
= 0; i
< 16; i
++) {
3429 e1000_raise_mdi_clk(hw
, &ctrl
);
3430 ctrl
= E1000_READ_REG(hw
, CTRL
);
3431 /* Check to see if we shifted in a "1". */
3432 if (ctrl
& E1000_CTRL_MDIO
)
3434 e1000_lower_mdi_clk(hw
, &ctrl
);
3437 e1000_raise_mdi_clk(hw
, &ctrl
);
3438 e1000_lower_mdi_clk(hw
, &ctrl
);
3444 e1000_swfw_sync_acquire(struct e1000_hw
*hw
, uint16_t mask
)
3446 uint32_t swfw_sync
= 0;
3447 uint32_t swmask
= mask
;
3448 uint32_t fwmask
= mask
<< 16;
3449 int32_t timeout
= 200;
3451 DEBUGFUNC("e1000_swfw_sync_acquire");
3453 if (hw
->swfwhw_semaphore_present
)
3454 return e1000_get_software_flag(hw
);
3456 if (!hw
->swfw_sync_present
)
3457 return e1000_get_hw_eeprom_semaphore(hw
);
3460 if (e1000_get_hw_eeprom_semaphore(hw
))
3461 return -E1000_ERR_SWFW_SYNC
;
3463 swfw_sync
= E1000_READ_REG(hw
, SW_FW_SYNC
);
3464 if (!(swfw_sync
& (fwmask
| swmask
))) {
3468 /* firmware currently using resource (fwmask) */
3469 /* or other software thread currently using resource (swmask) */
3470 e1000_put_hw_eeprom_semaphore(hw
);
3476 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
3477 return -E1000_ERR_SWFW_SYNC
;
3480 swfw_sync
|= swmask
;
3481 E1000_WRITE_REG(hw
, SW_FW_SYNC
, swfw_sync
);
3483 e1000_put_hw_eeprom_semaphore(hw
);
3484 return E1000_SUCCESS
;
3488 e1000_swfw_sync_release(struct e1000_hw
*hw
, uint16_t mask
)
3491 uint32_t swmask
= mask
;
3493 DEBUGFUNC("e1000_swfw_sync_release");
3495 if (hw
->swfwhw_semaphore_present
) {
3496 e1000_release_software_flag(hw
);
3500 if (!hw
->swfw_sync_present
) {
3501 e1000_put_hw_eeprom_semaphore(hw
);
3505 /* if (e1000_get_hw_eeprom_semaphore(hw))
3506 * return -E1000_ERR_SWFW_SYNC; */
3507 while (e1000_get_hw_eeprom_semaphore(hw
) != E1000_SUCCESS
);
3510 swfw_sync
= E1000_READ_REG(hw
, SW_FW_SYNC
);
3511 swfw_sync
&= ~swmask
;
3512 E1000_WRITE_REG(hw
, SW_FW_SYNC
, swfw_sync
);
3514 e1000_put_hw_eeprom_semaphore(hw
);
3517 /*****************************************************************************
3518 * Reads the value from a PHY register, if the value is on a specific non zero
3519 * page, sets the page first.
3520 * hw - Struct containing variables accessed by shared code
3521 * reg_addr - address of the PHY register to read
3522 ******************************************************************************/
3524 e1000_read_phy_reg(struct e1000_hw
*hw
,
3531 DEBUGFUNC("e1000_read_phy_reg");
3533 if ((hw
->mac_type
== e1000_80003es2lan
|| hw
->mac_type
== e1000_82576
) &&
3534 (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)) {
3535 swfw
= E1000_SWFW_PHY1_SM
;
3537 swfw
= E1000_SWFW_PHY0_SM
;
3539 if (e1000_swfw_sync_acquire(hw
, swfw
))
3540 return -E1000_ERR_SWFW_SYNC
;
3542 if ((hw
->phy_type
== e1000_phy_igp
||
3543 hw
->phy_type
== e1000_phy_igp_3
||
3544 hw
->phy_type
== e1000_phy_igp_2
) &&
3545 (reg_addr
> MAX_PHY_MULTI_PAGE_REG
)) {
3546 ret_val
= e1000_write_phy_reg_ex(hw
, IGP01E1000_PHY_PAGE_SELECT
,
3547 (uint16_t)reg_addr
);
3549 e1000_swfw_sync_release(hw
, swfw
);
3552 } else if (hw
->phy_type
== e1000_phy_gg82563
) {
3553 if (((reg_addr
& MAX_PHY_REG_ADDRESS
) > MAX_PHY_MULTI_PAGE_REG
) ||
3554 (hw
->mac_type
== e1000_80003es2lan
)) {
3555 /* Select Configuration Page */
3556 if ((reg_addr
& MAX_PHY_REG_ADDRESS
) < GG82563_MIN_ALT_REG
) {
3557 ret_val
= e1000_write_phy_reg_ex(hw
, GG82563_PHY_PAGE_SELECT
,
3558 (uint16_t)((uint16_t)reg_addr
>> GG82563_PAGE_SHIFT
));
3560 /* Use Alternative Page Select register to access
3561 * registers 30 and 31
3563 ret_val
= e1000_write_phy_reg_ex(hw
,
3564 GG82563_PHY_PAGE_SELECT_ALT
,
3565 (uint16_t)((uint16_t)reg_addr
>> GG82563_PAGE_SHIFT
));
3569 e1000_swfw_sync_release(hw
, swfw
);
3575 ret_val
= e1000_read_phy_reg_ex(hw
, MAX_PHY_REG_ADDRESS
& reg_addr
,
3578 e1000_swfw_sync_release(hw
, swfw
);
3583 e1000_read_phy_reg_ex(struct e1000_hw
*hw
, uint32_t reg_addr
,
3588 const uint32_t phy_addr
= 1;
3590 DEBUGFUNC("e1000_read_phy_reg_ex");
3592 if (reg_addr
> MAX_PHY_REG_ADDRESS
) {
3593 DEBUGOUT1("PHY Address %d is out of range\n", reg_addr
);
3594 return -E1000_ERR_PARAM
;
3597 if (hw
->mac_type
> e1000_82543
) {
3598 /* Set up Op-code, Phy Address, and register address in the MDI
3599 * Control register. The MAC will take care of interfacing with the
3600 * PHY to retrieve the desired data.
3602 mdic
= ((reg_addr
<< E1000_MDIC_REG_SHIFT
) |
3603 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
3604 (E1000_MDIC_OP_READ
));
3606 E1000_WRITE_REG(hw
, MDIC
, mdic
);
3608 /* Poll the ready bit to see if the MDI read completed */
3609 for (i
= 0; i
< 64; i
++) {
3611 mdic
= E1000_READ_REG(hw
, MDIC
);
3612 if (mdic
& E1000_MDIC_READY
) break;
3614 if (!(mdic
& E1000_MDIC_READY
)) {
3615 DEBUGOUT("MDI Read did not complete\n");
3616 return -E1000_ERR_PHY
;
3618 if (mdic
& E1000_MDIC_ERROR
) {
3619 DEBUGOUT("MDI Error\n");
3620 return -E1000_ERR_PHY
;
3622 *phy_data
= (uint16_t) mdic
;
3624 /* We must first send a preamble through the MDIO pin to signal the
3625 * beginning of an MII instruction. This is done by sending 32
3626 * consecutive "1" bits.
3628 e1000_shift_out_mdi_bits(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
3630 /* Now combine the next few fields that are required for a read
3631 * operation. We use this method instead of calling the
3632 * e1000_shift_out_mdi_bits routine five different times. The format of
3633 * a MII read instruction consists of a shift out of 14 bits and is
3634 * defined as follows:
3635 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
3636 * followed by a shift in of 18 bits. This first two bits shifted in
3637 * are TurnAround bits used to avoid contention on the MDIO pin when a
3638 * READ operation is performed. These two bits are thrown away
3639 * followed by a shift in of 16 bits which contains the desired data.
3641 mdic
= ((reg_addr
) | (phy_addr
<< 5) |
3642 (PHY_OP_READ
<< 10) | (PHY_SOF
<< 12));
3644 e1000_shift_out_mdi_bits(hw
, mdic
, 14);
3646 /* Now that we've shifted out the read command to the MII, we need to
3647 * "shift in" the 16-bit value (18 total bits) of the requested PHY
3650 *phy_data
= e1000_shift_in_mdi_bits(hw
);
3652 return E1000_SUCCESS
;
3655 /******************************************************************************
3656 * Writes a value to a PHY register
3658 * hw - Struct containing variables accessed by shared code
3659 * reg_addr - address of the PHY register to write
3660 * data - data to write to the PHY
3661 ******************************************************************************/
3663 e1000_write_phy_reg(struct e1000_hw
*hw
, uint32_t reg_addr
,
3669 DEBUGFUNC("e1000_write_phy_reg");
3671 if ((hw
->mac_type
== e1000_80003es2lan
|| hw
->mac_type
== e1000_82576
) &&
3672 (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)) {
3673 swfw
= E1000_SWFW_PHY1_SM
;
3675 swfw
= E1000_SWFW_PHY0_SM
;
3677 if (e1000_swfw_sync_acquire(hw
, swfw
))
3678 return -E1000_ERR_SWFW_SYNC
;
3680 if ((hw
->phy_type
== e1000_phy_igp
||
3681 hw
->phy_type
== e1000_phy_igp_3
||
3682 hw
->phy_type
== e1000_phy_igp_2
) &&
3683 (reg_addr
> MAX_PHY_MULTI_PAGE_REG
)) {
3684 ret_val
= e1000_write_phy_reg_ex(hw
, IGP01E1000_PHY_PAGE_SELECT
,
3685 (uint16_t)reg_addr
);
3687 e1000_swfw_sync_release(hw
, swfw
);
3690 } else if (hw
->phy_type
== e1000_phy_gg82563
) {
3691 if (((reg_addr
& MAX_PHY_REG_ADDRESS
) > MAX_PHY_MULTI_PAGE_REG
) ||
3692 (hw
->mac_type
== e1000_80003es2lan
)) {
3693 /* Select Configuration Page */
3694 if ((reg_addr
& MAX_PHY_REG_ADDRESS
) < GG82563_MIN_ALT_REG
) {
3695 ret_val
= e1000_write_phy_reg_ex(hw
, GG82563_PHY_PAGE_SELECT
,
3696 (uint16_t)((uint16_t)reg_addr
>> GG82563_PAGE_SHIFT
));
3698 /* Use Alternative Page Select register to access
3699 * registers 30 and 31
3701 ret_val
= e1000_write_phy_reg_ex(hw
,
3702 GG82563_PHY_PAGE_SELECT_ALT
,
3703 (uint16_t)((uint16_t)reg_addr
>> GG82563_PAGE_SHIFT
));
3707 e1000_swfw_sync_release(hw
, swfw
);
3713 ret_val
= e1000_write_phy_reg_ex(hw
, MAX_PHY_REG_ADDRESS
& reg_addr
,
3716 e1000_swfw_sync_release(hw
, swfw
);
3721 e1000_write_phy_reg_ex(struct e1000_hw
*hw
, uint32_t reg_addr
,
3726 const uint32_t phy_addr
= 1;
3728 DEBUGFUNC("e1000_write_phy_reg_ex");
3730 if (reg_addr
> MAX_PHY_REG_ADDRESS
) {
3731 DEBUGOUT1("PHY Address %d is out of range\n", reg_addr
);
3732 return -E1000_ERR_PARAM
;
3735 if (hw
->mac_type
> e1000_82543
) {
3736 /* Set up Op-code, Phy Address, register address, and data intended
3737 * for the PHY register in the MDI Control register. The MAC will take
3738 * care of interfacing with the PHY to send the desired data.
3740 mdic
= (((uint32_t) phy_data
) |
3741 (reg_addr
<< E1000_MDIC_REG_SHIFT
) |
3742 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
3743 (E1000_MDIC_OP_WRITE
));
3745 E1000_WRITE_REG(hw
, MDIC
, mdic
);
3747 /* Poll the ready bit to see if the MDI read completed */
3748 for (i
= 0; i
< 641; i
++) {
3750 mdic
= E1000_READ_REG(hw
, MDIC
);
3751 if (mdic
& E1000_MDIC_READY
) break;
3753 if (!(mdic
& E1000_MDIC_READY
)) {
3754 DEBUGOUT("MDI Write did not complete\n");
3755 return -E1000_ERR_PHY
;
3758 /* We'll need to use the SW defined pins to shift the write command
3759 * out to the PHY. We first send a preamble to the PHY to signal the
3760 * beginning of the MII instruction. This is done by sending 32
3761 * consecutive "1" bits.
3763 e1000_shift_out_mdi_bits(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
3765 /* Now combine the remaining required fields that will indicate a
3766 * write operation. We use this method instead of calling the
3767 * e1000_shift_out_mdi_bits routine for each field in the command. The
3768 * format of a MII write instruction is as follows:
3769 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
3771 mdic
= ((PHY_TURNAROUND
) | (reg_addr
<< 2) | (phy_addr
<< 7) |
3772 (PHY_OP_WRITE
<< 12) | (PHY_SOF
<< 14));
3774 mdic
|= (uint32_t) phy_data
;
3776 e1000_shift_out_mdi_bits(hw
, mdic
, 32);
3779 return E1000_SUCCESS
;
3783 e1000_read_kmrn_reg(struct e1000_hw
*hw
,
3789 DEBUGFUNC("e1000_read_kmrn_reg");
3791 if ((hw
->mac_type
== e1000_80003es2lan
|| hw
->mac_type
== e1000_82576
) &&
3792 (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)) {
3793 swfw
= E1000_SWFW_PHY1_SM
;
3795 swfw
= E1000_SWFW_PHY0_SM
;
3797 if (e1000_swfw_sync_acquire(hw
, swfw
))
3798 return -E1000_ERR_SWFW_SYNC
;
3800 /* Write register address */
3801 reg_val
= ((reg_addr
<< E1000_KUMCTRLSTA_OFFSET_SHIFT
) &
3802 E1000_KUMCTRLSTA_OFFSET
) |
3803 E1000_KUMCTRLSTA_REN
;
3804 E1000_WRITE_REG(hw
, KUMCTRLSTA
, reg_val
);
3807 /* Read the data returned */
3808 reg_val
= E1000_READ_REG(hw
, KUMCTRLSTA
);
3809 *data
= (uint16_t)reg_val
;
3811 e1000_swfw_sync_release(hw
, swfw
);
3812 return E1000_SUCCESS
;
3816 e1000_write_kmrn_reg(struct e1000_hw
*hw
,
3822 DEBUGFUNC("e1000_write_kmrn_reg");
3824 if ((hw
->mac_type
== e1000_80003es2lan
|| hw
->mac_type
== e1000_82576
) &&
3825 (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)) {
3826 swfw
= E1000_SWFW_PHY1_SM
;
3828 swfw
= E1000_SWFW_PHY0_SM
;
3830 if (e1000_swfw_sync_acquire(hw
, swfw
))
3831 return -E1000_ERR_SWFW_SYNC
;
3833 reg_val
= ((reg_addr
<< E1000_KUMCTRLSTA_OFFSET_SHIFT
) &
3834 E1000_KUMCTRLSTA_OFFSET
) | data
;
3835 E1000_WRITE_REG(hw
, KUMCTRLSTA
, reg_val
);
3838 e1000_swfw_sync_release(hw
, swfw
);
3839 return E1000_SUCCESS
;
3842 /******************************************************************************
3843 * Returns the PHY to the power-on reset state
3845 * hw - Struct containing variables accessed by shared code
3846 ******************************************************************************/
3848 e1000_phy_hw_reset(struct e1000_hw
*hw
)
3850 uint32_t ctrl
, ctrl_ext
;
3855 DEBUGFUNC("e1000_phy_hw_reset");
3857 /* In the case of the phy reset being blocked, it's not an error, we
3858 * simply return success without performing the reset. */
3859 ret_val
= e1000_check_phy_reset_block(hw
);
3861 return E1000_SUCCESS
;
3863 DEBUGOUT("Resetting Phy...\n");
3865 if (hw
->mac_type
> e1000_82543
) {
3866 if ((hw
->mac_type
== e1000_80003es2lan
||
3867 hw
->mac_type
== e1000_82576
) &&
3868 (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)) {
3869 swfw
= E1000_SWFW_PHY1_SM
;
3871 swfw
= E1000_SWFW_PHY0_SM
;
3873 if (e1000_swfw_sync_acquire(hw
, swfw
)) {
3874 DEBUGOUT("Unable to acquire swfw sync\n");
3875 return -E1000_ERR_SWFW_SYNC
;
3877 /* Read the device control register and assert the E1000_CTRL_PHY_RST
3878 * bit. Then, take it out of reset.
3879 * For pre-e1000_82571 hardware, we delay for 10ms between the assert
3880 * and deassert. For e1000_82571 hardware and later, we instead delay
3881 * for 50us between and 10ms after the deassertion.
3883 ctrl
= E1000_READ_REG(hw
, CTRL
);
3884 E1000_WRITE_REG(hw
, CTRL
, ctrl
| E1000_CTRL_PHY_RST
);
3885 E1000_WRITE_FLUSH(hw
);
3887 if (hw
->mac_type
< e1000_82571
)
3892 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
3893 E1000_WRITE_FLUSH(hw
);
3895 if (hw
->mac_type
>= e1000_82571
)
3898 e1000_swfw_sync_release(hw
, swfw
);
3900 /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
3901 * bit to put the PHY into reset. Then, take it out of reset.
3903 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
3904 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DIR
;
3905 ctrl_ext
&= ~E1000_CTRL_EXT_SDP4_DATA
;
3906 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
3907 E1000_WRITE_FLUSH(hw
);
3909 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DATA
;
3910 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
3911 E1000_WRITE_FLUSH(hw
);
3915 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
3916 /* Configure activity LED after PHY reset */
3917 led_ctrl
= E1000_READ_REG(hw
, LEDCTL
);
3918 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
3919 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
3920 E1000_WRITE_REG(hw
, LEDCTL
, led_ctrl
);
3923 /* Wait for FW to finish PHY configuration. */
3924 ret_val
= e1000_get_phy_cfg_done(hw
);
3925 if (ret_val
!= E1000_SUCCESS
)
3927 e1000_release_software_semaphore(hw
);
3929 if ((hw
->mac_type
== e1000_ich8lan
) && (hw
->phy_type
== e1000_phy_igp_3
))
3930 ret_val
= e1000_init_lcd_from_nvm(hw
);
3935 /******************************************************************************
3938 * hw - Struct containing variables accessed by shared code
3940 * Sets bit 15 of the MII Control register
3941 ******************************************************************************/
3943 e1000_phy_reset(struct e1000_hw
*hw
)
3948 DEBUGFUNC("e1000_phy_reset");
3950 /* In the case of the phy reset being blocked, it's not an error, we
3951 * simply return success without performing the reset. */
3952 ret_val
= e1000_check_phy_reset_block(hw
);
3954 return E1000_SUCCESS
;
3956 switch (hw
->phy_type
) {
3958 case e1000_phy_igp_2
:
3959 case e1000_phy_igp_3
:
3961 ret_val
= e1000_phy_hw_reset(hw
);
3966 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_data
);
3970 phy_data
|= MII_CR_RESET
;
3971 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, phy_data
);
3979 if (hw
->phy_type
== e1000_phy_igp
|| hw
->phy_type
== e1000_phy_igp_2
)
3980 e1000_phy_init_script(hw
);
3982 return E1000_SUCCESS
;
3985 /******************************************************************************
3986 * Work-around for 82566 power-down: on D3 entry-
3987 * 1) disable gigabit link
3988 * 2) write VR power-down enable
3990 * if successful continue, else issue LCD reset and repeat
3992 * hw - struct containing variables accessed by shared code
3993 ******************************************************************************/
3995 e1000_phy_powerdown_workaround(struct e1000_hw
*hw
)
4001 DEBUGFUNC("e1000_phy_powerdown_workaround");
4003 if (hw
->phy_type
!= e1000_phy_igp_3
)
4008 reg
= E1000_READ_REG(hw
, PHY_CTRL
);
4009 E1000_WRITE_REG(hw
, PHY_CTRL
, reg
| E1000_PHY_CTRL_GBE_DISABLE
|
4010 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
4012 /* Write VR power-down enable - bits 9:8 should be 10b */
4013 e1000_read_phy_reg(hw
, IGP3_VR_CTRL
, &phy_data
);
4014 phy_data
|= (1 << 9);
4015 phy_data
&= ~(1 << 8);
4016 e1000_write_phy_reg(hw
, IGP3_VR_CTRL
, phy_data
);
4018 /* Read it back and test */
4019 e1000_read_phy_reg(hw
, IGP3_VR_CTRL
, &phy_data
);
4020 if (((phy_data
& IGP3_VR_CTRL_MODE_MASK
) == IGP3_VR_CTRL_MODE_SHUT
) || retry
)
4023 /* Issue PHY reset and repeat at most one more time */
4024 reg
= E1000_READ_REG(hw
, CTRL
);
4025 E1000_WRITE_REG(hw
, CTRL
, reg
| E1000_CTRL_PHY_RST
);
4033 /******************************************************************************
4034 * Work-around for 82566 Kumeran PCS lock loss:
4035 * On link status change (i.e. PCI reset, speed change) and link is up and
4037 * 0) if workaround is optionally disabled do nothing
4038 * 1) wait 1ms for Kumeran link to come up
4039 * 2) check Kumeran Diagnostic register PCS lock loss bit
4040 * 3) if not set the link is locked (all is good), otherwise...
4042 * 5) repeat up to 10 times
4043 * Note: this is only called for IGP3 copper when speed is 1gb.
4045 * hw - struct containing variables accessed by shared code
4046 ******************************************************************************/
4048 e1000_kumeran_lock_loss_workaround(struct e1000_hw
*hw
)
4055 if (hw
->kmrn_lock_loss_workaround_disabled
)
4056 return E1000_SUCCESS
;
4058 /* Make sure link is up before proceeding. If not just return.
4059 * Attempting this while link is negotiating fouled up link
4061 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
4062 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
4064 if (phy_data
& MII_SR_LINK_STATUS
) {
4065 for (cnt
= 0; cnt
< 10; cnt
++) {
4066 /* read once to clear */
4067 ret_val
= e1000_read_phy_reg(hw
, IGP3_KMRN_DIAG
, &phy_data
);
4070 /* and again to get new status */
4071 ret_val
= e1000_read_phy_reg(hw
, IGP3_KMRN_DIAG
, &phy_data
);
4075 /* check for PCS lock */
4076 if (!(phy_data
& IGP3_KMRN_DIAG_PCS_LOCK_LOSS
))
4077 return E1000_SUCCESS
;
4079 /* Issue PHY reset */
4080 e1000_phy_hw_reset(hw
);
4083 /* Disable GigE link negotiation */
4084 reg
= E1000_READ_REG(hw
, PHY_CTRL
);
4085 E1000_WRITE_REG(hw
, PHY_CTRL
, reg
| E1000_PHY_CTRL_GBE_DISABLE
|
4086 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
4088 /* unable to acquire PCS lock */
4089 return E1000_ERR_PHY
;
4092 return E1000_SUCCESS
;
4095 /******************************************************************************
4096 * Probes the expected PHY address for known PHY IDs
4098 * hw - Struct containing variables accessed by shared code
4099 ******************************************************************************/
4101 e1000_detect_gig_phy(struct e1000_hw
*hw
)
4103 int32_t phy_init_status
, ret_val
;
4104 uint16_t phy_id_high
, phy_id_low
;
4105 boolean_t match
= FALSE
;
4107 DEBUGFUNC("e1000_detect_gig_phy");
4109 if (hw
->phy_id
!= 0)
4110 return E1000_SUCCESS
;
4112 /* The 82571 firmware may still be configuring the PHY. In this
4113 * case, we cannot access the PHY until the configuration is done. So
4114 * we explicitly set the PHY values. */
4115 if (hw
->mac_type
== e1000_82571
||
4116 hw
->mac_type
== e1000_82572
) {
4117 hw
->phy_id
= IGP01E1000_I_PHY_ID
;
4118 hw
->phy_type
= e1000_phy_igp_2
;
4119 return E1000_SUCCESS
;
4122 /* ESB-2 PHY reads require e1000_phy_gg82563 to be set because of a work-
4123 * around that forces PHY page 0 to be set or the reads fail. The rest of
4124 * the code in this routine uses e1000_read_phy_reg to read the PHY ID.
4125 * So for ESB-2 we need to have this set so our reads won't fail. If the
4126 * attached PHY is not a e1000_phy_gg82563, the routines below will figure
4127 * this out as well. */
4128 if (hw
->mac_type
== e1000_80003es2lan
)
4129 hw
->phy_type
= e1000_phy_gg82563
;
4131 /* Read the PHY ID Registers to identify which PHY is onboard. */
4132 ret_val
= e1000_read_phy_reg(hw
, PHY_ID1
, &phy_id_high
);
4136 hw
->phy_id
= (uint32_t) (phy_id_high
<< 16);
4138 ret_val
= e1000_read_phy_reg(hw
, PHY_ID2
, &phy_id_low
);
4142 hw
->phy_id
|= (uint32_t) (phy_id_low
& PHY_REVISION_MASK
);
4143 hw
->phy_revision
= (uint32_t) phy_id_low
& ~PHY_REVISION_MASK
;
4145 switch (hw
->mac_type
) {
4147 if (hw
->phy_id
== M88E1000_E_PHY_ID
) match
= TRUE
;
4150 if (hw
->phy_id
== M88E1000_I_PHY_ID
) match
= TRUE
;
4154 case e1000_82545_rev_3
:
4156 case e1000_82546_rev_3
:
4157 if (hw
->phy_id
== M88E1011_I_PHY_ID
) match
= TRUE
;
4160 case e1000_82541_rev_2
:
4162 case e1000_82547_rev_2
:
4163 if (hw
->phy_id
== IGP01E1000_I_PHY_ID
) match
= TRUE
;
4166 if (hw
->phy_id
== M88E1111_I_PHY_ID
) match
= TRUE
;
4168 case e1000_80003es2lan
:
4169 if (hw
->phy_id
== GG82563_E_PHY_ID
) match
= TRUE
;
4172 if (hw
->phy_id
== IGP03E1000_E_PHY_ID
) match
= TRUE
;
4173 if (hw
->phy_id
== IFE_E_PHY_ID
) match
= TRUE
;
4174 if (hw
->phy_id
== IFE_PLUS_E_PHY_ID
) match
= TRUE
;
4175 if (hw
->phy_id
== IFE_C_E_PHY_ID
) match
= TRUE
;
4181 DEBUGOUT1("Invalid MAC type %d\n", hw
->mac_type
);
4182 return -E1000_ERR_CONFIG
;
4184 phy_init_status
= e1000_set_phy_type(hw
);
4186 if ((match
) && (phy_init_status
== E1000_SUCCESS
)) {
4187 DEBUGOUT1("PHY ID %#08x detected\n", hw
->phy_id
);
4188 return E1000_SUCCESS
;
4190 DEBUGOUT1("Invalid PHY ID %#08x\n", hw
->phy_id
);
4191 return -E1000_ERR_PHY
;
4194 /******************************************************************************
4195 * Resets the PHY's DSP
4197 * hw - Struct containing variables accessed by shared code
4198 ******************************************************************************/
4200 e1000_phy_reset_dsp(struct e1000_hw
*hw
)
4203 DEBUGFUNC("e1000_phy_reset_dsp");
4206 if (hw
->phy_type
!= e1000_phy_gg82563
) {
4207 ret_val
= e1000_write_phy_reg(hw
, 29, 0x001d);
4210 ret_val
= e1000_write_phy_reg(hw
, 30, 0x00c1);
4212 ret_val
= e1000_write_phy_reg(hw
, 30, 0x0000);
4214 ret_val
= E1000_SUCCESS
;
4220 /******************************************************************************
4221 * Get PHY information from various PHY registers for igp PHY only.
4223 * hw - Struct containing variables accessed by shared code
4224 * phy_info - PHY information structure
4225 ******************************************************************************/
4227 e1000_phy_igp_get_info(struct e1000_hw
*hw
,
4228 struct e1000_phy_info
*phy_info
)
4231 uint16_t phy_data
, min_length
, max_length
, average
;
4232 e1000_rev_polarity polarity
;
4234 DEBUGFUNC("e1000_phy_igp_get_info");
4236 /* The downshift status is checked only once, after link is established,
4237 * and it stored in the hw->speed_downgraded parameter. */
4238 phy_info
->downshift
= (e1000_downshift
)hw
->speed_downgraded
;
4240 /* IGP01E1000 does not need to support it. */
4241 phy_info
->extended_10bt_distance
= e1000_10bt_ext_dist_enable_normal
;
4243 /* IGP01E1000 always correct polarity reversal */
4244 phy_info
->polarity_correction
= e1000_polarity_reversal_enabled
;
4246 /* Check polarity status */
4247 ret_val
= e1000_check_polarity(hw
, &polarity
);
4251 phy_info
->cable_polarity
= polarity
;
4253 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
, &phy_data
);
4257 phy_info
->mdix_mode
= (e1000_auto_x_mode
)((phy_data
& IGP01E1000_PSSR_MDIX
) >>
4258 IGP01E1000_PSSR_MDIX_SHIFT
);
4260 if ((phy_data
& IGP01E1000_PSSR_SPEED_MASK
) ==
4261 IGP01E1000_PSSR_SPEED_1000MBPS
) {
4262 /* Local/Remote Receiver Information are only valid at 1000 Mbps */
4263 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
4267 phy_info
->local_rx
= ((phy_data
& SR_1000T_LOCAL_RX_STATUS
) >>
4268 SR_1000T_LOCAL_RX_STATUS_SHIFT
) ?
4269 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
4270 phy_info
->remote_rx
= ((phy_data
& SR_1000T_REMOTE_RX_STATUS
) >>
4271 SR_1000T_REMOTE_RX_STATUS_SHIFT
) ?
4272 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
4274 /* Get cable length */
4275 ret_val
= e1000_get_cable_length(hw
, &min_length
, &max_length
);
4279 /* Translate to old method */
4280 average
= (max_length
+ min_length
) / 2;
4282 if (average
<= e1000_igp_cable_length_50
)
4283 phy_info
->cable_length
= e1000_cable_length_50
;
4284 else if (average
<= e1000_igp_cable_length_80
)
4285 phy_info
->cable_length
= e1000_cable_length_50_80
;
4286 else if (average
<= e1000_igp_cable_length_110
)
4287 phy_info
->cable_length
= e1000_cable_length_80_110
;
4288 else if (average
<= e1000_igp_cable_length_140
)
4289 phy_info
->cable_length
= e1000_cable_length_110_140
;
4291 phy_info
->cable_length
= e1000_cable_length_140
;
4294 return E1000_SUCCESS
;
4297 /******************************************************************************
4298 * Get PHY information from various PHY registers for ife PHY only.
4300 * hw - Struct containing variables accessed by shared code
4301 * phy_info - PHY information structure
4302 ******************************************************************************/
4304 e1000_phy_ife_get_info(struct e1000_hw
*hw
,
4305 struct e1000_phy_info
*phy_info
)
4309 e1000_rev_polarity polarity
;
4311 DEBUGFUNC("e1000_phy_ife_get_info");
4313 phy_info
->downshift
= (e1000_downshift
)hw
->speed_downgraded
;
4314 phy_info
->extended_10bt_distance
= e1000_10bt_ext_dist_enable_normal
;
4316 ret_val
= e1000_read_phy_reg(hw
, IFE_PHY_SPECIAL_CONTROL
, &phy_data
);
4319 phy_info
->polarity_correction
=
4320 ((phy_data
& IFE_PSC_AUTO_POLARITY_DISABLE
) >>
4321 IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT
) ?
4322 e1000_polarity_reversal_disabled
: e1000_polarity_reversal_enabled
;
4324 if (phy_info
->polarity_correction
== e1000_polarity_reversal_enabled
) {
4325 ret_val
= e1000_check_polarity(hw
, &polarity
);
4329 /* Polarity is forced. */
4330 polarity
= ((phy_data
& IFE_PSC_FORCE_POLARITY
) >>
4331 IFE_PSC_FORCE_POLARITY_SHIFT
) ?
4332 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
4334 phy_info
->cable_polarity
= polarity
;
4336 ret_val
= e1000_read_phy_reg(hw
, IFE_PHY_MDIX_CONTROL
, &phy_data
);
4340 phy_info
->mdix_mode
= (e1000_auto_x_mode
)
4341 ((phy_data
& (IFE_PMC_AUTO_MDIX
| IFE_PMC_FORCE_MDIX
)) >>
4342 IFE_PMC_MDIX_MODE_SHIFT
);
4344 return E1000_SUCCESS
;
4347 /******************************************************************************
4348 * Get PHY information from various PHY registers fot m88 PHY only.
4350 * hw - Struct containing variables accessed by shared code
4351 * phy_info - PHY information structure
4352 ******************************************************************************/
4354 e1000_phy_m88_get_info(struct e1000_hw
*hw
,
4355 struct e1000_phy_info
*phy_info
)
4359 e1000_rev_polarity polarity
;
4361 DEBUGFUNC("e1000_phy_m88_get_info");
4363 /* The downshift status is checked only once, after link is established,
4364 * and it stored in the hw->speed_downgraded parameter. */
4365 phy_info
->downshift
= (e1000_downshift
)hw
->speed_downgraded
;
4367 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
4371 phy_info
->extended_10bt_distance
=
4372 ((phy_data
& M88E1000_PSCR_10BT_EXT_DIST_ENABLE
) >>
4373 M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT
) ?
4374 e1000_10bt_ext_dist_enable_lower
: e1000_10bt_ext_dist_enable_normal
;
4376 phy_info
->polarity_correction
=
4377 ((phy_data
& M88E1000_PSCR_POLARITY_REVERSAL
) >>
4378 M88E1000_PSCR_POLARITY_REVERSAL_SHIFT
) ?
4379 e1000_polarity_reversal_disabled
: e1000_polarity_reversal_enabled
;
4381 /* Check polarity status */
4382 ret_val
= e1000_check_polarity(hw
, &polarity
);
4385 phy_info
->cable_polarity
= polarity
;
4387 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
4391 phy_info
->mdix_mode
= (e1000_auto_x_mode
)((phy_data
& M88E1000_PSSR_MDIX
) >>
4392 M88E1000_PSSR_MDIX_SHIFT
);
4394 if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_1000MBS
) {
4395 /* Cable Length Estimation and Local/Remote Receiver Information
4396 * are only valid at 1000 Mbps.
4398 if (hw
->phy_type
!= e1000_phy_gg82563
) {
4399 phy_info
->cable_length
= (e1000_cable_length
)((phy_data
& M88E1000_PSSR_CABLE_LENGTH
) >>
4400 M88E1000_PSSR_CABLE_LENGTH_SHIFT
);
4402 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_DSP_DISTANCE
,
4407 phy_info
->cable_length
= (e1000_cable_length
)(phy_data
& GG82563_DSPD_CABLE_LENGTH
);
4410 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
4414 phy_info
->local_rx
= ((phy_data
& SR_1000T_LOCAL_RX_STATUS
) >>
4415 SR_1000T_LOCAL_RX_STATUS_SHIFT
) ?
4416 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
4417 phy_info
->remote_rx
= ((phy_data
& SR_1000T_REMOTE_RX_STATUS
) >>
4418 SR_1000T_REMOTE_RX_STATUS_SHIFT
) ?
4419 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
4423 return E1000_SUCCESS
;
4426 /******************************************************************************
4427 * Get PHY information from various PHY registers
4429 * hw - Struct containing variables accessed by shared code
4430 * phy_info - PHY information structure
4431 ******************************************************************************/
4433 e1000_phy_get_info(struct e1000_hw
*hw
,
4434 struct e1000_phy_info
*phy_info
)
4439 DEBUGFUNC("e1000_phy_get_info");
4441 phy_info
->cable_length
= e1000_cable_length_undefined
;
4442 phy_info
->extended_10bt_distance
= e1000_10bt_ext_dist_enable_undefined
;
4443 phy_info
->cable_polarity
= e1000_rev_polarity_undefined
;
4444 phy_info
->downshift
= e1000_downshift_undefined
;
4445 phy_info
->polarity_correction
= e1000_polarity_reversal_undefined
;
4446 phy_info
->mdix_mode
= e1000_auto_x_mode_undefined
;
4447 phy_info
->local_rx
= e1000_1000t_rx_status_undefined
;
4448 phy_info
->remote_rx
= e1000_1000t_rx_status_undefined
;
4450 if (hw
->media_type
!= e1000_media_type_copper
) {
4451 DEBUGOUT("PHY info is only valid for copper media\n");
4452 return -E1000_ERR_CONFIG
;
4455 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
4459 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
4463 if ((phy_data
& MII_SR_LINK_STATUS
) != MII_SR_LINK_STATUS
) {
4464 DEBUGOUT("PHY info is only valid if link is up\n");
4465 return -E1000_ERR_CONFIG
;
4468 if (hw
->phy_type
== e1000_phy_igp
||
4469 hw
->phy_type
== e1000_phy_igp_3
||
4470 hw
->phy_type
== e1000_phy_igp_2
)
4471 return e1000_phy_igp_get_info(hw
, phy_info
);
4472 else if (hw
->phy_type
== e1000_phy_ife
)
4473 return e1000_phy_ife_get_info(hw
, phy_info
);
4475 return e1000_phy_m88_get_info(hw
, phy_info
);
4479 e1000_validate_mdi_setting(struct e1000_hw
*hw
)
4481 DEBUGFUNC("e1000_validate_mdi_settings");
4483 if (!hw
->autoneg
&& (hw
->mdix
== 0 || hw
->mdix
== 3)) {
4484 DEBUGOUT("Invalid MDI setting detected\n");
4486 return -E1000_ERR_CONFIG
;
4488 return E1000_SUCCESS
;
4492 /******************************************************************************
4493 * Sets up eeprom variables in the hw struct. Must be called after mac_type
4494 * is configured. Additionally, if this is ICH8, the flash controller GbE
4495 * registers must be mapped, or this will crash.
4497 * hw - Struct containing variables accessed by shared code
4498 *****************************************************************************/
4500 e1000_init_eeprom_params(struct e1000_hw
*hw
)
4502 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4503 uint32_t eecd
= E1000_READ_REG(hw
, EECD
);
4504 int32_t ret_val
= E1000_SUCCESS
;
4505 uint16_t eeprom_size
;
4507 DEBUGFUNC("e1000_init_eeprom_params");
4509 switch (hw
->mac_type
) {
4510 case e1000_82542_rev2_0
:
4511 case e1000_82542_rev2_1
:
4514 eeprom
->type
= e1000_eeprom_microwire
;
4515 eeprom
->word_size
= 64;
4516 eeprom
->opcode_bits
= 3;
4517 eeprom
->address_bits
= 6;
4518 eeprom
->delay_usec
= 50;
4519 eeprom
->use_eerd
= FALSE
;
4520 eeprom
->use_eewr
= FALSE
;
4524 case e1000_82545_rev_3
:
4526 case e1000_82546_rev_3
:
4527 eeprom
->type
= e1000_eeprom_microwire
;
4528 eeprom
->opcode_bits
= 3;
4529 eeprom
->delay_usec
= 50;
4530 if (eecd
& E1000_EECD_SIZE
) {
4531 eeprom
->word_size
= 256;
4532 eeprom
->address_bits
= 8;
4534 eeprom
->word_size
= 64;
4535 eeprom
->address_bits
= 6;
4537 eeprom
->use_eerd
= FALSE
;
4538 eeprom
->use_eewr
= FALSE
;
4541 case e1000_82541_rev_2
:
4543 case e1000_82547_rev_2
:
4544 if (eecd
& E1000_EECD_TYPE
) {
4545 eeprom
->type
= e1000_eeprom_spi
;
4546 eeprom
->opcode_bits
= 8;
4547 eeprom
->delay_usec
= 1;
4548 if (eecd
& E1000_EECD_ADDR_BITS
) {
4549 eeprom
->page_size
= 32;
4550 eeprom
->address_bits
= 16;
4552 eeprom
->page_size
= 8;
4553 eeprom
->address_bits
= 8;
4556 eeprom
->type
= e1000_eeprom_microwire
;
4557 eeprom
->opcode_bits
= 3;
4558 eeprom
->delay_usec
= 50;
4559 if (eecd
& E1000_EECD_ADDR_BITS
) {
4560 eeprom
->word_size
= 256;
4561 eeprom
->address_bits
= 8;
4563 eeprom
->word_size
= 64;
4564 eeprom
->address_bits
= 6;
4567 eeprom
->use_eerd
= FALSE
;
4568 eeprom
->use_eewr
= FALSE
;
4572 eeprom
->type
= e1000_eeprom_spi
;
4573 eeprom
->opcode_bits
= 8;
4574 eeprom
->delay_usec
= 1;
4575 if (eecd
& E1000_EECD_ADDR_BITS
) {
4576 eeprom
->page_size
= 32;
4577 eeprom
->address_bits
= 16;
4579 eeprom
->page_size
= 8;
4580 eeprom
->address_bits
= 8;
4582 eeprom
->use_eerd
= FALSE
;
4583 eeprom
->use_eewr
= FALSE
;
4586 eeprom
->type
= e1000_eeprom_spi
;
4587 eeprom
->opcode_bits
= 8;
4588 eeprom
->delay_usec
= 1;
4589 if (eecd
& E1000_EECD_ADDR_BITS
) {
4590 eeprom
->page_size
= 32;
4591 eeprom
->address_bits
= 16;
4593 eeprom
->page_size
= 8;
4594 eeprom
->address_bits
= 8;
4596 eeprom
->use_eerd
= TRUE
;
4597 eeprom
->use_eewr
= TRUE
;
4598 if (e1000_is_onboard_nvm_eeprom(hw
) == FALSE
) {
4599 eeprom
->type
= e1000_eeprom_flash
;
4600 eeprom
->word_size
= 2048;
4602 /* Ensure that the Autonomous FLASH update bit is cleared due to
4603 * Flash update issue on parts which use a FLASH for NVM. */
4604 eecd
&= ~E1000_EECD_AUPDEN
;
4605 E1000_WRITE_REG(hw
, EECD
, eecd
);
4608 case e1000_80003es2lan
:
4609 eeprom
->type
= e1000_eeprom_spi
;
4610 eeprom
->opcode_bits
= 8;
4611 eeprom
->delay_usec
= 1;
4612 if (eecd
& E1000_EECD_ADDR_BITS
) {
4613 eeprom
->page_size
= 32;
4614 eeprom
->address_bits
= 16;
4616 eeprom
->page_size
= 8;
4617 eeprom
->address_bits
= 8;
4619 eeprom
->use_eerd
= TRUE
;
4620 eeprom
->use_eewr
= FALSE
;
4625 uint32_t flash_size
= E1000_READ_ICH_FLASH_REG(hw
, ICH_FLASH_GFPREG
);
4627 eeprom
->type
= e1000_eeprom_ich8
;
4628 eeprom
->use_eerd
= FALSE
;
4629 eeprom
->use_eewr
= FALSE
;
4630 eeprom
->word_size
= E1000_SHADOW_RAM_WORDS
;
4632 /* Zero the shadow RAM structure. But don't load it from NVM
4633 * so as to save time for driver init */
4634 if (hw
->eeprom_shadow_ram
!= NULL
) {
4635 for (i
= 0; i
< E1000_SHADOW_RAM_WORDS
; i
++) {
4636 hw
->eeprom_shadow_ram
[i
].modified
= FALSE
;
4637 hw
->eeprom_shadow_ram
[i
].eeprom_word
= 0xFFFF;
4641 hw
->flash_base_addr
= (flash_size
& ICH_GFPREG_BASE_MASK
) *
4642 ICH_FLASH_SECTOR_SIZE
;
4644 hw
->flash_bank_size
= ((flash_size
>> 16) & ICH_GFPREG_BASE_MASK
) + 1;
4645 hw
->flash_bank_size
-= (flash_size
& ICH_GFPREG_BASE_MASK
);
4647 hw
->flash_bank_size
*= ICH_FLASH_SECTOR_SIZE
;
4649 hw
->flash_bank_size
/= 2 * sizeof(uint16_t);
4657 eeprom
->type
= e1000_eeprom_spi
;
4658 eeprom
->opcode_bits
= 8;
4659 eeprom
->delay_usec
= 1;
4660 if (eecd
& E1000_EECD_ADDR_BITS
) {
4661 eeprom
->page_size
= 32;
4662 eeprom
->address_bits
= 16;
4664 eeprom
->page_size
= 8;
4665 eeprom
->address_bits
= 8;
4667 eeprom
->use_eerd
= TRUE
;
4668 eeprom
->use_eewr
= FALSE
;
4670 size
= (uint16_t)((eecd
& E1000_EECD_SIZE_EX_MASK
) >>
4671 E1000_EECD_SIZE_EX_SHIFT
);
4673 * Added to a constant, "size" becomes the left-shift value
4674 * for setting word_size.
4676 size
+= EEPROM_WORD_SIZE_SHIFT
;
4678 /* EEPROM access above 16k is unsupported */
4681 eeprom
->word_size
= 1 << size
;
4689 if (eeprom
->type
== e1000_eeprom_spi
) {
4690 /* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to
4691 * 32KB (incremented by powers of 2).
4693 if (hw
->mac_type
<= e1000_82547_rev_2
) {
4694 /* Set to default value for initial eeprom read. */
4695 eeprom
->word_size
= 64;
4696 ret_val
= e1000_read_eeprom(hw
, EEPROM_CFG
, 1, &eeprom_size
);
4699 eeprom_size
= (eeprom_size
& EEPROM_SIZE_MASK
) >> EEPROM_SIZE_SHIFT
;
4700 /* 256B eeprom size was not supported in earlier hardware, so we
4701 * bump eeprom_size up one to ensure that "1" (which maps to 256B)
4702 * is never the result used in the shifting logic below. */
4706 eeprom_size
= (uint16_t)((eecd
& E1000_EECD_SIZE_EX_MASK
) >>
4707 E1000_EECD_SIZE_EX_SHIFT
);
4710 eeprom
->word_size
= 1 << (eeprom_size
+ EEPROM_WORD_SIZE_SHIFT
);
4715 /******************************************************************************
4716 * Raises the EEPROM's clock input.
4718 * hw - Struct containing variables accessed by shared code
4719 * eecd - EECD's current value
4720 *****************************************************************************/
4722 e1000_raise_ee_clk(struct e1000_hw
*hw
,
4725 /* Raise the clock input to the EEPROM (by setting the SK bit), and then
4726 * wait <delay> microseconds.
4728 *eecd
= *eecd
| E1000_EECD_SK
;
4729 E1000_WRITE_REG(hw
, EECD
, *eecd
);
4730 E1000_WRITE_FLUSH(hw
);
4731 udelay(hw
->eeprom
.delay_usec
);
4734 /******************************************************************************
4735 * Lowers the EEPROM's clock input.
4737 * hw - Struct containing variables accessed by shared code
4738 * eecd - EECD's current value
4739 *****************************************************************************/
4741 e1000_lower_ee_clk(struct e1000_hw
*hw
,
4744 /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
4745 * wait 50 microseconds.
4747 *eecd
= *eecd
& ~E1000_EECD_SK
;
4748 E1000_WRITE_REG(hw
, EECD
, *eecd
);
4749 E1000_WRITE_FLUSH(hw
);
4750 udelay(hw
->eeprom
.delay_usec
);
4753 /******************************************************************************
4754 * Shift data bits out to the EEPROM.
4756 * hw - Struct containing variables accessed by shared code
4757 * data - data to send to the EEPROM
4758 * count - number of bits to shift out
4759 *****************************************************************************/
4761 e1000_shift_out_ee_bits(struct e1000_hw
*hw
,
4765 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4769 /* We need to shift "count" bits out to the EEPROM. So, value in the
4770 * "data" parameter will be shifted out to the EEPROM one bit at a time.
4771 * In order to do this, "data" must be broken down into bits.
4773 mask
= 0x01 << (count
- 1);
4774 eecd
= E1000_READ_REG(hw
, EECD
);
4775 if (eeprom
->type
== e1000_eeprom_microwire
) {
4776 eecd
&= ~E1000_EECD_DO
;
4777 } else if (eeprom
->type
== e1000_eeprom_spi
) {
4778 eecd
|= E1000_EECD_DO
;
4781 /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
4782 * and then raising and then lowering the clock (the SK bit controls
4783 * the clock input to the EEPROM). A "0" is shifted out to the EEPROM
4784 * by setting "DI" to "0" and then raising and then lowering the clock.
4786 eecd
&= ~E1000_EECD_DI
;
4789 eecd
|= E1000_EECD_DI
;
4791 E1000_WRITE_REG(hw
, EECD
, eecd
);
4792 E1000_WRITE_FLUSH(hw
);
4794 udelay(eeprom
->delay_usec
);
4796 e1000_raise_ee_clk(hw
, &eecd
);
4797 e1000_lower_ee_clk(hw
, &eecd
);
4803 /* We leave the "DI" bit set to "0" when we leave this routine. */
4804 eecd
&= ~E1000_EECD_DI
;
4805 E1000_WRITE_REG(hw
, EECD
, eecd
);
4808 /******************************************************************************
4809 * Shift data bits in from the EEPROM
4811 * hw - Struct containing variables accessed by shared code
4812 *****************************************************************************/
4814 e1000_shift_in_ee_bits(struct e1000_hw
*hw
,
4821 /* In order to read a register from the EEPROM, we need to shift 'count'
4822 * bits in from the EEPROM. Bits are "shifted in" by raising the clock
4823 * input to the EEPROM (setting the SK bit), and then reading the value of
4824 * the "DO" bit. During this "shifting in" process the "DI" bit should
4828 eecd
= E1000_READ_REG(hw
, EECD
);
4830 eecd
&= ~(E1000_EECD_DO
| E1000_EECD_DI
);
4833 for (i
= 0; i
< count
; i
++) {
4835 e1000_raise_ee_clk(hw
, &eecd
);
4837 eecd
= E1000_READ_REG(hw
, EECD
);
4839 eecd
&= ~(E1000_EECD_DI
);
4840 if (eecd
& E1000_EECD_DO
)
4843 e1000_lower_ee_clk(hw
, &eecd
);
4849 /******************************************************************************
4850 * Prepares EEPROM for access
4852 * hw - Struct containing variables accessed by shared code
4854 * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
4855 * function should be called before issuing a command to the EEPROM.
4856 *****************************************************************************/
4858 e1000_acquire_eeprom(struct e1000_hw
*hw
)
4860 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4863 DEBUGFUNC("e1000_acquire_eeprom");
4865 if (e1000_swfw_sync_acquire(hw
, E1000_SWFW_EEP_SM
))
4866 return -E1000_ERR_SWFW_SYNC
;
4867 eecd
= E1000_READ_REG(hw
, EECD
);
4869 if (hw
->mac_type
!= e1000_82573
) {
4870 /* Request EEPROM Access */
4871 if (hw
->mac_type
> e1000_82544
) {
4872 eecd
|= E1000_EECD_REQ
;
4873 E1000_WRITE_REG(hw
, EECD
, eecd
);
4874 eecd
= E1000_READ_REG(hw
, EECD
);
4875 while ((!(eecd
& E1000_EECD_GNT
)) &&
4876 (i
< E1000_EEPROM_GRANT_ATTEMPTS
)) {
4879 eecd
= E1000_READ_REG(hw
, EECD
);
4881 if (!(eecd
& E1000_EECD_GNT
)) {
4882 eecd
&= ~E1000_EECD_REQ
;
4883 E1000_WRITE_REG(hw
, EECD
, eecd
);
4884 DEBUGOUT("Could not acquire EEPROM grant\n");
4885 e1000_swfw_sync_release(hw
, E1000_SWFW_EEP_SM
);
4886 return -E1000_ERR_EEPROM
;
4891 /* Setup EEPROM for Read/Write */
4893 if (eeprom
->type
== e1000_eeprom_microwire
) {
4894 /* Clear SK and DI */
4895 eecd
&= ~(E1000_EECD_DI
| E1000_EECD_SK
);
4896 E1000_WRITE_REG(hw
, EECD
, eecd
);
4899 eecd
|= E1000_EECD_CS
;
4900 E1000_WRITE_REG(hw
, EECD
, eecd
);
4901 } else if (eeprom
->type
== e1000_eeprom_spi
) {
4902 /* Clear SK and CS */
4903 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
4904 E1000_WRITE_REG(hw
, EECD
, eecd
);
4908 return E1000_SUCCESS
;
4911 /******************************************************************************
4912 * Returns EEPROM to a "standby" state
4914 * hw - Struct containing variables accessed by shared code
4915 *****************************************************************************/
4917 e1000_standby_eeprom(struct e1000_hw
*hw
)
4919 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4922 eecd
= E1000_READ_REG(hw
, EECD
);
4924 if (eeprom
->type
== e1000_eeprom_microwire
) {
4925 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
4926 E1000_WRITE_REG(hw
, EECD
, eecd
);
4927 E1000_WRITE_FLUSH(hw
);
4928 udelay(eeprom
->delay_usec
);
4931 eecd
|= E1000_EECD_SK
;
4932 E1000_WRITE_REG(hw
, EECD
, eecd
);
4933 E1000_WRITE_FLUSH(hw
);
4934 udelay(eeprom
->delay_usec
);
4937 eecd
|= E1000_EECD_CS
;
4938 E1000_WRITE_REG(hw
, EECD
, eecd
);
4939 E1000_WRITE_FLUSH(hw
);
4940 udelay(eeprom
->delay_usec
);
4943 eecd
&= ~E1000_EECD_SK
;
4944 E1000_WRITE_REG(hw
, EECD
, eecd
);
4945 E1000_WRITE_FLUSH(hw
);
4946 udelay(eeprom
->delay_usec
);
4947 } else if (eeprom
->type
== e1000_eeprom_spi
) {
4948 /* Toggle CS to flush commands */
4949 eecd
|= E1000_EECD_CS
;
4950 E1000_WRITE_REG(hw
, EECD
, eecd
);
4951 E1000_WRITE_FLUSH(hw
);
4952 udelay(eeprom
->delay_usec
);
4953 eecd
&= ~E1000_EECD_CS
;
4954 E1000_WRITE_REG(hw
, EECD
, eecd
);
4955 E1000_WRITE_FLUSH(hw
);
4956 udelay(eeprom
->delay_usec
);
4960 /******************************************************************************
4961 * Terminates a command by inverting the EEPROM's chip select pin
4963 * hw - Struct containing variables accessed by shared code
4964 *****************************************************************************/
4966 e1000_release_eeprom(struct e1000_hw
*hw
)
4970 DEBUGFUNC("e1000_release_eeprom");
4972 eecd
= E1000_READ_REG(hw
, EECD
);
4974 if (hw
->eeprom
.type
== e1000_eeprom_spi
) {
4975 eecd
|= E1000_EECD_CS
; /* Pull CS high */
4976 eecd
&= ~E1000_EECD_SK
; /* Lower SCK */
4978 E1000_WRITE_REG(hw
, EECD
, eecd
);
4980 udelay(hw
->eeprom
.delay_usec
);
4981 } else if (hw
->eeprom
.type
== e1000_eeprom_microwire
) {
4982 /* cleanup eeprom */
4984 /* CS on Microwire is active-high */
4985 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_DI
);
4987 E1000_WRITE_REG(hw
, EECD
, eecd
);
4989 /* Rising edge of clock */
4990 eecd
|= E1000_EECD_SK
;
4991 E1000_WRITE_REG(hw
, EECD
, eecd
);
4992 E1000_WRITE_FLUSH(hw
);
4993 udelay(hw
->eeprom
.delay_usec
);
4995 /* Falling edge of clock */
4996 eecd
&= ~E1000_EECD_SK
;
4997 E1000_WRITE_REG(hw
, EECD
, eecd
);
4998 E1000_WRITE_FLUSH(hw
);
4999 udelay(hw
->eeprom
.delay_usec
);
5002 /* Stop requesting EEPROM access */
5003 if (hw
->mac_type
> e1000_82544
) {
5004 eecd
&= ~E1000_EECD_REQ
;
5005 E1000_WRITE_REG(hw
, EECD
, eecd
);
5008 e1000_swfw_sync_release(hw
, E1000_SWFW_EEP_SM
);
5011 /******************************************************************************
5012 * Reads a 16 bit word from the EEPROM.
5014 * hw - Struct containing variables accessed by shared code
5015 *****************************************************************************/
5017 e1000_spi_eeprom_ready(struct e1000_hw
*hw
)
5019 uint16_t retry_count
= 0;
5020 uint8_t spi_stat_reg
;
5022 DEBUGFUNC("e1000_spi_eeprom_ready");
5024 /* Read "Status Register" repeatedly until the LSB is cleared. The
5025 * EEPROM will signal that the command has been completed by clearing
5026 * bit 0 of the internal status register. If it's not cleared within
5027 * 5 milliseconds, then error out.
5031 e1000_shift_out_ee_bits(hw
, EEPROM_RDSR_OPCODE_SPI
,
5032 hw
->eeprom
.opcode_bits
);
5033 spi_stat_reg
= (uint8_t)e1000_shift_in_ee_bits(hw
, 8);
5034 if (!(spi_stat_reg
& EEPROM_STATUS_RDY_SPI
))
5040 e1000_standby_eeprom(hw
);
5041 } while (retry_count
< EEPROM_MAX_RETRY_SPI
);
5043 /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
5044 * only 0-5mSec on 5V devices)
5046 if (retry_count
>= EEPROM_MAX_RETRY_SPI
) {
5047 DEBUGOUT("SPI EEPROM Status error\n");
5048 return -E1000_ERR_EEPROM
;
5051 return E1000_SUCCESS
;
5054 /******************************************************************************
5055 * Reads a 16 bit word from the EEPROM.
5057 * hw - Struct containing variables accessed by shared code
5058 * offset - offset of word in the EEPROM to read
5059 * data - word read from the EEPROM
5060 * words - number of words to read
5061 *****************************************************************************/
5063 e1000_read_eeprom(struct e1000_hw
*hw
,
5068 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
5071 DEBUGFUNC("e1000_read_eeprom");
5073 /* If eeprom is not yet detected, do so now */
5074 if (eeprom
->word_size
== 0)
5075 e1000_init_eeprom_params(hw
);
5077 /* A check for invalid values: offset too large, too many words, and not
5080 if ((offset
>= eeprom
->word_size
) || (words
> eeprom
->word_size
- offset
) ||
5082 DEBUGOUT2("\"words\" parameter out of bounds. Words = %d, size = %d\n", offset
, eeprom
->word_size
);
5083 return -E1000_ERR_EEPROM
;
5086 /* EEPROM's that don't use EERD to read require us to bit-bang the SPI
5087 * directly. In this case, we need to acquire the EEPROM so that
5088 * FW or other port software does not interrupt.
5090 if (hw
->eeprom
.use_eerd
== FALSE
&& e1000_is_onboard_nvm_eeprom(hw
)) {
5091 /* Prepare the EEPROM for bit-bang reading */
5092 if (e1000_acquire_eeprom(hw
) != E1000_SUCCESS
)
5093 return -E1000_ERR_EEPROM
;
5096 /* Eerd register EEPROM access requires no eeprom aquire/release */
5097 if (eeprom
->use_eerd
== TRUE
)
5098 return e1000_read_eeprom_eerd(hw
, offset
, words
, data
);
5100 /* ICH EEPROM access is done via the ICH flash controller */
5101 if (eeprom
->type
== e1000_eeprom_ich8
)
5102 return e1000_read_eeprom_ich8(hw
, offset
, words
, data
);
5104 /* Set up the SPI or Microwire EEPROM for bit-bang reading. We have
5105 * acquired the EEPROM at this point, so any returns should relase it */
5106 if (eeprom
->type
== e1000_eeprom_spi
) {
5108 uint8_t read_opcode
= EEPROM_READ_OPCODE_SPI
;
5110 if (e1000_spi_eeprom_ready(hw
)) {
5111 e1000_release_eeprom(hw
);
5112 return -E1000_ERR_EEPROM
;
5115 e1000_standby_eeprom(hw
);
5117 /* Some SPI eeproms use the 8th address bit embedded in the opcode */
5118 if ((eeprom
->address_bits
== 8) && (offset
>= 128))
5119 read_opcode
|= EEPROM_A8_OPCODE_SPI
;
5121 /* Send the READ command (opcode + addr) */
5122 e1000_shift_out_ee_bits(hw
, read_opcode
, eeprom
->opcode_bits
);
5123 e1000_shift_out_ee_bits(hw
, (uint16_t)(offset
*2), eeprom
->address_bits
);
5125 /* Read the data. The address of the eeprom internally increments with
5126 * each byte (spi) being read, saving on the overhead of eeprom setup
5127 * and tear-down. The address counter will roll over if reading beyond
5128 * the size of the eeprom, thus allowing the entire memory to be read
5129 * starting from any offset. */
5130 for (i
= 0; i
< words
; i
++) {
5131 word_in
= e1000_shift_in_ee_bits(hw
, 16);
5132 data
[i
] = (word_in
>> 8) | (word_in
<< 8);
5134 } else if (eeprom
->type
== e1000_eeprom_microwire
) {
5135 for (i
= 0; i
< words
; i
++) {
5136 /* Send the READ command (opcode + addr) */
5137 e1000_shift_out_ee_bits(hw
, EEPROM_READ_OPCODE_MICROWIRE
,
5138 eeprom
->opcode_bits
);
5139 e1000_shift_out_ee_bits(hw
, (uint16_t)(offset
+ i
),
5140 eeprom
->address_bits
);
5142 /* Read the data. For microwire, each word requires the overhead
5143 * of eeprom setup and tear-down. */
5144 data
[i
] = e1000_shift_in_ee_bits(hw
, 16);
5145 e1000_standby_eeprom(hw
);
5149 /* End this read operation */
5150 e1000_release_eeprom(hw
);
5152 return E1000_SUCCESS
;
5155 /******************************************************************************
5156 * Reads a 16 bit word from the EEPROM using the EERD register.
5158 * hw - Struct containing variables accessed by shared code
5159 * offset - offset of word in the EEPROM to read
5160 * data - word read from the EEPROM
5161 * words - number of words to read
5162 *****************************************************************************/
5164 e1000_read_eeprom_eerd(struct e1000_hw
*hw
,
5169 uint32_t i
, eerd
= 0;
5172 for (i
= 0; i
< words
; i
++) {
5173 eerd
= ((offset
+i
) << E1000_EEPROM_RW_ADDR_SHIFT
) +
5174 E1000_EEPROM_RW_REG_START
;
5176 E1000_WRITE_REG(hw
, EERD
, eerd
);
5177 error
= e1000_poll_eerd_eewr_done(hw
, E1000_EEPROM_POLL_READ
);
5182 data
[i
] = (E1000_READ_REG(hw
, EERD
) >> E1000_EEPROM_RW_REG_DATA
);
5189 /******************************************************************************
5190 * Writes a 16 bit word from the EEPROM using the EEWR register.
5192 * hw - Struct containing variables accessed by shared code
5193 * offset - offset of word in the EEPROM to read
5194 * data - word read from the EEPROM
5195 * words - number of words to read
5196 *****************************************************************************/
5198 e1000_write_eeprom_eewr(struct e1000_hw
*hw
,
5203 uint32_t register_value
= 0;
5207 if (e1000_swfw_sync_acquire(hw
, E1000_SWFW_EEP_SM
))
5208 return -E1000_ERR_SWFW_SYNC
;
5210 for (i
= 0; i
< words
; i
++) {
5211 register_value
= (data
[i
] << E1000_EEPROM_RW_REG_DATA
) |
5212 ((offset
+i
) << E1000_EEPROM_RW_ADDR_SHIFT
) |
5213 E1000_EEPROM_RW_REG_START
;
5215 error
= e1000_poll_eerd_eewr_done(hw
, E1000_EEPROM_POLL_WRITE
);
5220 E1000_WRITE_REG(hw
, EEWR
, register_value
);
5222 error
= e1000_poll_eerd_eewr_done(hw
, E1000_EEPROM_POLL_WRITE
);
5229 e1000_swfw_sync_release(hw
, E1000_SWFW_EEP_SM
);
5233 /******************************************************************************
5234 * Polls the status bit (bit 1) of the EERD to determine when the read is done.
5236 * hw - Struct containing variables accessed by shared code
5237 *****************************************************************************/
5239 e1000_poll_eerd_eewr_done(struct e1000_hw
*hw
, int eerd
)
5241 uint32_t attempts
= 100000;
5242 uint32_t i
, reg
= 0;
5243 int32_t done
= E1000_ERR_EEPROM
;
5245 for (i
= 0; i
< attempts
; i
++) {
5246 if (eerd
== E1000_EEPROM_POLL_READ
)
5247 reg
= E1000_READ_REG(hw
, EERD
);
5249 reg
= E1000_READ_REG(hw
, EEWR
);
5251 if (reg
& E1000_EEPROM_RW_REG_DONE
) {
5252 done
= E1000_SUCCESS
;
5261 /***************************************************************************
5262 * Description: Determines if the onboard NVM is FLASH or EEPROM.
5264 * hw - Struct containing variables accessed by shared code
5265 ****************************************************************************/
5267 e1000_is_onboard_nvm_eeprom(struct e1000_hw
*hw
)
5271 DEBUGFUNC("e1000_is_onboard_nvm_eeprom");
5273 assert(hw
->mac_type
!= e1000_82576
);
5275 if (hw
->mac_type
== e1000_ich8lan
)
5278 if (hw
->mac_type
== e1000_82573
) {
5279 eecd
= E1000_READ_REG(hw
, EECD
);
5281 /* Isolate bits 15 & 16 */
5282 eecd
= ((eecd
>> 15) & 0x03);
5284 /* If both bits are set, device is Flash type */
5292 /******************************************************************************
5293 * Verifies that the EEPROM has a valid checksum
5295 * hw - Struct containing variables accessed by shared code
5297 * Reads the first 64 16 bit words of the EEPROM and sums the values read.
5298 * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
5300 *****************************************************************************/
5302 e1000_validate_eeprom_checksum(struct e1000_hw
*hw
)
5304 uint16_t checksum
= 0;
5305 uint16_t i
, eeprom_data
;
5307 DEBUGFUNC("e1000_validate_eeprom_checksum");
5309 if ((hw
->mac_type
== e1000_82573
) &&
5310 (e1000_is_onboard_nvm_eeprom(hw
) == FALSE
)) {
5311 /* Check bit 4 of word 10h. If it is 0, firmware is done updating
5312 * 10h-12h. Checksum may need to be fixed. */
5313 e1000_read_eeprom(hw
, 0x10, 1, &eeprom_data
);
5314 if ((eeprom_data
& 0x10) == 0) {
5315 /* Read 0x23 and check bit 15. This bit is a 1 when the checksum
5316 * has already been fixed. If the checksum is still wrong and this
5317 * bit is a 1, we need to return bad checksum. Otherwise, we need
5318 * to set this bit to a 1 and update the checksum. */
5319 e1000_read_eeprom(hw
, 0x23, 1, &eeprom_data
);
5320 if ((eeprom_data
& 0x8000) == 0) {
5321 eeprom_data
|= 0x8000;
5322 e1000_write_eeprom(hw
, 0x23, 1, &eeprom_data
);
5323 e1000_update_eeprom_checksum(hw
);
5328 if (hw
->mac_type
== e1000_ich8lan
) {
5329 /* Drivers must allocate the shadow ram structure for the
5330 * EEPROM checksum to be updated. Otherwise, this bit as well
5331 * as the checksum must both be set correctly for this
5332 * validation to pass.
5334 e1000_read_eeprom(hw
, 0x19, 1, &eeprom_data
);
5335 if ((eeprom_data
& 0x40) == 0) {
5336 eeprom_data
|= 0x40;
5337 e1000_write_eeprom(hw
, 0x19, 1, &eeprom_data
);
5338 e1000_update_eeprom_checksum(hw
);
5342 for (i
= 0; i
< (EEPROM_CHECKSUM_REG
+ 1); i
++) {
5343 if (e1000_read_eeprom(hw
, i
, 1, &eeprom_data
) < 0) {
5344 DEBUGOUT("EEPROM Read Error\n");
5345 return -E1000_ERR_EEPROM
;
5347 checksum
+= eeprom_data
;
5350 if (checksum
== (uint16_t) EEPROM_SUM
)
5351 return E1000_SUCCESS
;
5353 DEBUGOUT("EEPROM Checksum Invalid\n");
5354 return -E1000_ERR_EEPROM
;
5358 /******************************************************************************
5359 * Calculates the EEPROM checksum and writes it to the EEPROM
5361 * hw - Struct containing variables accessed by shared code
5363 * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
5364 * Writes the difference to word offset 63 of the EEPROM.
5365 *****************************************************************************/
5367 e1000_update_eeprom_checksum(struct e1000_hw
*hw
)
5370 uint16_t checksum
= 0;
5371 uint16_t i
, eeprom_data
;
5373 DEBUGFUNC("e1000_update_eeprom_checksum");
5375 for (i
= 0; i
< EEPROM_CHECKSUM_REG
; i
++) {
5376 if (e1000_read_eeprom(hw
, i
, 1, &eeprom_data
) < 0) {
5377 DEBUGOUT("EEPROM Read Error\n");
5378 return -E1000_ERR_EEPROM
;
5380 checksum
+= eeprom_data
;
5382 checksum
= (uint16_t) EEPROM_SUM
- checksum
;
5383 if (e1000_write_eeprom(hw
, EEPROM_CHECKSUM_REG
, 1, &checksum
) < 0) {
5384 DEBUGOUT("EEPROM Write Error\n");
5385 return -E1000_ERR_EEPROM
;
5386 } else if (hw
->eeprom
.type
== e1000_eeprom_flash
) {
5387 e1000_commit_shadow_ram(hw
);
5388 } else if (hw
->eeprom
.type
== e1000_eeprom_ich8
) {
5389 e1000_commit_shadow_ram(hw
);
5390 /* Reload the EEPROM, or else modifications will not appear
5391 * until after next adapter reset. */
5392 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
5393 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
5394 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
5397 return E1000_SUCCESS
;
5400 /******************************************************************************
5401 * Parent function for writing words to the different EEPROM types.
5403 * hw - Struct containing variables accessed by shared code
5404 * offset - offset within the EEPROM to be written to
5405 * words - number of words to write
5406 * data - 16 bit word to be written to the EEPROM
5408 * If e1000_update_eeprom_checksum is not called after this function, the
5409 * EEPROM will most likely contain an invalid checksum.
5410 *****************************************************************************/
5412 e1000_write_eeprom(struct e1000_hw
*hw
,
5417 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
5420 DEBUGFUNC("e1000_write_eeprom");
5422 /* If eeprom is not yet detected, do so now */
5423 if (eeprom
->word_size
== 0)
5424 e1000_init_eeprom_params(hw
);
5426 /* A check for invalid values: offset too large, too many words, and not
5429 if ((offset
>= eeprom
->word_size
) || (words
> eeprom
->word_size
- offset
) ||
5431 DEBUGOUT("\"words\" parameter out of bounds\n");
5432 return -E1000_ERR_EEPROM
;
5435 /* 82573 writes only through eewr */
5436 if (eeprom
->use_eewr
== TRUE
)
5437 return e1000_write_eeprom_eewr(hw
, offset
, words
, data
);
5439 if (eeprom
->type
== e1000_eeprom_ich8
)
5440 return e1000_write_eeprom_ich8(hw
, offset
, words
, data
);
5442 /* Prepare the EEPROM for writing */
5443 if (e1000_acquire_eeprom(hw
) != E1000_SUCCESS
)
5444 return -E1000_ERR_EEPROM
;
5446 if (eeprom
->type
== e1000_eeprom_microwire
) {
5447 status
= e1000_write_eeprom_microwire(hw
, offset
, words
, data
);
5449 status
= e1000_write_eeprom_spi(hw
, offset
, words
, data
);
5453 /* Done with writing */
5454 e1000_release_eeprom(hw
);
5459 /******************************************************************************
5460 * Writes a 16 bit word to a given offset in an SPI EEPROM.
5462 * hw - Struct containing variables accessed by shared code
5463 * offset - offset within the EEPROM to be written to
5464 * words - number of words to write
5465 * data - pointer to array of 8 bit words to be written to the EEPROM
5467 *****************************************************************************/
5469 e1000_write_eeprom_spi(struct e1000_hw
*hw
,
5474 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
5477 DEBUGFUNC("e1000_write_eeprom_spi");
5479 while (widx
< words
) {
5480 uint8_t write_opcode
= EEPROM_WRITE_OPCODE_SPI
;
5482 if (e1000_spi_eeprom_ready(hw
)) return -E1000_ERR_EEPROM
;
5484 e1000_standby_eeprom(hw
);
5486 /* Send the WRITE ENABLE command (8 bit opcode ) */
5487 e1000_shift_out_ee_bits(hw
, EEPROM_WREN_OPCODE_SPI
,
5488 eeprom
->opcode_bits
);
5490 e1000_standby_eeprom(hw
);
5492 /* Some SPI eeproms use the 8th address bit embedded in the opcode */
5493 if ((eeprom
->address_bits
== 8) && (offset
>= 128))
5494 write_opcode
|= EEPROM_A8_OPCODE_SPI
;
5496 /* Send the Write command (8-bit opcode + addr) */
5497 e1000_shift_out_ee_bits(hw
, write_opcode
, eeprom
->opcode_bits
);
5499 e1000_shift_out_ee_bits(hw
, (uint16_t)((offset
+ widx
)*2),
5500 eeprom
->address_bits
);
5504 /* Loop to allow for up to whole page write (32 bytes) of eeprom */
5505 while (widx
< words
) {
5506 uint16_t word_out
= data
[widx
];
5507 word_out
= (word_out
>> 8) | (word_out
<< 8);
5508 e1000_shift_out_ee_bits(hw
, word_out
, 16);
5511 /* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE
5512 * operation, while the smaller eeproms are capable of an 8-byte
5513 * PAGE WRITE operation. Break the inner loop to pass new address
5515 if ((((offset
+ widx
)*2) % eeprom
->page_size
) == 0) {
5516 e1000_standby_eeprom(hw
);
5522 return E1000_SUCCESS
;
5525 /******************************************************************************
5526 * Writes a 16 bit word to a given offset in a Microwire EEPROM.
5528 * hw - Struct containing variables accessed by shared code
5529 * offset - offset within the EEPROM to be written to
5530 * words - number of words to write
5531 * data - pointer to array of 16 bit words to be written to the EEPROM
5533 *****************************************************************************/
5535 e1000_write_eeprom_microwire(struct e1000_hw
*hw
,
5540 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
5542 uint16_t words_written
= 0;
5545 DEBUGFUNC("e1000_write_eeprom_microwire");
5547 /* Send the write enable command to the EEPROM (3-bit opcode plus
5548 * 6/8-bit dummy address beginning with 11). It's less work to include
5549 * the 11 of the dummy address as part of the opcode than it is to shift
5550 * it over the correct number of bits for the address. This puts the
5551 * EEPROM into write/erase mode.
5553 e1000_shift_out_ee_bits(hw
, EEPROM_EWEN_OPCODE_MICROWIRE
,
5554 (uint16_t)(eeprom
->opcode_bits
+ 2));
5556 e1000_shift_out_ee_bits(hw
, 0, (uint16_t)(eeprom
->address_bits
- 2));
5558 /* Prepare the EEPROM */
5559 e1000_standby_eeprom(hw
);
5561 while (words_written
< words
) {
5562 /* Send the Write command (3-bit opcode + addr) */
5563 e1000_shift_out_ee_bits(hw
, EEPROM_WRITE_OPCODE_MICROWIRE
,
5564 eeprom
->opcode_bits
);
5566 e1000_shift_out_ee_bits(hw
, (uint16_t)(offset
+ words_written
),
5567 eeprom
->address_bits
);
5570 e1000_shift_out_ee_bits(hw
, data
[words_written
], 16);
5572 /* Toggle the CS line. This in effect tells the EEPROM to execute
5573 * the previous command.
5575 e1000_standby_eeprom(hw
);
5577 /* Read DO repeatedly until it is high (equal to '1'). The EEPROM will
5578 * signal that the command has been completed by raising the DO signal.
5579 * If DO does not go high in 10 milliseconds, then error out.
5581 for (i
= 0; i
< 200; i
++) {
5582 eecd
= E1000_READ_REG(hw
, EECD
);
5583 if (eecd
& E1000_EECD_DO
) break;
5587 DEBUGOUT("EEPROM Write did not complete\n");
5588 return -E1000_ERR_EEPROM
;
5591 /* Recover from write */
5592 e1000_standby_eeprom(hw
);
5597 /* Send the write disable command to the EEPROM (3-bit opcode plus
5598 * 6/8-bit dummy address beginning with 10). It's less work to include
5599 * the 10 of the dummy address as part of the opcode than it is to shift
5600 * it over the correct number of bits for the address. This takes the
5601 * EEPROM out of write/erase mode.
5603 e1000_shift_out_ee_bits(hw
, EEPROM_EWDS_OPCODE_MICROWIRE
,
5604 (uint16_t)(eeprom
->opcode_bits
+ 2));
5606 e1000_shift_out_ee_bits(hw
, 0, (uint16_t)(eeprom
->address_bits
- 2));
5608 return E1000_SUCCESS
;
5611 /******************************************************************************
5612 * Flushes the cached eeprom to NVM. This is done by saving the modified values
5613 * in the eeprom cache and the non modified values in the currently active bank
5616 * hw - Struct containing variables accessed by shared code
5617 * offset - offset of word in the EEPROM to read
5618 * data - word read from the EEPROM
5619 * words - number of words to read
5620 *****************************************************************************/
5622 e1000_commit_shadow_ram(struct e1000_hw
*hw
)
5624 uint32_t attempts
= 100000;
5628 int32_t error
= E1000_SUCCESS
;
5629 uint32_t old_bank_offset
= 0;
5630 uint32_t new_bank_offset
= 0;
5631 uint8_t low_byte
= 0;
5632 uint8_t high_byte
= 0;
5633 boolean_t sector_write_failed
= FALSE
;
5635 if (hw
->mac_type
== e1000_82573
) {
5636 /* The flop register will be used to determine if flash type is STM */
5637 flop
= E1000_READ_REG(hw
, FLOP
);
5638 for (i
=0; i
< attempts
; i
++) {
5639 eecd
= E1000_READ_REG(hw
, EECD
);
5640 if ((eecd
& E1000_EECD_FLUPD
) == 0) {
5646 if (i
== attempts
) {
5647 return -E1000_ERR_EEPROM
;
5650 /* If STM opcode located in bits 15:8 of flop, reset firmware */
5651 if ((flop
& 0xFF00) == E1000_STM_OPCODE
) {
5652 E1000_WRITE_REG(hw
, HICR
, E1000_HICR_FW_RESET
);
5655 /* Perform the flash update */
5656 E1000_WRITE_REG(hw
, EECD
, eecd
| E1000_EECD_FLUPD
);
5658 for (i
=0; i
< attempts
; i
++) {
5659 eecd
= E1000_READ_REG(hw
, EECD
);
5660 if ((eecd
& E1000_EECD_FLUPD
) == 0) {
5666 if (i
== attempts
) {
5667 return -E1000_ERR_EEPROM
;
5671 if (hw
->mac_type
== e1000_ich8lan
&& hw
->eeprom_shadow_ram
!= NULL
) {
5672 /* We're writing to the opposite bank so if we're on bank 1,
5673 * write to bank 0 etc. We also need to erase the segment that
5674 * is going to be written */
5675 if (!(E1000_READ_REG(hw
, EECD
) & E1000_EECD_SEC1VAL
)) {
5676 new_bank_offset
= hw
->flash_bank_size
* 2;
5677 old_bank_offset
= 0;
5678 e1000_erase_ich8_4k_segment(hw
, 1);
5680 old_bank_offset
= hw
->flash_bank_size
* 2;
5681 new_bank_offset
= 0;
5682 e1000_erase_ich8_4k_segment(hw
, 0);
5685 sector_write_failed
= FALSE
;
5686 /* Loop for every byte in the shadow RAM,
5687 * which is in units of words. */
5688 for (i
= 0; i
< E1000_SHADOW_RAM_WORDS
; i
++) {
5689 /* Determine whether to write the value stored
5690 * in the other NVM bank or a modified value stored
5691 * in the shadow RAM */
5692 if (hw
->eeprom_shadow_ram
[i
].modified
== TRUE
) {
5693 low_byte
= (uint8_t)hw
->eeprom_shadow_ram
[i
].eeprom_word
;
5695 error
= e1000_verify_write_ich8_byte(hw
,
5696 (i
<< 1) + new_bank_offset
, low_byte
);
5698 if (error
!= E1000_SUCCESS
)
5699 sector_write_failed
= TRUE
;
5702 (uint8_t)(hw
->eeprom_shadow_ram
[i
].eeprom_word
>> 8);
5706 e1000_read_ich8_byte(hw
, (i
<< 1) + old_bank_offset
,
5709 error
= e1000_verify_write_ich8_byte(hw
,
5710 (i
<< 1) + new_bank_offset
, low_byte
);
5712 if (error
!= E1000_SUCCESS
)
5713 sector_write_failed
= TRUE
;
5715 e1000_read_ich8_byte(hw
, (i
<< 1) + old_bank_offset
+ 1,
5721 /* If the write of the low byte was successful, go ahread and
5722 * write the high byte while checking to make sure that if it
5723 * is the signature byte, then it is handled properly */
5724 if (sector_write_failed
== FALSE
) {
5725 /* If the word is 0x13, then make sure the signature bits
5726 * (15:14) are 11b until the commit has completed.
5727 * This will allow us to write 10b which indicates the
5728 * signature is valid. We want to do this after the write
5729 * has completed so that we don't mark the segment valid
5730 * while the write is still in progress */
5731 if (i
== E1000_ICH_NVM_SIG_WORD
)
5732 high_byte
= E1000_ICH_NVM_SIG_MASK
| high_byte
;
5734 error
= e1000_verify_write_ich8_byte(hw
,
5735 (i
<< 1) + new_bank_offset
+ 1, high_byte
);
5736 if (error
!= E1000_SUCCESS
)
5737 sector_write_failed
= TRUE
;
5740 /* If the write failed then break from the loop and
5741 * return an error */
5746 /* Don't bother writing the segment valid bits if sector
5747 * programming failed. */
5748 if (sector_write_failed
== FALSE
) {
5749 /* Finally validate the new segment by setting bit 15:14
5750 * to 10b in word 0x13 , this can be done without an
5751 * erase as well since these bits are 11 to start with
5752 * and we need to change bit 14 to 0b */
5753 e1000_read_ich8_byte(hw
,
5754 E1000_ICH_NVM_SIG_WORD
* 2 + 1 + new_bank_offset
,
5757 error
= e1000_verify_write_ich8_byte(hw
,
5758 E1000_ICH_NVM_SIG_WORD
* 2 + 1 + new_bank_offset
, high_byte
);
5759 /* And invalidate the previously valid segment by setting
5760 * its signature word (0x13) high_byte to 0b. This can be
5761 * done without an erase because flash erase sets all bits
5762 * to 1's. We can write 1's to 0's without an erase */
5763 if (error
== E1000_SUCCESS
) {
5764 error
= e1000_verify_write_ich8_byte(hw
,
5765 E1000_ICH_NVM_SIG_WORD
* 2 + 1 + old_bank_offset
, 0);
5768 /* Clear the now not used entry in the cache */
5769 for (i
= 0; i
< E1000_SHADOW_RAM_WORDS
; i
++) {
5770 hw
->eeprom_shadow_ram
[i
].modified
= FALSE
;
5771 hw
->eeprom_shadow_ram
[i
].eeprom_word
= 0xFFFF;
5779 /******************************************************************************
5780 * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
5781 * second function of dual function devices
5783 * hw - Struct containing variables accessed by shared code
5784 *****************************************************************************/
5786 e1000_read_mac_addr(struct e1000_hw
* hw
)
5788 uint16_t offset
, mac_addr_offset
= 0;
5789 uint16_t eeprom_data
, i
;
5792 DEBUGFUNC("e1000_read_mac_addr");
5794 if (hw
->mac_type
== e1000_82571
) {
5795 /* Check for an alternate MAC address. An alternate MAC
5796 * address can be setup by pre-boot software and must be
5797 * treated like a permanent address and must override the
5798 * actual permanent MAC address.*/
5799 ret_val
= e1000_read_eeprom(hw
, EEPROM_ALT_MAC_ADDR_PTR
, 1,
5802 DEBUGOUT("EEPROM Read Error\n");
5803 return -E1000_ERR_EEPROM
;
5805 if (mac_addr_offset
== 0xFFFF)
5806 mac_addr_offset
= 0;
5808 if (mac_addr_offset
) {
5809 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)
5810 mac_addr_offset
+= NODE_ADDRESS_SIZE
/sizeof(u16
);
5812 /* make sure we have a valid mac address here
5813 * before using it */
5814 ret_val
= e1000_read_eeprom(hw
, mac_addr_offset
, 1,
5817 DEBUGOUT("EEPROM Read Error\n");
5818 return -E1000_ERR_EEPROM
;
5820 if (eeprom_data
& 0x0001)
5821 mac_addr_offset
= 0;
5824 if (mac_addr_offset
)
5825 hw
->laa_is_present
= TRUE
;
5828 for (i
= 0; i
< NODE_ADDRESS_SIZE
; i
+= 2) {
5829 offset
= mac_addr_offset
+ (i
>> 1);
5830 if (e1000_read_eeprom(hw
, offset
, 1, &eeprom_data
) < 0) {
5831 DEBUGOUT("EEPROM Read Error\n");
5832 return -E1000_ERR_EEPROM
;
5834 hw
->perm_mac_addr
[i
] = (uint8_t) (eeprom_data
& 0x00FF);
5835 hw
->perm_mac_addr
[i
+1] = (uint8_t) (eeprom_data
>> 8);
5838 switch (hw
->mac_type
) {
5842 case e1000_82546_rev_3
:
5845 case e1000_80003es2lan
:
5846 if (!mac_addr_offset
&&
5847 E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)
5848 hw
->perm_mac_addr
[5] ^= 0x01;
5852 for (i
= 0; i
< NODE_ADDRESS_SIZE
; i
++)
5853 hw
->mac_addr
[i
] = hw
->perm_mac_addr
[i
];
5854 return E1000_SUCCESS
;
5857 /******************************************************************************
5858 * Initializes receive address filters.
5860 * hw - Struct containing variables accessed by shared code
5862 * Places the MAC address in receive address register 0 and clears the rest
5863 * of the receive addresss registers. Clears the multicast table. Assumes
5864 * the receiver is in reset when the routine is called.
5865 *****************************************************************************/
5867 e1000_init_rx_addrs(struct e1000_hw
*hw
)
5872 DEBUGFUNC("e1000_init_rx_addrs");
5874 /* Setup the receive address. */
5875 DEBUGOUT("Programming MAC Address into RAR[0]\n");
5877 e1000_rar_set(hw
, hw
->mac_addr
, 0);
5879 rar_num
= E1000_RAR_ENTRIES
;
5881 /* Reserve a spot for the Locally Administered Address to work around
5882 * an 82571 issue in which a reset on one port will reload the MAC on
5883 * the other port. */
5884 if ((hw
->mac_type
== e1000_82571
) && (hw
->laa_is_present
== TRUE
))
5886 if (hw
->mac_type
== e1000_ich8lan
)
5887 rar_num
= E1000_RAR_ENTRIES_ICH8LAN
;
5889 /* Zero out the other 15 receive addresses. */
5890 DEBUGOUT("Clearing RAR[1-15]\n");
5891 for (i
= 1; i
< rar_num
; i
++) {
5892 E1000_WRITE_REG_ARRAY(hw
, RA
, (i
<< 1), 0);
5893 E1000_WRITE_FLUSH(hw
);
5894 E1000_WRITE_REG_ARRAY(hw
, RA
, ((i
<< 1) + 1), 0);
5895 E1000_WRITE_FLUSH(hw
);
5899 /******************************************************************************
5900 * Hashes an address to determine its location in the multicast table
5902 * hw - Struct containing variables accessed by shared code
5903 * mc_addr - the multicast address to hash
5904 *****************************************************************************/
5906 e1000_hash_mc_addr(struct e1000_hw
*hw
,
5909 uint32_t hash_value
= 0;
5911 /* The portion of the address that is used for the hash table is
5912 * determined by the mc_filter_type setting.
5914 switch (hw
->mc_filter_type
) {
5915 /* [0] [1] [2] [3] [4] [5]
5920 if (hw
->mac_type
== e1000_ich8lan
) {
5921 /* [47:38] i.e. 0x158 for above example address */
5922 hash_value
= ((mc_addr
[4] >> 6) | (((uint16_t) mc_addr
[5]) << 2));
5924 /* [47:36] i.e. 0x563 for above example address */
5925 hash_value
= ((mc_addr
[4] >> 4) | (((uint16_t) mc_addr
[5]) << 4));
5929 if (hw
->mac_type
== e1000_ich8lan
) {
5930 /* [46:37] i.e. 0x2B1 for above example address */
5931 hash_value
= ((mc_addr
[4] >> 5) | (((uint16_t) mc_addr
[5]) << 3));
5933 /* [46:35] i.e. 0xAC6 for above example address */
5934 hash_value
= ((mc_addr
[4] >> 3) | (((uint16_t) mc_addr
[5]) << 5));
5938 if (hw
->mac_type
== e1000_ich8lan
) {
5939 /*[45:36] i.e. 0x163 for above example address */
5940 hash_value
= ((mc_addr
[4] >> 4) | (((uint16_t) mc_addr
[5]) << 4));
5942 /* [45:34] i.e. 0x5D8 for above example address */
5943 hash_value
= ((mc_addr
[4] >> 2) | (((uint16_t) mc_addr
[5]) << 6));
5947 if (hw
->mac_type
== e1000_ich8lan
) {
5948 /* [43:34] i.e. 0x18D for above example address */
5949 hash_value
= ((mc_addr
[4] >> 2) | (((uint16_t) mc_addr
[5]) << 6));
5951 /* [43:32] i.e. 0x634 for above example address */
5952 hash_value
= ((mc_addr
[4]) | (((uint16_t) mc_addr
[5]) << 8));
5957 hash_value
&= 0xFFF;
5958 if (hw
->mac_type
== e1000_ich8lan
)
5959 hash_value
&= 0x3FF;
5964 /******************************************************************************
5965 * Sets the bit in the multicast table corresponding to the hash value.
5967 * hw - Struct containing variables accessed by shared code
5968 * hash_value - Multicast address hash value
5969 *****************************************************************************/
5971 e1000_mta_set(struct e1000_hw
*hw
,
5972 uint32_t hash_value
)
5974 uint32_t hash_bit
, hash_reg
;
5978 /* The MTA is a register array of 128 32-bit registers.
5979 * It is treated like an array of 4096 bits. We want to set
5980 * bit BitArray[hash_value]. So we figure out what register
5981 * the bit is in, read it, OR in the new bit, then write
5982 * back the new value. The register is determined by the
5983 * upper 7 bits of the hash value and the bit within that
5984 * register are determined by the lower 5 bits of the value.
5986 hash_reg
= (hash_value
>> 5) & 0x7F;
5987 if (hw
->mac_type
== e1000_ich8lan
)
5990 hash_bit
= hash_value
& 0x1F;
5992 mta
= E1000_READ_REG_ARRAY(hw
, MTA
, hash_reg
);
5994 mta
|= (1 << hash_bit
);
5996 /* If we are on an 82544 and we are trying to write an odd offset
5997 * in the MTA, save off the previous entry before writing and
5998 * restore the old value after writing.
6000 if ((hw
->mac_type
== e1000_82544
) && ((hash_reg
& 0x1) == 1)) {
6001 temp
= E1000_READ_REG_ARRAY(hw
, MTA
, (hash_reg
- 1));
6002 E1000_WRITE_REG_ARRAY(hw
, MTA
, hash_reg
, mta
);
6003 E1000_WRITE_FLUSH(hw
);
6004 E1000_WRITE_REG_ARRAY(hw
, MTA
, (hash_reg
- 1), temp
);
6005 E1000_WRITE_FLUSH(hw
);
6007 E1000_WRITE_REG_ARRAY(hw
, MTA
, hash_reg
, mta
);
6008 E1000_WRITE_FLUSH(hw
);
6012 /******************************************************************************
6013 * Puts an ethernet address into a receive address register.
6015 * hw - Struct containing variables accessed by shared code
6016 * addr - Address to put into receive address register
6017 * index - Receive address register to write
6018 *****************************************************************************/
6020 e1000_rar_set(struct e1000_hw
*hw
,
6024 uint32_t rar_low
, rar_high
;
6026 /* HW expects these in little endian so we reverse the byte order
6027 * from network order (big endian) to little endian
6029 rar_low
= ((uint32_t) addr
[0] |
6030 ((uint32_t) addr
[1] << 8) |
6031 ((uint32_t) addr
[2] << 16) | ((uint32_t) addr
[3] << 24));
6032 rar_high
= ((uint32_t) addr
[4] | ((uint32_t) addr
[5] << 8));
6034 /* Disable Rx and flush all Rx frames before enabling RSS to avoid Rx
6038 * If there are any Rx frames queued up or otherwise present in the HW
6039 * before RSS is enabled, and then we enable RSS, the HW Rx unit will
6040 * hang. To work around this issue, we have to disable receives and
6041 * flush out all Rx frames before we enable RSS. To do so, we modify we
6042 * redirect all Rx traffic to manageability and then reset the HW.
6043 * This flushes away Rx frames, and (since the redirections to
6044 * manageability persists across resets) keeps new ones from coming in
6045 * while we work. Then, we clear the Address Valid AV bit for all MAC
6046 * addresses and undo the re-direction to manageability.
6047 * Now, frames are coming in again, but the MAC won't accept them, so
6048 * far so good. We now proceed to initialize RSS (if necessary) and
6049 * configure the Rx unit. Last, we re-enable the AV bits and continue
6052 switch (hw
->mac_type
) {
6055 case e1000_80003es2lan
:
6056 if (hw
->leave_av_bit_off
== TRUE
)
6059 /* If MAC address zero, no need to set the AV bit */
6060 if (rar_low
|| rar_high
)
6061 rar_high
|= E1000_RAH_AV
;
6062 // Only neded when Multiple Receive Queues are enabmed in MRQC
6063 rar_high
|= E1000_RAH_POOL_1
;
6066 /* Indicate to hardware the Address is Valid. */
6067 rar_high
|= E1000_RAH_AV
;
6071 E1000_WRITE_REG_ARRAY(hw
, RA
, (index
<< 1), rar_low
);
6072 E1000_WRITE_FLUSH(hw
);
6073 E1000_WRITE_REG_ARRAY(hw
, RA
, ((index
<< 1) + 1), rar_high
);
6074 E1000_WRITE_FLUSH(hw
);
6077 /******************************************************************************
6078 * Writes a value to the specified offset in the VLAN filter table.
6080 * hw - Struct containing variables accessed by shared code
6081 * offset - Offset in VLAN filer table to write
6082 * value - Value to write into VLAN filter table
6083 *****************************************************************************/
6085 e1000_write_vfta(struct e1000_hw
*hw
,
6091 if (hw
->mac_type
== e1000_ich8lan
)
6094 if ((hw
->mac_type
== e1000_82544
) && ((offset
& 0x1) == 1)) {
6095 temp
= E1000_READ_REG_ARRAY(hw
, VFTA
, (offset
- 1));
6096 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, value
);
6097 E1000_WRITE_FLUSH(hw
);
6098 E1000_WRITE_REG_ARRAY(hw
, VFTA
, (offset
- 1), temp
);
6099 E1000_WRITE_FLUSH(hw
);
6101 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, value
);
6102 E1000_WRITE_FLUSH(hw
);
6106 /******************************************************************************
6107 * Clears the VLAN filer table
6109 * hw - Struct containing variables accessed by shared code
6110 *****************************************************************************/
6112 e1000_clear_vfta(struct e1000_hw
*hw
)
6115 uint32_t vfta_value
= 0;
6116 uint32_t vfta_offset
= 0;
6117 uint32_t vfta_bit_in_reg
= 0;
6119 if (hw
->mac_type
== e1000_ich8lan
)
6122 if (hw
->mac_type
== e1000_82573
) {
6123 if (hw
->mng_cookie
.vlan_id
!= 0) {
6124 /* The VFTA is a 4096b bit-field, each identifying a single VLAN
6125 * ID. The following operations determine which 32b entry
6126 * (i.e. offset) into the array we want to set the VLAN ID
6127 * (i.e. bit) of the manageability unit. */
6128 vfta_offset
= (hw
->mng_cookie
.vlan_id
>>
6129 E1000_VFTA_ENTRY_SHIFT
) &
6130 E1000_VFTA_ENTRY_MASK
;
6131 vfta_bit_in_reg
= 1 << (hw
->mng_cookie
.vlan_id
&
6132 E1000_VFTA_ENTRY_BIT_SHIFT_MASK
);
6135 for (offset
= 0; offset
< E1000_VLAN_FILTER_TBL_SIZE
; offset
++) {
6136 /* If the offset we want to clear is the same offset of the
6137 * manageability VLAN ID, then clear all bits except that of the
6138 * manageability unit */
6139 vfta_value
= (offset
== vfta_offset
) ? vfta_bit_in_reg
: 0;
6140 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, vfta_value
);
6141 E1000_WRITE_FLUSH(hw
);
6146 e1000_id_led_init(struct e1000_hw
* hw
)
6149 const uint32_t ledctl_mask
= 0x000000FF;
6150 const uint32_t ledctl_on
= E1000_LEDCTL_MODE_LED_ON
;
6151 const uint32_t ledctl_off
= E1000_LEDCTL_MODE_LED_OFF
;
6152 uint16_t eeprom_data
, i
, temp
;
6153 const uint16_t led_mask
= 0x0F;
6155 DEBUGFUNC("e1000_id_led_init");
6157 if (hw
->mac_type
< e1000_82540
) {
6159 return E1000_SUCCESS
;
6162 ledctl
= E1000_READ_REG(hw
, LEDCTL
);
6163 hw
->ledctl_default
= ledctl
;
6164 hw
->ledctl_mode1
= hw
->ledctl_default
;
6165 hw
->ledctl_mode2
= hw
->ledctl_default
;
6167 if (e1000_read_eeprom(hw
, EEPROM_ID_LED_SETTINGS
, 1, &eeprom_data
) < 0) {
6168 DEBUGOUT("EEPROM Read Error\n");
6169 return -E1000_ERR_EEPROM
;
6172 if ((hw
->mac_type
== e1000_82573
) &&
6173 (eeprom_data
== ID_LED_RESERVED_82573
))
6174 eeprom_data
= ID_LED_DEFAULT_82573
;
6175 else if ((eeprom_data
== ID_LED_RESERVED_0000
) ||
6176 (eeprom_data
== ID_LED_RESERVED_FFFF
)) {
6177 if (hw
->mac_type
== e1000_ich8lan
)
6178 eeprom_data
= ID_LED_DEFAULT_ICH8LAN
;
6180 eeprom_data
= ID_LED_DEFAULT
;
6183 for (i
= 0; i
< 4; i
++) {
6184 temp
= (eeprom_data
>> (i
<< 2)) & led_mask
;
6186 case ID_LED_ON1_DEF2
:
6187 case ID_LED_ON1_ON2
:
6188 case ID_LED_ON1_OFF2
:
6189 hw
->ledctl_mode1
&= ~(ledctl_mask
<< (i
<< 3));
6190 hw
->ledctl_mode1
|= ledctl_on
<< (i
<< 3);
6192 case ID_LED_OFF1_DEF2
:
6193 case ID_LED_OFF1_ON2
:
6194 case ID_LED_OFF1_OFF2
:
6195 hw
->ledctl_mode1
&= ~(ledctl_mask
<< (i
<< 3));
6196 hw
->ledctl_mode1
|= ledctl_off
<< (i
<< 3);
6203 case ID_LED_DEF1_ON2
:
6204 case ID_LED_ON1_ON2
:
6205 case ID_LED_OFF1_ON2
:
6206 hw
->ledctl_mode2
&= ~(ledctl_mask
<< (i
<< 3));
6207 hw
->ledctl_mode2
|= ledctl_on
<< (i
<< 3);
6209 case ID_LED_DEF1_OFF2
:
6210 case ID_LED_ON1_OFF2
:
6211 case ID_LED_OFF1_OFF2
:
6212 hw
->ledctl_mode2
&= ~(ledctl_mask
<< (i
<< 3));
6213 hw
->ledctl_mode2
|= ledctl_off
<< (i
<< 3);
6220 return E1000_SUCCESS
;
6223 /******************************************************************************
6224 * Prepares SW controlable LED for use and saves the current state of the LED.
6226 * hw - Struct containing variables accessed by shared code
6227 *****************************************************************************/
6229 e1000_setup_led(struct e1000_hw
*hw
)
6232 int32_t ret_val
= E1000_SUCCESS
;
6234 DEBUGFUNC("e1000_setup_led");
6236 switch (hw
->mac_type
) {
6237 case e1000_82542_rev2_0
:
6238 case e1000_82542_rev2_1
:
6241 /* No setup necessary */
6245 case e1000_82541_rev_2
:
6246 case e1000_82547_rev_2
:
6247 /* Turn off PHY Smart Power Down (if enabled) */
6248 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
6249 &hw
->phy_spd_default
);
6252 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
6253 (uint16_t)(hw
->phy_spd_default
&
6254 ~IGP01E1000_GMII_SPD
));
6259 if (hw
->media_type
== e1000_media_type_fiber
) {
6260 ledctl
= E1000_READ_REG(hw
, LEDCTL
);
6261 /* Save current LEDCTL settings */
6262 hw
->ledctl_default
= ledctl
;
6264 ledctl
&= ~(E1000_LEDCTL_LED0_IVRT
|
6265 E1000_LEDCTL_LED0_BLINK
|
6266 E1000_LEDCTL_LED0_MODE_MASK
);
6267 ledctl
|= (E1000_LEDCTL_MODE_LED_OFF
<<
6268 E1000_LEDCTL_LED0_MODE_SHIFT
);
6269 E1000_WRITE_REG(hw
, LEDCTL
, ledctl
);
6270 } else if (hw
->media_type
== e1000_media_type_copper
)
6271 E1000_WRITE_REG(hw
, LEDCTL
, hw
->ledctl_mode1
);
6275 return E1000_SUCCESS
;
6279 /******************************************************************************
6280 * Used on 82571 and later Si that has LED blink bits.
6281 * Callers must use their own timer and should have already called
6282 * e1000_id_led_init()
6283 * Call e1000_cleanup led() to stop blinking
6285 * hw - Struct containing variables accessed by shared code
6286 *****************************************************************************/
6288 e1000_blink_led_start(struct e1000_hw
*hw
)
6291 uint32_t ledctl_blink
= 0;
6293 DEBUGFUNC("e1000_id_led_blink_on");
6295 if (hw
->mac_type
< e1000_82571
) {
6297 return E1000_SUCCESS
;
6299 if (hw
->media_type
== e1000_media_type_fiber
) {
6300 /* always blink LED0 for PCI-E fiber */
6301 ledctl_blink
= E1000_LEDCTL_LED0_BLINK
|
6302 (E1000_LEDCTL_MODE_LED_ON
<< E1000_LEDCTL_LED0_MODE_SHIFT
);
6304 /* set the blink bit for each LED that's "on" (0x0E) in ledctl_mode2 */
6305 ledctl_blink
= hw
->ledctl_mode2
;
6306 for (i
=0; i
< 4; i
++)
6307 if (((hw
->ledctl_mode2
>> (i
* 8)) & 0xFF) ==
6308 E1000_LEDCTL_MODE_LED_ON
)
6309 ledctl_blink
|= (E1000_LEDCTL_LED0_BLINK
<< (i
* 8));
6312 E1000_WRITE_REG(hw
, LEDCTL
, ledctl_blink
);
6314 return E1000_SUCCESS
;
6317 /******************************************************************************
6318 * Restores the saved state of the SW controlable LED.
6320 * hw - Struct containing variables accessed by shared code
6321 *****************************************************************************/
6323 e1000_cleanup_led(struct e1000_hw
*hw
)
6325 int32_t ret_val
= E1000_SUCCESS
;
6327 DEBUGFUNC("e1000_cleanup_led");
6329 switch (hw
->mac_type
) {
6330 case e1000_82542_rev2_0
:
6331 case e1000_82542_rev2_1
:
6334 /* No cleanup necessary */
6338 case e1000_82541_rev_2
:
6339 case e1000_82547_rev_2
:
6340 /* Turn on PHY Smart Power Down (if previously enabled) */
6341 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
6342 hw
->phy_spd_default
);
6347 if (hw
->phy_type
== e1000_phy_ife
) {
6348 e1000_write_phy_reg(hw
, IFE_PHY_SPECIAL_CONTROL_LED
, 0);
6351 /* Restore LEDCTL settings */
6352 E1000_WRITE_REG(hw
, LEDCTL
, hw
->ledctl_default
);
6356 return E1000_SUCCESS
;
6359 /******************************************************************************
6360 * Turns on the software controllable LED
6362 * hw - Struct containing variables accessed by shared code
6363 *****************************************************************************/
6365 e1000_led_on(struct e1000_hw
*hw
)
6367 uint32_t ctrl
= E1000_READ_REG(hw
, CTRL
);
6369 DEBUGFUNC("e1000_led_on");
6371 switch (hw
->mac_type
) {
6372 case e1000_82542_rev2_0
:
6373 case e1000_82542_rev2_1
:
6375 /* Set SW Defineable Pin 0 to turn on the LED */
6376 ctrl
|= E1000_CTRL_SWDPIN0
;
6377 ctrl
|= E1000_CTRL_SWDPIO0
;
6380 if (hw
->media_type
== e1000_media_type_fiber
) {
6381 /* Set SW Defineable Pin 0 to turn on the LED */
6382 ctrl
|= E1000_CTRL_SWDPIN0
;
6383 ctrl
|= E1000_CTRL_SWDPIO0
;
6385 /* Clear SW Defineable Pin 0 to turn on the LED */
6386 ctrl
&= ~E1000_CTRL_SWDPIN0
;
6387 ctrl
|= E1000_CTRL_SWDPIO0
;
6391 if (hw
->media_type
== e1000_media_type_fiber
) {
6392 /* Clear SW Defineable Pin 0 to turn on the LED */
6393 ctrl
&= ~E1000_CTRL_SWDPIN0
;
6394 ctrl
|= E1000_CTRL_SWDPIO0
;
6395 } else if (hw
->phy_type
== e1000_phy_ife
) {
6396 e1000_write_phy_reg(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
6397 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_ON
));
6398 } else if (hw
->media_type
== e1000_media_type_copper
) {
6399 E1000_WRITE_REG(hw
, LEDCTL
, hw
->ledctl_mode2
);
6400 return E1000_SUCCESS
;
6405 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
6407 return E1000_SUCCESS
;
6410 /******************************************************************************
6411 * Turns off the software controllable LED
6413 * hw - Struct containing variables accessed by shared code
6414 *****************************************************************************/
6416 e1000_led_off(struct e1000_hw
*hw
)
6418 uint32_t ctrl
= E1000_READ_REG(hw
, CTRL
);
6420 DEBUGFUNC("e1000_led_off");
6422 switch (hw
->mac_type
) {
6423 case e1000_82542_rev2_0
:
6424 case e1000_82542_rev2_1
:
6426 /* Clear SW Defineable Pin 0 to turn off the LED */
6427 ctrl
&= ~E1000_CTRL_SWDPIN0
;
6428 ctrl
|= E1000_CTRL_SWDPIO0
;
6431 if (hw
->media_type
== e1000_media_type_fiber
) {
6432 /* Clear SW Defineable Pin 0 to turn off the LED */
6433 ctrl
&= ~E1000_CTRL_SWDPIN0
;
6434 ctrl
|= E1000_CTRL_SWDPIO0
;
6436 /* Set SW Defineable Pin 0 to turn off the LED */
6437 ctrl
|= E1000_CTRL_SWDPIN0
;
6438 ctrl
|= E1000_CTRL_SWDPIO0
;
6442 if (hw
->media_type
== e1000_media_type_fiber
) {
6443 /* Set SW Defineable Pin 0 to turn off the LED */
6444 ctrl
|= E1000_CTRL_SWDPIN0
;
6445 ctrl
|= E1000_CTRL_SWDPIO0
;
6446 } else if (hw
->phy_type
== e1000_phy_ife
) {
6447 e1000_write_phy_reg(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
6448 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_OFF
));
6449 } else if (hw
->media_type
== e1000_media_type_copper
) {
6450 E1000_WRITE_REG(hw
, LEDCTL
, hw
->ledctl_mode1
);
6451 return E1000_SUCCESS
;
6456 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
6458 return E1000_SUCCESS
;
6461 /******************************************************************************
6462 * Clears all hardware statistics counters.
6464 * hw - Struct containing variables accessed by shared code
6465 *****************************************************************************/
6467 e1000_clear_hw_cntrs(struct e1000_hw
*hw
)
6469 volatile uint32_t temp
;
6471 temp
= E1000_READ_REG(hw
, CRCERRS
);
6472 temp
= E1000_READ_REG(hw
, SYMERRS
);
6473 temp
= E1000_READ_REG(hw
, MPC
);
6474 temp
= E1000_READ_REG(hw
, SCC
);
6475 temp
= E1000_READ_REG(hw
, ECOL
);
6476 temp
= E1000_READ_REG(hw
, MCC
);
6477 temp
= E1000_READ_REG(hw
, LATECOL
);
6478 temp
= E1000_READ_REG(hw
, COLC
);
6479 temp
= E1000_READ_REG(hw
, DC
);
6480 temp
= E1000_READ_REG(hw
, SEC
);
6481 temp
= E1000_READ_REG(hw
, RLEC
);
6482 temp
= E1000_READ_REG(hw
, XONRXC
);
6483 temp
= E1000_READ_REG(hw
, XONTXC
);
6484 temp
= E1000_READ_REG(hw
, XOFFRXC
);
6485 temp
= E1000_READ_REG(hw
, XOFFTXC
);
6486 temp
= E1000_READ_REG(hw
, FCRUC
);
6488 if (hw
->mac_type
!= e1000_ich8lan
) {
6489 temp
= E1000_READ_REG(hw
, PRC64
);
6490 temp
= E1000_READ_REG(hw
, PRC127
);
6491 temp
= E1000_READ_REG(hw
, PRC255
);
6492 temp
= E1000_READ_REG(hw
, PRC511
);
6493 temp
= E1000_READ_REG(hw
, PRC1023
);
6494 temp
= E1000_READ_REG(hw
, PRC1522
);
6497 temp
= E1000_READ_REG(hw
, GPRC
);
6498 temp
= E1000_READ_REG(hw
, BPRC
);
6499 temp
= E1000_READ_REG(hw
, MPRC
);
6500 temp
= E1000_READ_REG(hw
, GPTC
);
6501 temp
= E1000_READ_REG(hw
, GORCL
);
6502 temp
= E1000_READ_REG(hw
, GORCH
);
6503 temp
= E1000_READ_REG(hw
, GOTCL
);
6504 temp
= E1000_READ_REG(hw
, GOTCH
);
6505 temp
= E1000_READ_REG(hw
, RNBC
);
6506 temp
= E1000_READ_REG(hw
, RUC
);
6507 temp
= E1000_READ_REG(hw
, RFC
);
6508 temp
= E1000_READ_REG(hw
, ROC
);
6509 temp
= E1000_READ_REG(hw
, RJC
);
6510 temp
= E1000_READ_REG(hw
, TORL
);
6511 temp
= E1000_READ_REG(hw
, TORH
);
6512 temp
= E1000_READ_REG(hw
, TOTL
);
6513 temp
= E1000_READ_REG(hw
, TOTH
);
6514 temp
= E1000_READ_REG(hw
, TPR
);
6515 temp
= E1000_READ_REG(hw
, TPT
);
6517 if (hw
->mac_type
!= e1000_ich8lan
) {
6518 temp
= E1000_READ_REG(hw
, PTC64
);
6519 temp
= E1000_READ_REG(hw
, PTC127
);
6520 temp
= E1000_READ_REG(hw
, PTC255
);
6521 temp
= E1000_READ_REG(hw
, PTC511
);
6522 temp
= E1000_READ_REG(hw
, PTC1023
);
6523 temp
= E1000_READ_REG(hw
, PTC1522
);
6526 temp
= E1000_READ_REG(hw
, MPTC
);
6527 temp
= E1000_READ_REG(hw
, BPTC
);
6529 if (hw
->mac_type
< e1000_82543
) return;
6531 temp
= E1000_READ_REG(hw
, ALGNERRC
);
6532 temp
= E1000_READ_REG(hw
, RXERRC
);
6533 temp
= E1000_READ_REG(hw
, TNCRS
);
6534 temp
= E1000_READ_REG(hw
, CEXTERR
);
6535 temp
= E1000_READ_REG(hw
, TSCTC
);
6536 temp
= E1000_READ_REG(hw
, TSCTFC
);
6538 if (hw
->mac_type
<= e1000_82544
) return;
6540 temp
= E1000_READ_REG(hw
, MGTPRC
);
6541 temp
= E1000_READ_REG(hw
, MGTPDC
);
6542 temp
= E1000_READ_REG(hw
, MGTPTC
);
6544 if (hw
->mac_type
<= e1000_82547_rev_2
) return;
6546 temp
= E1000_READ_REG(hw
, IAC
);
6547 temp
= E1000_READ_REG(hw
, ICRXOC
);
6549 if (hw
->mac_type
== e1000_ich8lan
) return;
6551 temp
= E1000_READ_REG(hw
, ICRXPTC
);
6552 temp
= E1000_READ_REG(hw
, ICRXATC
);
6553 temp
= E1000_READ_REG(hw
, ICTXPTC
);
6554 temp
= E1000_READ_REG(hw
, ICTXATC
);
6555 temp
= E1000_READ_REG(hw
, ICTXQEC
);
6556 temp
= E1000_READ_REG(hw
, ICTXQMTC
);
6557 temp
= E1000_READ_REG(hw
, ICRXDMTC
);
6560 /******************************************************************************
6561 * Resets Adaptive IFS to its default state.
6563 * hw - Struct containing variables accessed by shared code
6565 * Call this after e1000_init_hw. You may override the IFS defaults by setting
6566 * hw->ifs_params_forced to TRUE. However, you must initialize hw->
6567 * current_ifs_val, ifs_min_val, ifs_max_val, ifs_step_size, and ifs_ratio
6568 * before calling this function.
6569 *****************************************************************************/
6571 e1000_reset_adaptive(struct e1000_hw
*hw
)
6573 DEBUGFUNC("e1000_reset_adaptive");
6575 if (hw
->adaptive_ifs
) {
6576 if (!hw
->ifs_params_forced
) {
6577 hw
->current_ifs_val
= 0;
6578 hw
->ifs_min_val
= IFS_MIN
;
6579 hw
->ifs_max_val
= IFS_MAX
;
6580 hw
->ifs_step_size
= IFS_STEP
;
6581 hw
->ifs_ratio
= IFS_RATIO
;
6583 hw
->in_ifs_mode
= FALSE
;
6584 E1000_WRITE_REG(hw
, AIT
, 0);
6586 DEBUGOUT("Not in Adaptive IFS mode!\n");
6590 /******************************************************************************
6591 * Called during the callback/watchdog routine to update IFS value based on
6592 * the ratio of transmits to collisions.
6594 * hw - Struct containing variables accessed by shared code
6595 * tx_packets - Number of transmits since last callback
6596 * total_collisions - Number of collisions since last callback
6597 *****************************************************************************/
6599 e1000_update_adaptive(struct e1000_hw
*hw
)
6601 DEBUGFUNC("e1000_update_adaptive");
6603 if (hw
->adaptive_ifs
) {
6604 if ((hw
->collision_delta
* hw
->ifs_ratio
) > hw
->tx_packet_delta
) {
6605 if (hw
->tx_packet_delta
> MIN_NUM_XMITS
) {
6606 hw
->in_ifs_mode
= TRUE
;
6607 if (hw
->current_ifs_val
< hw
->ifs_max_val
) {
6608 if (hw
->current_ifs_val
== 0)
6609 hw
->current_ifs_val
= hw
->ifs_min_val
;
6611 hw
->current_ifs_val
+= hw
->ifs_step_size
;
6612 E1000_WRITE_REG(hw
, AIT
, hw
->current_ifs_val
);
6616 if (hw
->in_ifs_mode
&& (hw
->tx_packet_delta
<= MIN_NUM_XMITS
)) {
6617 hw
->current_ifs_val
= 0;
6618 hw
->in_ifs_mode
= FALSE
;
6619 E1000_WRITE_REG(hw
, AIT
, 0);
6623 DEBUGOUT("Not in Adaptive IFS mode!\n");
6627 /******************************************************************************
6628 * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT
6630 * hw - Struct containing variables accessed by shared code
6631 * frame_len - The length of the frame in question
6632 * mac_addr - The Ethernet destination address of the frame in question
6633 *****************************************************************************/
6635 e1000_tbi_adjust_stats(struct e1000_hw
*hw
,
6636 struct e1000_hw_stats
*stats
,
6642 /* First adjust the frame length. */
6644 /* We need to adjust the statistics counters, since the hardware
6645 * counters overcount this packet as a CRC error and undercount
6646 * the packet as a good packet
6648 /* This packet should not be counted as a CRC error. */
6650 /* This packet does count as a Good Packet Received. */
6653 /* Adjust the Good Octets received counters */
6654 carry_bit
= 0x80000000 & stats
->gorcl
;
6655 stats
->gorcl
+= frame_len
;
6656 /* If the high bit of Gorcl (the low 32 bits of the Good Octets
6657 * Received Count) was one before the addition,
6658 * AND it is zero after, then we lost the carry out,
6659 * need to add one to Gorch (Good Octets Received Count High).
6660 * This could be simplified if all environments supported
6663 if (carry_bit
&& ((stats
->gorcl
& 0x80000000) == 0))
6665 /* Is this a broadcast or multicast? Check broadcast first,
6666 * since the test for a multicast frame will test positive on
6667 * a broadcast frame.
6669 if ((mac_addr
[0] == (uint8_t) 0xff) && (mac_addr
[1] == (uint8_t) 0xff))
6670 /* Broadcast packet */
6672 else if (*mac_addr
& 0x01)
6673 /* Multicast packet */
6676 if (frame_len
== hw
->max_frame_size
) {
6677 /* In this case, the hardware has overcounted the number of
6684 /* Adjust the bin counters when the extra byte put the frame in the
6685 * wrong bin. Remember that the frame_len was adjusted above.
6687 if (frame_len
== 64) {
6690 } else if (frame_len
== 127) {
6693 } else if (frame_len
== 255) {
6696 } else if (frame_len
== 511) {
6699 } else if (frame_len
== 1023) {
6702 } else if (frame_len
== 1522) {
6707 /******************************************************************************
6708 * Gets the current PCI bus type, speed, and width of the hardware
6710 * hw - Struct containing variables accessed by shared code
6711 *****************************************************************************/
6713 e1000_get_bus_info(struct e1000_hw
*hw
)
6716 uint16_t pci_ex_link_status
;
6719 switch (hw
->mac_type
) {
6720 case e1000_82542_rev2_0
:
6721 case e1000_82542_rev2_1
:
6722 hw
->bus_type
= e1000_bus_type_pci
;
6723 hw
->bus_speed
= e1000_bus_speed_unknown
;
6724 hw
->bus_width
= e1000_bus_width_unknown
;
6729 case e1000_80003es2lan
:
6731 hw
->bus_type
= e1000_bus_type_pci_express
;
6732 hw
->bus_speed
= e1000_bus_speed_2500
;
6733 ret_val
= e1000_read_pcie_cap_reg(hw
,
6735 &pci_ex_link_status
);
6737 hw
->bus_width
= e1000_bus_width_unknown
;
6739 hw
->bus_width
= (pci_ex_link_status
& PCI_EX_LINK_WIDTH_MASK
) >>
6740 PCI_EX_LINK_WIDTH_SHIFT
;
6743 hw
->bus_type
= e1000_bus_type_pci_express
;
6744 hw
->bus_speed
= e1000_bus_speed_2500
;
6745 hw
->bus_width
= e1000_bus_width_pciex_1
;
6748 status
= E1000_READ_REG(hw
, STATUS
);
6749 hw
->bus_type
= (status
& E1000_STATUS_PCIX_MODE
) ?
6750 e1000_bus_type_pcix
: e1000_bus_type_pci
;
6752 if (hw
->device_id
== E1000_DEV_ID_82546EB_QUAD_COPPER
) {
6753 hw
->bus_speed
= (hw
->bus_type
== e1000_bus_type_pci
) ?
6754 e1000_bus_speed_66
: e1000_bus_speed_120
;
6755 } else if (hw
->bus_type
== e1000_bus_type_pci
) {
6756 hw
->bus_speed
= (status
& E1000_STATUS_PCI66
) ?
6757 e1000_bus_speed_66
: e1000_bus_speed_33
;
6759 switch (status
& E1000_STATUS_PCIX_SPEED
) {
6760 case E1000_STATUS_PCIX_SPEED_66
:
6761 hw
->bus_speed
= e1000_bus_speed_66
;
6763 case E1000_STATUS_PCIX_SPEED_100
:
6764 hw
->bus_speed
= e1000_bus_speed_100
;
6766 case E1000_STATUS_PCIX_SPEED_133
:
6767 hw
->bus_speed
= e1000_bus_speed_133
;
6770 hw
->bus_speed
= e1000_bus_speed_reserved
;
6774 hw
->bus_width
= (status
& E1000_STATUS_BUS64
) ?
6775 e1000_bus_width_64
: e1000_bus_width_32
;
6780 /******************************************************************************
6781 * Writes a value to one of the devices registers using port I/O (as opposed to
6782 * memory mapped I/O). Only 82544 and newer devices support port I/O.
6784 * hw - Struct containing variables accessed by shared code
6785 * offset - offset to write to
6786 * value - value to write
6787 *****************************************************************************/
6789 e1000_write_reg_io(struct e1000_hw
*hw
,
6793 unsigned long io_addr
= hw
->io_base
;
6794 unsigned long io_data
= hw
->io_base
+ 4;
6796 e1000_io_write(hw
, io_addr
, offset
);
6797 e1000_io_write(hw
, io_data
, value
);
6800 /******************************************************************************
6801 * Estimates the cable length.
6803 * hw - Struct containing variables accessed by shared code
6804 * min_length - The estimated minimum length
6805 * max_length - The estimated maximum length
6807 * returns: - E1000_ERR_XXX
6810 * This function always returns a ranged length (minimum & maximum).
6811 * So for M88 phy's, this function interprets the one value returned from the
6812 * register to the minimum and maximum range.
6813 * For IGP phy's, the function calculates the range by the AGC registers.
6814 *****************************************************************************/
6816 e1000_get_cable_length(struct e1000_hw
*hw
,
6817 uint16_t *min_length
,
6818 uint16_t *max_length
)
6821 uint16_t agc_value
= 0;
6822 uint16_t i
, phy_data
;
6823 uint16_t cable_length
;
6825 DEBUGFUNC("e1000_get_cable_length");
6827 *min_length
= *max_length
= 0;
6829 /* Use old method for Phy older than IGP */
6830 if (hw
->phy_type
== e1000_phy_m88
) {
6832 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
6836 cable_length
= (phy_data
& M88E1000_PSSR_CABLE_LENGTH
) >>
6837 M88E1000_PSSR_CABLE_LENGTH_SHIFT
;
6839 /* Convert the enum value to ranged values */
6840 switch (cable_length
) {
6841 case e1000_cable_length_50
:
6843 *max_length
= e1000_igp_cable_length_50
;
6845 case e1000_cable_length_50_80
:
6846 *min_length
= e1000_igp_cable_length_50
;
6847 *max_length
= e1000_igp_cable_length_80
;
6849 case e1000_cable_length_80_110
:
6850 *min_length
= e1000_igp_cable_length_80
;
6851 *max_length
= e1000_igp_cable_length_110
;
6853 case e1000_cable_length_110_140
:
6854 *min_length
= e1000_igp_cable_length_110
;
6855 *max_length
= e1000_igp_cable_length_140
;
6857 case e1000_cable_length_140
:
6858 *min_length
= e1000_igp_cable_length_140
;
6859 *max_length
= e1000_igp_cable_length_170
;
6862 return -E1000_ERR_PHY
;
6865 } else if (hw
->phy_type
== e1000_phy_gg82563
) {
6866 ret_val
= e1000_read_phy_reg(hw
, GG82563_PHY_DSP_DISTANCE
,
6870 cable_length
= phy_data
& GG82563_DSPD_CABLE_LENGTH
;
6872 switch (cable_length
) {
6873 case e1000_gg_cable_length_60
:
6875 *max_length
= e1000_igp_cable_length_60
;
6877 case e1000_gg_cable_length_60_115
:
6878 *min_length
= e1000_igp_cable_length_60
;
6879 *max_length
= e1000_igp_cable_length_115
;
6881 case e1000_gg_cable_length_115_150
:
6882 *min_length
= e1000_igp_cable_length_115
;
6883 *max_length
= e1000_igp_cable_length_150
;
6885 case e1000_gg_cable_length_150
:
6886 *min_length
= e1000_igp_cable_length_150
;
6887 *max_length
= e1000_igp_cable_length_180
;
6890 return -E1000_ERR_PHY
;
6893 } else if (hw
->phy_type
== e1000_phy_igp
) { /* For IGP PHY */
6894 uint16_t cur_agc_value
;
6895 uint16_t min_agc_value
= IGP01E1000_AGC_LENGTH_TABLE_SIZE
;
6896 uint16_t agc_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] =
6897 {IGP01E1000_PHY_AGC_A
,
6898 IGP01E1000_PHY_AGC_B
,
6899 IGP01E1000_PHY_AGC_C
,
6900 IGP01E1000_PHY_AGC_D
};
6901 /* Read the AGC registers for all channels */
6902 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
6904 ret_val
= e1000_read_phy_reg(hw
, agc_reg_array
[i
], &phy_data
);
6908 cur_agc_value
= phy_data
>> IGP01E1000_AGC_LENGTH_SHIFT
;
6910 /* Value bound check. */
6911 if ((cur_agc_value
>= IGP01E1000_AGC_LENGTH_TABLE_SIZE
- 1) ||
6912 (cur_agc_value
== 0))
6913 return -E1000_ERR_PHY
;
6915 agc_value
+= cur_agc_value
;
6917 /* Update minimal AGC value. */
6918 if (min_agc_value
> cur_agc_value
)
6919 min_agc_value
= cur_agc_value
;
6922 /* Remove the minimal AGC result for length < 50m */
6923 if (agc_value
< IGP01E1000_PHY_CHANNEL_NUM
* e1000_igp_cable_length_50
) {
6924 agc_value
-= min_agc_value
;
6926 /* Get the average length of the remaining 3 channels */
6927 agc_value
/= (IGP01E1000_PHY_CHANNEL_NUM
- 1);
6929 /* Get the average length of all the 4 channels. */
6930 agc_value
/= IGP01E1000_PHY_CHANNEL_NUM
;
6933 /* Set the range of the calculated length. */
6934 *min_length
= ((e1000_igp_cable_length_table
[agc_value
] -
6935 IGP01E1000_AGC_RANGE
) > 0) ?
6936 (e1000_igp_cable_length_table
[agc_value
] -
6937 IGP01E1000_AGC_RANGE
) : 0;
6938 *max_length
= e1000_igp_cable_length_table
[agc_value
] +
6939 IGP01E1000_AGC_RANGE
;
6940 } else if (hw
->phy_type
== e1000_phy_igp_2
||
6941 hw
->phy_type
== e1000_phy_igp_3
) {
6942 uint16_t cur_agc_index
, max_agc_index
= 0;
6943 uint16_t min_agc_index
= IGP02E1000_AGC_LENGTH_TABLE_SIZE
- 1;
6944 uint16_t agc_reg_array
[IGP02E1000_PHY_CHANNEL_NUM
] =
6945 {IGP02E1000_PHY_AGC_A
,
6946 IGP02E1000_PHY_AGC_B
,
6947 IGP02E1000_PHY_AGC_C
,
6948 IGP02E1000_PHY_AGC_D
};
6949 /* Read the AGC registers for all channels */
6950 for (i
= 0; i
< IGP02E1000_PHY_CHANNEL_NUM
; i
++) {
6951 ret_val
= e1000_read_phy_reg(hw
, agc_reg_array
[i
], &phy_data
);
6955 /* Getting bits 15:9, which represent the combination of course and
6956 * fine gain values. The result is a number that can be put into
6957 * the lookup table to obtain the approximate cable length. */
6958 cur_agc_index
= (phy_data
>> IGP02E1000_AGC_LENGTH_SHIFT
) &
6959 IGP02E1000_AGC_LENGTH_MASK
;
6961 /* Array index bound check. */
6962 if ((cur_agc_index
>= IGP02E1000_AGC_LENGTH_TABLE_SIZE
) ||
6963 (cur_agc_index
== 0))
6964 return -E1000_ERR_PHY
;
6966 /* Remove min & max AGC values from calculation. */
6967 if (e1000_igp_2_cable_length_table
[min_agc_index
] >
6968 e1000_igp_2_cable_length_table
[cur_agc_index
])
6969 min_agc_index
= cur_agc_index
;
6970 if (e1000_igp_2_cable_length_table
[max_agc_index
] <
6971 e1000_igp_2_cable_length_table
[cur_agc_index
])
6972 max_agc_index
= cur_agc_index
;
6974 agc_value
+= e1000_igp_2_cable_length_table
[cur_agc_index
];
6977 agc_value
-= (e1000_igp_2_cable_length_table
[min_agc_index
] +
6978 e1000_igp_2_cable_length_table
[max_agc_index
]);
6979 agc_value
/= (IGP02E1000_PHY_CHANNEL_NUM
- 2);
6981 /* Calculate cable length with the error range of +/- 10 meters. */
6982 *min_length
= ((agc_value
- IGP02E1000_AGC_RANGE
) > 0) ?
6983 (agc_value
- IGP02E1000_AGC_RANGE
) : 0;
6984 *max_length
= agc_value
+ IGP02E1000_AGC_RANGE
;
6987 return E1000_SUCCESS
;
6990 /******************************************************************************
6991 * Check the cable polarity
6993 * hw - Struct containing variables accessed by shared code
6994 * polarity - output parameter : 0 - Polarity is not reversed
6995 * 1 - Polarity is reversed.
6997 * returns: - E1000_ERR_XXX
7000 * For phy's older then IGP, this function simply reads the polarity bit in the
7001 * Phy Status register. For IGP phy's, this bit is valid only if link speed is
7002 * 10 Mbps. If the link speed is 100 Mbps there is no polarity so this bit will
7003 * return 0. If the link speed is 1000 Mbps the polarity status is in the
7004 * IGP01E1000_PHY_PCS_INIT_REG.
7005 *****************************************************************************/
7007 e1000_check_polarity(struct e1000_hw
*hw
,
7008 e1000_rev_polarity
*polarity
)
7013 DEBUGFUNC("e1000_check_polarity");
7015 if ((hw
->phy_type
== e1000_phy_m88
) ||
7016 (hw
->phy_type
== e1000_phy_gg82563
)) {
7017 /* return the Polarity bit in the Status register. */
7018 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
7022 *polarity
= ((phy_data
& M88E1000_PSSR_REV_POLARITY
) >>
7023 M88E1000_PSSR_REV_POLARITY_SHIFT
) ?
7024 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
7026 } else if (hw
->phy_type
== e1000_phy_igp
||
7027 hw
->phy_type
== e1000_phy_igp_3
||
7028 hw
->phy_type
== e1000_phy_igp_2
) {
7029 /* Read the Status register to check the speed */
7030 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
,
7035 /* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to
7036 * find the polarity status */
7037 if ((phy_data
& IGP01E1000_PSSR_SPEED_MASK
) ==
7038 IGP01E1000_PSSR_SPEED_1000MBPS
) {
7040 /* Read the GIG initialization PCS register (0x00B4) */
7041 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PCS_INIT_REG
,
7046 /* Check the polarity bits */
7047 *polarity
= (phy_data
& IGP01E1000_PHY_POLARITY_MASK
) ?
7048 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
7050 /* For 10 Mbps, read the polarity bit in the status register. (for
7051 * 100 Mbps this bit is always 0) */
7052 *polarity
= (phy_data
& IGP01E1000_PSSR_POLARITY_REVERSED
) ?
7053 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
7055 } else if (hw
->phy_type
== e1000_phy_ife
) {
7056 ret_val
= e1000_read_phy_reg(hw
, IFE_PHY_EXTENDED_STATUS_CONTROL
,
7060 *polarity
= ((phy_data
& IFE_PESC_POLARITY_REVERSED
) >>
7061 IFE_PESC_POLARITY_REVERSED_SHIFT
) ?
7062 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
7064 return E1000_SUCCESS
;
7067 /******************************************************************************
7068 * Check if Downshift occured
7070 * hw - Struct containing variables accessed by shared code
7071 * downshift - output parameter : 0 - No Downshift ocured.
7072 * 1 - Downshift ocured.
7074 * returns: - E1000_ERR_XXX
7077 * For phy's older then IGP, this function reads the Downshift bit in the Phy
7078 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the
7079 * Link Health register. In IGP this bit is latched high, so the driver must
7080 * read it immediately after link is established.
7081 *****************************************************************************/
7083 e1000_check_downshift(struct e1000_hw
*hw
)
7088 DEBUGFUNC("e1000_check_downshift");
7090 if (hw
->phy_type
== e1000_phy_igp
||
7091 hw
->phy_type
== e1000_phy_igp_3
||
7092 hw
->phy_type
== e1000_phy_igp_2
) {
7093 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_LINK_HEALTH
,
7098 hw
->speed_downgraded
= (phy_data
& IGP01E1000_PLHR_SS_DOWNGRADE
) ? 1 : 0;
7099 } else if ((hw
->phy_type
== e1000_phy_m88
) ||
7100 (hw
->phy_type
== e1000_phy_gg82563
)) {
7101 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
7106 hw
->speed_downgraded
= (phy_data
& M88E1000_PSSR_DOWNSHIFT
) >>
7107 M88E1000_PSSR_DOWNSHIFT_SHIFT
;
7108 } else if (hw
->phy_type
== e1000_phy_ife
) {
7109 /* e1000_phy_ife supports 10/100 speed only */
7110 hw
->speed_downgraded
= FALSE
;
7113 return E1000_SUCCESS
;
7116 /*****************************************************************************
7118 * 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
7119 * gigabit link is achieved to improve link quality.
7121 * hw: Struct containing variables accessed by shared code
7123 * returns: - E1000_ERR_PHY if fail to read/write the PHY
7124 * E1000_SUCCESS at any other case.
7126 ****************************************************************************/
7129 e1000_config_dsp_after_link_change(struct e1000_hw
*hw
,
7133 uint16_t phy_data
, phy_saved_data
, speed
, duplex
, i
;
7134 uint16_t dsp_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] =
7135 {IGP01E1000_PHY_AGC_PARAM_A
,
7136 IGP01E1000_PHY_AGC_PARAM_B
,
7137 IGP01E1000_PHY_AGC_PARAM_C
,
7138 IGP01E1000_PHY_AGC_PARAM_D
};
7139 uint16_t min_length
, max_length
;
7141 DEBUGFUNC("e1000_config_dsp_after_link_change");
7143 if (hw
->phy_type
!= e1000_phy_igp
)
7144 return E1000_SUCCESS
;
7147 ret_val
= e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
7149 DEBUGOUT("Error getting link speed and duplex\n");
7153 if (speed
== SPEED_1000
) {
7155 ret_val
= e1000_get_cable_length(hw
, &min_length
, &max_length
);
7159 if ((hw
->dsp_config_state
== e1000_dsp_config_enabled
) &&
7160 min_length
>= e1000_igp_cable_length_50
) {
7162 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
7163 ret_val
= e1000_read_phy_reg(hw
, dsp_reg_array
[i
],
7168 phy_data
&= ~IGP01E1000_PHY_EDAC_MU_INDEX
;
7170 ret_val
= e1000_write_phy_reg(hw
, dsp_reg_array
[i
],
7175 hw
->dsp_config_state
= e1000_dsp_config_activated
;
7178 if ((hw
->ffe_config_state
== e1000_ffe_config_enabled
) &&
7179 (min_length
< e1000_igp_cable_length_50
)) {
7181 uint16_t ffe_idle_err_timeout
= FFE_IDLE_ERR_COUNT_TIMEOUT_20
;
7182 uint32_t idle_errs
= 0;
7184 /* clear previous idle error counts */
7185 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
,
7190 for (i
= 0; i
< ffe_idle_err_timeout
; i
++) {
7192 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
,
7197 idle_errs
+= (phy_data
& SR_1000T_IDLE_ERROR_CNT
);
7198 if (idle_errs
> SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT
) {
7199 hw
->ffe_config_state
= e1000_ffe_config_active
;
7201 ret_val
= e1000_write_phy_reg(hw
,
7202 IGP01E1000_PHY_DSP_FFE
,
7203 IGP01E1000_PHY_DSP_FFE_CM_CP
);
7210 ffe_idle_err_timeout
= FFE_IDLE_ERR_COUNT_TIMEOUT_100
;
7215 if (hw
->dsp_config_state
== e1000_dsp_config_activated
) {
7216 /* Save off the current value of register 0x2F5B to be restored at
7217 * the end of the routines. */
7218 ret_val
= e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
7223 /* Disable the PHY transmitter */
7224 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
7231 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
7232 IGP01E1000_IEEE_FORCE_GIGA
);
7235 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
7236 ret_val
= e1000_read_phy_reg(hw
, dsp_reg_array
[i
], &phy_data
);
7240 phy_data
&= ~IGP01E1000_PHY_EDAC_MU_INDEX
;
7241 phy_data
|= IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS
;
7243 ret_val
= e1000_write_phy_reg(hw
,dsp_reg_array
[i
], phy_data
);
7248 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
7249 IGP01E1000_IEEE_RESTART_AUTONEG
);
7255 /* Now enable the transmitter */
7256 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
7261 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
7264 if (hw
->ffe_config_state
== e1000_ffe_config_active
) {
7265 /* Save off the current value of register 0x2F5B to be restored at
7266 * the end of the routines. */
7267 ret_val
= e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
7272 /* Disable the PHY transmitter */
7273 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
7280 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
7281 IGP01E1000_IEEE_FORCE_GIGA
);
7284 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_DSP_FFE
,
7285 IGP01E1000_PHY_DSP_FFE_DEFAULT
);
7289 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
7290 IGP01E1000_IEEE_RESTART_AUTONEG
);
7296 /* Now enable the transmitter */
7297 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
7302 hw
->ffe_config_state
= e1000_ffe_config_enabled
;
7305 return E1000_SUCCESS
;
7308 /*****************************************************************************
7309 * Set PHY to class A mode
7310 * Assumes the following operations will follow to enable the new class mode.
7311 * 1. Do a PHY soft reset
7312 * 2. Restart auto-negotiation or force link.
7314 * hw - Struct containing variables accessed by shared code
7315 ****************************************************************************/
7317 e1000_set_phy_mode(struct e1000_hw
*hw
)
7320 uint16_t eeprom_data
;
7322 DEBUGFUNC("e1000_set_phy_mode");
7324 if ((hw
->mac_type
== e1000_82545_rev_3
) &&
7325 (hw
->media_type
== e1000_media_type_copper
)) {
7326 ret_val
= e1000_read_eeprom(hw
, EEPROM_PHY_CLASS_WORD
, 1, &eeprom_data
);
7331 if ((eeprom_data
!= EEPROM_RESERVED_WORD
) &&
7332 (eeprom_data
& EEPROM_PHY_CLASS_A
)) {
7333 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x000B);
7336 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0x8104);
7340 hw
->phy_reset_disable
= FALSE
;
7344 return E1000_SUCCESS
;
7347 /*****************************************************************************
7349 * This function sets the lplu state according to the active flag. When
7350 * activating lplu this function also disables smart speed and vise versa.
7351 * lplu will not be activated unless the device autonegotiation advertisment
7352 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
7353 * hw: Struct containing variables accessed by shared code
7354 * active - true to enable lplu false to disable lplu.
7356 * returns: - E1000_ERR_PHY if fail to read/write the PHY
7357 * E1000_SUCCESS at any other case.
7359 ****************************************************************************/
7362 e1000_set_d3_lplu_state(struct e1000_hw
*hw
,
7365 uint32_t phy_ctrl
= 0;
7368 DEBUGFUNC("e1000_set_d3_lplu_state");
7370 if (hw
->phy_type
!= e1000_phy_igp
&& hw
->phy_type
!= e1000_phy_igp_2
7371 && hw
->phy_type
!= e1000_phy_igp_3
)
7372 return E1000_SUCCESS
;
7374 /* During driver activity LPLU should not be used or it will attain link
7375 * from the lowest speeds starting from 10Mbps. The capability is used for
7376 * Dx transitions and states */
7377 if (hw
->mac_type
== e1000_82541_rev_2
|| hw
->mac_type
== e1000_82547_rev_2
) {
7378 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_GMII_FIFO
, &phy_data
);
7381 } else if (hw
->mac_type
== e1000_ich8lan
) {
7382 /* MAC writes into PHY register based on the state transition
7383 * and start auto-negotiation. SW driver can overwrite the settings
7384 * in CSR PHY power control E1000_PHY_CTRL register. */
7385 phy_ctrl
= E1000_READ_REG(hw
, PHY_CTRL
);
7387 ret_val
= e1000_read_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
, &phy_data
);
7393 if (hw
->mac_type
== e1000_82541_rev_2
||
7394 hw
->mac_type
== e1000_82547_rev_2
) {
7395 phy_data
&= ~IGP01E1000_GMII_FLEX_SPD
;
7396 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
, phy_data
);
7400 if (hw
->mac_type
== e1000_ich8lan
) {
7401 phy_ctrl
&= ~E1000_PHY_CTRL_NOND0A_LPLU
;
7402 E1000_WRITE_REG(hw
, PHY_CTRL
, phy_ctrl
);
7404 phy_data
&= ~IGP02E1000_PM_D3_LPLU
;
7405 ret_val
= e1000_write_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
,
7412 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during
7413 * Dx states where the power conservation is most important. During
7414 * driver activity we should enable SmartSpeed, so performance is
7416 if (hw
->smart_speed
== e1000_smart_speed_on
) {
7417 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7422 phy_data
|= IGP01E1000_PSCFR_SMART_SPEED
;
7423 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7427 } else if (hw
->smart_speed
== e1000_smart_speed_off
) {
7428 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7433 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
7434 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7440 } else if ((hw
->autoneg_advertised
== AUTONEG_ADVERTISE_SPEED_DEFAULT
) ||
7441 (hw
->autoneg_advertised
== AUTONEG_ADVERTISE_10_ALL
) ||
7442 (hw
->autoneg_advertised
== AUTONEG_ADVERTISE_10_100_ALL
)) {
7444 if (hw
->mac_type
== e1000_82541_rev_2
||
7445 hw
->mac_type
== e1000_82547_rev_2
) {
7446 phy_data
|= IGP01E1000_GMII_FLEX_SPD
;
7447 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
, phy_data
);
7451 if (hw
->mac_type
== e1000_ich8lan
) {
7452 phy_ctrl
|= E1000_PHY_CTRL_NOND0A_LPLU
;
7453 E1000_WRITE_REG(hw
, PHY_CTRL
, phy_ctrl
);
7455 phy_data
|= IGP02E1000_PM_D3_LPLU
;
7456 ret_val
= e1000_write_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
,
7463 /* When LPLU is enabled we should disable SmartSpeed */
7464 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
, &phy_data
);
7468 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
7469 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
, phy_data
);
7474 return E1000_SUCCESS
;
7477 /*****************************************************************************
7479 * This function sets the lplu d0 state according to the active flag. When
7480 * activating lplu this function also disables smart speed and vise versa.
7481 * lplu will not be activated unless the device autonegotiation advertisment
7482 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
7483 * hw: Struct containing variables accessed by shared code
7484 * active - true to enable lplu false to disable lplu.
7486 * returns: - E1000_ERR_PHY if fail to read/write the PHY
7487 * E1000_SUCCESS at any other case.
7489 ****************************************************************************/
7492 e1000_set_d0_lplu_state(struct e1000_hw
*hw
,
7495 uint32_t phy_ctrl
= 0;
7498 DEBUGFUNC("e1000_set_d0_lplu_state");
7500 if (hw
->mac_type
<= e1000_82547_rev_2
)
7501 return E1000_SUCCESS
;
7503 if (hw
->mac_type
== e1000_ich8lan
) {
7504 phy_ctrl
= E1000_READ_REG(hw
, PHY_CTRL
);
7506 ret_val
= e1000_read_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
, &phy_data
);
7512 if (hw
->mac_type
== e1000_ich8lan
) {
7513 phy_ctrl
&= ~E1000_PHY_CTRL_D0A_LPLU
;
7514 E1000_WRITE_REG(hw
, PHY_CTRL
, phy_ctrl
);
7516 phy_data
&= ~IGP02E1000_PM_D0_LPLU
;
7517 ret_val
= e1000_write_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
, phy_data
);
7522 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during
7523 * Dx states where the power conservation is most important. During
7524 * driver activity we should enable SmartSpeed, so performance is
7526 if (hw
->smart_speed
== e1000_smart_speed_on
) {
7527 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7532 phy_data
|= IGP01E1000_PSCFR_SMART_SPEED
;
7533 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7537 } else if (hw
->smart_speed
== e1000_smart_speed_off
) {
7538 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7543 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
7544 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
7553 if (hw
->mac_type
== e1000_ich8lan
) {
7554 phy_ctrl
|= E1000_PHY_CTRL_D0A_LPLU
;
7555 E1000_WRITE_REG(hw
, PHY_CTRL
, phy_ctrl
);
7557 phy_data
|= IGP02E1000_PM_D0_LPLU
;
7558 ret_val
= e1000_write_phy_reg(hw
, IGP02E1000_PHY_POWER_MGMT
, phy_data
);
7563 /* When LPLU is enabled we should disable SmartSpeed */
7564 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
, &phy_data
);
7568 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
7569 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
, phy_data
);
7574 return E1000_SUCCESS
;
7577 /******************************************************************************
7578 * Change VCO speed register to improve Bit Error Rate performance of SERDES.
7580 * hw - Struct containing variables accessed by shared code
7581 *****************************************************************************/
7583 e1000_set_vco_speed(struct e1000_hw
*hw
)
7586 uint16_t default_page
= 0;
7589 DEBUGFUNC("e1000_set_vco_speed");
7591 switch (hw
->mac_type
) {
7592 case e1000_82545_rev_3
:
7593 case e1000_82546_rev_3
:
7596 return E1000_SUCCESS
;
7599 /* Set PHY register 30, page 5, bit 8 to 0 */
7601 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, &default_page
);
7605 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0005);
7609 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, &phy_data
);
7613 phy_data
&= ~M88E1000_PHY_VCO_REG_BIT8
;
7614 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, phy_data
);
7618 /* Set PHY register 30, page 4, bit 11 to 1 */
7620 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0004);
7624 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, &phy_data
);
7628 phy_data
|= M88E1000_PHY_VCO_REG_BIT11
;
7629 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, phy_data
);
7633 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, default_page
);
7637 return E1000_SUCCESS
;
7641 /*****************************************************************************
7642 * This function reads the cookie from ARC ram.
7644 * returns: - E1000_SUCCESS .
7645 ****************************************************************************/
7647 e1000_host_if_read_cookie(struct e1000_hw
* hw
, uint8_t *buffer
)
7650 uint32_t offset
= E1000_MNG_DHCP_COOKIE_OFFSET
;
7651 uint8_t length
= E1000_MNG_DHCP_COOKIE_LENGTH
;
7653 length
= (length
>> 2);
7654 offset
= (offset
>> 2);
7656 for (i
= 0; i
< length
; i
++) {
7657 *((uint32_t *) buffer
+ i
) =
7658 E1000_READ_REG_ARRAY_DWORD(hw
, HOST_IF
, offset
+ i
);
7660 return E1000_SUCCESS
;
7664 /*****************************************************************************
7665 * This function checks whether the HOST IF is enabled for command operaton
7666 * and also checks whether the previous command is completed.
7667 * It busy waits in case of previous command is not completed.
7669 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or
7671 * - E1000_SUCCESS for success.
7672 ****************************************************************************/
7674 e1000_mng_enable_host_if(struct e1000_hw
* hw
)
7679 /* Check that the host interface is enabled. */
7680 hicr
= E1000_READ_REG(hw
, HICR
);
7681 if ((hicr
& E1000_HICR_EN
) == 0) {
7682 DEBUGOUT("E1000_HOST_EN bit disabled.\n");
7683 return -E1000_ERR_HOST_INTERFACE_COMMAND
;
7685 /* check the previous command is completed */
7686 for (i
= 0; i
< E1000_MNG_DHCP_COMMAND_TIMEOUT
; i
++) {
7687 hicr
= E1000_READ_REG(hw
, HICR
);
7688 if (!(hicr
& E1000_HICR_C
))
7693 if (i
== E1000_MNG_DHCP_COMMAND_TIMEOUT
) {
7694 DEBUGOUT("Previous command timeout failed .\n");
7695 return -E1000_ERR_HOST_INTERFACE_COMMAND
;
7697 return E1000_SUCCESS
;
7700 /*****************************************************************************
7701 * This function writes the buffer content at the offset given on the host if.
7702 * It also does alignment considerations to do the writes in most efficient way.
7703 * Also fills up the sum of the buffer in *buffer parameter.
7705 * returns - E1000_SUCCESS for success.
7706 ****************************************************************************/
7708 e1000_mng_host_if_write(struct e1000_hw
* hw
, uint8_t *buffer
,
7709 uint16_t length
, uint16_t offset
, uint8_t *sum
)
7712 uint8_t *bufptr
= buffer
;
7714 uint16_t remaining
, i
, j
, prev_bytes
;
7716 /* sum = only sum of the data and it is not checksum */
7718 if (length
== 0 || offset
+ length
> E1000_HI_MAX_MNG_DATA_LENGTH
) {
7719 return -E1000_ERR_PARAM
;
7722 tmp
= (uint8_t *)&data
;
7723 prev_bytes
= offset
& 0x3;
7728 data
= E1000_READ_REG_ARRAY_DWORD(hw
, HOST_IF
, offset
);
7729 for (j
= prev_bytes
; j
< sizeof(uint32_t); j
++) {
7730 *(tmp
+ j
) = *bufptr
++;
7733 E1000_WRITE_REG_ARRAY_DWORD(hw
, HOST_IF
, offset
, data
);
7734 length
-= j
- prev_bytes
;
7738 remaining
= length
& 0x3;
7739 length
-= remaining
;
7741 /* Calculate length in DWORDs */
7744 /* The device driver writes the relevant command block into the
7746 for (i
= 0; i
< length
; i
++) {
7747 for (j
= 0; j
< sizeof(uint32_t); j
++) {
7748 *(tmp
+ j
) = *bufptr
++;
7752 E1000_WRITE_REG_ARRAY_DWORD(hw
, HOST_IF
, offset
+ i
, data
);
7755 for (j
= 0; j
< sizeof(uint32_t); j
++) {
7757 *(tmp
+ j
) = *bufptr
++;
7763 E1000_WRITE_REG_ARRAY_DWORD(hw
, HOST_IF
, offset
+ i
, data
);
7766 return E1000_SUCCESS
;
7770 /*****************************************************************************
7771 * This function writes the command header after does the checksum calculation.
7773 * returns - E1000_SUCCESS for success.
7774 ****************************************************************************/
7776 e1000_mng_write_cmd_header(struct e1000_hw
* hw
,
7777 struct e1000_host_mng_command_header
* hdr
)
7783 /* Write the whole command header structure which includes sum of
7786 uint16_t length
= sizeof(struct e1000_host_mng_command_header
);
7788 sum
= hdr
->checksum
;
7791 buffer
= (uint8_t *) hdr
;
7796 hdr
->checksum
= 0 - sum
;
7799 /* The device driver writes the relevant command block into the ram area. */
7800 for (i
= 0; i
< length
; i
++) {
7801 E1000_WRITE_REG_ARRAY_DWORD(hw
, HOST_IF
, i
, *((uint32_t *) hdr
+ i
));
7802 E1000_WRITE_FLUSH(hw
);
7805 return E1000_SUCCESS
;
7809 /*****************************************************************************
7810 * This function indicates to ARC that a new command is pending which completes
7811 * one write operation by the driver.
7813 * returns - E1000_SUCCESS for success.
7814 ****************************************************************************/
7816 e1000_mng_write_commit(struct e1000_hw
* hw
)
7820 hicr
= E1000_READ_REG(hw
, HICR
);
7821 /* Setting this bit tells the ARC that a new command is pending. */
7822 E1000_WRITE_REG(hw
, HICR
, hicr
| E1000_HICR_C
);
7824 return E1000_SUCCESS
;
7828 /*****************************************************************************
7829 * This function checks the mode of the firmware.
7831 * returns - TRUE when the mode is IAMT or FALSE.
7832 ****************************************************************************/
7834 e1000_check_mng_mode(struct e1000_hw
*hw
)
7838 fwsm
= E1000_READ_REG(hw
, FWSM
);
7840 if (hw
->mac_type
== e1000_ich8lan
) {
7841 if ((fwsm
& E1000_FWSM_MODE_MASK
) ==
7842 (E1000_MNG_ICH_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
))
7844 } else if ((fwsm
& E1000_FWSM_MODE_MASK
) ==
7845 (E1000_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
))
7852 /*****************************************************************************
7853 * This function writes the dhcp info .
7854 ****************************************************************************/
7856 e1000_mng_write_dhcp_info(struct e1000_hw
* hw
, uint8_t *buffer
,
7860 struct e1000_host_mng_command_header hdr
;
7862 hdr
.command_id
= E1000_MNG_DHCP_TX_PAYLOAD_CMD
;
7863 hdr
.command_length
= length
;
7868 ret_val
= e1000_mng_enable_host_if(hw
);
7869 if (ret_val
== E1000_SUCCESS
) {
7870 ret_val
= e1000_mng_host_if_write(hw
, buffer
, length
, sizeof(hdr
),
7872 if (ret_val
== E1000_SUCCESS
) {
7873 ret_val
= e1000_mng_write_cmd_header(hw
, &hdr
);
7874 if (ret_val
== E1000_SUCCESS
)
7875 ret_val
= e1000_mng_write_commit(hw
);
7882 /*****************************************************************************
7883 * This function calculates the checksum.
7885 * returns - checksum of buffer contents.
7886 ****************************************************************************/
7888 e1000_calculate_mng_checksum(char *buffer
, uint32_t length
)
7896 for (i
=0; i
< length
; i
++)
7899 return (uint8_t) (0 - sum
);
7902 /*****************************************************************************
7903 * This function checks whether tx pkt filtering needs to be enabled or not.
7905 * returns - TRUE for packet filtering or FALSE.
7906 ****************************************************************************/
7908 e1000_enable_tx_pkt_filtering(struct e1000_hw
*hw
)
7910 /* called in init as well as watchdog timer functions */
7912 int32_t ret_val
, checksum
;
7913 boolean_t tx_filter
= FALSE
;
7914 struct e1000_host_mng_dhcp_cookie
*hdr
= &(hw
->mng_cookie
);
7915 uint8_t *buffer
= (uint8_t *) &(hw
->mng_cookie
);
7917 if (e1000_check_mng_mode(hw
)) {
7918 ret_val
= e1000_mng_enable_host_if(hw
);
7919 if (ret_val
== E1000_SUCCESS
) {
7920 ret_val
= e1000_host_if_read_cookie(hw
, buffer
);
7921 if (ret_val
== E1000_SUCCESS
) {
7922 checksum
= hdr
->checksum
;
7924 if ((hdr
->signature
== E1000_IAMT_SIGNATURE
) &&
7925 checksum
== e1000_calculate_mng_checksum((char *)buffer
,
7926 E1000_MNG_DHCP_COOKIE_LENGTH
)) {
7928 E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT
)
7937 hw
->tx_pkt_filtering
= tx_filter
;
7941 /******************************************************************************
7942 * Verifies the hardware needs to allow ARPs to be processed by the host
7944 * hw - Struct containing variables accessed by shared code
7946 * returns: - TRUE/FALSE
7948 *****************************************************************************/
7950 e1000_enable_mng_pass_thru(struct e1000_hw
*hw
)
7953 uint32_t fwsm
, factps
;
7955 if (hw
->asf_firmware_present
) {
7956 manc
= E1000_READ_REG(hw
, MANC
);
7958 if (!(manc
& E1000_MANC_RCV_TCO_EN
) ||
7959 !(manc
& E1000_MANC_EN_MAC_ADDR_FILTER
))
7961 if (e1000_arc_subsystem_valid(hw
) == TRUE
) {
7962 fwsm
= E1000_READ_REG(hw
, FWSM
);
7963 factps
= E1000_READ_REG(hw
, FACTPS
);
7965 if ((((fwsm
& E1000_FWSM_MODE_MASK
) >> E1000_FWSM_MODE_SHIFT
) ==
7966 e1000_mng_mode_pt
) && !(factps
& E1000_FACTPS_MNGCG
))
7969 if ((manc
& E1000_MANC_SMBUS_EN
) && !(manc
& E1000_MANC_ASF_EN
))
7976 e1000_polarity_reversal_workaround(struct e1000_hw
*hw
)
7979 uint16_t mii_status_reg
;
7982 /* Polarity reversal workaround for forced 10F/10H links. */
7984 /* Disable the transmitter on the PHY */
7986 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
7989 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFFF);
7993 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
7997 /* This loop will early-out if the NO link condition has been met. */
7998 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
7999 /* Read the MII Status Register and wait for Link Status bit
8003 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
8007 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
8011 if ((mii_status_reg
& ~MII_SR_LINK_STATUS
) == 0) break;
8015 /* Recommended delay time after link has been lost */
8018 /* Now we will re-enable th transmitter on the PHY */
8020 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
8024 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFF0);
8028 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFF00);
8032 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0x0000);
8036 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
8040 /* This loop will early-out if the link condition has been met. */
8041 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
8042 /* Read the MII Status Register and wait for Link Status bit
8046 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
8050 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
8054 if (mii_status_reg
& MII_SR_LINK_STATUS
) break;
8057 return E1000_SUCCESS
;
8060 /***************************************************************************
8062 * Disables PCI-Express master access.
8064 * hw: Struct containing variables accessed by shared code
8068 ***************************************************************************/
8070 e1000_set_pci_express_master_disable(struct e1000_hw
*hw
)
8074 DEBUGFUNC("e1000_set_pci_express_master_disable");
8076 if (hw
->bus_type
!= e1000_bus_type_pci_express
)
8079 ctrl
= E1000_READ_REG(hw
, CTRL
);
8080 ctrl
|= E1000_CTRL_GIO_MASTER_DISABLE
;
8081 E1000_WRITE_REG(hw
, CTRL
, ctrl
);
8084 /*******************************************************************************
8086 * Disables PCI-Express master access and verifies there are no pending requests
8088 * hw: Struct containing variables accessed by shared code
8090 * returns: - E1000_ERR_MASTER_REQUESTS_PENDING if master disable bit hasn't
8091 * caused the master requests to be disabled.
8092 * E1000_SUCCESS master requests disabled.
8094 ******************************************************************************/
8096 e1000_disable_pciex_master(struct e1000_hw
*hw
)
8098 int32_t timeout
= MASTER_DISABLE_TIMEOUT
; /* 80ms */
8100 DEBUGFUNC("e1000_disable_pciex_master");
8102 if (hw
->bus_type
!= e1000_bus_type_pci_express
)
8103 return E1000_SUCCESS
;
8105 e1000_set_pci_express_master_disable(hw
);
8108 if (!(E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_GIO_MASTER_ENABLE
))
8116 DEBUGOUT("Master requests are pending.\n");
8117 return -E1000_ERR_MASTER_REQUESTS_PENDING
;
8120 return E1000_SUCCESS
;
8123 /*******************************************************************************
8125 * Check for EEPROM Auto Read bit done.
8127 * hw: Struct containing variables accessed by shared code
8129 * returns: - E1000_ERR_RESET if fail to reset MAC
8130 * E1000_SUCCESS at any other case.
8132 ******************************************************************************/
8134 e1000_get_auto_rd_done(struct e1000_hw
*hw
)
8136 int32_t timeout
= AUTO_READ_DONE_TIMEOUT
;
8138 DEBUGFUNC("e1000_get_auto_rd_done");
8140 switch (hw
->mac_type
) {
8147 case e1000_80003es2lan
:
8151 if (E1000_READ_REG(hw
, EECD
) & E1000_EECD_AUTO_RD
)
8158 DEBUGOUT("Auto read by HW from EEPROM has not completed.\n");
8159 return -E1000_ERR_RESET
;
8164 /* PHY configuration from NVM just starts after EECD_AUTO_RD sets to high.
8165 * Need to wait for PHY configuration completion before accessing NVM
8167 if (hw
->mac_type
== e1000_82573
)
8170 return E1000_SUCCESS
;
8173 /***************************************************************************
8174 * Checks if the PHY configuration is done
8176 * hw: Struct containing variables accessed by shared code
8178 * returns: - E1000_ERR_RESET if fail to reset MAC
8179 * E1000_SUCCESS at any other case.
8181 ***************************************************************************/
8183 e1000_get_phy_cfg_done(struct e1000_hw
*hw
)
8185 int32_t timeout
= PHY_CFG_TIMEOUT
;
8186 uint32_t cfg_mask
= E1000_EEPROM_CFG_DONE
;
8188 DEBUGFUNC("e1000_get_phy_cfg_done");
8190 switch (hw
->mac_type
) {
8194 case e1000_80003es2lan
:
8196 /* Separate *_CFG_DONE_* bit for each port */
8197 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
)
8198 cfg_mask
= E1000_EEPROM_CFG_DONE_PORT_1
;
8203 if (E1000_READ_REG(hw
, EEMNGCTL
) & cfg_mask
)
8210 DEBUGOUT("MNG configuration cycle has not completed.\n");
8211 return -E1000_ERR_RESET
;
8216 return E1000_SUCCESS
;
8219 /***************************************************************************
8221 * Using the combination of SMBI and SWESMBI semaphore bits when resetting
8222 * adapter or Eeprom access.
8224 * hw: Struct containing variables accessed by shared code
8226 * returns: - E1000_ERR_EEPROM if fail to access EEPROM.
8227 * E1000_SUCCESS at any other case.
8229 ***************************************************************************/
8231 e1000_get_hw_eeprom_semaphore(struct e1000_hw
*hw
)
8236 DEBUGFUNC("e1000_get_hw_eeprom_semaphore");
8238 if (!hw
->eeprom_semaphore_present
)
8239 return E1000_SUCCESS
;
8241 if (hw
->mac_type
== e1000_80003es2lan
) {
8242 /* Get the SW semaphore. */
8243 if (e1000_get_software_semaphore(hw
) != E1000_SUCCESS
)
8244 return -E1000_ERR_EEPROM
;
8247 /* Get the FW semaphore. */
8248 timeout
= hw
->eeprom
.word_size
+ 1;
8250 swsm
= E1000_READ_REG(hw
, SWSM
);
8251 swsm
|= E1000_SWSM_SWESMBI
;
8252 E1000_WRITE_REG(hw
, SWSM
, swsm
);
8253 /* if we managed to set the bit we got the semaphore. */
8254 swsm
= E1000_READ_REG(hw
, SWSM
);
8255 if (swsm
& E1000_SWSM_SWESMBI
)
8263 /* Release semaphores */
8264 e1000_put_hw_eeprom_semaphore(hw
);
8265 DEBUGOUT("Driver can't access the Eeprom - SWESMBI bit is set.\n");
8266 return -E1000_ERR_EEPROM
;
8269 return E1000_SUCCESS
;
8272 /***************************************************************************
8273 * This function clears HW semaphore bits.
8275 * hw: Struct containing variables accessed by shared code
8279 ***************************************************************************/
8281 e1000_put_hw_eeprom_semaphore(struct e1000_hw
*hw
)
8285 DEBUGFUNC("e1000_put_hw_eeprom_semaphore");
8287 if (!hw
->eeprom_semaphore_present
)
8290 swsm
= E1000_READ_REG(hw
, SWSM
);
8291 if (hw
->mac_type
== e1000_80003es2lan
) {
8292 /* Release both semaphores. */
8293 swsm
&= ~(E1000_SWSM_SMBI
| E1000_SWSM_SWESMBI
);
8295 swsm
&= ~(E1000_SWSM_SWESMBI
);
8296 E1000_WRITE_REG(hw
, SWSM
, swsm
);
8299 /***************************************************************************
8301 * Obtaining software semaphore bit (SMBI) before resetting PHY.
8303 * hw: Struct containing variables accessed by shared code
8305 * returns: - E1000_ERR_RESET if fail to obtain semaphore.
8306 * E1000_SUCCESS at any other case.
8308 ***************************************************************************/
8310 e1000_get_software_semaphore(struct e1000_hw
*hw
)
8312 int32_t timeout
= hw
->eeprom
.word_size
+ 1;
8315 DEBUGFUNC("e1000_get_software_semaphore");
8317 if (hw
->mac_type
!= e1000_80003es2lan
) {
8318 return E1000_SUCCESS
;
8322 swsm
= E1000_READ_REG(hw
, SWSM
);
8323 /* If SMBI bit cleared, it is now set and we hold the semaphore */
8324 if (!(swsm
& E1000_SWSM_SMBI
))
8331 DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
8332 return -E1000_ERR_RESET
;
8335 return E1000_SUCCESS
;
8338 /***************************************************************************
8340 * Release semaphore bit (SMBI).
8342 * hw: Struct containing variables accessed by shared code
8344 ***************************************************************************/
8346 e1000_release_software_semaphore(struct e1000_hw
*hw
)
8350 DEBUGFUNC("e1000_release_software_semaphore");
8352 if (hw
->mac_type
!= e1000_80003es2lan
) {
8356 swsm
= E1000_READ_REG(hw
, SWSM
);
8357 /* Release the SW semaphores.*/
8358 swsm
&= ~E1000_SWSM_SMBI
;
8359 E1000_WRITE_REG(hw
, SWSM
, swsm
);
8362 /******************************************************************************
8363 * Checks if PHY reset is blocked due to SOL/IDER session, for example.
8364 * Returning E1000_BLK_PHY_RESET isn't necessarily an error. But it's up to
8365 * the caller to figure out how to deal with it.
8367 * hw - Struct containing variables accessed by shared code
8369 * returns: - E1000_BLK_PHY_RESET
8372 *****************************************************************************/
8374 e1000_check_phy_reset_block(struct e1000_hw
*hw
)
8379 if (hw
->mac_type
== e1000_ich8lan
) {
8380 fwsm
= E1000_READ_REG(hw
, FWSM
);
8381 return (fwsm
& E1000_FWSM_RSPCIPHY
) ? E1000_SUCCESS
8382 : E1000_BLK_PHY_RESET
;
8385 if (hw
->mac_type
> e1000_82547_rev_2
)
8386 manc
= E1000_READ_REG(hw
, MANC
);
8387 return (manc
& E1000_MANC_BLK_PHY_RST_ON_IDE
) ?
8388 E1000_BLK_PHY_RESET
: E1000_SUCCESS
;
8392 e1000_arc_subsystem_valid(struct e1000_hw
*hw
)
8396 /* On 8257x silicon, registers in the range of 0x8800 - 0x8FFC
8397 * may not be provided a DMA clock when no manageability features are
8398 * enabled. We do not want to perform any reads/writes to these registers
8399 * if this is the case. We read FWSM to determine the manageability mode.
8401 switch (hw
->mac_type
) {
8405 case e1000_80003es2lan
:
8407 fwsm
= E1000_READ_REG(hw
, FWSM
);
8408 if ((fwsm
& E1000_FWSM_MODE_MASK
) != 0)
8420 /******************************************************************************
8421 * Configure PCI-Ex no-snoop
8423 * hw - Struct containing variables accessed by shared code.
8424 * no_snoop - Bitmap of no-snoop events.
8426 * returns: E1000_SUCCESS
8428 *****************************************************************************/
8430 e1000_set_pci_ex_no_snoop(struct e1000_hw
*hw
, uint32_t no_snoop
)
8432 uint32_t gcr_reg
= 0;
8434 DEBUGFUNC("e1000_set_pci_ex_no_snoop");
8436 if (hw
->bus_type
== e1000_bus_type_unknown
)
8437 e1000_get_bus_info(hw
);
8439 if (hw
->bus_type
!= e1000_bus_type_pci_express
)
8440 return E1000_SUCCESS
;
8443 gcr_reg
= E1000_READ_REG(hw
, GCR
);
8444 gcr_reg
&= ~(PCI_EX_NO_SNOOP_ALL
);
8445 gcr_reg
|= no_snoop
;
8446 E1000_WRITE_REG(hw
, GCR
, gcr_reg
);
8448 if (hw
->mac_type
== e1000_ich8lan
) {
8451 E1000_WRITE_REG(hw
, GCR
, PCI_EX_82566_SNOOP_ALL
);
8453 ctrl_ext
= E1000_READ_REG(hw
, CTRL_EXT
);
8454 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
8455 E1000_WRITE_REG(hw
, CTRL_EXT
, ctrl_ext
);
8458 return E1000_SUCCESS
;
8461 /***************************************************************************
8463 * Get software semaphore FLAG bit (SWFLAG).
8464 * SWFLAG is used to synchronize the access to all shared resource between
8467 * hw: Struct containing variables accessed by shared code
8469 ***************************************************************************/
8471 e1000_get_software_flag(struct e1000_hw
*hw
)
8473 int32_t timeout
= PHY_CFG_TIMEOUT
;
8474 uint32_t extcnf_ctrl
;
8476 DEBUGFUNC("e1000_get_software_flag");
8478 if (hw
->mac_type
== e1000_ich8lan
) {
8480 extcnf_ctrl
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
8481 extcnf_ctrl
|= E1000_EXTCNF_CTRL_SWFLAG
;
8482 E1000_WRITE_REG(hw
, EXTCNF_CTRL
, extcnf_ctrl
);
8484 extcnf_ctrl
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
8485 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
)
8492 DEBUGOUT("FW or HW locks the resource too long.\n");
8493 return -E1000_ERR_CONFIG
;
8497 return E1000_SUCCESS
;
8500 /***************************************************************************
8502 * Release software semaphore FLAG bit (SWFLAG).
8503 * SWFLAG is used to synchronize the access to all shared resource between
8506 * hw: Struct containing variables accessed by shared code
8508 ***************************************************************************/
8510 e1000_release_software_flag(struct e1000_hw
*hw
)
8512 uint32_t extcnf_ctrl
;
8514 DEBUGFUNC("e1000_release_software_flag");
8516 if (hw
->mac_type
== e1000_ich8lan
) {
8517 extcnf_ctrl
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
8518 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
8519 E1000_WRITE_REG(hw
, EXTCNF_CTRL
, extcnf_ctrl
);
8525 /******************************************************************************
8526 * Reads a 16 bit word or words from the EEPROM using the ICH8's flash access
8529 * hw - Struct containing variables accessed by shared code
8530 * offset - offset of word in the EEPROM to read
8531 * data - word read from the EEPROM
8532 * words - number of words to read
8533 *****************************************************************************/
8535 e1000_read_eeprom_ich8(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
,
8538 int32_t error
= E1000_SUCCESS
;
8539 uint32_t flash_bank
= 0;
8540 uint32_t act_offset
= 0;
8541 uint32_t bank_offset
= 0;
8545 /* We need to know which is the valid flash bank. In the event
8546 * that we didn't allocate eeprom_shadow_ram, we may not be
8547 * managing flash_bank. So it cannot be trusted and needs
8548 * to be updated with each read.
8550 /* Value of bit 22 corresponds to the flash bank we're on. */
8551 flash_bank
= (E1000_READ_REG(hw
, EECD
) & E1000_EECD_SEC1VAL
) ? 1 : 0;
8553 /* Adjust offset appropriately if we're on bank 1 - adjust for word size */
8554 bank_offset
= flash_bank
* (hw
->flash_bank_size
* 2);
8556 error
= e1000_get_software_flag(hw
);
8557 if (error
!= E1000_SUCCESS
)
8560 for (i
= 0; i
< words
; i
++) {
8561 if (hw
->eeprom_shadow_ram
!= NULL
&&
8562 hw
->eeprom_shadow_ram
[offset
+i
].modified
== TRUE
) {
8563 data
[i
] = hw
->eeprom_shadow_ram
[offset
+i
].eeprom_word
;
8565 /* The NVM part needs a byte offset, hence * 2 */
8566 act_offset
= bank_offset
+ ((offset
+ i
) * 2);
8567 error
= e1000_read_ich8_word(hw
, act_offset
, &word
);
8568 if (error
!= E1000_SUCCESS
)
8574 e1000_release_software_flag(hw
);
8579 /******************************************************************************
8580 * Writes a 16 bit word or words to the EEPROM using the ICH8's flash access
8581 * register. Actually, writes are written to the shadow ram cache in the hw
8582 * structure hw->e1000_shadow_ram. e1000_commit_shadow_ram flushes this to
8583 * the NVM, which occurs when the NVM checksum is updated.
8585 * hw - Struct containing variables accessed by shared code
8586 * offset - offset of word in the EEPROM to write
8587 * words - number of words to write
8588 * data - words to write to the EEPROM
8589 *****************************************************************************/
8591 e1000_write_eeprom_ich8(struct e1000_hw
*hw
, uint16_t offset
, uint16_t words
,
8595 int32_t error
= E1000_SUCCESS
;
8597 error
= e1000_get_software_flag(hw
);
8598 if (error
!= E1000_SUCCESS
)
8601 /* A driver can write to the NVM only if it has eeprom_shadow_ram
8602 * allocated. Subsequent reads to the modified words are read from
8603 * this cached structure as well. Writes will only go into this
8604 * cached structure unless it's followed by a call to
8605 * e1000_update_eeprom_checksum() where it will commit the changes
8606 * and clear the "modified" field.
8608 if (hw
->eeprom_shadow_ram
!= NULL
) {
8609 for (i
= 0; i
< words
; i
++) {
8610 if ((offset
+ i
) < E1000_SHADOW_RAM_WORDS
) {
8611 hw
->eeprom_shadow_ram
[offset
+i
].modified
= TRUE
;
8612 hw
->eeprom_shadow_ram
[offset
+i
].eeprom_word
= data
[i
];
8614 error
= -E1000_ERR_EEPROM
;
8619 /* Drivers have the option to not allocate eeprom_shadow_ram as long
8620 * as they don't perform any NVM writes. An attempt in doing so
8621 * will result in this error.
8623 error
= -E1000_ERR_EEPROM
;
8626 e1000_release_software_flag(hw
);
8631 /******************************************************************************
8632 * This function does initial flash setup so that a new read/write/erase cycle
8635 * hw - The pointer to the hw structure
8636 ****************************************************************************/
8638 e1000_ich8_cycle_init(struct e1000_hw
*hw
)
8640 union ich8_hws_flash_status hsfsts
;
8641 int32_t error
= E1000_ERR_EEPROM
;
8644 DEBUGFUNC("e1000_ich8_cycle_init");
8646 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
8648 /* May be check the Flash Des Valid bit in Hw status */
8649 if (hsfsts
.hsf_status
.fldesvalid
== 0) {
8650 DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used.");
8654 /* Clear FCERR in Hw status by writing 1 */
8655 /* Clear DAEL in Hw status by writing a 1 */
8656 hsfsts
.hsf_status
.flcerr
= 1;
8657 hsfsts
.hsf_status
.dael
= 1;
8659 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
, hsfsts
.regval
);
8661 /* Either we should have a hardware SPI cycle in progress bit to check
8662 * against, in order to start a new cycle or FDONE bit should be changed
8663 * in the hardware so that it is 1 after harware reset, which can then be
8664 * used as an indication whether a cycle is in progress or has been
8665 * completed .. we should also have some software semaphore mechanism to
8666 * guard FDONE or the cycle in progress bit so that two threads access to
8667 * those bits can be sequentiallized or a way so that 2 threads dont
8668 * start the cycle at the same time */
8670 if (hsfsts
.hsf_status
.flcinprog
== 0) {
8671 /* There is no cycle running at present, so we can start a cycle */
8672 /* Begin by setting Flash Cycle Done. */
8673 hsfsts
.hsf_status
.flcdone
= 1;
8674 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
, hsfsts
.regval
);
8675 error
= E1000_SUCCESS
;
8677 /* otherwise poll for sometime so the current cycle has a chance
8678 * to end before giving up. */
8679 for (i
= 0; i
< ICH_FLASH_COMMAND_TIMEOUT
; i
++) {
8680 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
8681 if (hsfsts
.hsf_status
.flcinprog
== 0) {
8682 error
= E1000_SUCCESS
;
8687 if (error
== E1000_SUCCESS
) {
8688 /* Successful in waiting for previous cycle to timeout,
8689 * now set the Flash Cycle Done. */
8690 hsfsts
.hsf_status
.flcdone
= 1;
8691 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
, hsfsts
.regval
);
8693 DEBUGOUT("Flash controller busy, cannot get access");
8699 /******************************************************************************
8700 * This function starts a flash cycle and waits for its completion
8702 * hw - The pointer to the hw structure
8703 ****************************************************************************/
8705 e1000_ich8_flash_cycle(struct e1000_hw
*hw
, uint32_t timeout
)
8707 union ich8_hws_flash_ctrl hsflctl
;
8708 union ich8_hws_flash_status hsfsts
;
8709 int32_t error
= E1000_ERR_EEPROM
;
8712 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
8713 hsflctl
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
);
8714 hsflctl
.hsf_ctrl
.flcgo
= 1;
8715 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
, hsflctl
.regval
);
8717 /* wait till FDONE bit is set to 1 */
8719 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
8720 if (hsfsts
.hsf_status
.flcdone
== 1)
8724 } while (i
< timeout
);
8725 if (hsfsts
.hsf_status
.flcdone
== 1 && hsfsts
.hsf_status
.flcerr
== 0) {
8726 error
= E1000_SUCCESS
;
8731 /******************************************************************************
8732 * Reads a byte or word from the NVM using the ICH8 flash access registers.
8734 * hw - The pointer to the hw structure
8735 * index - The index of the byte or word to read.
8736 * size - Size of data to read, 1=byte 2=word
8737 * data - Pointer to the word to store the value read.
8738 *****************************************************************************/
8740 e1000_read_ich8_data(struct e1000_hw
*hw
, uint32_t index
,
8741 uint32_t size
, uint16_t* data
)
8743 union ich8_hws_flash_status hsfsts
;
8744 union ich8_hws_flash_ctrl hsflctl
;
8745 uint32_t flash_linear_address
;
8746 uint32_t flash_data
= 0;
8747 int32_t error
= -E1000_ERR_EEPROM
;
8750 DEBUGFUNC("e1000_read_ich8_data");
8752 if (size
< 1 || size
> 2 || data
== 0x0 ||
8753 index
> ICH_FLASH_LINEAR_ADDR_MASK
)
8756 flash_linear_address
= (ICH_FLASH_LINEAR_ADDR_MASK
& index
) +
8757 hw
->flash_base_addr
;
8762 error
= e1000_ich8_cycle_init(hw
);
8763 if (error
!= E1000_SUCCESS
)
8766 hsflctl
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
);
8767 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8768 hsflctl
.hsf_ctrl
.fldbcount
= size
- 1;
8769 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_READ
;
8770 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
, hsflctl
.regval
);
8772 /* Write the last 24 bits of index into Flash Linear address field in
8774 /* TODO: TBD maybe check the index against the size of flash */
8776 E1000_WRITE_ICH_FLASH_REG(hw
, ICH_FLASH_FADDR
, flash_linear_address
);
8778 error
= e1000_ich8_flash_cycle(hw
, ICH_FLASH_COMMAND_TIMEOUT
);
8780 /* Check if FCERR is set to 1, if set to 1, clear it and try the whole
8781 * sequence a few more times, else read in (shift in) the Flash Data0,
8782 * the order is least significant byte first msb to lsb */
8783 if (error
== E1000_SUCCESS
) {
8784 flash_data
= E1000_READ_ICH_FLASH_REG(hw
, ICH_FLASH_FDATA0
);
8786 *data
= (uint8_t)(flash_data
& 0x000000FF);
8787 } else if (size
== 2) {
8788 *data
= (uint16_t)(flash_data
& 0x0000FFFF);
8792 /* If we've gotten here, then things are probably completely hosed,
8793 * but if the error condition is detected, it won't hurt to give
8794 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8796 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
8797 if (hsfsts
.hsf_status
.flcerr
== 1) {
8798 /* Repeat for some time before giving up. */
8800 } else if (hsfsts
.hsf_status
.flcdone
== 0) {
8801 DEBUGOUT("Timeout error - flash cycle did not complete.");
8805 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
8810 /******************************************************************************
8811 * Writes One /two bytes to the NVM using the ICH8 flash access registers.
8813 * hw - The pointer to the hw structure
8814 * index - The index of the byte/word to read.
8815 * size - Size of data to read, 1=byte 2=word
8816 * data - The byte(s) to write to the NVM.
8817 *****************************************************************************/
8819 e1000_write_ich8_data(struct e1000_hw
*hw
, uint32_t index
, uint32_t size
,
8822 union ich8_hws_flash_status hsfsts
;
8823 union ich8_hws_flash_ctrl hsflctl
;
8824 uint32_t flash_linear_address
;
8825 uint32_t flash_data
= 0;
8826 int32_t error
= -E1000_ERR_EEPROM
;
8829 DEBUGFUNC("e1000_write_ich8_data");
8831 if (size
< 1 || size
> 2 || data
> size
* 0xff ||
8832 index
> ICH_FLASH_LINEAR_ADDR_MASK
)
8835 flash_linear_address
= (ICH_FLASH_LINEAR_ADDR_MASK
& index
) +
8836 hw
->flash_base_addr
;
8841 error
= e1000_ich8_cycle_init(hw
);
8842 if (error
!= E1000_SUCCESS
)
8845 hsflctl
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
);
8846 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8847 hsflctl
.hsf_ctrl
.fldbcount
= size
-1;
8848 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_WRITE
;
8849 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
, hsflctl
.regval
);
8851 /* Write the last 24 bits of index into Flash Linear address field in
8853 E1000_WRITE_ICH_FLASH_REG(hw
, ICH_FLASH_FADDR
, flash_linear_address
);
8856 flash_data
= (uint32_t)data
& 0x00FF;
8858 flash_data
= (uint32_t)data
;
8860 E1000_WRITE_ICH_FLASH_REG(hw
, ICH_FLASH_FDATA0
, flash_data
);
8862 /* check if FCERR is set to 1 , if set to 1, clear it and try the whole
8863 * sequence a few more times else done */
8864 error
= e1000_ich8_flash_cycle(hw
, ICH_FLASH_COMMAND_TIMEOUT
);
8865 if (error
== E1000_SUCCESS
) {
8868 /* If we're here, then things are most likely completely hosed,
8869 * but if the error condition is detected, it won't hurt to give
8870 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8872 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
8873 if (hsfsts
.hsf_status
.flcerr
== 1) {
8874 /* Repeat for some time before giving up. */
8876 } else if (hsfsts
.hsf_status
.flcdone
== 0) {
8877 DEBUGOUT("Timeout error - flash cycle did not complete.");
8881 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
8886 /******************************************************************************
8887 * Reads a single byte from the NVM using the ICH8 flash access registers.
8889 * hw - pointer to e1000_hw structure
8890 * index - The index of the byte to read.
8891 * data - Pointer to a byte to store the value read.
8892 *****************************************************************************/
8894 e1000_read_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t* data
)
8896 int32_t status
= E1000_SUCCESS
;
8899 status
= e1000_read_ich8_data(hw
, index
, 1, &word
);
8900 if (status
== E1000_SUCCESS
) {
8901 *data
= (uint8_t)word
;
8907 /******************************************************************************
8908 * Writes a single byte to the NVM using the ICH8 flash access registers.
8909 * Performs verification by reading back the value and then going through
8910 * a retry algorithm before giving up.
8912 * hw - pointer to e1000_hw structure
8913 * index - The index of the byte to write.
8914 * byte - The byte to write to the NVM.
8915 *****************************************************************************/
8917 e1000_verify_write_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t byte
)
8919 int32_t error
= E1000_SUCCESS
;
8920 int32_t program_retries
= 0;
8922 DEBUGOUT2("Byte := %2.2X Offset := %d\n", byte
, index
);
8924 error
= e1000_write_ich8_byte(hw
, index
, byte
);
8926 if (error
!= E1000_SUCCESS
) {
8927 for (program_retries
= 0; program_retries
< 100; program_retries
++) {
8928 DEBUGOUT2("Retrying \t Byte := %2.2X Offset := %d\n", byte
, index
);
8929 error
= e1000_write_ich8_byte(hw
, index
, byte
);
8931 if (error
== E1000_SUCCESS
)
8936 if (program_retries
== 100)
8937 error
= E1000_ERR_EEPROM
;
8942 /******************************************************************************
8943 * Writes a single byte to the NVM using the ICH8 flash access registers.
8945 * hw - pointer to e1000_hw structure
8946 * index - The index of the byte to read.
8947 * data - The byte to write to the NVM.
8948 *****************************************************************************/
8950 e1000_write_ich8_byte(struct e1000_hw
*hw
, uint32_t index
, uint8_t data
)
8952 int32_t status
= E1000_SUCCESS
;
8953 uint16_t word
= (uint16_t)data
;
8955 status
= e1000_write_ich8_data(hw
, index
, 1, word
);
8960 /******************************************************************************
8961 * Reads a word from the NVM using the ICH8 flash access registers.
8963 * hw - pointer to e1000_hw structure
8964 * index - The starting byte index of the word to read.
8965 * data - Pointer to a word to store the value read.
8966 *****************************************************************************/
8968 e1000_read_ich8_word(struct e1000_hw
*hw
, uint32_t index
, uint16_t *data
)
8970 int32_t status
= E1000_SUCCESS
;
8971 status
= e1000_read_ich8_data(hw
, index
, 2, data
);
8975 /******************************************************************************
8976 * Erases the bank specified. Each bank may be a 4, 8 or 64k block. Banks are 0
8979 * hw - pointer to e1000_hw structure
8980 * bank - 0 for first bank, 1 for second bank
8982 * Note that this function may actually erase as much as 8 or 64 KBytes. The
8983 * amount of NVM used in each bank is a *minimum* of 4 KBytes, but in fact the
8984 * bank size may be 4, 8 or 64 KBytes
8985 *****************************************************************************/
8987 e1000_erase_ich8_4k_segment(struct e1000_hw
*hw
, uint32_t bank
)
8989 union ich8_hws_flash_status hsfsts
;
8990 union ich8_hws_flash_ctrl hsflctl
;
8991 uint32_t flash_linear_address
;
8993 int32_t error
= E1000_ERR_EEPROM
;
8995 int32_t sub_sector_size
= 0;
8998 int32_t error_flag
= 0;
9000 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
9002 /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */
9003 /* 00: The Hw sector is 256 bytes, hence we need to erase 16
9004 * consecutive sectors. The start index for the nth Hw sector can be
9005 * calculated as bank * 4096 + n * 256
9006 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
9007 * The start index for the nth Hw sector can be calculated
9009 * 10: The HW sector is 8K bytes
9010 * 11: The Hw sector size is 64K bytes */
9011 if (hsfsts
.hsf_status
.berasesz
== 0x0) {
9012 /* Hw sector size 256 */
9013 sub_sector_size
= ICH_FLASH_SEG_SIZE_256
;
9014 bank_size
= ICH_FLASH_SECTOR_SIZE
;
9015 iteration
= ICH_FLASH_SECTOR_SIZE
/ ICH_FLASH_SEG_SIZE_256
;
9016 } else if (hsfsts
.hsf_status
.berasesz
== 0x1) {
9017 bank_size
= ICH_FLASH_SEG_SIZE_4K
;
9019 } else if (hsfsts
.hsf_status
.berasesz
== 0x3) {
9020 bank_size
= ICH_FLASH_SEG_SIZE_64K
;
9026 for (j
= 0; j
< iteration
; j
++) {
9030 error
= e1000_ich8_cycle_init(hw
);
9031 if (error
!= E1000_SUCCESS
) {
9036 /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash
9038 hsflctl
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
);
9039 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_ERASE
;
9040 E1000_WRITE_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFCTL
, hsflctl
.regval
);
9042 /* Write the last 24 bits of an index within the block into Flash
9043 * Linear address field in Flash Address. This probably needs to
9044 * be calculated here based off the on-chip erase sector size and
9045 * the software bank size (4, 8 or 64 KBytes) */
9046 flash_linear_address
= bank
* bank_size
+ j
* sub_sector_size
;
9047 flash_linear_address
+= hw
->flash_base_addr
;
9048 flash_linear_address
&= ICH_FLASH_LINEAR_ADDR_MASK
;
9050 E1000_WRITE_ICH_FLASH_REG(hw
, ICH_FLASH_FADDR
, flash_linear_address
);
9052 error
= e1000_ich8_flash_cycle(hw
, ICH_FLASH_ERASE_TIMEOUT
);
9053 /* Check if FCERR is set to 1. If 1, clear it and try the whole
9054 * sequence a few more times else Done */
9055 if (error
== E1000_SUCCESS
) {
9058 hsfsts
.regval
= E1000_READ_ICH_FLASH_REG16(hw
, ICH_FLASH_HSFSTS
);
9059 if (hsfsts
.hsf_status
.flcerr
== 1) {
9060 /* repeat for some time before giving up */
9062 } else if (hsfsts
.hsf_status
.flcdone
== 0) {
9067 } while ((count
< ICH_FLASH_CYCLE_REPEAT_COUNT
) && !error_flag
);
9068 if (error_flag
== 1)
9071 if (error_flag
!= 1)
9072 error
= E1000_SUCCESS
;
9077 e1000_init_lcd_from_nvm_config_region(struct e1000_hw
*hw
,
9078 uint32_t cnf_base_addr
, uint32_t cnf_size
)
9080 uint32_t ret_val
= E1000_SUCCESS
;
9081 uint16_t word_addr
, reg_data
, reg_addr
;
9084 /* cnf_base_addr is in DWORD */
9085 word_addr
= (uint16_t)(cnf_base_addr
<< 1);
9087 /* cnf_size is returned in size of dwords */
9088 for (i
= 0; i
< cnf_size
; i
++) {
9089 ret_val
= e1000_read_eeprom(hw
, (word_addr
+ i
*2), 1, ®_data
);
9093 ret_val
= e1000_read_eeprom(hw
, (word_addr
+ i
*2 + 1), 1, ®_addr
);
9097 ret_val
= e1000_get_software_flag(hw
);
9098 if (ret_val
!= E1000_SUCCESS
)
9101 ret_val
= e1000_write_phy_reg_ex(hw
, (uint32_t)reg_addr
, reg_data
);
9103 e1000_release_software_flag(hw
);
9110 /******************************************************************************
9111 * This function initializes the PHY from the NVM on ICH8 platforms. This
9112 * is needed due to an issue where the NVM configuration is not properly
9113 * autoloaded after power transitions. Therefore, after each PHY reset, we
9114 * will load the configuration data out of the NVM manually.
9116 * hw: Struct containing variables accessed by shared code
9117 *****************************************************************************/
9119 e1000_init_lcd_from_nvm(struct e1000_hw
*hw
)
9121 uint32_t reg_data
, cnf_base_addr
, cnf_size
, ret_val
, loop
;
9123 if (hw
->phy_type
!= e1000_phy_igp_3
)
9124 return E1000_SUCCESS
;
9126 /* Check if SW needs configure the PHY */
9127 reg_data
= E1000_READ_REG(hw
, FEXTNVM
);
9128 if (!(reg_data
& FEXTNVM_SW_CONFIG
))
9129 return E1000_SUCCESS
;
9131 /* Wait for basic configuration completes before proceeding*/
9134 reg_data
= E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_LAN_INIT_DONE
;
9137 } while ((!reg_data
) && (loop
< 50));
9139 /* Clear the Init Done bit for the next init event */
9140 reg_data
= E1000_READ_REG(hw
, STATUS
);
9141 reg_data
&= ~E1000_STATUS_LAN_INIT_DONE
;
9142 E1000_WRITE_REG(hw
, STATUS
, reg_data
);
9144 /* Make sure HW does not configure LCD from PHY extended configuration
9145 before SW configuration */
9146 reg_data
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
9147 if ((reg_data
& E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE
) == 0x0000) {
9148 reg_data
= E1000_READ_REG(hw
, EXTCNF_SIZE
);
9149 cnf_size
= reg_data
& E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH
;
9152 reg_data
= E1000_READ_REG(hw
, EXTCNF_CTRL
);
9153 cnf_base_addr
= reg_data
& E1000_EXTCNF_CTRL_EXT_CNF_POINTER
;
9154 /* cnf_base_addr is in DWORD */
9155 cnf_base_addr
>>= 16;
9157 /* Configure LCD from extended configuration region. */
9158 ret_val
= e1000_init_lcd_from_nvm_config_region(hw
, cnf_base_addr
,
9165 return E1000_SUCCESS
;