1177867Sjfv/******************************************************************************
2169240Sjfv
3247064Sjfv  Copyright (c) 2001-2013, 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
32177867Sjfv******************************************************************************/
33177867Sjfv/*$FreeBSD$*/
34169240Sjfv
35169589Sjfv#include "e1000_api.h"
36169240Sjfv
37169240Sjfv/**
38169240Sjfv *  e1000_init_mac_params - Initialize MAC function pointers
39169589Sjfv *  @hw: pointer to the HW structure
40169240Sjfv *
41169240Sjfv *  This function initializes the function pointers for the MAC
42169240Sjfv *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
43169240Sjfv **/
44173788Sjfvs32 e1000_init_mac_params(struct e1000_hw *hw)
45169240Sjfv{
46169240Sjfv	s32 ret_val = E1000_SUCCESS;
47169240Sjfv
48177867Sjfv	if (hw->mac.ops.init_params) {
49177867Sjfv		ret_val = hw->mac.ops.init_params(hw);
50169240Sjfv		if (ret_val) {
51169240Sjfv			DEBUGOUT("MAC Initialization Error\n");
52169240Sjfv			goto out;
53169240Sjfv		}
54169240Sjfv	} else {
55169240Sjfv		DEBUGOUT("mac.init_mac_params was NULL\n");
56169240Sjfv		ret_val = -E1000_ERR_CONFIG;
57169240Sjfv	}
58169240Sjfv
59169240Sjfvout:
60169240Sjfv	return ret_val;
61169240Sjfv}
62169240Sjfv
63169240Sjfv/**
64169240Sjfv *  e1000_init_nvm_params - Initialize NVM function pointers
65169589Sjfv *  @hw: pointer to the HW structure
66169240Sjfv *
67169240Sjfv *  This function initializes the function pointers for the NVM
68169240Sjfv *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
69169240Sjfv **/
70173788Sjfvs32 e1000_init_nvm_params(struct e1000_hw *hw)
71169240Sjfv{
72169240Sjfv	s32 ret_val = E1000_SUCCESS;
73169240Sjfv
74177867Sjfv	if (hw->nvm.ops.init_params) {
75177867Sjfv		ret_val = hw->nvm.ops.init_params(hw);
76169240Sjfv		if (ret_val) {
77169240Sjfv			DEBUGOUT("NVM Initialization Error\n");
78169240Sjfv			goto out;
79169240Sjfv		}
80169240Sjfv	} else {
81169240Sjfv		DEBUGOUT("nvm.init_nvm_params was NULL\n");
82169240Sjfv		ret_val = -E1000_ERR_CONFIG;
83169240Sjfv	}
84169240Sjfv
85169240Sjfvout:
86169240Sjfv	return ret_val;
87169240Sjfv}
88169240Sjfv
89169240Sjfv/**
90169240Sjfv *  e1000_init_phy_params - Initialize PHY function pointers
91169589Sjfv *  @hw: pointer to the HW structure
92169240Sjfv *
93169240Sjfv *  This function initializes the function pointers for the PHY
94169240Sjfv *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
95169240Sjfv **/
96173788Sjfvs32 e1000_init_phy_params(struct e1000_hw *hw)
97169240Sjfv{
98169240Sjfv	s32 ret_val = E1000_SUCCESS;
99169240Sjfv
100177867Sjfv	if (hw->phy.ops.init_params) {
101177867Sjfv		ret_val = hw->phy.ops.init_params(hw);
102169240Sjfv		if (ret_val) {
103169240Sjfv			DEBUGOUT("PHY Initialization Error\n");
104169240Sjfv			goto out;
105169240Sjfv		}
106169240Sjfv	} else {
107169240Sjfv		DEBUGOUT("phy.init_phy_params was NULL\n");
108169240Sjfv		ret_val =  -E1000_ERR_CONFIG;
109169240Sjfv	}
110169240Sjfv
111169240Sjfvout:
112169240Sjfv	return ret_val;
113169240Sjfv}
114169240Sjfv
115209616Sjfv/**
116209616Sjfv *  e1000_init_mbx_params - Initialize mailbox function pointers
117209616Sjfv *  @hw: pointer to the HW structure
118209616Sjfv *
119209616Sjfv *  This function initializes the function pointers for the PHY
120209616Sjfv *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
121209616Sjfv **/
122209616Sjfvs32 e1000_init_mbx_params(struct e1000_hw *hw)
123209616Sjfv{
124209616Sjfv	s32 ret_val = E1000_SUCCESS;
125190872Sjfv
126209616Sjfv	if (hw->mbx.ops.init_params) {
127209616Sjfv		ret_val = hw->mbx.ops.init_params(hw);
128209616Sjfv		if (ret_val) {
129209616Sjfv			DEBUGOUT("Mailbox Initialization Error\n");
130209616Sjfv			goto out;
131209616Sjfv		}
132209616Sjfv	} else {
133209616Sjfv		DEBUGOUT("mbx.init_mbx_params was NULL\n");
134209616Sjfv		ret_val =  -E1000_ERR_CONFIG;
135209616Sjfv	}
136209616Sjfv
137209616Sjfvout:
138209616Sjfv	return ret_val;
139209616Sjfv}
140209616Sjfv
141169240Sjfv/**
142169240Sjfv *  e1000_set_mac_type - Sets MAC type
143169589Sjfv *  @hw: pointer to the HW structure
144169240Sjfv *
145169240Sjfv *  This function sets the mac type of the adapter based on the
146169240Sjfv *  device ID stored in the hw structure.
147169240Sjfv *  MUST BE FIRST FUNCTION CALLED (explicitly or through
148169240Sjfv *  e1000_setup_init_funcs()).
149169240Sjfv **/
150173788Sjfvs32 e1000_set_mac_type(struct e1000_hw *hw)
151169240Sjfv{
152169240Sjfv	struct e1000_mac_info *mac = &hw->mac;
153169240Sjfv	s32 ret_val = E1000_SUCCESS;
154169240Sjfv
155169240Sjfv	DEBUGFUNC("e1000_set_mac_type");
156169240Sjfv
157169240Sjfv	switch (hw->device_id) {
158169240Sjfv	case E1000_DEV_ID_82542:
159169240Sjfv		mac->type = e1000_82542;
160169240Sjfv		break;
161169240Sjfv	case E1000_DEV_ID_82543GC_FIBER:
162169240Sjfv	case E1000_DEV_ID_82543GC_COPPER:
163169240Sjfv		mac->type = e1000_82543;
164169240Sjfv		break;
165169240Sjfv	case E1000_DEV_ID_82544EI_COPPER:
166169240Sjfv	case E1000_DEV_ID_82544EI_FIBER:
167169240Sjfv	case E1000_DEV_ID_82544GC_COPPER:
168169240Sjfv	case E1000_DEV_ID_82544GC_LOM:
169169240Sjfv		mac->type = e1000_82544;
170169240Sjfv		break;
171169240Sjfv	case E1000_DEV_ID_82540EM:
172169240Sjfv	case E1000_DEV_ID_82540EM_LOM:
173169240Sjfv	case E1000_DEV_ID_82540EP:
174169240Sjfv	case E1000_DEV_ID_82540EP_LOM:
175169240Sjfv	case E1000_DEV_ID_82540EP_LP:
176169240Sjfv		mac->type = e1000_82540;
177169240Sjfv		break;
178169240Sjfv	case E1000_DEV_ID_82545EM_COPPER:
179169240Sjfv	case E1000_DEV_ID_82545EM_FIBER:
180169240Sjfv		mac->type = e1000_82545;
181169240Sjfv		break;
182169240Sjfv	case E1000_DEV_ID_82545GM_COPPER:
183169240Sjfv	case E1000_DEV_ID_82545GM_FIBER:
184169240Sjfv	case E1000_DEV_ID_82545GM_SERDES:
185169240Sjfv		mac->type = e1000_82545_rev_3;
186169240Sjfv		break;
187169240Sjfv	case E1000_DEV_ID_82546EB_COPPER:
188169240Sjfv	case E1000_DEV_ID_82546EB_FIBER:
189169240Sjfv	case E1000_DEV_ID_82546EB_QUAD_COPPER:
190169240Sjfv		mac->type = e1000_82546;
191169240Sjfv		break;
192169240Sjfv	case E1000_DEV_ID_82546GB_COPPER:
193169240Sjfv	case E1000_DEV_ID_82546GB_FIBER:
194169240Sjfv	case E1000_DEV_ID_82546GB_SERDES:
195169240Sjfv	case E1000_DEV_ID_82546GB_PCIE:
196169240Sjfv	case E1000_DEV_ID_82546GB_QUAD_COPPER:
197169240Sjfv	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
198169240Sjfv		mac->type = e1000_82546_rev_3;
199169240Sjfv		break;
200169240Sjfv	case E1000_DEV_ID_82541EI:
201169240Sjfv	case E1000_DEV_ID_82541EI_MOBILE:
202169240Sjfv	case E1000_DEV_ID_82541ER_LOM:
203169240Sjfv		mac->type = e1000_82541;
204169240Sjfv		break;
205169240Sjfv	case E1000_DEV_ID_82541ER:
206169240Sjfv	case E1000_DEV_ID_82541GI:
207169240Sjfv	case E1000_DEV_ID_82541GI_LF:
208169240Sjfv	case E1000_DEV_ID_82541GI_MOBILE:
209169240Sjfv		mac->type = e1000_82541_rev_2;
210169240Sjfv		break;
211169240Sjfv	case E1000_DEV_ID_82547EI:
212169240Sjfv	case E1000_DEV_ID_82547EI_MOBILE:
213169240Sjfv		mac->type = e1000_82547;
214169240Sjfv		break;
215169240Sjfv	case E1000_DEV_ID_82547GI:
216169240Sjfv		mac->type = e1000_82547_rev_2;
217169240Sjfv		break;
218169240Sjfv	case E1000_DEV_ID_82571EB_COPPER:
219169240Sjfv	case E1000_DEV_ID_82571EB_FIBER:
220169240Sjfv	case E1000_DEV_ID_82571EB_SERDES:
221169589Sjfv	case E1000_DEV_ID_82571EB_SERDES_DUAL:
222169589Sjfv	case E1000_DEV_ID_82571EB_SERDES_QUAD:
223169240Sjfv	case E1000_DEV_ID_82571EB_QUAD_COPPER:
224173788Sjfv	case E1000_DEV_ID_82571PT_QUAD_COPPER:
225169240Sjfv	case E1000_DEV_ID_82571EB_QUAD_FIBER:
226169240Sjfv	case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
227169240Sjfv		mac->type = e1000_82571;
228169240Sjfv		break;
229169240Sjfv	case E1000_DEV_ID_82572EI:
230169240Sjfv	case E1000_DEV_ID_82572EI_COPPER:
231169240Sjfv	case E1000_DEV_ID_82572EI_FIBER:
232169240Sjfv	case E1000_DEV_ID_82572EI_SERDES:
233169240Sjfv		mac->type = e1000_82572;
234169240Sjfv		break;
235169240Sjfv	case E1000_DEV_ID_82573E:
236169240Sjfv	case E1000_DEV_ID_82573E_IAMT:
237169240Sjfv	case E1000_DEV_ID_82573L:
238169240Sjfv		mac->type = e1000_82573;
239169240Sjfv		break;
240178523Sjfv	case E1000_DEV_ID_82574L:
241194865Sjfv	case E1000_DEV_ID_82574LA:
242178523Sjfv		mac->type = e1000_82574;
243178523Sjfv		break;
244194865Sjfv	case E1000_DEV_ID_82583V:
245194865Sjfv		mac->type = e1000_82583;
246194865Sjfv		break;
247169240Sjfv	case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
248169240Sjfv	case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
249169240Sjfv	case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
250169240Sjfv	case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
251169240Sjfv		mac->type = e1000_80003es2lan;
252169240Sjfv		break;
253169240Sjfv	case E1000_DEV_ID_ICH8_IFE:
254169240Sjfv	case E1000_DEV_ID_ICH8_IFE_GT:
255169240Sjfv	case E1000_DEV_ID_ICH8_IFE_G:
256169240Sjfv	case E1000_DEV_ID_ICH8_IGP_M:
257169240Sjfv	case E1000_DEV_ID_ICH8_IGP_M_AMT:
258169240Sjfv	case E1000_DEV_ID_ICH8_IGP_AMT:
259169240Sjfv	case E1000_DEV_ID_ICH8_IGP_C:
260200243Sjfv	case E1000_DEV_ID_ICH8_82567V_3:
261169240Sjfv		mac->type = e1000_ich8lan;
262169240Sjfv		break;
263169240Sjfv	case E1000_DEV_ID_ICH9_IFE:
264169240Sjfv	case E1000_DEV_ID_ICH9_IFE_GT:
265169240Sjfv	case E1000_DEV_ID_ICH9_IFE_G:
266176667Sjfv	case E1000_DEV_ID_ICH9_IGP_M:
267176667Sjfv	case E1000_DEV_ID_ICH9_IGP_M_AMT:
268177867Sjfv	case E1000_DEV_ID_ICH9_IGP_M_V:
269169240Sjfv	case E1000_DEV_ID_ICH9_IGP_AMT:
270178523Sjfv	case E1000_DEV_ID_ICH9_BM:
271169240Sjfv	case E1000_DEV_ID_ICH9_IGP_C:
272178523Sjfv	case E1000_DEV_ID_ICH10_R_BM_LM:
273178523Sjfv	case E1000_DEV_ID_ICH10_R_BM_LF:
274178523Sjfv	case E1000_DEV_ID_ICH10_R_BM_V:
275169240Sjfv		mac->type = e1000_ich9lan;
276169240Sjfv		break;
277178523Sjfv	case E1000_DEV_ID_ICH10_D_BM_LM:
278178523Sjfv	case E1000_DEV_ID_ICH10_D_BM_LF:
279213234Sjfv	case E1000_DEV_ID_ICH10_D_BM_V:
280178523Sjfv		mac->type = e1000_ich10lan;
281178523Sjfv		break;
282194865Sjfv	case E1000_DEV_ID_PCH_D_HV_DM:
283194865Sjfv	case E1000_DEV_ID_PCH_D_HV_DC:
284194865Sjfv	case E1000_DEV_ID_PCH_M_HV_LM:
285194865Sjfv	case E1000_DEV_ID_PCH_M_HV_LC:
286194865Sjfv		mac->type = e1000_pchlan;
287194865Sjfv		break;
288213234Sjfv	case E1000_DEV_ID_PCH2_LV_LM:
289213234Sjfv	case E1000_DEV_ID_PCH2_LV_V:
290213234Sjfv		mac->type = e1000_pch2lan;
291213234Sjfv		break;
292247064Sjfv	case E1000_DEV_ID_PCH_LPT_I217_LM:
293247064Sjfv	case E1000_DEV_ID_PCH_LPT_I217_V:
294247064Sjfv	case E1000_DEV_ID_PCH_LPTLP_I218_LM:
295247064Sjfv	case E1000_DEV_ID_PCH_LPTLP_I218_V:
296247064Sjfv		mac->type = e1000_pch_lpt;
297247064Sjfv		break;
298177867Sjfv	case E1000_DEV_ID_82575EB_COPPER:
299177867Sjfv	case E1000_DEV_ID_82575EB_FIBER_SERDES:
300177867Sjfv	case E1000_DEV_ID_82575GB_QUAD_COPPER:
301177867Sjfv		mac->type = e1000_82575;
302169240Sjfv		break;
303181027Sjfv	case E1000_DEV_ID_82576:
304181027Sjfv	case E1000_DEV_ID_82576_FIBER:
305181027Sjfv	case E1000_DEV_ID_82576_SERDES:
306181027Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER:
307213234Sjfv	case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
308190872Sjfv	case E1000_DEV_ID_82576_NS:
309200243Sjfv	case E1000_DEV_ID_82576_NS_SERDES:
310194865Sjfv	case E1000_DEV_ID_82576_SERDES_QUAD:
311181027Sjfv		mac->type = e1000_82576;
312181027Sjfv		break;
313200243Sjfv	case E1000_DEV_ID_82580_COPPER:
314200243Sjfv	case E1000_DEV_ID_82580_FIBER:
315200243Sjfv	case E1000_DEV_ID_82580_SERDES:
316200243Sjfv	case E1000_DEV_ID_82580_SGMII:
317200243Sjfv	case E1000_DEV_ID_82580_COPPER_DUAL:
318213234Sjfv	case E1000_DEV_ID_82580_QUAD_FIBER:
319215789Sjfv	case E1000_DEV_ID_DH89XXCC_SGMII:
320215789Sjfv	case E1000_DEV_ID_DH89XXCC_SERDES:
321218530Sjfv	case E1000_DEV_ID_DH89XXCC_BACKPLANE:
322218530Sjfv	case E1000_DEV_ID_DH89XXCC_SFP:
323200243Sjfv		mac->type = e1000_82580;
324200243Sjfv		break;
325218530Sjfv	case E1000_DEV_ID_I350_COPPER:
326218530Sjfv	case E1000_DEV_ID_I350_FIBER:
327218530Sjfv	case E1000_DEV_ID_I350_SERDES:
328218530Sjfv	case E1000_DEV_ID_I350_SGMII:
329228386Sjfv	case E1000_DEV_ID_I350_DA4:
330218530Sjfv		mac->type = e1000_i350;
331218530Sjfv		break;
332256200Sjfv	case E1000_DEV_ID_I210_COPPER_FLASHLESS:
333256200Sjfv	case E1000_DEV_ID_I210_SERDES_FLASHLESS:
334238148Sjfv	case E1000_DEV_ID_I210_COPPER:
335238148Sjfv	case E1000_DEV_ID_I210_COPPER_OEM1:
336238148Sjfv	case E1000_DEV_ID_I210_COPPER_IT:
337238148Sjfv	case E1000_DEV_ID_I210_FIBER:
338238148Sjfv	case E1000_DEV_ID_I210_SERDES:
339238148Sjfv	case E1000_DEV_ID_I210_SGMII:
340238148Sjfv		mac->type = e1000_i210;
341238148Sjfv		break;
342238148Sjfv	case E1000_DEV_ID_I211_COPPER:
343247064Sjfv		mac->type = e1000_i211;
344247064Sjfv		break;
345209616Sjfv	case E1000_DEV_ID_82576_VF:
346247064Sjfv	case E1000_DEV_ID_82576_VF_HV:
347209616Sjfv		mac->type = e1000_vfadapt;
348209616Sjfv		break;
349218530Sjfv	case E1000_DEV_ID_I350_VF:
350247064Sjfv	case E1000_DEV_ID_I350_VF_HV:
351218530Sjfv		mac->type = e1000_vfadapt_i350;
352218530Sjfv		break;
353247064Sjfv
354256200Sjfv	case E1000_DEV_ID_I354_BACKPLANE_1GBPS:
355256200Sjfv	case E1000_DEV_ID_I354_SGMII:
356256200Sjfv	case E1000_DEV_ID_I354_BACKPLANE_2_5GBPS:
357256200Sjfv		mac->type = e1000_i354;
358256200Sjfv		break;
359169240Sjfv	default:
360169240Sjfv		/* Should never have loaded on this device */
361169240Sjfv		ret_val = -E1000_ERR_MAC_INIT;
362169240Sjfv		break;
363169240Sjfv	}
364169240Sjfv
365169240Sjfv	return ret_val;
366169240Sjfv}
367169240Sjfv
368169240Sjfv/**
369169240Sjfv *  e1000_setup_init_funcs - Initializes function pointers
370169589Sjfv *  @hw: pointer to the HW structure
371169589Sjfv *  @init_device: TRUE will initialize the rest of the function pointers
372228386Sjfv *		  getting the device ready for use.  FALSE will only set
373228386Sjfv *		  MAC type and the function pointers for the other init
374228386Sjfv *		  functions.  Passing FALSE will not generate any hardware
375228386Sjfv *		  reads or writes.
376169240Sjfv *
377169240Sjfv *  This function must be called by a driver in order to use the rest
378169240Sjfv *  of the 'shared' code files. Called by drivers only.
379169240Sjfv **/
380173788Sjfvs32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
381169240Sjfv{
382169240Sjfv	s32 ret_val;
383169240Sjfv
384173788Sjfv	/* Can't do much good without knowing the MAC type. */
385169240Sjfv	ret_val = e1000_set_mac_type(hw);
386169240Sjfv	if (ret_val) {
387169240Sjfv		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
388169240Sjfv		goto out;
389169240Sjfv	}
390169240Sjfv
391169240Sjfv	if (!hw->hw_addr) {
392169240Sjfv		DEBUGOUT("ERROR: Registers not mapped\n");
393169240Sjfv		ret_val = -E1000_ERR_CONFIG;
394169240Sjfv		goto out;
395169240Sjfv	}
396169240Sjfv
397173788Sjfv	/*
398177867Sjfv	 * Init function pointers to generic implementations. We do this first
399177867Sjfv	 * allowing a driver module to override it afterward.
400169240Sjfv	 */
401177867Sjfv	e1000_init_mac_ops_generic(hw);
402177867Sjfv	e1000_init_phy_ops_generic(hw);
403177867Sjfv	e1000_init_nvm_ops_generic(hw);
404209616Sjfv	e1000_init_mbx_ops_generic(hw);
405169240Sjfv
406173788Sjfv	/*
407173788Sjfv	 * Set up the init function pointers. These are functions within the
408169240Sjfv	 * adapter family file that sets up function pointers for the rest of
409169240Sjfv	 * the functions in that family.
410169240Sjfv	 */
411169240Sjfv	switch (hw->mac.type) {
412169240Sjfv	case e1000_82542:
413169240Sjfv		e1000_init_function_pointers_82542(hw);
414169240Sjfv		break;
415169240Sjfv	case e1000_82543:
416169240Sjfv	case e1000_82544:
417169240Sjfv		e1000_init_function_pointers_82543(hw);
418169240Sjfv		break;
419169240Sjfv	case e1000_82540:
420169240Sjfv	case e1000_82545:
421169240Sjfv	case e1000_82545_rev_3:
422169240Sjfv	case e1000_82546:
423169240Sjfv	case e1000_82546_rev_3:
424169240Sjfv		e1000_init_function_pointers_82540(hw);
425169240Sjfv		break;
426169240Sjfv	case e1000_82541:
427169240Sjfv	case e1000_82541_rev_2:
428169240Sjfv	case e1000_82547:
429169240Sjfv	case e1000_82547_rev_2:
430169240Sjfv		e1000_init_function_pointers_82541(hw);
431169240Sjfv		break;
432169240Sjfv	case e1000_82571:
433169240Sjfv	case e1000_82572:
434169240Sjfv	case e1000_82573:
435178523Sjfv	case e1000_82574:
436194865Sjfv	case e1000_82583:
437169240Sjfv		e1000_init_function_pointers_82571(hw);
438169240Sjfv		break;
439169240Sjfv	case e1000_80003es2lan:
440169240Sjfv		e1000_init_function_pointers_80003es2lan(hw);
441169240Sjfv		break;
442169240Sjfv	case e1000_ich8lan:
443169240Sjfv	case e1000_ich9lan:
444178523Sjfv	case e1000_ich10lan:
445194865Sjfv	case e1000_pchlan:
446213234Sjfv	case e1000_pch2lan:
447247064Sjfv	case e1000_pch_lpt:
448169240Sjfv		e1000_init_function_pointers_ich8lan(hw);
449169240Sjfv		break;
450177867Sjfv	case e1000_82575:
451181027Sjfv	case e1000_82576:
452200243Sjfv	case e1000_82580:
453218530Sjfv	case e1000_i350:
454256200Sjfv	case e1000_i354:
455177867Sjfv		e1000_init_function_pointers_82575(hw);
456177867Sjfv		break;
457238148Sjfv	case e1000_i210:
458238148Sjfv	case e1000_i211:
459238148Sjfv		e1000_init_function_pointers_i210(hw);
460238148Sjfv		break;
461209616Sjfv	case e1000_vfadapt:
462209616Sjfv		e1000_init_function_pointers_vf(hw);
463209616Sjfv		break;
464218530Sjfv	case e1000_vfadapt_i350:
465218530Sjfv		e1000_init_function_pointers_vf(hw);
466218530Sjfv		break;
467169240Sjfv	default:
468169240Sjfv		DEBUGOUT("Hardware not supported\n");
469169240Sjfv		ret_val = -E1000_ERR_CONFIG;
470169240Sjfv		break;
471169240Sjfv	}
472169240Sjfv
473173788Sjfv	/*
474173788Sjfv	 * Initialize the rest of the function pointers. These require some
475169240Sjfv	 * register reads/writes in some cases.
476169240Sjfv	 */
477173788Sjfv	if (!(ret_val) && init_device) {
478169240Sjfv		ret_val = e1000_init_mac_params(hw);
479169240Sjfv		if (ret_val)
480169240Sjfv			goto out;
481169240Sjfv
482169240Sjfv		ret_val = e1000_init_nvm_params(hw);
483169240Sjfv		if (ret_val)
484169240Sjfv			goto out;
485169240Sjfv
486169240Sjfv		ret_val = e1000_init_phy_params(hw);
487169240Sjfv		if (ret_val)
488169240Sjfv			goto out;
489209616Sjfv
490209616Sjfv		ret_val = e1000_init_mbx_params(hw);
491209616Sjfv		if (ret_val)
492209616Sjfv			goto out;
493169240Sjfv	}
494169240Sjfv
495169240Sjfvout:
496169240Sjfv	return ret_val;
497169240Sjfv}
498169240Sjfv
499169240Sjfv/**
500169240Sjfv *  e1000_get_bus_info - Obtain bus information for adapter
501169589Sjfv *  @hw: pointer to the HW structure
502169240Sjfv *
503169240Sjfv *  This will obtain information about the HW bus for which the
504176667Sjfv *  adapter is attached and stores it in the hw structure. This is a
505169240Sjfv *  function pointer entry point called by drivers.
506169240Sjfv **/
507173788Sjfvs32 e1000_get_bus_info(struct e1000_hw *hw)
508169240Sjfv{
509177867Sjfv	if (hw->mac.ops.get_bus_info)
510177867Sjfv		return hw->mac.ops.get_bus_info(hw);
511173788Sjfv
512173788Sjfv	return E1000_SUCCESS;
513169240Sjfv}
514169240Sjfv
515169240Sjfv/**
516169240Sjfv *  e1000_clear_vfta - Clear VLAN filter table
517169589Sjfv *  @hw: pointer to the HW structure
518169240Sjfv *
519169240Sjfv *  This clears the VLAN filter table on the adapter. This is a function
520169240Sjfv *  pointer entry point called by drivers.
521169240Sjfv **/
522173788Sjfvvoid e1000_clear_vfta(struct e1000_hw *hw)
523169240Sjfv{
524177867Sjfv	if (hw->mac.ops.clear_vfta)
525178523Sjfv		hw->mac.ops.clear_vfta(hw);
526169240Sjfv}
527169240Sjfv
528169240Sjfv/**
529169240Sjfv *  e1000_write_vfta - Write value to VLAN filter table
530169589Sjfv *  @hw: pointer to the HW structure
531169589Sjfv *  @offset: the 32-bit offset in which to write the value to.
532169589Sjfv *  @value: the 32-bit value to write at location offset.
533169240Sjfv *
534169240Sjfv *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
535169240Sjfv *  table. This is a function pointer entry point called by drivers.
536169240Sjfv **/
537173788Sjfvvoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
538169240Sjfv{
539177867Sjfv	if (hw->mac.ops.write_vfta)
540177867Sjfv		hw->mac.ops.write_vfta(hw, offset, value);
541169240Sjfv}
542169240Sjfv
543169240Sjfv/**
544173788Sjfv *  e1000_update_mc_addr_list - Update Multicast addresses
545169589Sjfv *  @hw: pointer to the HW structure
546169589Sjfv *  @mc_addr_list: array of multicast addresses to program
547169589Sjfv *  @mc_addr_count: number of multicast addresses to program
548169240Sjfv *
549190872Sjfv *  Updates the Multicast Table Array.
550169240Sjfv *  The caller must have a packed mc_addr_list of multicast addresses.
551169240Sjfv **/
552173788Sjfvvoid e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
553228386Sjfv			       u32 mc_addr_count)
554169240Sjfv{
555177867Sjfv	if (hw->mac.ops.update_mc_addr_list)
556190872Sjfv		hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
557228386Sjfv						mc_addr_count);
558169240Sjfv}
559169240Sjfv
560169240Sjfv/**
561169240Sjfv *  e1000_force_mac_fc - Force MAC flow control
562169589Sjfv *  @hw: pointer to the HW structure
563169240Sjfv *
564169240Sjfv *  Force the MAC's flow control settings. Currently no func pointer exists
565169240Sjfv *  and all implementations are handled in the generic version of this
566169240Sjfv *  function.
567169240Sjfv **/
568173788Sjfvs32 e1000_force_mac_fc(struct e1000_hw *hw)
569169240Sjfv{
570169240Sjfv	return e1000_force_mac_fc_generic(hw);
571169240Sjfv}
572169240Sjfv
573169240Sjfv/**
574169240Sjfv *  e1000_check_for_link - Check/Store link connection
575169589Sjfv *  @hw: pointer to the HW structure
576169240Sjfv *
577169240Sjfv *  This checks the link condition of the adapter and stores the
578169240Sjfv *  results in the hw->mac structure. This is a function pointer entry
579169240Sjfv *  point called by drivers.
580169240Sjfv **/
581173788Sjfvs32 e1000_check_for_link(struct e1000_hw *hw)
582169240Sjfv{
583177867Sjfv	if (hw->mac.ops.check_for_link)
584177867Sjfv		return hw->mac.ops.check_for_link(hw);
585173788Sjfv
586173788Sjfv	return -E1000_ERR_CONFIG;
587169240Sjfv}
588169240Sjfv
589169240Sjfv/**
590169240Sjfv *  e1000_check_mng_mode - Check management mode
591169589Sjfv *  @hw: pointer to the HW structure
592169240Sjfv *
593169240Sjfv *  This checks if the adapter has manageability enabled.
594169240Sjfv *  This is a function pointer entry point called by drivers.
595169240Sjfv **/
596173788Sjfvbool e1000_check_mng_mode(struct e1000_hw *hw)
597169240Sjfv{
598177867Sjfv	if (hw->mac.ops.check_mng_mode)
599177867Sjfv		return hw->mac.ops.check_mng_mode(hw);
600173788Sjfv
601173788Sjfv	return FALSE;
602169240Sjfv}
603169240Sjfv
604169240Sjfv/**
605169240Sjfv *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
606169589Sjfv *  @hw: pointer to the HW structure
607169589Sjfv *  @buffer: pointer to the host interface
608169589Sjfv *  @length: size of the buffer
609169240Sjfv *
610169240Sjfv *  Writes the DHCP information to the host interface.
611169240Sjfv **/
612173788Sjfvs32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
613169240Sjfv{
614169240Sjfv	return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
615169240Sjfv}
616169240Sjfv
617169240Sjfv/**
618169240Sjfv *  e1000_reset_hw - Reset hardware
619169589Sjfv *  @hw: pointer to the HW structure
620169240Sjfv *
621169240Sjfv *  This resets the hardware into a known state. This is a function pointer
622169240Sjfv *  entry point called by drivers.
623169240Sjfv **/
624173788Sjfvs32 e1000_reset_hw(struct e1000_hw *hw)
625169240Sjfv{
626177867Sjfv	if (hw->mac.ops.reset_hw)
627177867Sjfv		return hw->mac.ops.reset_hw(hw);
628173788Sjfv
629173788Sjfv	return -E1000_ERR_CONFIG;
630169240Sjfv}
631169240Sjfv
632169240Sjfv/**
633169240Sjfv *  e1000_init_hw - Initialize hardware
634169589Sjfv *  @hw: pointer to the HW structure
635169240Sjfv *
636169240Sjfv *  This inits the hardware readying it for operation. This is a function
637169240Sjfv *  pointer entry point called by drivers.
638169240Sjfv **/
639173788Sjfvs32 e1000_init_hw(struct e1000_hw *hw)
640169240Sjfv{
641177867Sjfv	if (hw->mac.ops.init_hw)
642177867Sjfv		return hw->mac.ops.init_hw(hw);
643173788Sjfv
644173788Sjfv	return -E1000_ERR_CONFIG;
645169240Sjfv}
646169240Sjfv
647169240Sjfv/**
648169240Sjfv *  e1000_setup_link - Configures link and flow control
649169589Sjfv *  @hw: pointer to the HW structure
650169240Sjfv *
651169240Sjfv *  This configures link and flow control settings for the adapter. This
652169240Sjfv *  is a function pointer entry point called by drivers. While modules can
653169240Sjfv *  also call this, they probably call their own version of this function.
654169240Sjfv **/
655173788Sjfvs32 e1000_setup_link(struct e1000_hw *hw)
656169240Sjfv{
657177867Sjfv	if (hw->mac.ops.setup_link)
658177867Sjfv		return hw->mac.ops.setup_link(hw);
659173788Sjfv
660173788Sjfv	return -E1000_ERR_CONFIG;
661169240Sjfv}
662169240Sjfv
663169240Sjfv/**
664169240Sjfv *  e1000_get_speed_and_duplex - Returns current speed and duplex
665169589Sjfv *  @hw: pointer to the HW structure
666169589Sjfv *  @speed: pointer to a 16-bit value to store the speed
667169589Sjfv *  @duplex: pointer to a 16-bit value to store the duplex.
668169240Sjfv *
669169240Sjfv *  This returns the speed and duplex of the adapter in the two 'out'
670169240Sjfv *  variables passed in. This is a function pointer entry point called
671169240Sjfv *  by drivers.
672169240Sjfv **/
673173788Sjfvs32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
674169240Sjfv{
675177867Sjfv	if (hw->mac.ops.get_link_up_info)
676177867Sjfv		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
677173788Sjfv
678173788Sjfv	return -E1000_ERR_CONFIG;
679169240Sjfv}
680169240Sjfv
681169240Sjfv/**
682169240Sjfv *  e1000_setup_led - Configures SW controllable LED
683169589Sjfv *  @hw: pointer to the HW structure
684169240Sjfv *
685169240Sjfv *  This prepares the SW controllable LED for use and saves the current state
686169240Sjfv *  of the LED so it can be later restored. This is a function pointer entry
687169240Sjfv *  point called by drivers.
688169240Sjfv **/
689173788Sjfvs32 e1000_setup_led(struct e1000_hw *hw)
690169240Sjfv{
691177867Sjfv	if (hw->mac.ops.setup_led)
692177867Sjfv		return hw->mac.ops.setup_led(hw);
693173788Sjfv
694173788Sjfv	return E1000_SUCCESS;
695169240Sjfv}
696169240Sjfv
697169240Sjfv/**
698169240Sjfv *  e1000_cleanup_led - Restores SW controllable LED
699169589Sjfv *  @hw: pointer to the HW structure
700169240Sjfv *
701169240Sjfv *  This restores the SW controllable LED to the value saved off by
702169240Sjfv *  e1000_setup_led. This is a function pointer entry point called by drivers.
703169240Sjfv **/
704173788Sjfvs32 e1000_cleanup_led(struct e1000_hw *hw)
705169240Sjfv{
706177867Sjfv	if (hw->mac.ops.cleanup_led)
707177867Sjfv		return hw->mac.ops.cleanup_led(hw);
708173788Sjfv
709173788Sjfv	return E1000_SUCCESS;
710169240Sjfv}
711169240Sjfv
712169240Sjfv/**
713169240Sjfv *  e1000_blink_led - Blink SW controllable LED
714169589Sjfv *  @hw: pointer to the HW structure
715169240Sjfv *
716169240Sjfv *  This starts the adapter LED blinking. Request the LED to be setup first
717169240Sjfv *  and cleaned up after. This is a function pointer entry point called by
718169240Sjfv *  drivers.
719169240Sjfv **/
720173788Sjfvs32 e1000_blink_led(struct e1000_hw *hw)
721169240Sjfv{
722177867Sjfv	if (hw->mac.ops.blink_led)
723177867Sjfv		return hw->mac.ops.blink_led(hw);
724173788Sjfv
725173788Sjfv	return E1000_SUCCESS;
726169240Sjfv}
727169240Sjfv
728169240Sjfv/**
729190872Sjfv *  e1000_id_led_init - store LED configurations in SW
730190872Sjfv *  @hw: pointer to the HW structure
731190872Sjfv *
732190872Sjfv *  Initializes the LED config in SW. This is a function pointer entry point
733190872Sjfv *  called by drivers.
734190872Sjfv **/
735190872Sjfvs32 e1000_id_led_init(struct e1000_hw *hw)
736190872Sjfv{
737190872Sjfv	if (hw->mac.ops.id_led_init)
738190872Sjfv		return hw->mac.ops.id_led_init(hw);
739190872Sjfv
740190872Sjfv	return E1000_SUCCESS;
741190872Sjfv}
742190872Sjfv
743190872Sjfv/**
744169240Sjfv *  e1000_led_on - Turn on SW controllable LED
745169589Sjfv *  @hw: pointer to the HW structure
746169240Sjfv *
747169240Sjfv *  Turns the SW defined LED on. This is a function pointer entry point
748169240Sjfv *  called by drivers.
749169240Sjfv **/
750173788Sjfvs32 e1000_led_on(struct e1000_hw *hw)
751169240Sjfv{
752177867Sjfv	if (hw->mac.ops.led_on)
753177867Sjfv		return hw->mac.ops.led_on(hw);
754173788Sjfv
755173788Sjfv	return E1000_SUCCESS;
756169240Sjfv}
757169240Sjfv
758169240Sjfv/**
759169240Sjfv *  e1000_led_off - Turn off SW controllable LED
760169589Sjfv *  @hw: pointer to the HW structure
761169240Sjfv *
762169240Sjfv *  Turns the SW defined LED off. This is a function pointer entry point
763169240Sjfv *  called by drivers.
764169240Sjfv **/
765173788Sjfvs32 e1000_led_off(struct e1000_hw *hw)
766169240Sjfv{
767177867Sjfv	if (hw->mac.ops.led_off)
768177867Sjfv		return hw->mac.ops.led_off(hw);
769173788Sjfv
770173788Sjfv	return E1000_SUCCESS;
771169240Sjfv}
772169240Sjfv
773169240Sjfv/**
774169240Sjfv *  e1000_reset_adaptive - Reset adaptive IFS
775169589Sjfv *  @hw: pointer to the HW structure
776169240Sjfv *
777169240Sjfv *  Resets the adaptive IFS. Currently no func pointer exists and all
778169240Sjfv *  implementations are handled in the generic version of this function.
779169240Sjfv **/
780173788Sjfvvoid e1000_reset_adaptive(struct e1000_hw *hw)
781169240Sjfv{
782169240Sjfv	e1000_reset_adaptive_generic(hw);
783169240Sjfv}
784169240Sjfv
785169240Sjfv/**
786169240Sjfv *  e1000_update_adaptive - Update adaptive IFS
787169589Sjfv *  @hw: pointer to the HW structure
788169240Sjfv *
789169240Sjfv *  Updates adapter IFS. Currently no func pointer exists and all
790169240Sjfv *  implementations are handled in the generic version of this function.
791169240Sjfv **/
792173788Sjfvvoid e1000_update_adaptive(struct e1000_hw *hw)
793169240Sjfv{
794169240Sjfv	e1000_update_adaptive_generic(hw);
795169240Sjfv}
796169240Sjfv
797169240Sjfv/**
798169240Sjfv *  e1000_disable_pcie_master - Disable PCI-Express master access
799169589Sjfv *  @hw: pointer to the HW structure
800169240Sjfv *
801169240Sjfv *  Disables PCI-Express master access and verifies there are no pending
802169240Sjfv *  requests. Currently no func pointer exists and all implementations are
803169240Sjfv *  handled in the generic version of this function.
804169240Sjfv **/
805173788Sjfvs32 e1000_disable_pcie_master(struct e1000_hw *hw)
806169240Sjfv{
807169240Sjfv	return e1000_disable_pcie_master_generic(hw);
808169240Sjfv}
809169240Sjfv
810169240Sjfv/**
811169240Sjfv *  e1000_config_collision_dist - Configure collision distance
812169589Sjfv *  @hw: pointer to the HW structure
813169240Sjfv *
814169240Sjfv *  Configures the collision distance to the default value and is used
815169240Sjfv *  during link setup.
816169240Sjfv **/
817173788Sjfvvoid e1000_config_collision_dist(struct e1000_hw *hw)
818169240Sjfv{
819177867Sjfv	if (hw->mac.ops.config_collision_dist)
820177867Sjfv		hw->mac.ops.config_collision_dist(hw);
821169240Sjfv}
822169240Sjfv
823169240Sjfv/**
824169240Sjfv *  e1000_rar_set - Sets a receive address register
825169589Sjfv *  @hw: pointer to the HW structure
826169589Sjfv *  @addr: address to set the RAR to
827169589Sjfv *  @index: the RAR to set
828169240Sjfv *
829169240Sjfv *  Sets a Receive Address Register (RAR) to the specified address.
830169240Sjfv **/
831173788Sjfvvoid e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
832169240Sjfv{
833177867Sjfv	if (hw->mac.ops.rar_set)
834177867Sjfv		hw->mac.ops.rar_set(hw, addr, index);
835169240Sjfv}
836169240Sjfv
837169240Sjfv/**
838169240Sjfv *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
839169589Sjfv *  @hw: pointer to the HW structure
840169240Sjfv *
841169240Sjfv *  Ensures that the MDI/MDIX SW state is valid.
842169240Sjfv **/
843173788Sjfvs32 e1000_validate_mdi_setting(struct e1000_hw *hw)
844169240Sjfv{
845177867Sjfv	if (hw->mac.ops.validate_mdi_setting)
846177867Sjfv		return hw->mac.ops.validate_mdi_setting(hw);
847173788Sjfv
848173788Sjfv	return E1000_SUCCESS;
849169240Sjfv}
850169240Sjfv
851169240Sjfv/**
852169240Sjfv *  e1000_hash_mc_addr - Determines address location in multicast table
853169589Sjfv *  @hw: pointer to the HW structure
854169589Sjfv *  @mc_addr: Multicast address to hash.
855169240Sjfv *
856169240Sjfv *  This hashes an address to determine its location in the multicast
857169240Sjfv *  table. Currently no func pointer exists and all implementations
858169240Sjfv *  are handled in the generic version of this function.
859169240Sjfv **/
860173788Sjfvu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
861169240Sjfv{
862169240Sjfv	return e1000_hash_mc_addr_generic(hw, mc_addr);
863169240Sjfv}
864169240Sjfv
865169240Sjfv/**
866169240Sjfv *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
867169589Sjfv *  @hw: pointer to the HW structure
868169240Sjfv *
869169240Sjfv *  Enables packet filtering on transmit packets if manageability is enabled
870169240Sjfv *  and host interface is enabled.
871169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
872169240Sjfv *  generic version of this function.
873169240Sjfv **/
874173788Sjfvbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
875169240Sjfv{
876169240Sjfv	return e1000_enable_tx_pkt_filtering_generic(hw);
877169240Sjfv}
878169240Sjfv
879169240Sjfv/**
880169240Sjfv *  e1000_mng_host_if_write - Writes to the manageability host interface
881169589Sjfv *  @hw: pointer to the HW structure
882169589Sjfv *  @buffer: pointer to the host interface buffer
883169589Sjfv *  @length: size of the buffer
884169589Sjfv *  @offset: location in the buffer to write to
885169589Sjfv *  @sum: sum of the data (not checksum)
886169240Sjfv *
887169240Sjfv *  This function writes the buffer content at the offset given on the host if.
888169240Sjfv *  It also does alignment considerations to do the writes in most efficient
889169240Sjfv *  way.  Also fills up the sum of the buffer in *buffer parameter.
890169240Sjfv **/
891228386Sjfvs32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
892228386Sjfv			    u16 offset, u8 *sum)
893169240Sjfv{
894247064Sjfv	return e1000_mng_host_if_write_generic(hw, buffer, length, offset, sum);
895169240Sjfv}
896169240Sjfv
897169240Sjfv/**
898169240Sjfv *  e1000_mng_write_cmd_header - Writes manageability command header
899169589Sjfv *  @hw: pointer to the HW structure
900169589Sjfv *  @hdr: pointer to the host interface command header
901169240Sjfv *
902169240Sjfv *  Writes the command header after does the checksum calculation.
903169240Sjfv **/
904173788Sjfvs32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
905228386Sjfv			       struct e1000_host_mng_command_header *hdr)
906169240Sjfv{
907247064Sjfv	return e1000_mng_write_cmd_header_generic(hw, hdr);
908169240Sjfv}
909169240Sjfv
910169240Sjfv/**
911169240Sjfv *  e1000_mng_enable_host_if - Checks host interface is enabled
912169589Sjfv *  @hw: pointer to the HW structure
913169240Sjfv *
914169240Sjfv *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
915169240Sjfv *
916176667Sjfv *  This function checks whether the HOST IF is enabled for command operation
917169240Sjfv *  and also checks whether the previous command is completed.  It busy waits
918169240Sjfv *  in case of previous command is not completed.
919169240Sjfv **/
920228386Sjfvs32 e1000_mng_enable_host_if(struct e1000_hw *hw)
921169240Sjfv{
922247064Sjfv	return e1000_mng_enable_host_if_generic(hw);
923169240Sjfv}
924169240Sjfv
925169240Sjfv/**
926247064Sjfv *  e1000_set_obff_timer - Set Optimized Buffer Flush/Fill timer
927169589Sjfv *  @hw: pointer to the HW structure
928247064Sjfv *  @itr: u32 indicating itr value
929169240Sjfv *
930247064Sjfv *  Set the OBFF timer based on the given interrupt rate.
931169240Sjfv **/
932247064Sjfvs32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr)
933169240Sjfv{
934247064Sjfv	if (hw->mac.ops.set_obff_timer)
935247064Sjfv		return hw->mac.ops.set_obff_timer(hw, itr);
936173788Sjfv
937173788Sjfv	return E1000_SUCCESS;
938169240Sjfv}
939169240Sjfv
940169240Sjfv/**
941169240Sjfv *  e1000_check_reset_block - Verifies PHY can be reset
942169589Sjfv *  @hw: pointer to the HW structure
943169240Sjfv *
944169240Sjfv *  Checks if the PHY is in a state that can be reset or if manageability
945169240Sjfv *  has it tied up. This is a function pointer entry point called by drivers.
946169240Sjfv **/
947173788Sjfvs32 e1000_check_reset_block(struct e1000_hw *hw)
948169240Sjfv{
949177867Sjfv	if (hw->phy.ops.check_reset_block)
950177867Sjfv		return hw->phy.ops.check_reset_block(hw);
951173788Sjfv
952173788Sjfv	return E1000_SUCCESS;
953169240Sjfv}
954169240Sjfv
955169240Sjfv/**
956169240Sjfv *  e1000_read_phy_reg - Reads PHY register
957169589Sjfv *  @hw: pointer to the HW structure
958169589Sjfv *  @offset: the register to read
959169589Sjfv *  @data: the buffer to store the 16-bit read.
960169240Sjfv *
961169240Sjfv *  Reads the PHY register and returns the value in data.
962169240Sjfv *  This is a function pointer entry point called by drivers.
963169240Sjfv **/
964173788Sjfvs32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
965169240Sjfv{
966177867Sjfv	if (hw->phy.ops.read_reg)
967177867Sjfv		return hw->phy.ops.read_reg(hw, offset, data);
968173788Sjfv
969173788Sjfv	return E1000_SUCCESS;
970169240Sjfv}
971169240Sjfv
972169240Sjfv/**
973169240Sjfv *  e1000_write_phy_reg - Writes PHY register
974169589Sjfv *  @hw: pointer to the HW structure
975169589Sjfv *  @offset: the register to write
976169589Sjfv *  @data: the value to write.
977169240Sjfv *
978169240Sjfv *  Writes the PHY register at offset with the value in data.
979169240Sjfv *  This is a function pointer entry point called by drivers.
980169240Sjfv **/
981173788Sjfvs32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
982169240Sjfv{
983177867Sjfv	if (hw->phy.ops.write_reg)
984177867Sjfv		return hw->phy.ops.write_reg(hw, offset, data);
985173788Sjfv
986173788Sjfv	return E1000_SUCCESS;
987169240Sjfv}
988169240Sjfv
989169240Sjfv/**
990177867Sjfv *  e1000_release_phy - Generic release PHY
991177867Sjfv *  @hw: pointer to the HW structure
992177867Sjfv *
993177867Sjfv *  Return if silicon family does not require a semaphore when accessing the
994177867Sjfv *  PHY.
995177867Sjfv **/
996177867Sjfvvoid e1000_release_phy(struct e1000_hw *hw)
997177867Sjfv{
998177867Sjfv	if (hw->phy.ops.release)
999177867Sjfv		hw->phy.ops.release(hw);
1000177867Sjfv}
1001177867Sjfv
1002177867Sjfv/**
1003177867Sjfv *  e1000_acquire_phy - Generic acquire PHY
1004177867Sjfv *  @hw: pointer to the HW structure
1005177867Sjfv *
1006177867Sjfv *  Return success if silicon family does not require a semaphore when
1007177867Sjfv *  accessing the PHY.
1008177867Sjfv **/
1009177867Sjfvs32 e1000_acquire_phy(struct e1000_hw *hw)
1010177867Sjfv{
1011177867Sjfv	if (hw->phy.ops.acquire)
1012177867Sjfv		return hw->phy.ops.acquire(hw);
1013177867Sjfv
1014177867Sjfv	return E1000_SUCCESS;
1015177867Sjfv}
1016177867Sjfv
1017177867Sjfv/**
1018185353Sjfv *  e1000_cfg_on_link_up - Configure PHY upon link up
1019185353Sjfv *  @hw: pointer to the HW structure
1020185353Sjfv **/
1021185353Sjfvs32 e1000_cfg_on_link_up(struct e1000_hw *hw)
1022185353Sjfv{
1023185353Sjfv	if (hw->phy.ops.cfg_on_link_up)
1024185353Sjfv		return hw->phy.ops.cfg_on_link_up(hw);
1025185353Sjfv
1026185353Sjfv	return E1000_SUCCESS;
1027185353Sjfv}
1028185353Sjfv
1029185353Sjfv/**
1030169240Sjfv *  e1000_read_kmrn_reg - Reads register using Kumeran interface
1031169589Sjfv *  @hw: pointer to the HW structure
1032169589Sjfv *  @offset: the register to read
1033169589Sjfv *  @data: the location to store the 16-bit value read.
1034169240Sjfv *
1035169240Sjfv *  Reads a register out of the Kumeran interface. Currently no func pointer
1036169240Sjfv *  exists and all implementations are handled in the generic version of
1037169240Sjfv *  this function.
1038169240Sjfv **/
1039173788Sjfvs32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
1040169240Sjfv{
1041169240Sjfv	return e1000_read_kmrn_reg_generic(hw, offset, data);
1042169240Sjfv}
1043169240Sjfv
1044169240Sjfv/**
1045169240Sjfv *  e1000_write_kmrn_reg - Writes register using Kumeran interface
1046169589Sjfv *  @hw: pointer to the HW structure
1047169589Sjfv *  @offset: the register to write
1048169589Sjfv *  @data: the value to write.
1049169240Sjfv *
1050169240Sjfv *  Writes a register to the Kumeran interface. Currently no func pointer
1051169240Sjfv *  exists and all implementations are handled in the generic version of
1052169240Sjfv *  this function.
1053169240Sjfv **/
1054173788Sjfvs32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
1055169240Sjfv{
1056169240Sjfv	return e1000_write_kmrn_reg_generic(hw, offset, data);
1057169240Sjfv}
1058169240Sjfv
1059169240Sjfv/**
1060169240Sjfv *  e1000_get_cable_length - Retrieves cable length estimation
1061169589Sjfv *  @hw: pointer to the HW structure
1062169240Sjfv *
1063169240Sjfv *  This function estimates the cable length and stores them in
1064169240Sjfv *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
1065169240Sjfv *  entry point called by drivers.
1066169240Sjfv **/
1067173788Sjfvs32 e1000_get_cable_length(struct e1000_hw *hw)
1068169240Sjfv{
1069177867Sjfv	if (hw->phy.ops.get_cable_length)
1070177867Sjfv		return hw->phy.ops.get_cable_length(hw);
1071173788Sjfv
1072173788Sjfv	return E1000_SUCCESS;
1073169240Sjfv}
1074169240Sjfv
1075169240Sjfv/**
1076169240Sjfv *  e1000_get_phy_info - Retrieves PHY information from registers
1077169589Sjfv *  @hw: pointer to the HW structure
1078169240Sjfv *
1079169240Sjfv *  This function gets some information from various PHY registers and
1080169240Sjfv *  populates hw->phy values with it. This is a function pointer entry
1081169240Sjfv *  point called by drivers.
1082169240Sjfv **/
1083173788Sjfvs32 e1000_get_phy_info(struct e1000_hw *hw)
1084169240Sjfv{
1085177867Sjfv	if (hw->phy.ops.get_info)
1086177867Sjfv		return hw->phy.ops.get_info(hw);
1087173788Sjfv
1088173788Sjfv	return E1000_SUCCESS;
1089169240Sjfv}
1090169240Sjfv
1091169240Sjfv/**
1092169240Sjfv *  e1000_phy_hw_reset - Hard PHY reset
1093169589Sjfv *  @hw: pointer to the HW structure
1094169240Sjfv *
1095169240Sjfv *  Performs a hard PHY reset. This is a function pointer entry point called
1096169240Sjfv *  by drivers.
1097169240Sjfv **/
1098173788Sjfvs32 e1000_phy_hw_reset(struct e1000_hw *hw)
1099169240Sjfv{
1100177867Sjfv	if (hw->phy.ops.reset)
1101177867Sjfv		return hw->phy.ops.reset(hw);
1102173788Sjfv
1103173788Sjfv	return E1000_SUCCESS;
1104169240Sjfv}
1105169240Sjfv
1106169240Sjfv/**
1107169240Sjfv *  e1000_phy_commit - Soft PHY reset
1108169589Sjfv *  @hw: pointer to the HW structure
1109169240Sjfv *
1110169240Sjfv *  Performs a soft PHY reset on those that apply. This is a function pointer
1111169240Sjfv *  entry point called by drivers.
1112169240Sjfv **/
1113173788Sjfvs32 e1000_phy_commit(struct e1000_hw *hw)
1114169240Sjfv{
1115177867Sjfv	if (hw->phy.ops.commit)
1116177867Sjfv		return hw->phy.ops.commit(hw);
1117173788Sjfv
1118173788Sjfv	return E1000_SUCCESS;
1119169240Sjfv}
1120169240Sjfv
1121169240Sjfv/**
1122177867Sjfv *  e1000_set_d0_lplu_state - Sets low power link up state for D0
1123169589Sjfv *  @hw: pointer to the HW structure
1124169589Sjfv *  @active: boolean used to enable/disable lplu
1125169240Sjfv *
1126169240Sjfv *  Success returns 0, Failure returns 1
1127169240Sjfv *
1128169240Sjfv *  The low power link up (lplu) state is set to the power management level D0
1129177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D0
1130169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1131169240Sjfv *  is used during Dx states where the power conservation is most important.
1132169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1133169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1134169240Sjfv **/
1135173788Sjfvs32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
1136169240Sjfv{
1137177867Sjfv	if (hw->phy.ops.set_d0_lplu_state)
1138177867Sjfv		return hw->phy.ops.set_d0_lplu_state(hw, active);
1139173788Sjfv
1140173788Sjfv	return E1000_SUCCESS;
1141169240Sjfv}
1142169240Sjfv
1143169240Sjfv/**
1144169240Sjfv *  e1000_set_d3_lplu_state - Sets low power link up state for D3
1145169589Sjfv *  @hw: pointer to the HW structure
1146169589Sjfv *  @active: boolean used to enable/disable lplu
1147169240Sjfv *
1148169240Sjfv *  Success returns 0, Failure returns 1
1149169240Sjfv *
1150169240Sjfv *  The low power link up (lplu) state is set to the power management level D3
1151177867Sjfv *  and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
1152169240Sjfv *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
1153169240Sjfv *  is used during Dx states where the power conservation is most important.
1154169240Sjfv *  During driver activity, SmartSpeed should be enabled so performance is
1155169240Sjfv *  maintained.  This is a function pointer entry point called by drivers.
1156169240Sjfv **/
1157173788Sjfvs32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1158169240Sjfv{
1159177867Sjfv	if (hw->phy.ops.set_d3_lplu_state)
1160177867Sjfv		return hw->phy.ops.set_d3_lplu_state(hw, active);
1161173788Sjfv
1162173788Sjfv	return E1000_SUCCESS;
1163169240Sjfv}
1164169240Sjfv
1165169240Sjfv/**
1166169240Sjfv *  e1000_read_mac_addr - Reads MAC address
1167169589Sjfv *  @hw: pointer to the HW structure
1168169240Sjfv *
1169169240Sjfv *  Reads the MAC address out of the adapter and stores it in the HW structure.
1170169240Sjfv *  Currently no func pointer exists and all implementations are handled in the
1171169240Sjfv *  generic version of this function.
1172169240Sjfv **/
1173173788Sjfvs32 e1000_read_mac_addr(struct e1000_hw *hw)
1174169240Sjfv{
1175177867Sjfv	if (hw->mac.ops.read_mac_addr)
1176177867Sjfv		return hw->mac.ops.read_mac_addr(hw);
1177173788Sjfv
1178169240Sjfv	return e1000_read_mac_addr_generic(hw);
1179169240Sjfv}
1180169240Sjfv
1181169240Sjfv/**
1182213234Sjfv *  e1000_read_pba_string - Read device part number string
1183213234Sjfv *  @hw: pointer to the HW structure
1184213234Sjfv *  @pba_num: pointer to device part number
1185213234Sjfv *  @pba_num_size: size of part number buffer
1186213234Sjfv *
1187213234Sjfv *  Reads the product board assembly (PBA) number from the EEPROM and stores
1188213234Sjfv *  the value in pba_num.
1189213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1190213234Sjfv *  generic version of this function.
1191213234Sjfv **/
1192213234Sjfvs32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size)
1193213234Sjfv{
1194213234Sjfv	return e1000_read_pba_string_generic(hw, pba_num, pba_num_size);
1195213234Sjfv}
1196213234Sjfv
1197213234Sjfv/**
1198213234Sjfv *  e1000_read_pba_length - Read device part number string length
1199213234Sjfv *  @hw: pointer to the HW structure
1200213234Sjfv *  @pba_num_size: size of part number buffer
1201213234Sjfv *
1202213234Sjfv *  Reads the product board assembly (PBA) number length from the EEPROM and
1203213234Sjfv *  stores the value in pba_num.
1204213234Sjfv *  Currently no func pointer exists and all implementations are handled in the
1205213234Sjfv *  generic version of this function.
1206213234Sjfv **/
1207213234Sjfvs32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size)
1208213234Sjfv{
1209213234Sjfv	return e1000_read_pba_length_generic(hw, pba_num_size);
1210213234Sjfv}
1211213234Sjfv
1212213234Sjfv/**
1213169240Sjfv *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1214169589Sjfv *  @hw: pointer to the HW structure
1215169240Sjfv *
1216169240Sjfv *  Validates the NVM checksum is correct. This is a function pointer entry
1217169240Sjfv *  point called by drivers.
1218169240Sjfv **/
1219173788Sjfvs32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1220169240Sjfv{
1221177867Sjfv	if (hw->nvm.ops.validate)
1222177867Sjfv		return hw->nvm.ops.validate(hw);
1223173788Sjfv
1224173788Sjfv	return -E1000_ERR_CONFIG;
1225169240Sjfv}
1226169240Sjfv
1227169240Sjfv/**
1228169240Sjfv *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1229169589Sjfv *  @hw: pointer to the HW structure
1230169240Sjfv *
1231169240Sjfv *  Updates the NVM checksum. Currently no func pointer exists and all
1232169240Sjfv *  implementations are handled in the generic version of this function.
1233169240Sjfv **/
1234173788Sjfvs32 e1000_update_nvm_checksum(struct e1000_hw *hw)
1235169240Sjfv{
1236177867Sjfv	if (hw->nvm.ops.update)
1237177867Sjfv		return hw->nvm.ops.update(hw);
1238173788Sjfv
1239173788Sjfv	return -E1000_ERR_CONFIG;
1240169240Sjfv}
1241169240Sjfv
1242169240Sjfv/**
1243169240Sjfv *  e1000_reload_nvm - Reloads EEPROM
1244169589Sjfv *  @hw: pointer to the HW structure
1245169240Sjfv *
1246169240Sjfv *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1247169240Sjfv *  extended control register.
1248169240Sjfv **/
1249173788Sjfvvoid e1000_reload_nvm(struct e1000_hw *hw)
1250169240Sjfv{
1251177867Sjfv	if (hw->nvm.ops.reload)
1252177867Sjfv		hw->nvm.ops.reload(hw);
1253169240Sjfv}
1254169240Sjfv
1255169240Sjfv/**
1256169240Sjfv *  e1000_read_nvm - Reads NVM (EEPROM)
1257169589Sjfv *  @hw: pointer to the HW structure
1258169589Sjfv *  @offset: the word offset to read
1259169589Sjfv *  @words: number of 16-bit words to read
1260169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1261169240Sjfv *
1262169240Sjfv *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1263169240Sjfv *  pointer entry point called by drivers.
1264169240Sjfv **/
1265173788Sjfvs32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1266169240Sjfv{
1267177867Sjfv	if (hw->nvm.ops.read)
1268177867Sjfv		return hw->nvm.ops.read(hw, offset, words, data);
1269173788Sjfv
1270173788Sjfv	return -E1000_ERR_CONFIG;
1271169240Sjfv}
1272169240Sjfv
1273169240Sjfv/**
1274169240Sjfv *  e1000_write_nvm - Writes to NVM (EEPROM)
1275169589Sjfv *  @hw: pointer to the HW structure
1276169589Sjfv *  @offset: the word offset to read
1277169589Sjfv *  @words: number of 16-bit words to write
1278169589Sjfv *  @data: pointer to the properly sized buffer for the data.
1279169240Sjfv *
1280169240Sjfv *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1281169240Sjfv *  pointer entry point called by drivers.
1282169240Sjfv **/
1283173788Sjfvs32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1284169240Sjfv{
1285177867Sjfv	if (hw->nvm.ops.write)
1286177867Sjfv		return hw->nvm.ops.write(hw, offset, words, data);
1287173788Sjfv
1288173788Sjfv	return E1000_SUCCESS;
1289169240Sjfv}
1290169240Sjfv
1291169240Sjfv/**
1292169240Sjfv *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1293169589Sjfv *  @hw: pointer to the HW structure
1294169589Sjfv *  @reg: 32bit register offset
1295169589Sjfv *  @offset: the register to write
1296169589Sjfv *  @data: the value to write.
1297169240Sjfv *
1298169240Sjfv *  Writes the PHY register at offset with the value in data.
1299169240Sjfv *  This is a function pointer entry point called by drivers.
1300169240Sjfv **/
1301176667Sjfvs32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
1302228386Sjfv			      u8 data)
1303169240Sjfv{
1304169240Sjfv	return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1305169240Sjfv}
1306173788Sjfv
1307173788Sjfv/**
1308173788Sjfv * e1000_power_up_phy - Restores link in case of PHY power down
1309173788Sjfv * @hw: pointer to the HW structure
1310173788Sjfv *
1311173788Sjfv * The phy may be powered down to save power, to turn off link when the
1312173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1313173788Sjfv **/
1314173788Sjfvvoid e1000_power_up_phy(struct e1000_hw *hw)
1315173788Sjfv{
1316177867Sjfv	if (hw->phy.ops.power_up)
1317177867Sjfv		hw->phy.ops.power_up(hw);
1318173788Sjfv
1319173788Sjfv	e1000_setup_link(hw);
1320173788Sjfv}
1321173788Sjfv
1322173788Sjfv/**
1323176667Sjfv * e1000_power_down_phy - Power down PHY
1324173788Sjfv * @hw: pointer to the HW structure
1325173788Sjfv *
1326173788Sjfv * The phy may be powered down to save power, to turn off link when the
1327173788Sjfv * driver is unloaded, or wake on lan is not enabled (among others).
1328173788Sjfv **/
1329173788Sjfvvoid e1000_power_down_phy(struct e1000_hw *hw)
1330173788Sjfv{
1331177867Sjfv	if (hw->phy.ops.power_down)
1332177867Sjfv		hw->phy.ops.power_down(hw);
1333173788Sjfv}
1334173788Sjfv
1335181027Sjfv/**
1336203049Sjfv *  e1000_power_up_fiber_serdes_link - Power up serdes link
1337203049Sjfv *  @hw: pointer to the HW structure
1338203049Sjfv *
1339203049Sjfv *  Power on the optics and PCS.
1340203049Sjfv **/
1341203049Sjfvvoid e1000_power_up_fiber_serdes_link(struct e1000_hw *hw)
1342203049Sjfv{
1343203049Sjfv	if (hw->mac.ops.power_up_serdes)
1344203049Sjfv		hw->mac.ops.power_up_serdes(hw);
1345203049Sjfv}
1346203049Sjfv
1347203049Sjfv/**
1348181027Sjfv *  e1000_shutdown_fiber_serdes_link - Remove link during power down
1349181027Sjfv *  @hw: pointer to the HW structure
1350181027Sjfv *
1351181027Sjfv *  Shutdown the optics and PCS on driver unload.
1352181027Sjfv **/
1353181027Sjfvvoid e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1354181027Sjfv{
1355181027Sjfv	if (hw->mac.ops.shutdown_serdes)
1356181027Sjfv		hw->mac.ops.shutdown_serdes(hw);
1357181027Sjfv}
1358181027Sjfv
1359