e1000_82542.c revision 169240
1169240Sjfv/*******************************************************************************
2169240Sjfv
3169240Sjfv  Copyright (c) 2001-2007, Intel Corporation
4169240Sjfv  All rights reserved.
5169240Sjfv
6169240Sjfv  Redistribution and use in source and binary forms, with or without
7169240Sjfv  modification, are permitted provided that the following conditions are met:
8169240Sjfv
9169240Sjfv   1. Redistributions of source code must retain the above copyright notice,
10169240Sjfv      this list of conditions and the following disclaimer.
11169240Sjfv
12169240Sjfv   2. Redistributions in binary form must reproduce the above copyright
13169240Sjfv      notice, this list of conditions and the following disclaimer in the
14169240Sjfv      documentation and/or other materials provided with the distribution.
15169240Sjfv
16169240Sjfv   3. Neither the name of the Intel Corporation nor the names of its
17169240Sjfv      contributors may be used to endorse or promote products derived from
18169240Sjfv      this software without specific prior written permission.
19169240Sjfv
20169240Sjfv  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21169240Sjfv  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22169240Sjfv  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23169240Sjfv  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24169240Sjfv  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25169240Sjfv  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26169240Sjfv  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27169240Sjfv  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28169240Sjfv  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29169240Sjfv  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30169240Sjfv  POSSIBILITY OF SUCH DAMAGE.
31169240Sjfv
32169240Sjfv*******************************************************************************/
33169240Sjfv$FreeBSD: head/sys/dev/em/e1000_82542.c 169240 2007-05-04 00:00:12Z jfv $
34169240Sjfv
35169240Sjfv
36169240Sjfv/* e1000_82542 (rev 1 & 2)
37169240Sjfv */
38169240Sjfv
39169240Sjfv#include "e1000_api.h"
40169240Sjfv
41169240Sjfvvoid e1000_init_function_pointers_82542(struct e1000_hw *hw);
42169240Sjfv
43169240SjfvSTATIC s32  e1000_init_phy_params_82542(struct e1000_hw *hw);
44169240SjfvSTATIC s32  e1000_init_nvm_params_82542(struct e1000_hw *hw);
45169240SjfvSTATIC s32  e1000_init_mac_params_82542(struct e1000_hw *hw);
46169240SjfvSTATIC s32  e1000_get_bus_info_82542(struct e1000_hw *hw);
47169240SjfvSTATIC s32  e1000_reset_hw_82542(struct e1000_hw *hw);
48169240SjfvSTATIC s32  e1000_init_hw_82542(struct e1000_hw *hw);
49169240SjfvSTATIC s32  e1000_setup_link_82542(struct e1000_hw *hw);
50169240SjfvSTATIC s32  e1000_led_on_82542(struct e1000_hw *hw);
51169240SjfvSTATIC s32  e1000_led_off_82542(struct e1000_hw *hw);
52169240SjfvSTATIC void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw);
53169240Sjfv
54169240Sjfvstruct e1000_dev_spec_82542 {
55169240Sjfv	boolean_t dma_fairness;
56169240Sjfv};
57169240Sjfv
58169240Sjfv/**
59169240Sjfv *  e1000_init_phy_params_82542 - Init PHY func ptrs.
60169240Sjfv *  @hw - pointer to the HW structure
61169240Sjfv *
62169240Sjfv *  This is a function pointer entry point called by the api module.
63169240Sjfv **/
64169240SjfvSTATIC s32
65169240Sjfve1000_init_phy_params_82542(struct e1000_hw *hw)
66169240Sjfv{
67169240Sjfv	struct e1000_phy_info *phy = &hw->phy;
68169240Sjfv	s32 ret_val = E1000_SUCCESS;
69169240Sjfv
70169240Sjfv	DEBUGFUNC("e1000_init_phy_params_82542");
71169240Sjfv
72169240Sjfv	phy->type               = e1000_phy_none;
73169240Sjfv
74169240Sjfv	return ret_val;
75169240Sjfv}
76169240Sjfv
77169240Sjfv/**
78169240Sjfv *  e1000_init_nvm_params_82542 - Init NVM func ptrs.
79169240Sjfv *  @hw - pointer to the HW structure
80169240Sjfv *
81169240Sjfv *  This is a function pointer entry point called by the api module.
82169240Sjfv **/
83169240SjfvSTATIC s32
84169240Sjfve1000_init_nvm_params_82542(struct e1000_hw *hw)
85169240Sjfv{
86169240Sjfv	struct e1000_nvm_info *nvm = &hw->nvm;
87169240Sjfv	struct e1000_functions *func = &hw->func;
88169240Sjfv
89169240Sjfv	DEBUGFUNC("e1000_init_nvm_params_82542");
90169240Sjfv
91169240Sjfv	nvm->address_bits       =  6;
92169240Sjfv	nvm->delay_usec         = 50;
93169240Sjfv	nvm->opcode_bits        =  3;
94169240Sjfv	nvm->type               = e1000_nvm_eeprom_microwire;
95169240Sjfv	nvm->word_size          = 64;
96169240Sjfv
97169240Sjfv	/* Function Pointers */
98169240Sjfv	func->read_nvm          = e1000_read_nvm_microwire;
99169240Sjfv	func->release_nvm       = e1000_stop_nvm;
100169240Sjfv	func->write_nvm         = e1000_write_nvm_microwire;
101169240Sjfv	func->update_nvm        = e1000_update_nvm_checksum_generic;
102169240Sjfv	func->validate_nvm      = e1000_validate_nvm_checksum_generic;
103169240Sjfv
104169240Sjfv	return E1000_SUCCESS;
105169240Sjfv}
106169240Sjfv
107169240Sjfv/**
108169240Sjfv *  e1000_init_mac_params_82542 - Init MAC func ptrs.
109169240Sjfv *  @hw - pointer to the HW structure
110169240Sjfv *
111169240Sjfv *  This is a function pointer entry point called by the api module.
112169240Sjfv **/
113169240SjfvSTATIC s32
114169240Sjfve1000_init_mac_params_82542(struct e1000_hw *hw)
115169240Sjfv{
116169240Sjfv	struct e1000_mac_info *mac = &hw->mac;
117169240Sjfv	struct e1000_functions *func = &hw->func;
118169240Sjfv	s32 ret_val = E1000_SUCCESS;
119169240Sjfv
120169240Sjfv	DEBUGFUNC("e1000_init_mac_params_82542");
121169240Sjfv
122169240Sjfv	/* Set media type */
123169240Sjfv	hw->media_type = e1000_media_type_fiber;
124169240Sjfv
125169240Sjfv	/* Set mta register count */
126169240Sjfv	mac->mta_reg_count = 128;
127169240Sjfv	/* Set rar entry count */
128169240Sjfv	mac->rar_entry_count = E1000_RAR_ENTRIES;
129169240Sjfv
130169240Sjfv	/* Function pointers */
131169240Sjfv
132169240Sjfv	/* bus type/speed/width */
133169240Sjfv	func->get_bus_info = e1000_get_bus_info_82542;
134169240Sjfv	/* reset */
135169240Sjfv	func->reset_hw = e1000_reset_hw_82542;
136169240Sjfv	/* hw initialization */
137169240Sjfv	func->init_hw = e1000_init_hw_82542;
138169240Sjfv	/* link setup */
139169240Sjfv	func->setup_link = e1000_setup_link_82542;
140169240Sjfv	/* phy/fiber/serdes setup */
141169240Sjfv	func->setup_physical_interface = e1000_setup_fiber_serdes_link_generic;
142169240Sjfv	/* check for link */
143169240Sjfv	func->check_for_link = e1000_check_for_fiber_link_generic;
144169240Sjfv	/* multicast address update */
145169240Sjfv	func->mc_addr_list_update = e1000_mc_addr_list_update_generic;
146169240Sjfv	/* writing VFTA */
147169240Sjfv	func->write_vfta = e1000_write_vfta_generic;
148169240Sjfv	/* clearing VFTA */
149169240Sjfv	func->clear_vfta = e1000_clear_vfta_generic;
150169240Sjfv	/* setting MTA */
151169240Sjfv	func->mta_set = e1000_mta_set_generic;
152169240Sjfv	/* turn on/off LED */
153169240Sjfv	func->led_on = e1000_led_on_82542;
154169240Sjfv	func->led_off = e1000_led_off_82542;
155169240Sjfv	/* remove device */
156169240Sjfv	func->remove_device = e1000_remove_device_generic;
157169240Sjfv	/* clear hardware counters */
158169240Sjfv	func->clear_hw_cntrs = e1000_clear_hw_cntrs_82542;
159169240Sjfv	/* link info */
160169240Sjfv	func->get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes_generic;
161169240Sjfv
162169240Sjfv	hw->dev_spec_size = sizeof(struct e1000_dev_spec_82542);
163169240Sjfv
164169240Sjfv	/* Device-specific structure allocation */
165169240Sjfv	ret_val = e1000_alloc_zeroed_dev_spec_struct(hw, hw->dev_spec_size);
166169240Sjfv
167169240Sjfv	return ret_val;
168169240Sjfv}
169169240Sjfv
170169240Sjfv/**
171169240Sjfv *  e1000_init_function_pointers_82542 - Init func ptrs.
172169240Sjfv *  @hw - pointer to the HW structure
173169240Sjfv *
174169240Sjfv *  The only function explicitly called by the api module to initialize
175169240Sjfv *  all function pointers and parameters.
176169240Sjfv **/
177169240Sjfvvoid
178169240Sjfve1000_init_function_pointers_82542(struct e1000_hw *hw)
179169240Sjfv{
180169240Sjfv	DEBUGFUNC("e1000_init_function_pointers_82542");
181169240Sjfv
182169240Sjfv	hw->func.init_mac_params = e1000_init_mac_params_82542;
183169240Sjfv	hw->func.init_nvm_params = e1000_init_nvm_params_82542;
184169240Sjfv	hw->func.init_phy_params = e1000_init_phy_params_82542;
185169240Sjfv}
186169240Sjfv
187169240Sjfv/**
188169240Sjfv *  e1000_get_bus_info_82542 - Obtain bus information for adapter
189169240Sjfv *  @hw - pointer to the HW structure
190169240Sjfv *
191169240Sjfv *  This will obtain information about the HW bus for which the
192169240Sjfv *  adaper is attached and stores it in the hw structure.  This is a function
193169240Sjfv *  pointer entry point called by the api module.
194169240Sjfv **/
195169240SjfvSTATIC s32
196169240Sjfve1000_get_bus_info_82542(struct e1000_hw *hw)
197169240Sjfv{
198169240Sjfv	DEBUGFUNC("e1000_get_bus_info_82542");
199169240Sjfv
200169240Sjfv	hw->bus.type = e1000_bus_type_pci;
201169240Sjfv	hw->bus.speed = e1000_bus_speed_unknown;
202169240Sjfv	hw->bus.width = e1000_bus_width_unknown;
203169240Sjfv
204169240Sjfv	return E1000_SUCCESS;
205169240Sjfv}
206169240Sjfv
207169240Sjfv/**
208169240Sjfv *  e1000_reset_hw_82542 - Reset hardware
209169240Sjfv *  @hw - pointer to the HW structure
210169240Sjfv *
211169240Sjfv *  This resets the hardware into a known state.  This is a
212169240Sjfv *  function pointer entry point called by the api module.
213169240Sjfv **/
214169240SjfvSTATIC s32
215169240Sjfve1000_reset_hw_82542(struct e1000_hw *hw)
216169240Sjfv{
217169240Sjfv	struct e1000_bus_info *bus = &hw->bus;
218169240Sjfv	s32 ret_val = E1000_SUCCESS;
219169240Sjfv	u32 ctrl, icr;
220169240Sjfv
221169240Sjfv	DEBUGFUNC("e1000_reset_hw_82542");
222169240Sjfv
223169240Sjfv	if (hw->revision_id == E1000_REVISION_2) {
224169240Sjfv		DEBUGOUT("Disabling MWI on 82542 rev 2\n");
225169240Sjfv		e1000_pci_clear_mwi(hw);
226169240Sjfv	}
227169240Sjfv
228169240Sjfv	DEBUGOUT("Masking off all interrupts\n");
229169240Sjfv	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
230169240Sjfv
231169240Sjfv	E1000_WRITE_REG(hw, E1000_RCTL, 0);
232169240Sjfv	E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
233169240Sjfv	E1000_WRITE_FLUSH(hw);
234169240Sjfv
235169240Sjfv	/* Delay to allow any outstanding PCI transactions to complete before
236169240Sjfv	 * resetting the device
237169240Sjfv	 */
238169240Sjfv	msec_delay(10);
239169240Sjfv
240169240Sjfv	ctrl = E1000_READ_REG(hw, E1000_CTRL);
241169240Sjfv
242169240Sjfv	DEBUGOUT("Issuing a global reset to 82542/82543 MAC\n");
243169240Sjfv	E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
244169240Sjfv
245169240Sjfv	e1000_reload_nvm(hw);
246169240Sjfv	msec_delay(2);
247169240Sjfv
248169240Sjfv	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
249169240Sjfv	icr = E1000_READ_REG(hw, E1000_ICR);
250169240Sjfv
251169240Sjfv	if (hw->revision_id == E1000_REVISION_2) {
252169240Sjfv		if (bus->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
253169240Sjfv			e1000_pci_set_mwi(hw);
254169240Sjfv	}
255169240Sjfv
256169240Sjfv	return ret_val;
257169240Sjfv}
258169240Sjfv
259169240Sjfv/**
260169240Sjfv *  e1000_init_hw_82542 - Initialize hardware
261169240Sjfv *  @hw - pointer to the HW structure
262169240Sjfv *
263169240Sjfv *  This inits the hardware readying it for operation.  This is a
264169240Sjfv *  function pointer entry point called by the api module.
265169240Sjfv **/
266169240SjfvSTATIC s32
267169240Sjfve1000_init_hw_82542(struct e1000_hw *hw)
268169240Sjfv{
269169240Sjfv	struct e1000_mac_info *mac = &hw->mac;
270169240Sjfv	struct e1000_dev_spec_82542 *dev_spec;
271169240Sjfv	s32 ret_val = E1000_SUCCESS;
272169240Sjfv	u32 ctrl;
273169240Sjfv	u16 i;
274169240Sjfv
275169240Sjfv	DEBUGFUNC("e1000_init_hw_82542");
276169240Sjfv
277169240Sjfv	dev_spec = (struct e1000_dev_spec_82542 *)hw->dev_spec;
278169240Sjfv
279169240Sjfv	/* Disabling VLAN filtering */
280169240Sjfv	E1000_WRITE_REG(hw, E1000_VET, 0);
281169240Sjfv	e1000_clear_vfta(hw);
282169240Sjfv
283169240Sjfv	/* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
284169240Sjfv	if (hw->revision_id == E1000_REVISION_2) {
285169240Sjfv		DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
286169240Sjfv		e1000_pci_clear_mwi(hw);
287169240Sjfv		E1000_WRITE_REG(hw, E1000_RCTL, E1000_RCTL_RST);
288169240Sjfv		E1000_WRITE_FLUSH(hw);
289169240Sjfv		msec_delay(5);
290169240Sjfv	}
291169240Sjfv
292169240Sjfv	/* Setup the receive address. */
293169240Sjfv	e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
294169240Sjfv
295169240Sjfv	/* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
296169240Sjfv	if (hw->revision_id == E1000_REVISION_2) {
297169240Sjfv		E1000_WRITE_REG(hw, E1000_RCTL, 0);
298169240Sjfv		E1000_WRITE_FLUSH(hw);
299169240Sjfv		msec_delay(1);
300169240Sjfv		if (hw->bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
301169240Sjfv			e1000_pci_set_mwi(hw);
302169240Sjfv	}
303169240Sjfv
304169240Sjfv	/* Zero out the Multicast HASH table */
305169240Sjfv	DEBUGOUT("Zeroing the MTA\n");
306169240Sjfv	for (i = 0; i < mac->mta_reg_count; i++)
307169240Sjfv		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
308169240Sjfv
309169240Sjfv	/* Set the PCI priority bit correctly in the CTRL register.  This
310169240Sjfv	 * determines if the adapter gives priority to receives, or if it
311169240Sjfv	 * gives equal priority to transmits and receives.
312169240Sjfv	 */
313169240Sjfv	if (dev_spec->dma_fairness) {
314169240Sjfv		ctrl = E1000_READ_REG(hw, E1000_CTRL);
315169240Sjfv		E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
316169240Sjfv	}
317169240Sjfv
318169240Sjfv	/* Setup link and flow control */
319169240Sjfv	ret_val = e1000_setup_link_82542(hw);
320169240Sjfv
321169240Sjfv	/* Clear all of the statistics registers (clear on read).  It is
322169240Sjfv	 * important that we do this after we have tried to establish link
323169240Sjfv	 * because the symbol error count will increment wildly if there
324169240Sjfv	 * is no link.
325169240Sjfv	 */
326169240Sjfv	e1000_clear_hw_cntrs_82542(hw);
327169240Sjfv
328169240Sjfv	return ret_val;
329169240Sjfv}
330169240Sjfv
331169240Sjfv/**
332169240Sjfv *  e1000_setup_link_82542 - Setup flow control and link settings
333169240Sjfv *  @hw - pointer to the HW structure
334169240Sjfv *
335169240Sjfv *  Determines which flow control settings to use, then configures flow
336169240Sjfv *  control.  Calls the appropriate media-specific link configuration
337169240Sjfv *  function.  Assuming the adapter has a valid link partner, a valid link
338169240Sjfv *  should be established.  Assumes the hardware has previously been reset
339169240Sjfv *  and the transmitter and receiver are not enabled.  This is a function
340169240Sjfv *  pointer entry point called by the api module.
341169240Sjfv **/
342169240SjfvSTATIC s32
343169240Sjfve1000_setup_link_82542(struct e1000_hw *hw)
344169240Sjfv{
345169240Sjfv	struct e1000_mac_info *mac = &hw->mac;
346169240Sjfv	struct e1000_functions *func = &hw->func;
347169240Sjfv	s32 ret_val = E1000_SUCCESS;
348169240Sjfv
349169240Sjfv	DEBUGFUNC("e1000_setup_link_82542");
350169240Sjfv
351169240Sjfv	ret_val = e1000_set_default_fc_generic(hw);
352169240Sjfv	if (ret_val)
353169240Sjfv		goto out;
354169240Sjfv
355169240Sjfv	mac->fc &= ~e1000_fc_tx_pause;
356169240Sjfv
357169240Sjfv	if (mac->report_tx_early == 1)
358169240Sjfv		mac->fc &= ~e1000_fc_rx_pause;
359169240Sjfv
360169240Sjfv	/* We want to save off the original Flow Control configuration just in
361169240Sjfv	 * case we get disconnected and then reconnected into a different hub
362169240Sjfv	 * or switch with different Flow Control capabilities.
363169240Sjfv	 */
364169240Sjfv	mac->original_fc = mac->fc;
365169240Sjfv
366169240Sjfv	DEBUGOUT1("After fix-ups FlowControl is now = %x\n", mac->fc);
367169240Sjfv
368169240Sjfv	/* Call the necessary subroutine to configure the link. */
369169240Sjfv	ret_val = func->setup_physical_interface(hw);
370169240Sjfv	if (ret_val)
371169240Sjfv		goto out;
372169240Sjfv
373169240Sjfv	/* Initialize the flow control address, type, and PAUSE timer
374169240Sjfv	 * registers to their default values.  This is done even if flow
375169240Sjfv	 * control is disabled, because it does not hurt anything to
376169240Sjfv	 * initialize these registers.
377169240Sjfv	 */
378169240Sjfv	DEBUGOUT("Initializing Flow Control address, type and timer regs\n");
379169240Sjfv
380169240Sjfv	E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
381169240Sjfv	E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
382169240Sjfv	E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
383169240Sjfv
384169240Sjfv	E1000_WRITE_REG(hw, E1000_FCTTV, mac->fc_pause_time);
385169240Sjfv
386169240Sjfv	ret_val = e1000_set_fc_watermarks_generic(hw);
387169240Sjfv
388169240Sjfvout:
389169240Sjfv	return ret_val;
390169240Sjfv}
391169240Sjfv
392169240Sjfv/**
393169240Sjfv *  e1000_led_on_82542 - Turn on SW controllable LED
394169240Sjfv *  @hw - pointer to the HW structure
395169240Sjfv *
396169240Sjfv *  Turns the SW defined LED on.  This is a function pointer entry point
397169240Sjfv *  called by the api module.
398169240Sjfv **/
399169240SjfvSTATIC s32
400169240Sjfve1000_led_on_82542(struct e1000_hw *hw)
401169240Sjfv{
402169240Sjfv	u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
403169240Sjfv
404169240Sjfv	DEBUGFUNC("e1000_led_on_82542");
405169240Sjfv
406169240Sjfv	ctrl |= E1000_CTRL_SWDPIN0;
407169240Sjfv	ctrl |= E1000_CTRL_SWDPIO0;
408169240Sjfv	E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
409169240Sjfv
410169240Sjfv	return E1000_SUCCESS;
411169240Sjfv}
412169240Sjfv
413169240Sjfv/**
414169240Sjfv *  e1000_led_off_82542 - Turn off SW controllable LED
415169240Sjfv *  @hw - pointer to the HW structure
416169240Sjfv *
417169240Sjfv *  Turns the SW defined LED off.  This is a function pointer entry point
418169240Sjfv *  called by the api module.
419169240Sjfv **/
420169240SjfvSTATIC s32
421169240Sjfve1000_led_off_82542(struct e1000_hw *hw)
422169240Sjfv{
423169240Sjfv	u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
424169240Sjfv
425169240Sjfv	DEBUGFUNC("e1000_led_off_82542");
426169240Sjfv
427169240Sjfv	ctrl &= ~E1000_CTRL_SWDPIN0;
428169240Sjfv	ctrl |= E1000_CTRL_SWDPIO0;
429169240Sjfv	E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
430169240Sjfv
431169240Sjfv	return E1000_SUCCESS;
432169240Sjfv}
433169240Sjfv
434169240Sjfv/**
435169240Sjfv *  e1000_translate_register_82542 - Translate the proper regiser offset
436169240Sjfv *  @reg - e1000 register to be read
437169240Sjfv *
438169240Sjfv *  Registers in 82542 are located in different offsets than other adapters
439169240Sjfv *  even though they function in the same manner.  This function takes in
440169240Sjfv *  the name of the register to read and returns the correct offset for
441169240Sjfv *  82542 silicon.
442169240Sjfv **/
443169240Sjfvu32
444169240Sjfve1000_translate_register_82542(u32 reg)
445169240Sjfv{
446169240Sjfv	/* Some of the 82542 registers are located at different
447169240Sjfv	 * offsets than they are in newer adapters.
448169240Sjfv	 * Despite the difference in location, the registers
449169240Sjfv	 * function in the same manner.
450169240Sjfv	 */
451169240Sjfv	switch (reg) {
452169240Sjfv	case E1000_RA:
453169240Sjfv		reg = 0x00040;
454169240Sjfv		break;
455169240Sjfv	case E1000_RDTR:
456169240Sjfv		reg = 0x00108;
457169240Sjfv		break;
458169240Sjfv	case E1000_RDBAL:
459169240Sjfv		reg = 0x00110;
460169240Sjfv		break;
461169240Sjfv	case E1000_RDBAH:
462169240Sjfv		reg = 0x00114;
463169240Sjfv		break;
464169240Sjfv	case E1000_RDLEN:
465169240Sjfv		reg = 0x00118;
466169240Sjfv		break;
467169240Sjfv	case E1000_RDH:
468169240Sjfv		reg = 0x00120;
469169240Sjfv		break;
470169240Sjfv	case E1000_RDT:
471169240Sjfv		reg = 0x00128;
472169240Sjfv		break;
473169240Sjfv	case E1000_RDBAL1:
474169240Sjfv		reg = 0x00138;
475169240Sjfv		break;
476169240Sjfv	case E1000_RDBAH1:
477169240Sjfv		reg = 0x0013C;
478169240Sjfv		break;
479169240Sjfv	case E1000_RDLEN1:
480169240Sjfv		reg = 0x00140;
481169240Sjfv		break;
482169240Sjfv	case E1000_RDH1:
483169240Sjfv		reg = 0x00148;
484169240Sjfv		break;
485169240Sjfv	case E1000_RDT1:
486169240Sjfv		reg = 0x00150;
487169240Sjfv		break;
488169240Sjfv	case E1000_FCRTH:
489169240Sjfv		reg = 0x00160;
490169240Sjfv		break;
491169240Sjfv	case E1000_FCRTL:
492169240Sjfv		reg = 0x00168;
493169240Sjfv		break;
494169240Sjfv	case E1000_MTA:
495169240Sjfv		reg = 0x00200;
496169240Sjfv		break;
497169240Sjfv	case E1000_TDBAL:
498169240Sjfv		reg = 0x00420;
499169240Sjfv		break;
500169240Sjfv	case E1000_TDBAH:
501169240Sjfv		reg = 0x00424;
502169240Sjfv		break;
503169240Sjfv	case E1000_TDLEN:
504169240Sjfv		reg = 0x00428;
505169240Sjfv		break;
506169240Sjfv	case E1000_TDH:
507169240Sjfv		reg = 0x00430;
508169240Sjfv		break;
509169240Sjfv	case E1000_TDT:
510169240Sjfv		reg = 0x00438;
511169240Sjfv		break;
512169240Sjfv	case E1000_TIDV:
513169240Sjfv		reg = 0x00440;
514169240Sjfv		break;
515169240Sjfv	case E1000_VFTA:
516169240Sjfv		reg = 0x00600;
517169240Sjfv		break;
518169240Sjfv	case E1000_TDFH:
519169240Sjfv		reg = 0x08010;
520169240Sjfv		break;
521169240Sjfv	case E1000_TDFT:
522169240Sjfv		reg = 0x08018;
523169240Sjfv		break;
524169240Sjfv	default:
525169240Sjfv		break;
526169240Sjfv	}
527169240Sjfv
528169240Sjfv	return reg;
529169240Sjfv}
530169240Sjfv
531169240Sjfv/**
532169240Sjfv *  e1000_clear_hw_cntrs_82542 - Clear device specific hardware counters
533169240Sjfv *  @hw - pointer to the HW structure
534169240Sjfv *
535169240Sjfv *  Clears the hardware counters by reading the counter registers.
536169240Sjfv **/
537169240SjfvSTATIC void
538169240Sjfve1000_clear_hw_cntrs_82542(struct e1000_hw *hw)
539169240Sjfv{
540169240Sjfv	volatile u32 temp;
541169240Sjfv
542169240Sjfv	DEBUGFUNC("e1000_clear_hw_cntrs_82542");
543169240Sjfv
544169240Sjfv	e1000_clear_hw_cntrs_base_generic(hw);
545169240Sjfv
546169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC64);
547169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC127);
548169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC255);
549169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC511);
550169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC1023);
551169240Sjfv	temp = E1000_READ_REG(hw, E1000_PRC1522);
552169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC64);
553169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC127);
554169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC255);
555169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC511);
556169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC1023);
557169240Sjfv	temp = E1000_READ_REG(hw, E1000_PTC1522);
558169240Sjfv}
559