1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 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_OR_LATER
);
32 * 82543GC Gigabit Ethernet Controller (Fiber)
33 * 82543GC Gigabit Ethernet Controller (Copper)
34 * 82544EI Gigabit Ethernet Controller (Copper)
35 * 82544EI Gigabit Ethernet Controller (Fiber)
36 * 82544GC Gigabit Ethernet Controller (Copper)
37 * 82544GC Gigabit Ethernet Controller (LOM)
40 #include "e1000_api.h"
42 static s32
e1000_init_phy_params_82543(struct e1000_hw
*hw
);
43 static s32
e1000_init_nvm_params_82543(struct e1000_hw
*hw
);
44 static s32
e1000_init_mac_params_82543(struct e1000_hw
*hw
);
45 static s32
e1000_read_phy_reg_82543(struct e1000_hw
*hw
, u32 offset
,
47 static s32
e1000_write_phy_reg_82543(struct e1000_hw
*hw
, u32 offset
,
50 static s32
e1000_phy_force_speed_duplex_82543(struct e1000_hw
*hw
);
52 static s32
e1000_phy_hw_reset_82543(struct e1000_hw
*hw
);
53 static s32
e1000_reset_hw_82543(struct e1000_hw
*hw
);
54 static s32
e1000_init_hw_82543(struct e1000_hw
*hw
);
55 static s32
e1000_setup_link_82543(struct e1000_hw
*hw
);
56 static s32
e1000_setup_copper_link_82543(struct e1000_hw
*hw
);
57 static s32
e1000_setup_fiber_link_82543(struct e1000_hw
*hw
);
58 static s32
e1000_check_for_copper_link_82543(struct e1000_hw
*hw
);
59 static s32
e1000_check_for_fiber_link_82543(struct e1000_hw
*hw
);
60 static s32
e1000_led_on_82543(struct e1000_hw
*hw
);
61 static s32
e1000_led_off_82543(struct e1000_hw
*hw
);
62 static void e1000_write_vfta_82543(struct e1000_hw
*hw
, u32 offset
,
64 static void e1000_mta_set_82543(struct e1000_hw
*hw
, u32 hash_value
);
65 static void e1000_clear_hw_cntrs_82543(struct e1000_hw
*hw
);
66 static s32
e1000_config_mac_to_phy_82543(struct e1000_hw
*hw
);
67 static bool e1000_init_phy_disabled_82543(struct e1000_hw
*hw
);
68 static void e1000_lower_mdi_clk_82543(struct e1000_hw
*hw
, u32
*ctrl
);
69 static s32
e1000_polarity_reversal_workaround_82543(struct e1000_hw
*hw
);
70 static void e1000_raise_mdi_clk_82543(struct e1000_hw
*hw
, u32
*ctrl
);
71 static u16
e1000_shift_in_mdi_bits_82543(struct e1000_hw
*hw
);
72 static void e1000_shift_out_mdi_bits_82543(struct e1000_hw
*hw
, u32 data
,
74 static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw
*hw
);
75 static void e1000_set_tbi_compatibility_82543(struct e1000_hw
*hw
, bool state
);
76 static void e1000_set_tbi_sbp_82543(struct e1000_hw
*hw
, bool state
);
79 * e1000_init_phy_params_82543 - Init PHY func ptrs.
80 * @hw: pointer to the HW structure
82 static s32
e1000_init_phy_params_82543(struct e1000_hw
*hw
)
84 struct e1000_phy_info
*phy
= &hw
->phy
;
85 s32 ret_val
= E1000_SUCCESS
;
87 DEBUGFUNC("e1000_init_phy_params_82543");
89 if (hw
->phy
.media_type
!= e1000_media_type_copper
) {
90 phy
->type
= e1000_phy_none
;
93 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
94 phy
->ops
.power_down
= e1000_power_down_phy_copper
;
98 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
99 phy
->reset_delay_us
= 10000;
100 phy
->type
= e1000_phy_m88
;
102 /* Function Pointers */
103 phy
->ops
.check_polarity
= e1000_check_polarity_m88
;
104 phy
->ops
.commit
= e1000_phy_sw_reset_generic
;
106 phy
->ops
.force_speed_duplex
= e1000_phy_force_speed_duplex_82543
;
109 phy
->ops
.get_cable_length
= e1000_get_cable_length_m88
;
111 phy
->ops
.get_cfg_done
= e1000_get_cfg_done_generic
;
112 phy
->ops
.read_reg
= (hw
->mac
.type
== e1000_82543
)
113 ? e1000_read_phy_reg_82543
114 : e1000_read_phy_reg_m88
;
115 phy
->ops
.reset
= (hw
->mac
.type
== e1000_82543
)
116 ? e1000_phy_hw_reset_82543
117 : e1000_phy_hw_reset_generic
;
118 phy
->ops
.write_reg
= (hw
->mac
.type
== e1000_82543
)
119 ? e1000_write_phy_reg_82543
120 : e1000_write_phy_reg_m88
;
121 phy
->ops
.get_info
= e1000_get_phy_info_m88
;
124 * The external PHY of the 82543 can be in a funky state.
125 * Resetting helps us read the PHY registers for acquiring
128 if (!e1000_init_phy_disabled_82543(hw
)) {
129 ret_val
= phy
->ops
.reset(hw
);
131 DEBUGOUT("Resetting PHY during init failed.\n");
137 ret_val
= e1000_get_phy_id(hw
);
142 switch (hw
->mac
.type
) {
144 if (phy
->id
!= M88E1000_E_PHY_ID
) {
145 ret_val
= -E1000_ERR_PHY
;
150 if (phy
->id
!= M88E1000_I_PHY_ID
) {
151 ret_val
= -E1000_ERR_PHY
;
156 ret_val
= -E1000_ERR_PHY
;
166 * e1000_init_nvm_params_82543 - Init NVM func ptrs.
167 * @hw: pointer to the HW structure
169 static s32
e1000_init_nvm_params_82543(struct e1000_hw
*hw
)
171 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
173 DEBUGFUNC("e1000_init_nvm_params_82543");
175 nvm
->type
= e1000_nvm_eeprom_microwire
;
177 nvm
->delay_usec
= 50;
178 nvm
->address_bits
= 6;
179 nvm
->opcode_bits
= 3;
181 /* Function Pointers */
182 nvm
->ops
.read
= e1000_read_nvm_microwire
;
183 nvm
->ops
.update
= e1000_update_nvm_checksum_generic
;
184 nvm
->ops
.valid_led_default
= e1000_valid_led_default_generic
;
185 nvm
->ops
.validate
= e1000_validate_nvm_checksum_generic
;
186 nvm
->ops
.write
= e1000_write_nvm_microwire
;
188 return E1000_SUCCESS
;
192 * e1000_init_mac_params_82543 - Init MAC func ptrs.
193 * @hw: pointer to the HW structure
195 static s32
e1000_init_mac_params_82543(struct e1000_hw
*hw
)
197 struct e1000_mac_info
*mac
= &hw
->mac
;
199 DEBUGFUNC("e1000_init_mac_params_82543");
202 switch (hw
->device_id
) {
203 case E1000_DEV_ID_82543GC_FIBER
:
204 case E1000_DEV_ID_82544EI_FIBER
:
205 hw
->phy
.media_type
= e1000_media_type_fiber
;
208 hw
->phy
.media_type
= e1000_media_type_copper
;
212 /* Set mta register count */
213 mac
->mta_reg_count
= 128;
214 /* Set rar entry count */
215 mac
->rar_entry_count
= E1000_RAR_ENTRIES
;
217 /* Function pointers */
219 /* bus type/speed/width */
220 mac
->ops
.get_bus_info
= e1000_get_bus_info_pci_generic
;
222 mac
->ops
.set_lan_id
= e1000_set_lan_id_multi_port_pci
;
224 mac
->ops
.reset_hw
= e1000_reset_hw_82543
;
225 /* hw initialization */
226 mac
->ops
.init_hw
= e1000_init_hw_82543
;
228 mac
->ops
.setup_link
= e1000_setup_link_82543
;
229 /* physical interface setup */
230 mac
->ops
.setup_physical_interface
=
231 (hw
->phy
.media_type
== e1000_media_type_copper
)
232 ? e1000_setup_copper_link_82543
233 : e1000_setup_fiber_link_82543
;
235 mac
->ops
.check_for_link
=
236 (hw
->phy
.media_type
== e1000_media_type_copper
)
237 ? e1000_check_for_copper_link_82543
238 : e1000_check_for_fiber_link_82543
;
240 mac
->ops
.get_link_up_info
=
241 (hw
->phy
.media_type
== e1000_media_type_copper
)
242 ? e1000_get_speed_and_duplex_copper_generic
243 : e1000_get_speed_and_duplex_fiber_serdes_generic
;
244 /* multicast address update */
245 mac
->ops
.update_mc_addr_list
= e1000_update_mc_addr_list_generic
;
247 mac
->ops
.write_vfta
= e1000_write_vfta_82543
;
249 mac
->ops
.clear_vfta
= e1000_clear_vfta_generic
;
251 mac
->ops
.mta_set
= e1000_mta_set_82543
;
252 /* turn on/off LED */
253 mac
->ops
.led_on
= e1000_led_on_82543
;
254 mac
->ops
.led_off
= e1000_led_off_82543
;
255 /* clear hardware counters */
256 mac
->ops
.clear_hw_cntrs
= e1000_clear_hw_cntrs_82543
;
258 /* Set tbi compatibility */
259 if ((hw
->mac
.type
!= e1000_82543
) ||
260 (hw
->phy
.media_type
== e1000_media_type_fiber
))
261 e1000_set_tbi_compatibility_82543(hw
, false);
263 return E1000_SUCCESS
;
267 * e1000_init_function_pointers_82543 - Init func ptrs.
268 * @hw: pointer to the HW structure
270 * Called to initialize all function pointers and parameters.
272 void e1000_init_function_pointers_82543(struct e1000_hw
*hw
)
274 DEBUGFUNC("e1000_init_function_pointers_82543");
276 hw
->mac
.ops
.init_params
= e1000_init_mac_params_82543
;
277 hw
->nvm
.ops
.init_params
= e1000_init_nvm_params_82543
;
278 hw
->phy
.ops
.init_params
= e1000_init_phy_params_82543
;
282 * e1000_tbi_compatibility_enabled_82543 - Returns TBI compat status
283 * @hw: pointer to the HW structure
285 * Returns the current status of 10-bit Interface (TBI) compatibility
286 * (enabled/disabled).
288 static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw
*hw
)
290 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
293 DEBUGFUNC("e1000_tbi_compatibility_enabled_82543");
295 if (hw
->mac
.type
!= e1000_82543
) {
296 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
300 state
= (dev_spec
->tbi_compatibility
& TBI_COMPAT_ENABLED
)
308 * e1000_set_tbi_compatibility_82543 - Set TBI compatibility
309 * @hw: pointer to the HW structure
310 * @state: enable/disable TBI compatibility
312 * Enables or disabled 10-bit Interface (TBI) compatibility.
314 static void e1000_set_tbi_compatibility_82543(struct e1000_hw
*hw
, bool state
)
316 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
318 DEBUGFUNC("e1000_set_tbi_compatibility_82543");
320 if (hw
->mac
.type
!= e1000_82543
) {
321 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
326 dev_spec
->tbi_compatibility
|= TBI_COMPAT_ENABLED
;
328 dev_spec
->tbi_compatibility
&= ~TBI_COMPAT_ENABLED
;
335 * e1000_tbi_sbp_enabled_82543 - Returns TBI SBP status
336 * @hw: pointer to the HW structure
338 * Returns the current status of 10-bit Interface (TBI) store bad packet (SBP)
339 * (enabled/disabled).
341 bool e1000_tbi_sbp_enabled_82543(struct e1000_hw
*hw
)
343 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
346 DEBUGFUNC("e1000_tbi_sbp_enabled_82543");
348 if (hw
->mac
.type
!= e1000_82543
) {
349 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
353 state
= (dev_spec
->tbi_compatibility
& TBI_SBP_ENABLED
)
361 * e1000_set_tbi_sbp_82543 - Set TBI SBP
362 * @hw: pointer to the HW structure
363 * @state: enable/disable TBI store bad packet
365 * Enables or disabled 10-bit Interface (TBI) store bad packet (SBP).
367 static void e1000_set_tbi_sbp_82543(struct e1000_hw
*hw
, bool state
)
369 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
371 DEBUGFUNC("e1000_set_tbi_sbp_82543");
373 if (state
&& e1000_tbi_compatibility_enabled_82543(hw
))
374 dev_spec
->tbi_compatibility
|= TBI_SBP_ENABLED
;
376 dev_spec
->tbi_compatibility
&= ~TBI_SBP_ENABLED
;
382 * e1000_init_phy_disabled_82543 - Returns init PHY status
383 * @hw: pointer to the HW structure
385 * Returns the current status of whether PHY initialization is disabled.
386 * True if PHY initialization is disabled else false.
388 static bool e1000_init_phy_disabled_82543(struct e1000_hw
*hw
)
390 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
393 DEBUGFUNC("e1000_init_phy_disabled_82543");
395 if (hw
->mac
.type
!= e1000_82543
) {
400 ret_val
= dev_spec
->init_phy_disabled
;
408 * e1000_tbi_adjust_stats_82543 - Adjust stats when TBI enabled
409 * @hw: pointer to the HW structure
410 * @stats: Struct containing statistic register values
411 * @frame_len: The length of the frame in question
412 * @mac_addr: The Ethernet destination address of the frame in question
413 * @max_frame_size: The maximum frame size
415 * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT
417 void e1000_tbi_adjust_stats_82543(struct e1000_hw
*hw
,
418 struct e1000_hw_stats
*stats
, u32 frame_len
,
419 u8
*mac_addr
, u32 max_frame_size
)
421 if (!(e1000_tbi_sbp_enabled_82543(hw
)))
424 /* First adjust the frame length. */
427 * We need to adjust the statistics counters, since the hardware
428 * counters overcount this packet as a CRC error and undercount
429 * the packet as a good packet
431 /* This packet should not be counted as a CRC error. */
433 /* This packet does count as a Good Packet Received. */
436 /* Adjust the Good Octets received counters */
437 stats
->gorc
+= frame_len
;
440 * Is this a broadcast or multicast? Check broadcast first,
441 * since the test for a multicast frame will test positive on
444 if ((mac_addr
[0] == 0xff) && (mac_addr
[1] == 0xff))
445 /* Broadcast packet */
447 else if (*mac_addr
& 0x01)
448 /* Multicast packet */
452 * In this case, the hardware has overcounted the number of
455 if ((frame_len
== max_frame_size
) && (stats
->roc
> 0))
459 * Adjust the bin counters when the extra byte put the frame in the
460 * wrong bin. Remember that the frame_len was adjusted above.
462 if (frame_len
== 64) {
465 } else if (frame_len
== 127) {
468 } else if (frame_len
== 255) {
471 } else if (frame_len
== 511) {
474 } else if (frame_len
== 1023) {
477 } else if (frame_len
== 1522) {
487 * e1000_read_phy_reg_82543 - Read PHY register
488 * @hw: pointer to the HW structure
489 * @offset: register offset to be read
490 * @data: pointer to the read data
492 * Reads the PHY at offset and stores the information read to data.
494 static s32
e1000_read_phy_reg_82543(struct e1000_hw
*hw
, u32 offset
, u16
*data
)
497 s32 ret_val
= E1000_SUCCESS
;
499 DEBUGFUNC("e1000_read_phy_reg_82543");
501 if (offset
> MAX_PHY_REG_ADDRESS
) {
502 DEBUGOUT1("PHY Address %d is out of range\n", offset
);
503 ret_val
= -E1000_ERR_PARAM
;
508 * We must first send a preamble through the MDIO pin to signal the
509 * beginning of an MII instruction. This is done by sending 32
510 * consecutive "1" bits.
512 e1000_shift_out_mdi_bits_82543(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
515 * Now combine the next few fields that are required for a read
516 * operation. We use this method instead of calling the
517 * e1000_shift_out_mdi_bits routine five different times. The format
518 * of an MII read instruction consists of a shift out of 14 bits and
519 * is defined as follows:
520 * <Preamble><SOF><Op Code><Phy Addr><Offset>
521 * followed by a shift in of 18 bits. This first two bits shifted in
522 * are TurnAround bits used to avoid contention on the MDIO pin when a
523 * READ operation is performed. These two bits are thrown away
524 * followed by a shift in of 16 bits which contains the desired data.
526 mdic
= (offset
| (hw
->phy
.addr
<< 5) |
527 (PHY_OP_READ
<< 10) | (PHY_SOF
<< 12));
529 e1000_shift_out_mdi_bits_82543(hw
, mdic
, 14);
532 * Now that we've shifted out the read command to the MII, we need to
533 * "shift in" the 16-bit value (18 total bits) of the requested PHY
536 *data
= e1000_shift_in_mdi_bits_82543(hw
);
543 * e1000_write_phy_reg_82543 - Write PHY register
544 * @hw: pointer to the HW structure
545 * @offset: register offset to be written
546 * @data: pointer to the data to be written at offset
548 * Writes data to the PHY at offset.
550 static s32
e1000_write_phy_reg_82543(struct e1000_hw
*hw
, u32 offset
, u16 data
)
553 s32 ret_val
= E1000_SUCCESS
;
555 DEBUGFUNC("e1000_write_phy_reg_82543");
557 if (offset
> MAX_PHY_REG_ADDRESS
) {
558 DEBUGOUT1("PHY Address %d is out of range\n", offset
);
559 ret_val
= -E1000_ERR_PARAM
;
564 * We'll need to use the SW defined pins to shift the write command
565 * out to the PHY. We first send a preamble to the PHY to signal the
566 * beginning of the MII instruction. This is done by sending 32
567 * consecutive "1" bits.
569 e1000_shift_out_mdi_bits_82543(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
572 * Now combine the remaining required fields that will indicate a
573 * write operation. We use this method instead of calling the
574 * e1000_shift_out_mdi_bits routine for each field in the command. The
575 * format of a MII write instruction is as follows:
576 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
578 mdic
= ((PHY_TURNAROUND
) | (offset
<< 2) | (hw
->phy
.addr
<< 7) |
579 (PHY_OP_WRITE
<< 12) | (PHY_SOF
<< 14));
583 e1000_shift_out_mdi_bits_82543(hw
, mdic
, 32);
590 * e1000_raise_mdi_clk_82543 - Raise Management Data Input clock
591 * @hw: pointer to the HW structure
592 * @ctrl: pointer to the control register
594 * Raise the management data input clock by setting the MDC bit in the control
597 static void e1000_raise_mdi_clk_82543(struct e1000_hw
*hw
, u32
*ctrl
)
600 * Raise the clock input to the Management Data Clock (by setting the
601 * MDC bit), and then delay a sufficient amount of time.
603 E1000_WRITE_REG(hw
, E1000_CTRL
, (*ctrl
| E1000_CTRL_MDC
));
604 E1000_WRITE_FLUSH(hw
);
609 * e1000_lower_mdi_clk_82543 - Lower Management Data Input clock
610 * @hw: pointer to the HW structure
611 * @ctrl: pointer to the control register
613 * Lower the management data input clock by clearing the MDC bit in the
616 static void e1000_lower_mdi_clk_82543(struct e1000_hw
*hw
, u32
*ctrl
)
619 * Lower the clock input to the Management Data Clock (by clearing the
620 * MDC bit), and then delay a sufficient amount of time.
622 E1000_WRITE_REG(hw
, E1000_CTRL
, (*ctrl
& ~E1000_CTRL_MDC
));
623 E1000_WRITE_FLUSH(hw
);
628 * e1000_shift_out_mdi_bits_82543 - Shift data bits our to the PHY
629 * @hw: pointer to the HW structure
630 * @data: data to send to the PHY
631 * @count: number of bits to shift out
633 * We need to shift 'count' bits out to the PHY. So, the value in the
634 * "data" parameter will be shifted out to the PHY one bit at a time.
635 * In order to do this, "data" must be broken down into bits.
637 static void e1000_shift_out_mdi_bits_82543(struct e1000_hw
*hw
, u32 data
,
643 * We need to shift "count" number of bits out to the PHY. So, the
644 * value in the "data" parameter will be shifted out to the PHY one
645 * bit at a time. In order to do this, "data" must be broken down
651 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
653 /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
654 ctrl
|= (E1000_CTRL_MDIO_DIR
| E1000_CTRL_MDC_DIR
);
658 * A "1" is shifted out to the PHY by setting the MDIO bit to
659 * "1" and then raising and lowering the Management Data Clock.
660 * A "0" is shifted out to the PHY by setting the MDIO bit to
661 * "0" and then raising and lowering the clock.
663 if (data
& mask
) ctrl
|= E1000_CTRL_MDIO
;
664 else ctrl
&= ~E1000_CTRL_MDIO
;
666 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
667 E1000_WRITE_FLUSH(hw
);
671 e1000_raise_mdi_clk_82543(hw
, &ctrl
);
672 e1000_lower_mdi_clk_82543(hw
, &ctrl
);
679 * e1000_shift_in_mdi_bits_82543 - Shift data bits in from the PHY
680 * @hw: pointer to the HW structure
682 * In order to read a register from the PHY, we need to shift 18 bits
683 * in from the PHY. Bits are "shifted in" by raising the clock input to
684 * the PHY (setting the MDC bit), and then reading the value of the data out
687 static u16
e1000_shift_in_mdi_bits_82543(struct e1000_hw
*hw
)
694 * In order to read a register from the PHY, we need to shift in a
695 * total of 18 bits from the PHY. The first two bit (turnaround)
696 * times are used to avoid contention on the MDIO pin when a read
697 * operation is performed. These two bits are ignored by us and
698 * thrown away. Bits are "shifted in" by raising the input to the
699 * Management Data Clock (setting the MDC bit) and then reading the
700 * value of the MDIO bit.
702 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
705 * Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as
708 ctrl
&= ~E1000_CTRL_MDIO_DIR
;
709 ctrl
&= ~E1000_CTRL_MDIO
;
711 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
712 E1000_WRITE_FLUSH(hw
);
715 * Raise and lower the clock before reading in the data. This accounts
716 * for the turnaround bits. The first clock occurred when we clocked
717 * out the last bit of the Register Address.
719 e1000_raise_mdi_clk_82543(hw
, &ctrl
);
720 e1000_lower_mdi_clk_82543(hw
, &ctrl
);
722 for (data
= 0, i
= 0; i
< 16; i
++) {
724 e1000_raise_mdi_clk_82543(hw
, &ctrl
);
725 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
726 /* Check to see if we shifted in a "1". */
727 if (ctrl
& E1000_CTRL_MDIO
)
729 e1000_lower_mdi_clk_82543(hw
, &ctrl
);
732 e1000_raise_mdi_clk_82543(hw
, &ctrl
);
733 e1000_lower_mdi_clk_82543(hw
, &ctrl
);
740 * e1000_phy_force_speed_duplex_82543 - Force speed/duplex for PHY
741 * @hw: pointer to the HW structure
743 * Calls the function to force speed and duplex for the m88 PHY, and
744 * if the PHY is not auto-negotiating and the speed is forced to 10Mbit,
745 * then call the function for polarity reversal workaround.
747 static s32
e1000_phy_force_speed_duplex_82543(struct e1000_hw
*hw
)
751 DEBUGFUNC("e1000_phy_force_speed_duplex_82543");
753 ret_val
= e1000_phy_force_speed_duplex_m88(hw
);
757 if (!hw
->mac
.autoneg
&&
758 (hw
->mac
.forced_speed_duplex
& E1000_ALL_10_SPEED
))
759 ret_val
= e1000_polarity_reversal_workaround_82543(hw
);
767 * e1000_polarity_reversal_workaround_82543 - Workaround polarity reversal
768 * @hw: pointer to the HW structure
770 * When forcing link to 10 Full or 10 Half, the PHY can reverse the polarity
771 * inadvertently. To workaround the issue, we disable the transmitter on
772 * the PHY until we have established the link partner's link parameters.
774 static s32
e1000_polarity_reversal_workaround_82543(struct e1000_hw
*hw
)
776 s32 ret_val
= E1000_SUCCESS
;
781 if (!(hw
->phy
.ops
.write_reg
))
784 /* Polarity reversal workaround for forced 10F/10H links. */
786 /* Disable the transmitter on the PHY */
788 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
791 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFFF);
795 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
800 * This loop will early-out if the NO link condition has been met.
801 * In other words, DO NOT use e1000_phy_has_link_generic() here.
803 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
805 * Read the MII Status Register and wait for Link Status bit
809 ret_val
= hw
->phy
.ops
.read_reg(hw
, PHY_STATUS
, &mii_status_reg
);
813 ret_val
= hw
->phy
.ops
.read_reg(hw
, PHY_STATUS
, &mii_status_reg
);
817 if ((mii_status_reg
& ~MII_SR_LINK_STATUS
) == 0)
822 /* Recommended delay time after link has been lost */
823 msec_delay_irq(1000);
825 /* Now we will re-enable the transmitter on the PHY */
827 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
831 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFF0);
835 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFF00);
839 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0x0000);
843 ret_val
= hw
->phy
.ops
.write_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
848 * Read the MII Status Register and wait for Link Status bit
851 ret_val
= e1000_phy_has_link_generic(hw
, PHY_FORCE_TIME
, 100000, &link
);
860 * e1000_phy_hw_reset_82543 - PHY hardware reset
861 * @hw: pointer to the HW structure
863 * Sets the PHY_RESET_DIR bit in the extended device control register
864 * to put the PHY into a reset and waits for completion. Once the reset
865 * has been accomplished, clear the PHY_RESET_DIR bit to take the PHY out
868 static s32
e1000_phy_hw_reset_82543(struct e1000_hw
*hw
)
873 DEBUGFUNC("e1000_phy_hw_reset_82543");
876 * Read the Extended Device Control Register, assert the PHY_RESET_DIR
877 * bit to put the PHY into reset...
879 ctrl_ext
= E1000_READ_REG(hw
, E1000_CTRL_EXT
);
880 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DIR
;
881 ctrl_ext
&= ~E1000_CTRL_EXT_SDP4_DATA
;
882 E1000_WRITE_REG(hw
, E1000_CTRL_EXT
, ctrl_ext
);
883 E1000_WRITE_FLUSH(hw
);
887 /* ...then take it out of reset. */
888 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DATA
;
889 E1000_WRITE_REG(hw
, E1000_CTRL_EXT
, ctrl_ext
);
890 E1000_WRITE_FLUSH(hw
);
894 if (!(hw
->phy
.ops
.get_cfg_done
))
895 return E1000_SUCCESS
;
897 ret_val
= hw
->phy
.ops
.get_cfg_done(hw
);
903 * e1000_reset_hw_82543 - Reset hardware
904 * @hw: pointer to the HW structure
906 * This resets the hardware into a known state.
908 static s32
e1000_reset_hw_82543(struct e1000_hw
*hw
)
911 s32 ret_val
= E1000_SUCCESS
;
913 DEBUGFUNC("e1000_reset_hw_82543");
915 DEBUGOUT("Masking off all interrupts\n");
916 E1000_WRITE_REG(hw
, E1000_IMC
, 0xffffffff);
918 E1000_WRITE_REG(hw
, E1000_RCTL
, 0);
919 E1000_WRITE_REG(hw
, E1000_TCTL
, E1000_TCTL_PSP
);
920 E1000_WRITE_FLUSH(hw
);
922 e1000_set_tbi_sbp_82543(hw
, false);
925 * Delay to allow any outstanding PCI transactions to complete before
926 * resetting the device
930 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
932 DEBUGOUT("Issuing a global reset to 82543/82544 MAC\n");
933 if (hw
->mac
.type
== e1000_82543
) {
934 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
| E1000_CTRL_RST
);
937 * The 82544 can't ACK the 64-bit write when issuing the
938 * reset, so use IO-mapping as a workaround.
940 E1000_WRITE_REG_IO(hw
, E1000_CTRL
, ctrl
| E1000_CTRL_RST
);
944 * After MAC reset, force reload of NVM to restore power-on
945 * settings to device.
947 hw
->nvm
.ops
.reload(hw
);
950 /* Masking off and clearing any pending interrupts */
951 E1000_WRITE_REG(hw
, E1000_IMC
, 0xffffffff);
952 icr
= E1000_READ_REG(hw
, E1000_ICR
);
958 * e1000_init_hw_82543 - Initialize hardware
959 * @hw: pointer to the HW structure
961 * This inits the hardware readying it for operation.
963 static s32
e1000_init_hw_82543(struct e1000_hw
*hw
)
965 struct e1000_mac_info
*mac
= &hw
->mac
;
966 struct e1000_dev_spec_82543
*dev_spec
= &hw
->dev_spec
._82543
;
971 DEBUGFUNC("e1000_init_hw_82543");
973 /* Disabling VLAN filtering */
974 E1000_WRITE_REG(hw
, E1000_VET
, 0);
975 mac
->ops
.clear_vfta(hw
);
977 /* Setup the receive address. */
978 e1000_init_rx_addrs_generic(hw
, mac
->rar_entry_count
);
980 /* Zero out the Multicast HASH table */
981 DEBUGOUT("Zeroing the MTA\n");
982 for (i
= 0; i
< mac
->mta_reg_count
; i
++) {
983 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
984 E1000_WRITE_FLUSH(hw
);
988 * Set the PCI priority bit correctly in the CTRL register. This
989 * determines if the adapter gives priority to receives, or if it
990 * gives equal priority to transmits and receives.
992 if (hw
->mac
.type
== e1000_82543
&& dev_spec
->dma_fairness
) {
993 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
994 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
| E1000_CTRL_PRIOR
);
997 e1000_pcix_mmrbc_workaround_generic(hw
);
999 /* Setup link and flow control */
1000 ret_val
= mac
->ops
.setup_link(hw
);
1003 * Clear all of the statistics registers (clear on read). It is
1004 * important that we do this after we have tried to establish link
1005 * because the symbol error count will increment wildly if there
1008 e1000_clear_hw_cntrs_82543(hw
);
1014 * e1000_setup_link_82543 - Setup flow control and link settings
1015 * @hw: pointer to the HW structure
1017 * Read the EEPROM to determine the initial polarity value and write the
1018 * extended device control register with the information before calling
1019 * the generic setup link function, which does the following:
1020 * Determines which flow control settings to use, then configures flow
1021 * control. Calls the appropriate media-specific link configuration
1022 * function. Assuming the adapter has a valid link partner, a valid link
1023 * should be established. Assumes the hardware has previously been reset
1024 * and the transmitter and receiver are not enabled.
1026 static s32
e1000_setup_link_82543(struct e1000_hw
*hw
)
1032 DEBUGFUNC("e1000_setup_link_82543");
1035 * Take the 4 bits from NVM word 0xF that determine the initial
1036 * polarity value for the SW controlled pins, and setup the
1037 * Extended Device Control reg with that info.
1038 * This is needed because one of the SW controlled pins is used for
1039 * signal detection. So this should be done before phy setup.
1041 if (hw
->mac
.type
== e1000_82543
) {
1042 ret_val
= hw
->nvm
.ops
.read(hw
, NVM_INIT_CONTROL2_REG
, 1, &data
);
1044 DEBUGOUT("NVM Read Error\n");
1045 ret_val
= -E1000_ERR_NVM
;
1048 ctrl_ext
= ((data
& NVM_WORD0F_SWPDIO_EXT_MASK
) <<
1049 NVM_SWDPIO_EXT_SHIFT
);
1050 E1000_WRITE_REG(hw
, E1000_CTRL_EXT
, ctrl_ext
);
1053 ret_val
= e1000_setup_link_generic(hw
);
1060 * e1000_setup_copper_link_82543 - Configure copper link settings
1061 * @hw: pointer to the HW structure
1063 * Configures the link for auto-neg or forced speed and duplex. Then we check
1064 * for link, once link is established calls to configure collision distance
1065 * and flow control are called.
1067 static s32
e1000_setup_copper_link_82543(struct e1000_hw
*hw
)
1073 DEBUGFUNC("e1000_setup_copper_link_82543");
1075 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
) | E1000_CTRL_SLU
;
1077 * With 82543, we need to force speed and duplex on the MAC
1078 * equal to what the PHY speed and duplex configuration is.
1079 * In addition, we need to perform a hardware reset on the
1080 * PHY to take it out of reset.
1082 if (hw
->mac
.type
== e1000_82543
) {
1083 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1084 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1085 ret_val
= hw
->phy
.ops
.reset(hw
);
1088 hw
->phy
.reset_disable
= false;
1090 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1091 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1094 /* Set MDI/MDI-X, Polarity Reversal, and downshift settings */
1095 ret_val
= e1000_copper_link_setup_m88(hw
);
1099 if (hw
->mac
.autoneg
) {
1101 * Setup autoneg and flow control advertisement and perform
1104 ret_val
= e1000_copper_link_autoneg(hw
);
1109 * PHY will be set to 10H, 10F, 100H or 100F
1110 * depending on user settings.
1113 DEBUGOUT("Forcing Speed and Duplex\n");
1114 ret_val
= e1000_phy_force_speed_duplex_82543(hw
);
1116 DEBUGOUT("Error Forcing Speed and Duplex\n");
1123 * Check link status. Wait up to 100 microseconds for link to become
1126 ret_val
= e1000_phy_has_link_generic(hw
,
1127 COPPER_LINK_UP_LIMIT
,
1135 DEBUGOUT("Valid link established!!!\n");
1136 /* Config the MAC and PHY after link is up */
1137 if (hw
->mac
.type
== e1000_82544
) {
1138 e1000_config_collision_dist_generic(hw
);
1140 ret_val
= e1000_config_mac_to_phy_82543(hw
);
1144 ret_val
= e1000_config_fc_after_link_up_generic(hw
);
1146 DEBUGOUT("Unable to establish link!!!\n");
1154 * e1000_setup_fiber_link_82543 - Setup link for fiber
1155 * @hw: pointer to the HW structure
1157 * Configures collision distance and flow control for fiber links. Upon
1158 * successful setup, poll for link.
1160 static s32
e1000_setup_fiber_link_82543(struct e1000_hw
*hw
)
1165 DEBUGFUNC("e1000_setup_fiber_link_82543");
1167 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1169 /* Take the link out of reset */
1170 ctrl
&= ~E1000_CTRL_LRST
;
1172 e1000_config_collision_dist_generic(hw
);
1174 ret_val
= e1000_commit_fc_settings_generic(hw
);
1178 DEBUGOUT("Auto-negotiation enabled\n");
1180 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1181 E1000_WRITE_FLUSH(hw
);
1185 * For these adapters, the SW definable pin 1 is cleared when the
1186 * optics detect a signal. If we have a signal, then poll for a
1187 * "Link-Up" indication.
1189 if (!(E1000_READ_REG(hw
, E1000_CTRL
) & E1000_CTRL_SWDPIN1
)) {
1190 ret_val
= e1000_poll_fiber_serdes_link_generic(hw
);
1192 DEBUGOUT("No signal detected\n");
1200 * e1000_check_for_copper_link_82543 - Check for link (Copper)
1201 * @hw: pointer to the HW structure
1203 * Checks the phy for link, if link exists, do the following:
1204 * - check for downshift
1205 * - do polarity workaround (if necessary)
1206 * - configure collision distance
1207 * - configure flow control after link up
1208 * - configure tbi compatibility
1210 static s32
e1000_check_for_copper_link_82543(struct e1000_hw
*hw
)
1212 struct e1000_mac_info
*mac
= &hw
->mac
;
1218 DEBUGFUNC("e1000_check_for_copper_link_82543");
1220 if (!mac
->get_link_status
) {
1221 ret_val
= E1000_SUCCESS
;
1225 ret_val
= e1000_phy_has_link_generic(hw
, 1, 0, &link
);
1230 goto out
; /* No link detected */
1232 mac
->get_link_status
= false;
1234 e1000_check_downshift_generic(hw
);
1237 * If we are forcing speed/duplex, then we can return since
1238 * we have already determined whether we have link or not.
1240 if (!mac
->autoneg
) {
1242 * If speed and duplex are forced to 10H or 10F, then we will
1243 * implement the polarity reversal workaround. We disable
1244 * interrupts first, and upon returning, place the devices
1245 * interrupt state to its previous value except for the link
1246 * status change interrupt which will happened due to the
1247 * execution of this workaround.
1249 if (mac
->forced_speed_duplex
& E1000_ALL_10_SPEED
) {
1250 E1000_WRITE_REG(hw
, E1000_IMC
, 0xFFFFFFFF);
1251 ret_val
= e1000_polarity_reversal_workaround_82543(hw
);
1252 icr
= E1000_READ_REG(hw
, E1000_ICR
);
1253 E1000_WRITE_REG(hw
, E1000_ICS
, (icr
& ~E1000_ICS_LSC
));
1254 E1000_WRITE_REG(hw
, E1000_IMS
, IMS_ENABLE_MASK
);
1257 ret_val
= -E1000_ERR_CONFIG
;
1262 * We have a M88E1000 PHY and Auto-Neg is enabled. If we
1263 * have Si on board that is 82544 or newer, Auto
1264 * Speed Detection takes care of MAC speed/duplex
1265 * configuration. So we only need to configure Collision
1266 * Distance in the MAC. Otherwise, we need to force
1267 * speed/duplex on the MAC to the current PHY speed/duplex
1270 if (mac
->type
== e1000_82544
)
1271 e1000_config_collision_dist_generic(hw
);
1273 ret_val
= e1000_config_mac_to_phy_82543(hw
);
1275 DEBUGOUT("Error configuring MAC to PHY settings\n");
1281 * Configure Flow Control now that Auto-Neg has completed.
1282 * First, we need to restore the desired flow control
1283 * settings because we may have had to re-autoneg with a
1284 * different link partner.
1286 ret_val
= e1000_config_fc_after_link_up_generic(hw
);
1288 DEBUGOUT("Error configuring flow control\n");
1292 * At this point we know that we are on copper and we have
1293 * auto-negotiated link. These are conditions for checking the link
1294 * partner capability register. We use the link speed to determine if
1295 * TBI compatibility needs to be turned on or off. If the link is not
1296 * at gigabit speed, then TBI compatibility is not needed. If we are
1297 * at gigabit speed, we turn on TBI compatibility.
1299 if (e1000_tbi_compatibility_enabled_82543(hw
)) {
1300 ret_val
= mac
->ops
.get_link_up_info(hw
, &speed
, &duplex
);
1302 DEBUGOUT("Error getting link speed and duplex\n");
1305 if (speed
!= SPEED_1000
) {
1307 * If link speed is not set to gigabit speed,
1308 * we do not need to enable TBI compatibility.
1310 if (e1000_tbi_sbp_enabled_82543(hw
)) {
1312 * If we previously were in the mode,
1315 e1000_set_tbi_sbp_82543(hw
, false);
1316 rctl
= E1000_READ_REG(hw
, E1000_RCTL
);
1317 rctl
&= ~E1000_RCTL_SBP
;
1318 E1000_WRITE_REG(hw
, E1000_RCTL
, rctl
);
1322 * If TBI compatibility is was previously off,
1323 * turn it on. For compatibility with a TBI link
1324 * partner, we will store bad packets. Some
1325 * frames have an additional byte on the end and
1326 * will look like CRC errors to to the hardware.
1328 if (!e1000_tbi_sbp_enabled_82543(hw
)) {
1329 e1000_set_tbi_sbp_82543(hw
, true);
1330 rctl
= E1000_READ_REG(hw
, E1000_RCTL
);
1331 rctl
|= E1000_RCTL_SBP
;
1332 E1000_WRITE_REG(hw
, E1000_RCTL
, rctl
);
1341 * e1000_check_for_fiber_link_82543 - Check for link (Fiber)
1342 * @hw: pointer to the HW structure
1344 * Checks for link up on the hardware. If link is not up and we have
1345 * a signal, then we need to force link up.
1347 static s32
e1000_check_for_fiber_link_82543(struct e1000_hw
*hw
)
1349 struct e1000_mac_info
*mac
= &hw
->mac
;
1350 u32 rxcw
, ctrl
, status
;
1351 s32 ret_val
= E1000_SUCCESS
;
1353 DEBUGFUNC("e1000_check_for_fiber_link_82543");
1355 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1356 status
= E1000_READ_REG(hw
, E1000_STATUS
);
1357 rxcw
= E1000_READ_REG(hw
, E1000_RXCW
);
1360 * If we don't have link (auto-negotiation failed or link partner
1361 * cannot auto-negotiate), the cable is plugged in (we have signal),
1362 * and our link partner is not trying to auto-negotiate with us (we
1363 * are receiving idles or data), we need to force link up. We also
1364 * need to give auto-negotiation time to complete, in case the cable
1365 * was just plugged in. The autoneg_failed flag does this.
1367 /* (ctrl & E1000_CTRL_SWDPIN1) == 0 == have signal */
1368 if ((!(ctrl
& E1000_CTRL_SWDPIN1
)) &&
1369 (!(status
& E1000_STATUS_LU
)) &&
1370 (!(rxcw
& E1000_RXCW_C
))) {
1371 if (mac
->autoneg_failed
== 0) {
1372 mac
->autoneg_failed
= 1;
1376 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
1378 /* Disable auto-negotiation in the TXCW register */
1379 E1000_WRITE_REG(hw
, E1000_TXCW
, (mac
->txcw
& ~E1000_TXCW_ANE
));
1381 /* Force link-up and also force full-duplex. */
1382 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1383 ctrl
|= (E1000_CTRL_SLU
| E1000_CTRL_FD
);
1384 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1386 /* Configure Flow Control after forcing link up. */
1387 ret_val
= e1000_config_fc_after_link_up_generic(hw
);
1389 DEBUGOUT("Error configuring flow control\n");
1392 } else if ((ctrl
& E1000_CTRL_SLU
) && (rxcw
& E1000_RXCW_C
)) {
1394 * If we are forcing link and we are receiving /C/ ordered
1395 * sets, re-enable auto-negotiation in the TXCW register
1396 * and disable forced link in the Device Control register
1397 * in an attempt to auto-negotiate with our link partner.
1399 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
1400 E1000_WRITE_REG(hw
, E1000_TXCW
, mac
->txcw
);
1401 E1000_WRITE_REG(hw
, E1000_CTRL
, (ctrl
& ~E1000_CTRL_SLU
));
1403 mac
->serdes_has_link
= true;
1411 * e1000_config_mac_to_phy_82543 - Configure MAC to PHY settings
1412 * @hw: pointer to the HW structure
1414 * For the 82543 silicon, we need to set the MAC to match the settings
1415 * of the PHY, even if the PHY is auto-negotiating.
1417 static s32
e1000_config_mac_to_phy_82543(struct e1000_hw
*hw
)
1420 s32 ret_val
= E1000_SUCCESS
;
1423 DEBUGFUNC("e1000_config_mac_to_phy_82543");
1425 if (!(hw
->phy
.ops
.read_reg
))
1428 /* Set the bits to force speed and duplex */
1429 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1430 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1431 ctrl
&= ~(E1000_CTRL_SPD_SEL
| E1000_CTRL_ILOS
);
1434 * Set up duplex in the Device Control and Transmit Control
1435 * registers depending on negotiated values.
1437 ret_val
= hw
->phy
.ops
.read_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
1441 ctrl
&= ~E1000_CTRL_FD
;
1442 if (phy_data
& M88E1000_PSSR_DPLX
)
1443 ctrl
|= E1000_CTRL_FD
;
1445 e1000_config_collision_dist_generic(hw
);
1448 * Set up speed in the Device Control register depending on
1449 * negotiated values.
1451 if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_1000MBS
)
1452 ctrl
|= E1000_CTRL_SPD_1000
;
1453 else if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_100MBS
)
1454 ctrl
|= E1000_CTRL_SPD_100
;
1456 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1463 * e1000_write_vfta_82543 - Write value to VLAN filter table
1464 * @hw: pointer to the HW structure
1465 * @offset: the 32-bit offset in which to write the value to.
1466 * @value: the 32-bit value to write at location offset.
1468 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
1471 static void e1000_write_vfta_82543(struct e1000_hw
*hw
, u32 offset
, u32 value
)
1475 DEBUGFUNC("e1000_write_vfta_82543");
1477 if ((hw
->mac
.type
== e1000_82544
) && (offset
& 1)) {
1478 temp
= E1000_READ_REG_ARRAY(hw
, E1000_VFTA
, offset
- 1);
1479 E1000_WRITE_REG_ARRAY(hw
, E1000_VFTA
, offset
, value
);
1480 E1000_WRITE_FLUSH(hw
);
1481 E1000_WRITE_REG_ARRAY(hw
, E1000_VFTA
, offset
- 1, temp
);
1482 E1000_WRITE_FLUSH(hw
);
1484 e1000_write_vfta_generic(hw
, offset
, value
);
1489 * e1000_mta_set_82543 - Set multicast filter table address
1490 * @hw: pointer to the HW structure
1491 * @hash_value: determines the MTA register and bit to set
1493 * The multicast table address is a register array of 32-bit registers.
1494 * The hash_value is used to determine what register the bit is in, the
1495 * current value is read, the new bit is OR'd in and the new value is
1496 * written back into the register.
1498 static void e1000_mta_set_82543(struct e1000_hw
*hw
, u32 hash_value
)
1500 u32 hash_bit
, hash_reg
, mta
, temp
;
1502 DEBUGFUNC("e1000_mta_set_82543");
1504 hash_reg
= (hash_value
>> 5);
1507 * If we are on an 82544 and we are trying to write an odd offset
1508 * in the MTA, save off the previous entry before writing and
1509 * restore the old value after writing.
1511 if ((hw
->mac
.type
== e1000_82544
) && (hash_reg
& 1)) {
1512 hash_reg
&= (hw
->mac
.mta_reg_count
- 1);
1513 hash_bit
= hash_value
& 0x1F;
1514 mta
= E1000_READ_REG_ARRAY(hw
, E1000_MTA
, hash_reg
);
1515 mta
|= (1 << hash_bit
);
1516 temp
= E1000_READ_REG_ARRAY(hw
, E1000_MTA
, hash_reg
- 1);
1518 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, hash_reg
, mta
);
1519 E1000_WRITE_FLUSH(hw
);
1520 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, hash_reg
- 1, temp
);
1521 E1000_WRITE_FLUSH(hw
);
1523 e1000_mta_set_generic(hw
, hash_value
);
1528 * e1000_led_on_82543 - Turn on SW controllable LED
1529 * @hw: pointer to the HW structure
1531 * Turns the SW defined LED on.
1533 static s32
e1000_led_on_82543(struct e1000_hw
*hw __unused
)
1536 u32 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1538 DEBUGFUNC("e1000_led_on_82543");
1540 if (hw
->mac
.type
== e1000_82544
&&
1541 hw
->phy
.media_type
== e1000_media_type_copper
) {
1542 /* Clear SW-definable Pin 0 to turn on the LED */
1543 ctrl
&= ~E1000_CTRL_SWDPIN0
;
1544 ctrl
|= E1000_CTRL_SWDPIO0
;
1546 /* Fiber 82544 and all 82543 use this method */
1547 ctrl
|= E1000_CTRL_SWDPIN0
;
1548 ctrl
|= E1000_CTRL_SWDPIO0
;
1550 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1552 return E1000_SUCCESS
;
1558 * e1000_led_off_82543 - Turn off SW controllable LED
1559 * @hw: pointer to the HW structure
1561 * Turns the SW defined LED off.
1563 static s32
e1000_led_off_82543(struct e1000_hw
*hw __unused
)
1566 u32 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
1568 DEBUGFUNC("e1000_led_off_82543");
1570 if (hw
->mac
.type
== e1000_82544
&&
1571 hw
->phy
.media_type
== e1000_media_type_copper
) {
1572 /* Set SW-definable Pin 0 to turn off the LED */
1573 ctrl
|= E1000_CTRL_SWDPIN0
;
1574 ctrl
|= E1000_CTRL_SWDPIO0
;
1576 ctrl
&= ~E1000_CTRL_SWDPIN0
;
1577 ctrl
|= E1000_CTRL_SWDPIO0
;
1579 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
1581 return E1000_SUCCESS
;
1587 * e1000_clear_hw_cntrs_82543 - Clear device specific hardware counters
1588 * @hw: pointer to the HW structure
1590 * Clears the hardware counters by reading the counter registers.
1592 static void e1000_clear_hw_cntrs_82543(struct e1000_hw
*hw
)
1594 DEBUGFUNC("e1000_clear_hw_cntrs_82543");
1596 e1000_clear_hw_cntrs_base_generic(hw
);
1599 E1000_READ_REG(hw
, E1000_PRC64
);
1600 E1000_READ_REG(hw
, E1000_PRC127
);
1601 E1000_READ_REG(hw
, E1000_PRC255
);
1602 E1000_READ_REG(hw
, E1000_PRC511
);
1603 E1000_READ_REG(hw
, E1000_PRC1023
);
1604 E1000_READ_REG(hw
, E1000_PRC1522
);
1605 E1000_READ_REG(hw
, E1000_PTC64
);
1606 E1000_READ_REG(hw
, E1000_PTC127
);
1607 E1000_READ_REG(hw
, E1000_PTC255
);
1608 E1000_READ_REG(hw
, E1000_PTC511
);
1609 E1000_READ_REG(hw
, E1000_PTC1023
);
1610 E1000_READ_REG(hw
, E1000_PTC1522
);
1612 E1000_READ_REG(hw
, E1000_ALGNERRC
);
1613 E1000_READ_REG(hw
, E1000_RXERRC
);
1614 E1000_READ_REG(hw
, E1000_TNCRS
);
1615 E1000_READ_REG(hw
, E1000_CEXTERR
);
1616 E1000_READ_REG(hw
, E1000_TSCTC
);
1617 E1000_READ_REG(hw
, E1000_TSCTFC
);
1621 static struct pci_device_id e1000_82543_nics
[] = {
1622 PCI_ROM(0x8086, 0x1001, "E1000_DEV_ID_82543GC_FIBER", "E1000_DEV_ID_82543GC_FIBER", e1000_82543
),
1623 PCI_ROM(0x8086, 0x1004, "E1000_DEV_ID_82543GC_COPPER", "E1000_DEV_ID_82543GC_COPPER", e1000_82543
),
1624 PCI_ROM(0x8086, 0x1008, "E1000_DEV_ID_82544EI_COPPER", "E1000_DEV_ID_82544EI_COPPER", e1000_82544
),
1625 PCI_ROM(0x8086, 0x1009, "E1000_DEV_ID_82544EI_FIBER", "E1000_DEV_ID_82544EI_FIBER", e1000_82544
),
1626 PCI_ROM(0x8086, 0x100C, "E1000_DEV_ID_82544GC_COPPER", "E1000_DEV_ID_82544GC_COPPER", e1000_82544
),
1627 PCI_ROM(0x8086, 0x100D, "E1000_DEV_ID_82544GC_LOM", "E1000_DEV_ID_82544GC_LOM", e1000_82544
),
1630 struct pci_driver e1000_82543_driver __pci_driver
= {
1631 .ids
= e1000_82543_nics
,
1632 .id_count
= (sizeof (e1000_82543_nics
) / sizeof (e1000_82543_nics
[0])),
1633 .probe
= e1000_probe
,
1634 .remove
= e1000_remove
,