Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2020 Intel Corporation
3 : : */
4 : :
5 : : #include "igc_api.h"
6 : :
7 : : /**
8 : : * igc_get_i2c_data - Reads the I2C SDA data bit
9 : : * @i2cctl: Current value of I2CCTL register
10 : : *
11 : : * Returns the I2C data bit value
12 : : **/
13 : 0 : static bool igc_get_i2c_data(u32 *i2cctl)
14 : : {
15 : : bool data;
16 : :
17 : 0 : DEBUGFUNC("igc_get_i2c_data");
18 : :
19 [ # # ]: 0 : if (*i2cctl & IGC_I2C_DATA_IN)
20 : : data = 1;
21 : : else
22 : : data = 0;
23 : :
24 : 0 : return data;
25 : : }
26 : :
27 : : /**
28 : : * igc_set_i2c_data - Sets the I2C data bit
29 : : * @hw: pointer to hardware structure
30 : : * @i2cctl: Current value of I2CCTL register
31 : : * @data: I2C data value (0 or 1) to set
32 : : *
33 : : * Sets the I2C data bit
34 : : **/
35 : 0 : static s32 igc_set_i2c_data(struct igc_hw *hw, u32 *i2cctl, bool data)
36 : : {
37 : : s32 status = IGC_SUCCESS;
38 : :
39 : 0 : DEBUGFUNC("igc_set_i2c_data");
40 : :
41 [ # # ]: 0 : if (data)
42 : 0 : *i2cctl |= IGC_I2C_DATA_OUT;
43 : : else
44 : 0 : *i2cctl &= ~IGC_I2C_DATA_OUT;
45 : :
46 : 0 : *i2cctl &= ~IGC_I2C_DATA_OE_N;
47 : 0 : *i2cctl |= IGC_I2C_CLK_OE_N;
48 : 0 : IGC_WRITE_REG(hw, IGC_I2CPARAMS, *i2cctl);
49 : 0 : IGC_WRITE_FLUSH(hw);
50 : :
51 : : /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
52 : 0 : usec_delay(IGC_I2C_T_RISE + IGC_I2C_T_FALL + IGC_I2C_T_SU_DATA);
53 : :
54 : 0 : *i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
55 [ # # ]: 0 : if (data != igc_get_i2c_data(i2cctl)) {
56 : : status = IGC_ERR_I2C;
57 : 0 : DEBUGOUT1("Error - I2C data was not set to %X.\n", data);
58 : : }
59 : :
60 : 0 : return status;
61 : : }
62 : :
63 : : /**
64 : : * igc_raise_i2c_clk - Raises the I2C SCL clock
65 : : * @hw: pointer to hardware structure
66 : : * @i2cctl: Current value of I2CCTL register
67 : : *
68 : : * Raises the I2C clock line '0'->'1'
69 : : **/
70 : 0 : static void igc_raise_i2c_clk(struct igc_hw *hw, u32 *i2cctl)
71 : : {
72 : 0 : DEBUGFUNC("igc_raise_i2c_clk");
73 : :
74 : 0 : *i2cctl |= IGC_I2C_CLK_OUT;
75 : 0 : *i2cctl &= ~IGC_I2C_CLK_OE_N;
76 : 0 : IGC_WRITE_REG(hw, IGC_I2CPARAMS, *i2cctl);
77 : 0 : IGC_WRITE_FLUSH(hw);
78 : :
79 : : /* SCL rise time (1000ns) */
80 : 0 : usec_delay(IGC_I2C_T_RISE);
81 : 0 : }
82 : :
83 : : /**
84 : : * igc_lower_i2c_clk - Lowers the I2C SCL clock
85 : : * @hw: pointer to hardware structure
86 : : * @i2cctl: Current value of I2CCTL register
87 : : *
88 : : * Lowers the I2C clock line '1'->'0'
89 : : **/
90 : 0 : static void igc_lower_i2c_clk(struct igc_hw *hw, u32 *i2cctl)
91 : : {
92 : 0 : DEBUGFUNC("igc_lower_i2c_clk");
93 : :
94 : 0 : *i2cctl &= ~IGC_I2C_CLK_OUT;
95 : 0 : *i2cctl &= ~IGC_I2C_CLK_OE_N;
96 : 0 : IGC_WRITE_REG(hw, IGC_I2CPARAMS, *i2cctl);
97 : 0 : IGC_WRITE_FLUSH(hw);
98 : :
99 : : /* SCL fall time (300ns) */
100 : 0 : usec_delay(IGC_I2C_T_FALL);
101 : 0 : }
102 : :
103 : : /**
104 : : * igc_i2c_start - Sets I2C start condition
105 : : * @hw: pointer to hardware structure
106 : : *
107 : : * Sets I2C start condition (High -> Low on SDA while SCL is High)
108 : : **/
109 : 0 : static void igc_i2c_start(struct igc_hw *hw)
110 : : {
111 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
112 : :
113 : 0 : DEBUGFUNC("igc_i2c_start");
114 : :
115 : : /* Start condition must begin with data and clock high */
116 : 0 : igc_set_i2c_data(hw, &i2cctl, 1);
117 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
118 : :
119 : : /* Setup time for start condition (4.7us) */
120 : 0 : usec_delay(IGC_I2C_T_SU_STA);
121 : :
122 : 0 : igc_set_i2c_data(hw, &i2cctl, 0);
123 : :
124 : : /* Hold time for start condition (4us) */
125 : 0 : usec_delay(IGC_I2C_T_HD_STA);
126 : :
127 : 0 : igc_lower_i2c_clk(hw, &i2cctl);
128 : :
129 : : /* Minimum low period of clock is 4.7 us */
130 : 0 : usec_delay(IGC_I2C_T_LOW);
131 : 0 : }
132 : :
133 : : /**
134 : : * igc_i2c_stop - Sets I2C stop condition
135 : : * @hw: pointer to hardware structure
136 : : *
137 : : * Sets I2C stop condition (Low -> High on SDA while SCL is High)
138 : : **/
139 : 0 : static void igc_i2c_stop(struct igc_hw *hw)
140 : : {
141 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
142 : :
143 : 0 : DEBUGFUNC("igc_i2c_stop");
144 : :
145 : : /* Stop condition must begin with data low and clock high */
146 : 0 : igc_set_i2c_data(hw, &i2cctl, 0);
147 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
148 : :
149 : : /* Setup time for stop condition (4us) */
150 : 0 : usec_delay(IGC_I2C_T_SU_STO);
151 : :
152 : 0 : igc_set_i2c_data(hw, &i2cctl, 1);
153 : :
154 : : /* bus free time between stop and start (4.7us)*/
155 : 0 : usec_delay(IGC_I2C_T_BUF);
156 : 0 : }
157 : :
158 : : /**
159 : : * igc_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
160 : : * @hw: pointer to hardware structure
161 : : * @data: read data value
162 : : *
163 : : * Clocks in one bit via I2C data/clock
164 : : **/
165 : 0 : static void igc_clock_in_i2c_bit(struct igc_hw *hw, bool *data)
166 : : {
167 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
168 : :
169 : 0 : DEBUGFUNC("igc_clock_in_i2c_bit");
170 : :
171 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
172 : :
173 : : /* Minimum high period of clock is 4us */
174 : 0 : usec_delay(IGC_I2C_T_HIGH);
175 : :
176 : 0 : i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
177 : 0 : *data = igc_get_i2c_data(&i2cctl);
178 : :
179 : 0 : igc_lower_i2c_clk(hw, &i2cctl);
180 : :
181 : : /* Minimum low period of clock is 4.7 us */
182 : 0 : usec_delay(IGC_I2C_T_LOW);
183 : 0 : }
184 : :
185 : : /**
186 : : * igc_clock_in_i2c_byte - Clocks in one byte via I2C
187 : : * @hw: pointer to hardware structure
188 : : * @data: data byte to clock in
189 : : *
190 : : * Clocks in one byte data via I2C data/clock
191 : : **/
192 : 0 : static void igc_clock_in_i2c_byte(struct igc_hw *hw, u8 *data)
193 : : {
194 : : s32 i;
195 : 0 : bool bit = 0;
196 : :
197 : 0 : DEBUGFUNC("igc_clock_in_i2c_byte");
198 : :
199 : 0 : *data = 0;
200 [ # # ]: 0 : for (i = 7; i >= 0; i--) {
201 : 0 : igc_clock_in_i2c_bit(hw, &bit);
202 : 0 : *data |= bit << i;
203 : : }
204 : 0 : }
205 : :
206 : : /**
207 : : * igc_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
208 : : * @hw: pointer to hardware structure
209 : : * @data: data value to write
210 : : *
211 : : * Clocks out one bit via I2C data/clock
212 : : **/
213 : 0 : static s32 igc_clock_out_i2c_bit(struct igc_hw *hw, bool data)
214 : : {
215 : : s32 status;
216 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
217 : :
218 : 0 : DEBUGFUNC("igc_clock_out_i2c_bit");
219 : :
220 : 0 : status = igc_set_i2c_data(hw, &i2cctl, data);
221 [ # # ]: 0 : if (status == IGC_SUCCESS) {
222 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
223 : :
224 : : /* Minimum high period of clock is 4us */
225 : 0 : usec_delay(IGC_I2C_T_HIGH);
226 : :
227 : 0 : igc_lower_i2c_clk(hw, &i2cctl);
228 : :
229 : : /* Minimum low period of clock is 4.7 us.
230 : : * This also takes care of the data hold time.
231 : : */
232 : 0 : usec_delay(IGC_I2C_T_LOW);
233 : : } else {
234 : : status = IGC_ERR_I2C;
235 : 0 : DEBUGOUT1("I2C data was not set to %X\n", data);
236 : : }
237 : :
238 : 0 : return status;
239 : : }
240 : :
241 : : /**
242 : : * igc_clock_out_i2c_byte - Clocks out one byte via I2C
243 : : * @hw: pointer to hardware structure
244 : : * @data: data byte clocked out
245 : : *
246 : : * Clocks out one byte data via I2C data/clock
247 : : **/
248 : 0 : static s32 igc_clock_out_i2c_byte(struct igc_hw *hw, u8 data)
249 : : {
250 : : s32 status = IGC_SUCCESS;
251 : : s32 i;
252 : : u32 i2cctl;
253 : : bool bit = 0;
254 : :
255 : 0 : DEBUGFUNC("igc_clock_out_i2c_byte");
256 : :
257 [ # # ]: 0 : for (i = 7; i >= 0; i--) {
258 : 0 : bit = (data >> i) & 0x1;
259 : 0 : status = igc_clock_out_i2c_bit(hw, bit);
260 : :
261 [ # # ]: 0 : if (status != IGC_SUCCESS)
262 : : break;
263 : : }
264 : :
265 : : /* Release SDA line (set high) */
266 : 0 : i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
267 : :
268 : 0 : i2cctl |= IGC_I2C_DATA_OE_N;
269 : 0 : IGC_WRITE_REG(hw, IGC_I2CPARAMS, i2cctl);
270 : 0 : IGC_WRITE_FLUSH(hw);
271 : :
272 : 0 : return status;
273 : : }
274 : :
275 : : /**
276 : : * igc_get_i2c_ack - Polls for I2C ACK
277 : : * @hw: pointer to hardware structure
278 : : *
279 : : * Clocks in/out one bit via I2C data/clock
280 : : **/
281 : 0 : static s32 igc_get_i2c_ack(struct igc_hw *hw)
282 : : {
283 : : s32 status = IGC_SUCCESS;
284 : : u32 i = 0;
285 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
286 : : u32 timeout = 10;
287 : : bool ack = true;
288 : :
289 : 0 : DEBUGFUNC("igc_get_i2c_ack");
290 : :
291 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
292 : :
293 : : /* Minimum high period of clock is 4us */
294 : 0 : usec_delay(IGC_I2C_T_HIGH);
295 : :
296 : : /* Wait until SCL returns high */
297 [ # # ]: 0 : for (i = 0; i < timeout; i++) {
298 : 0 : usec_delay(1);
299 : 0 : i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
300 [ # # ]: 0 : if (i2cctl & IGC_I2C_CLK_IN)
301 : : break;
302 : : }
303 [ # # ]: 0 : if (!(i2cctl & IGC_I2C_CLK_IN))
304 : : return IGC_ERR_I2C;
305 : :
306 : 0 : ack = igc_get_i2c_data(&i2cctl);
307 [ # # ]: 0 : if (ack) {
308 : 0 : DEBUGOUT("I2C ack was not received.\n");
309 : : status = IGC_ERR_I2C;
310 : : }
311 : :
312 : 0 : igc_lower_i2c_clk(hw, &i2cctl);
313 : :
314 : : /* Minimum low period of clock is 4.7 us */
315 : 0 : usec_delay(IGC_I2C_T_LOW);
316 : :
317 : 0 : return status;
318 : : }
319 : :
320 : : /**
321 : : * igc_set_i2c_bb - Enable I2C bit-bang
322 : : * @hw: pointer to the HW structure
323 : : *
324 : : * Enable I2C bit-bang interface
325 : : *
326 : : **/
327 : 0 : s32 igc_set_i2c_bb(struct igc_hw *hw)
328 : : {
329 : : s32 ret_val = IGC_SUCCESS;
330 : : u32 ctrl_ext, i2cparams;
331 : :
332 : 0 : DEBUGFUNC("igc_set_i2c_bb");
333 : :
334 : 0 : ctrl_ext = IGC_READ_REG(hw, IGC_CTRL_EXT);
335 : 0 : ctrl_ext |= IGC_CTRL_I2C_ENA;
336 : 0 : IGC_WRITE_REG(hw, IGC_CTRL_EXT, ctrl_ext);
337 : 0 : IGC_WRITE_FLUSH(hw);
338 : :
339 : 0 : i2cparams = IGC_READ_REG(hw, IGC_I2CPARAMS);
340 : : i2cparams |= IGC_I2CBB_EN;
341 : : i2cparams |= IGC_I2C_DATA_OE_N;
342 : 0 : i2cparams |= IGC_I2C_CLK_OE_N;
343 : 0 : IGC_WRITE_REG(hw, IGC_I2CPARAMS, i2cparams);
344 : 0 : IGC_WRITE_FLUSH(hw);
345 : :
346 : 0 : return ret_val;
347 : : }
348 : :
349 : : /**
350 : : * igc_read_i2c_byte_generic - Reads 8 bit word over I2C
351 : : * @hw: pointer to hardware structure
352 : : * @byte_offset: byte offset to read
353 : : * @dev_addr: device address
354 : : * @data: value read
355 : : *
356 : : * Performs byte read operation over I2C interface at
357 : : * a specified device address.
358 : : **/
359 : 0 : s32 igc_read_i2c_byte_generic(struct igc_hw *hw, u8 byte_offset,
360 : : u8 dev_addr, u8 *data)
361 : : {
362 : : s32 status = IGC_SUCCESS;
363 : : u32 max_retry = 10;
364 : : u32 retry = 1;
365 : : u16 swfw_mask = 0;
366 : :
367 : : bool nack = true;
368 : :
369 : 0 : DEBUGFUNC("igc_read_i2c_byte_generic");
370 : :
371 : : swfw_mask = IGC_SWFW_PHY0_SM;
372 : :
373 : : do {
374 [ # # ]: 0 : if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask)
375 : : != IGC_SUCCESS) {
376 : : status = IGC_ERR_SWFW_SYNC;
377 : 0 : goto read_byte_out;
378 : : }
379 : :
380 : 0 : igc_i2c_start(hw);
381 : :
382 : : /* Device Address and write indication */
383 : 0 : status = igc_clock_out_i2c_byte(hw, dev_addr);
384 [ # # ]: 0 : if (status != IGC_SUCCESS)
385 : 0 : goto fail;
386 : :
387 : 0 : status = igc_get_i2c_ack(hw);
388 [ # # ]: 0 : if (status != IGC_SUCCESS)
389 : 0 : goto fail;
390 : :
391 : 0 : status = igc_clock_out_i2c_byte(hw, byte_offset);
392 [ # # ]: 0 : if (status != IGC_SUCCESS)
393 : 0 : goto fail;
394 : :
395 : 0 : status = igc_get_i2c_ack(hw);
396 [ # # ]: 0 : if (status != IGC_SUCCESS)
397 : 0 : goto fail;
398 : :
399 : 0 : igc_i2c_start(hw);
400 : :
401 : : /* Device Address and read indication */
402 : 0 : status = igc_clock_out_i2c_byte(hw, (dev_addr | 0x1));
403 [ # # ]: 0 : if (status != IGC_SUCCESS)
404 : 0 : goto fail;
405 : :
406 : 0 : status = igc_get_i2c_ack(hw);
407 [ # # ]: 0 : if (status != IGC_SUCCESS)
408 : 0 : goto fail;
409 : :
410 : 0 : igc_clock_in_i2c_byte(hw, data);
411 : :
412 : 0 : status = igc_clock_out_i2c_bit(hw, nack);
413 [ # # ]: 0 : if (status != IGC_SUCCESS)
414 : 0 : goto fail;
415 : :
416 : 0 : igc_i2c_stop(hw);
417 : 0 : break;
418 : :
419 : 0 : fail:
420 : 0 : hw->mac.ops.release_swfw_sync(hw, swfw_mask);
421 : 0 : msec_delay(100);
422 : 0 : igc_i2c_bus_clear(hw);
423 : 0 : retry++;
424 [ # # ]: 0 : if (retry < max_retry)
425 : 0 : DEBUGOUT("I2C byte read error - Retrying.\n");
426 : : else
427 : 0 : DEBUGOUT("I2C byte read error.\n");
428 : :
429 [ # # ]: 0 : } while (retry < max_retry);
430 : :
431 : 0 : hw->mac.ops.release_swfw_sync(hw, swfw_mask);
432 : :
433 : 0 : read_byte_out:
434 : :
435 : 0 : return status;
436 : : }
437 : :
438 : : /**
439 : : * igc_write_i2c_byte_generic - Writes 8 bit word over I2C
440 : : * @hw: pointer to hardware structure
441 : : * @byte_offset: byte offset to write
442 : : * @dev_addr: device address
443 : : * @data: value to write
444 : : *
445 : : * Performs byte write operation over I2C interface at
446 : : * a specified device address.
447 : : **/
448 : 0 : s32 igc_write_i2c_byte_generic(struct igc_hw *hw, u8 byte_offset,
449 : : u8 dev_addr, u8 data)
450 : : {
451 : : s32 status = IGC_SUCCESS;
452 : : u32 max_retry = 1;
453 : : u32 retry = 0;
454 : : u16 swfw_mask = 0;
455 : :
456 : 0 : DEBUGFUNC("igc_write_i2c_byte_generic");
457 : :
458 : : swfw_mask = IGC_SWFW_PHY0_SM;
459 : :
460 [ # # ]: 0 : if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != IGC_SUCCESS) {
461 : : status = IGC_ERR_SWFW_SYNC;
462 : 0 : goto write_byte_out;
463 : : }
464 : :
465 : : do {
466 : 0 : igc_i2c_start(hw);
467 : :
468 : 0 : status = igc_clock_out_i2c_byte(hw, dev_addr);
469 [ # # ]: 0 : if (status != IGC_SUCCESS)
470 : 0 : goto fail;
471 : :
472 : 0 : status = igc_get_i2c_ack(hw);
473 [ # # ]: 0 : if (status != IGC_SUCCESS)
474 : 0 : goto fail;
475 : :
476 : 0 : status = igc_clock_out_i2c_byte(hw, byte_offset);
477 [ # # ]: 0 : if (status != IGC_SUCCESS)
478 : 0 : goto fail;
479 : :
480 : 0 : status = igc_get_i2c_ack(hw);
481 [ # # ]: 0 : if (status != IGC_SUCCESS)
482 : 0 : goto fail;
483 : :
484 : 0 : status = igc_clock_out_i2c_byte(hw, data);
485 [ # # ]: 0 : if (status != IGC_SUCCESS)
486 : 0 : goto fail;
487 : :
488 : 0 : status = igc_get_i2c_ack(hw);
489 [ # # ]: 0 : if (status != IGC_SUCCESS)
490 : 0 : goto fail;
491 : :
492 : 0 : igc_i2c_stop(hw);
493 : 0 : break;
494 : :
495 : 0 : fail:
496 : 0 : igc_i2c_bus_clear(hw);
497 : : retry++;
498 : : if (retry < max_retry)
499 : : DEBUGOUT("I2C byte write error - Retrying.\n");
500 : : else
501 : 0 : DEBUGOUT("I2C byte write error.\n");
502 : : } while (retry < max_retry);
503 : :
504 : 0 : hw->mac.ops.release_swfw_sync(hw, swfw_mask);
505 : :
506 : 0 : write_byte_out:
507 : :
508 : 0 : return status;
509 : : }
510 : :
511 : : /**
512 : : * igc_i2c_bus_clear - Clears the I2C bus
513 : : * @hw: pointer to hardware structure
514 : : *
515 : : * Clears the I2C bus by sending nine clock pulses.
516 : : * Used when data line is stuck low.
517 : : **/
518 : 0 : void igc_i2c_bus_clear(struct igc_hw *hw)
519 : : {
520 : 0 : u32 i2cctl = IGC_READ_REG(hw, IGC_I2CPARAMS);
521 : : u32 i;
522 : :
523 : 0 : DEBUGFUNC("igc_i2c_bus_clear");
524 : :
525 : 0 : igc_i2c_start(hw);
526 : :
527 : 0 : igc_set_i2c_data(hw, &i2cctl, 1);
528 : :
529 [ # # ]: 0 : for (i = 0; i < 9; i++) {
530 : 0 : igc_raise_i2c_clk(hw, &i2cctl);
531 : :
532 : : /* Min high period of clock is 4us */
533 : 0 : usec_delay(IGC_I2C_T_HIGH);
534 : :
535 : 0 : igc_lower_i2c_clk(hw, &i2cctl);
536 : :
537 : : /* Min low period of clock is 4.7us*/
538 : 0 : usec_delay(IGC_I2C_T_LOW);
539 : : }
540 : :
541 : 0 : igc_i2c_start(hw);
542 : :
543 : : /* Put the i2c bus back to default state */
544 : 0 : igc_i2c_stop(hw);
545 : 0 : }
546 : :
547 : : /**
548 : : * igc_init_mac_params - Initialize MAC function pointers
549 : : * @hw: pointer to the HW structure
550 : : *
551 : : * This function initializes the function pointers for the MAC
552 : : * set of functions. Called by drivers or by igc_setup_init_funcs.
553 : : **/
554 : 0 : s32 igc_init_mac_params(struct igc_hw *hw)
555 : : {
556 : : s32 ret_val = IGC_SUCCESS;
557 : :
558 [ # # ]: 0 : if (hw->mac.ops.init_params) {
559 : 0 : ret_val = hw->mac.ops.init_params(hw);
560 [ # # ]: 0 : if (ret_val) {
561 : 0 : DEBUGOUT("MAC Initialization Error\n");
562 : 0 : goto out;
563 : : }
564 : : } else {
565 : 0 : DEBUGOUT("mac.init_mac_params was NULL\n");
566 : : ret_val = -IGC_ERR_CONFIG;
567 : : }
568 : :
569 : 0 : out:
570 : 0 : return ret_val;
571 : : }
572 : :
573 : : /**
574 : : * igc_init_nvm_params - Initialize NVM function pointers
575 : : * @hw: pointer to the HW structure
576 : : *
577 : : * This function initializes the function pointers for the NVM
578 : : * set of functions. Called by drivers or by igc_setup_init_funcs.
579 : : **/
580 : 0 : s32 igc_init_nvm_params(struct igc_hw *hw)
581 : : {
582 : : s32 ret_val = IGC_SUCCESS;
583 : :
584 [ # # ]: 0 : if (hw->nvm.ops.init_params) {
585 : 0 : ret_val = hw->nvm.ops.init_params(hw);
586 [ # # ]: 0 : if (ret_val) {
587 : 0 : DEBUGOUT("NVM Initialization Error\n");
588 : 0 : goto out;
589 : : }
590 : : } else {
591 : 0 : DEBUGOUT("nvm.init_nvm_params was NULL\n");
592 : : ret_val = -IGC_ERR_CONFIG;
593 : : }
594 : :
595 : 0 : out:
596 : 0 : return ret_val;
597 : : }
598 : :
599 : : /**
600 : : * igc_init_phy_params - Initialize PHY function pointers
601 : : * @hw: pointer to the HW structure
602 : : *
603 : : * This function initializes the function pointers for the PHY
604 : : * set of functions. Called by drivers or by igc_setup_init_funcs.
605 : : **/
606 : 0 : s32 igc_init_phy_params(struct igc_hw *hw)
607 : : {
608 : : s32 ret_val = IGC_SUCCESS;
609 : :
610 [ # # ]: 0 : if (hw->phy.ops.init_params) {
611 : 0 : ret_val = hw->phy.ops.init_params(hw);
612 [ # # ]: 0 : if (ret_val) {
613 : 0 : DEBUGOUT("PHY Initialization Error\n");
614 : 0 : goto out;
615 : : }
616 : : } else {
617 : 0 : DEBUGOUT("phy.init_phy_params was NULL\n");
618 : : ret_val = -IGC_ERR_CONFIG;
619 : : }
620 : :
621 : 0 : out:
622 : 0 : return ret_val;
623 : : }
624 : :
625 : : /**
626 : : * igc_init_mbx_params - Initialize mailbox function pointers
627 : : * @hw: pointer to the HW structure
628 : : *
629 : : * This function initializes the function pointers for the PHY
630 : : * set of functions. Called by drivers or by igc_setup_init_funcs.
631 : : **/
632 : 0 : s32 igc_init_mbx_params(struct igc_hw *hw)
633 : : {
634 : : s32 ret_val = IGC_SUCCESS;
635 : :
636 [ # # ]: 0 : if (hw->mbx.ops.init_params) {
637 : 0 : ret_val = hw->mbx.ops.init_params(hw);
638 [ # # ]: 0 : if (ret_val) {
639 : 0 : DEBUGOUT("Mailbox Initialization Error\n");
640 : 0 : goto out;
641 : : }
642 : : } else {
643 : 0 : DEBUGOUT("mbx.init_mbx_params was NULL\n");
644 : : ret_val = -IGC_ERR_CONFIG;
645 : : }
646 : :
647 : 0 : out:
648 : 0 : return ret_val;
649 : : }
650 : :
651 : : /**
652 : : * igc_set_mac_type - Sets MAC type
653 : : * @hw: pointer to the HW structure
654 : : *
655 : : * This function sets the mac type of the adapter based on the
656 : : * device ID stored in the hw structure.
657 : : * MUST BE FIRST FUNCTION CALLED (explicitly or through
658 : : * igc_setup_init_funcs()).
659 : : **/
660 : 0 : s32 igc_set_mac_type(struct igc_hw *hw)
661 : : {
662 : : struct igc_mac_info *mac = &hw->mac;
663 : : s32 ret_val = IGC_SUCCESS;
664 : :
665 : 0 : DEBUGFUNC("igc_set_mac_type");
666 : :
667 [ # # # # : 0 : switch (hw->device_id) {
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
668 : 0 : case IGC_DEV_ID_82542:
669 : 0 : mac->type = igc_82542;
670 : 0 : break;
671 : 0 : case IGC_DEV_ID_82543GC_FIBER:
672 : : case IGC_DEV_ID_82543GC_COPPER:
673 : 0 : mac->type = igc_82543;
674 : 0 : break;
675 : 0 : case IGC_DEV_ID_82544EI_COPPER:
676 : : case IGC_DEV_ID_82544EI_FIBER:
677 : : case IGC_DEV_ID_82544GC_COPPER:
678 : : case IGC_DEV_ID_82544GC_LOM:
679 : 0 : mac->type = igc_82544;
680 : 0 : break;
681 : 0 : case IGC_DEV_ID_82540EM:
682 : : case IGC_DEV_ID_82540EM_LOM:
683 : : case IGC_DEV_ID_82540EP:
684 : : case IGC_DEV_ID_82540EP_LOM:
685 : : case IGC_DEV_ID_82540EP_LP:
686 : 0 : mac->type = igc_82540;
687 : 0 : break;
688 : 0 : case IGC_DEV_ID_82545EM_COPPER:
689 : : case IGC_DEV_ID_82545EM_FIBER:
690 : 0 : mac->type = igc_82545;
691 : 0 : break;
692 : 0 : case IGC_DEV_ID_82545GM_COPPER:
693 : : case IGC_DEV_ID_82545GM_FIBER:
694 : : case IGC_DEV_ID_82545GM_SERDES:
695 : 0 : mac->type = igc_82545_rev_3;
696 : 0 : break;
697 : 0 : case IGC_DEV_ID_82546EB_COPPER:
698 : : case IGC_DEV_ID_82546EB_FIBER:
699 : : case IGC_DEV_ID_82546EB_QUAD_COPPER:
700 : 0 : mac->type = igc_82546;
701 : 0 : break;
702 : 0 : case IGC_DEV_ID_82546GB_COPPER:
703 : : case IGC_DEV_ID_82546GB_FIBER:
704 : : case IGC_DEV_ID_82546GB_SERDES:
705 : : case IGC_DEV_ID_82546GB_PCIE:
706 : : case IGC_DEV_ID_82546GB_QUAD_COPPER:
707 : : case IGC_DEV_ID_82546GB_QUAD_COPPER_KSP3:
708 : 0 : mac->type = igc_82546_rev_3;
709 : 0 : break;
710 : 0 : case IGC_DEV_ID_82541EI:
711 : : case IGC_DEV_ID_82541EI_MOBILE:
712 : : case IGC_DEV_ID_82541ER_LOM:
713 : 0 : mac->type = igc_82541;
714 : 0 : break;
715 : 0 : case IGC_DEV_ID_82541ER:
716 : : case IGC_DEV_ID_82541GI:
717 : : case IGC_DEV_ID_82541GI_LF:
718 : : case IGC_DEV_ID_82541GI_MOBILE:
719 : 0 : mac->type = igc_82541_rev_2;
720 : 0 : break;
721 : 0 : case IGC_DEV_ID_82547EI:
722 : : case IGC_DEV_ID_82547EI_MOBILE:
723 : 0 : mac->type = igc_82547;
724 : 0 : break;
725 : 0 : case IGC_DEV_ID_82547GI:
726 : 0 : mac->type = igc_82547_rev_2;
727 : 0 : break;
728 : 0 : case IGC_DEV_ID_82571EB_COPPER:
729 : : case IGC_DEV_ID_82571EB_FIBER:
730 : : case IGC_DEV_ID_82571EB_SERDES:
731 : : case IGC_DEV_ID_82571EB_SERDES_DUAL:
732 : : case IGC_DEV_ID_82571EB_SERDES_QUAD:
733 : : case IGC_DEV_ID_82571EB_QUAD_COPPER:
734 : : case IGC_DEV_ID_82571PT_QUAD_COPPER:
735 : : case IGC_DEV_ID_82571EB_QUAD_FIBER:
736 : : case IGC_DEV_ID_82571EB_QUAD_COPPER_LP:
737 : 0 : mac->type = igc_82571;
738 : 0 : break;
739 : 0 : case IGC_DEV_ID_82572EI:
740 : : case IGC_DEV_ID_82572EI_COPPER:
741 : : case IGC_DEV_ID_82572EI_FIBER:
742 : : case IGC_DEV_ID_82572EI_SERDES:
743 : 0 : mac->type = igc_82572;
744 : 0 : break;
745 : 0 : case IGC_DEV_ID_82573E:
746 : : case IGC_DEV_ID_82573E_IAMT:
747 : : case IGC_DEV_ID_82573L:
748 : 0 : mac->type = igc_82573;
749 : 0 : break;
750 : 0 : case IGC_DEV_ID_82574L:
751 : : case IGC_DEV_ID_82574LA:
752 : 0 : mac->type = igc_82574;
753 : 0 : break;
754 : 0 : case IGC_DEV_ID_82583V:
755 : 0 : mac->type = igc_82583;
756 : 0 : break;
757 : 0 : case IGC_DEV_ID_80003ES2LAN_COPPER_DPT:
758 : : case IGC_DEV_ID_80003ES2LAN_SERDES_DPT:
759 : : case IGC_DEV_ID_80003ES2LAN_COPPER_SPT:
760 : : case IGC_DEV_ID_80003ES2LAN_SERDES_SPT:
761 : 0 : mac->type = igc_80003es2lan;
762 : 0 : break;
763 : 0 : case IGC_DEV_ID_ICH8_IFE:
764 : : case IGC_DEV_ID_ICH8_IFE_GT:
765 : : case IGC_DEV_ID_ICH8_IFE_G:
766 : : case IGC_DEV_ID_ICH8_IGP_M:
767 : : case IGC_DEV_ID_ICH8_IGP_M_AMT:
768 : : case IGC_DEV_ID_ICH8_IGP_AMT:
769 : : case IGC_DEV_ID_ICH8_IGP_C:
770 : : case IGC_DEV_ID_ICH8_82567V_3:
771 : 0 : mac->type = igc_ich8lan;
772 : 0 : break;
773 : 0 : case IGC_DEV_ID_ICH9_IFE:
774 : : case IGC_DEV_ID_ICH9_IFE_GT:
775 : : case IGC_DEV_ID_ICH9_IFE_G:
776 : : case IGC_DEV_ID_ICH9_IGP_M:
777 : : case IGC_DEV_ID_ICH9_IGP_M_AMT:
778 : : case IGC_DEV_ID_ICH9_IGP_M_V:
779 : : case IGC_DEV_ID_ICH9_IGP_AMT:
780 : : case IGC_DEV_ID_ICH9_BM:
781 : : case IGC_DEV_ID_ICH9_IGP_C:
782 : : case IGC_DEV_ID_ICH10_R_BM_LM:
783 : : case IGC_DEV_ID_ICH10_R_BM_LF:
784 : : case IGC_DEV_ID_ICH10_R_BM_V:
785 : 0 : mac->type = igc_ich9lan;
786 : 0 : break;
787 : 0 : case IGC_DEV_ID_ICH10_D_BM_LM:
788 : : case IGC_DEV_ID_ICH10_D_BM_LF:
789 : : case IGC_DEV_ID_ICH10_D_BM_V:
790 : 0 : mac->type = igc_ich10lan;
791 : 0 : break;
792 : 0 : case IGC_DEV_ID_PCH_D_HV_DM:
793 : : case IGC_DEV_ID_PCH_D_HV_DC:
794 : : case IGC_DEV_ID_PCH_M_HV_LM:
795 : : case IGC_DEV_ID_PCH_M_HV_LC:
796 : 0 : mac->type = igc_pchlan;
797 : 0 : break;
798 : 0 : case IGC_DEV_ID_PCH2_LV_LM:
799 : : case IGC_DEV_ID_PCH2_LV_V:
800 : 0 : mac->type = igc_pch2lan;
801 : 0 : break;
802 : 0 : case IGC_DEV_ID_PCH_LPT_I217_LM:
803 : : case IGC_DEV_ID_PCH_LPT_I217_V:
804 : : case IGC_DEV_ID_PCH_LPTLP_I218_LM:
805 : : case IGC_DEV_ID_PCH_LPTLP_I218_V:
806 : : case IGC_DEV_ID_PCH_I218_LM2:
807 : : case IGC_DEV_ID_PCH_I218_V2:
808 : : case IGC_DEV_ID_PCH_I218_LM3:
809 : : case IGC_DEV_ID_PCH_I218_V3:
810 : 0 : mac->type = igc_pch_lpt;
811 : 0 : break;
812 : 0 : case IGC_DEV_ID_PCH_SPT_I219_LM:
813 : : case IGC_DEV_ID_PCH_SPT_I219_V:
814 : : case IGC_DEV_ID_PCH_SPT_I219_LM2:
815 : : case IGC_DEV_ID_PCH_SPT_I219_V2:
816 : : case IGC_DEV_ID_PCH_LBG_I219_LM3:
817 : : case IGC_DEV_ID_PCH_SPT_I219_LM4:
818 : : case IGC_DEV_ID_PCH_SPT_I219_V4:
819 : : case IGC_DEV_ID_PCH_SPT_I219_LM5:
820 : : case IGC_DEV_ID_PCH_SPT_I219_V5:
821 : 0 : mac->type = igc_pch_spt;
822 : 0 : break;
823 : 0 : case IGC_DEV_ID_PCH_CNP_I219_LM6:
824 : : case IGC_DEV_ID_PCH_CNP_I219_V6:
825 : : case IGC_DEV_ID_PCH_CNP_I219_LM7:
826 : : case IGC_DEV_ID_PCH_CNP_I219_V7:
827 : : case IGC_DEV_ID_PCH_ICP_I219_LM8:
828 : : case IGC_DEV_ID_PCH_ICP_I219_V8:
829 : : case IGC_DEV_ID_PCH_ICP_I219_LM9:
830 : : case IGC_DEV_ID_PCH_ICP_I219_V9:
831 : 0 : mac->type = igc_pch_cnp;
832 : 0 : break;
833 : 0 : case IGC_DEV_ID_82575EB_COPPER:
834 : : case IGC_DEV_ID_82575EB_FIBER_SERDES:
835 : : case IGC_DEV_ID_82575GB_QUAD_COPPER:
836 : 0 : mac->type = igc_82575;
837 : 0 : break;
838 : 0 : case IGC_DEV_ID_82576:
839 : : case IGC_DEV_ID_82576_FIBER:
840 : : case IGC_DEV_ID_82576_SERDES:
841 : : case IGC_DEV_ID_82576_QUAD_COPPER:
842 : : case IGC_DEV_ID_82576_QUAD_COPPER_ET2:
843 : : case IGC_DEV_ID_82576_NS:
844 : : case IGC_DEV_ID_82576_NS_SERDES:
845 : : case IGC_DEV_ID_82576_SERDES_QUAD:
846 : 0 : mac->type = igc_82576;
847 : 0 : break;
848 : 0 : case IGC_DEV_ID_82576_VF:
849 : : case IGC_DEV_ID_82576_VF_HV:
850 : 0 : mac->type = igc_vfadapt;
851 : 0 : break;
852 : 0 : case IGC_DEV_ID_82580_COPPER:
853 : : case IGC_DEV_ID_82580_FIBER:
854 : : case IGC_DEV_ID_82580_SERDES:
855 : : case IGC_DEV_ID_82580_SGMII:
856 : : case IGC_DEV_ID_82580_COPPER_DUAL:
857 : : case IGC_DEV_ID_82580_QUAD_FIBER:
858 : : case IGC_DEV_ID_DH89XXCC_SGMII:
859 : : case IGC_DEV_ID_DH89XXCC_SERDES:
860 : : case IGC_DEV_ID_DH89XXCC_BACKPLANE:
861 : : case IGC_DEV_ID_DH89XXCC_SFP:
862 : 0 : mac->type = igc_82580;
863 : 0 : break;
864 : 0 : case IGC_DEV_ID_I350_COPPER:
865 : : case IGC_DEV_ID_I350_FIBER:
866 : : case IGC_DEV_ID_I350_SERDES:
867 : : case IGC_DEV_ID_I350_SGMII:
868 : : case IGC_DEV_ID_I350_DA4:
869 : 0 : mac->type = igc_i350;
870 : 0 : break;
871 : 0 : case IGC_DEV_ID_I210_COPPER_FLASHLESS:
872 : : case IGC_DEV_ID_I210_SERDES_FLASHLESS:
873 : : case IGC_DEV_ID_I210_SGMII_FLASHLESS:
874 : : case IGC_DEV_ID_I210_COPPER:
875 : : case IGC_DEV_ID_I210_COPPER_OEM1:
876 : : case IGC_DEV_ID_I210_COPPER_IT:
877 : : case IGC_DEV_ID_I210_FIBER:
878 : : case IGC_DEV_ID_I210_SERDES:
879 : : case IGC_DEV_ID_I210_SGMII:
880 : 0 : mac->type = igc_i210;
881 : 0 : break;
882 : 0 : case IGC_DEV_ID_I211_COPPER:
883 : 0 : mac->type = igc_i211;
884 : 0 : break;
885 : 0 : case IGC_DEV_ID_I225_LM:
886 : : case IGC_DEV_ID_I225_LMVP:
887 : : case IGC_DEV_ID_I225_V:
888 : : case IGC_DEV_ID_I225_K:
889 : : case IGC_DEV_ID_I225_I:
890 : : case IGC_DEV_ID_I225_IT:
891 : : case IGC_DEV_ID_I220_V:
892 : : case IGC_DEV_ID_I225_BLANK_NVM:
893 : : case IGC_DEV_ID_I226_K:
894 : : case IGC_DEV_ID_I226_LMVP:
895 : : case IGC_DEV_ID_I226_LM:
896 : : case IGC_DEV_ID_I226_V:
897 : : case IGC_DEV_ID_I226_IT:
898 : : case IGC_DEV_ID_I226_BLANK_NVM:
899 : 0 : mac->type = igc_i225;
900 : 0 : break;
901 : 0 : case IGC_DEV_ID_I350_VF:
902 : : case IGC_DEV_ID_I350_VF_HV:
903 : 0 : mac->type = igc_vfadapt_i350;
904 : 0 : break;
905 : 0 : case IGC_DEV_ID_I354_BACKPLANE_1GBPS:
906 : : case IGC_DEV_ID_I354_SGMII:
907 : : case IGC_DEV_ID_I354_BACKPLANE_2_5GBPS:
908 : 0 : mac->type = igc_i354;
909 : 0 : break;
910 : : default:
911 : : /* Should never have loaded on this device */
912 : : ret_val = -IGC_ERR_MAC_INIT;
913 : : break;
914 : : }
915 : :
916 : 0 : return ret_val;
917 : : }
918 : :
919 : : /**
920 : : * igc_setup_init_funcs - Initializes function pointers
921 : : * @hw: pointer to the HW structure
922 : : * @init_device: true will initialize the rest of the function pointers
923 : : * getting the device ready for use. false will only set
924 : : * MAC type and the function pointers for the other init
925 : : * functions. Passing false will not generate any hardware
926 : : * reads or writes.
927 : : *
928 : : * This function must be called by a driver in order to use the rest
929 : : * of the 'shared' code files. Called by drivers only.
930 : : **/
931 : 0 : s32 igc_setup_init_funcs(struct igc_hw *hw, bool init_device)
932 : : {
933 : : s32 ret_val;
934 : :
935 : : /* Can't do much good without knowing the MAC type. */
936 : 0 : ret_val = igc_set_mac_type(hw);
937 [ # # ]: 0 : if (ret_val) {
938 : 0 : DEBUGOUT("ERROR: MAC type could not be set properly.\n");
939 : 0 : goto out;
940 : : }
941 : :
942 [ # # ]: 0 : if (!hw->hw_addr) {
943 : 0 : DEBUGOUT("ERROR: Registers not mapped\n");
944 : : ret_val = -IGC_ERR_CONFIG;
945 : 0 : goto out;
946 : : }
947 : :
948 : : /*
949 : : * Init function pointers to generic implementations. We do this first
950 : : * allowing a driver module to override it afterward.
951 : : */
952 : 0 : igc_init_mac_ops_generic(hw);
953 : 0 : igc_init_phy_ops_generic(hw);
954 : 0 : igc_init_nvm_ops_generic(hw);
955 : :
956 : : /*
957 : : * Set up the init function pointers. These are functions within the
958 : : * adapter family file that sets up function pointers for the rest of
959 : : * the functions in that family.
960 : : */
961 [ # # ]: 0 : switch (hw->mac.type) {
962 : 0 : case igc_i225:
963 : 0 : igc_init_function_pointers_i225(hw);
964 : 0 : break;
965 : 0 : default:
966 : 0 : DEBUGOUT("Hardware not supported\n");
967 : : ret_val = -IGC_ERR_CONFIG;
968 : 0 : break;
969 : : }
970 : :
971 : : /*
972 : : * Initialize the rest of the function pointers. These require some
973 : : * register reads/writes in some cases.
974 : : */
975 [ # # ]: 0 : if (!(ret_val) && init_device) {
976 : 0 : ret_val = igc_init_mac_params(hw);
977 [ # # ]: 0 : if (ret_val)
978 : 0 : goto out;
979 : :
980 : 0 : ret_val = igc_init_nvm_params(hw);
981 [ # # ]: 0 : if (ret_val)
982 : 0 : goto out;
983 : :
984 : 0 : ret_val = igc_init_phy_params(hw);
985 [ # # ]: 0 : if (ret_val)
986 : 0 : goto out;
987 : : }
988 : :
989 : 0 : out:
990 : 0 : return ret_val;
991 : : }
992 : :
993 : : /**
994 : : * igc_get_bus_info - Obtain bus information for adapter
995 : : * @hw: pointer to the HW structure
996 : : *
997 : : * This will obtain information about the HW bus for which the
998 : : * adapter is attached and stores it in the hw structure. This is a
999 : : * function pointer entry point called by drivers.
1000 : : **/
1001 : 0 : s32 igc_get_bus_info(struct igc_hw *hw)
1002 : : {
1003 [ # # ]: 0 : if (hw->mac.ops.get_bus_info)
1004 : 0 : return hw->mac.ops.get_bus_info(hw);
1005 : :
1006 : : return IGC_SUCCESS;
1007 : : }
1008 : :
1009 : : /**
1010 : : * igc_clear_vfta - Clear VLAN filter table
1011 : : * @hw: pointer to the HW structure
1012 : : *
1013 : : * This clears the VLAN filter table on the adapter. This is a function
1014 : : * pointer entry point called by drivers.
1015 : : **/
1016 : 0 : void igc_clear_vfta(struct igc_hw *hw)
1017 : : {
1018 [ # # ]: 0 : if (hw->mac.ops.clear_vfta)
1019 : 0 : hw->mac.ops.clear_vfta(hw);
1020 : 0 : }
1021 : :
1022 : : /**
1023 : : * igc_write_vfta - Write value to VLAN filter table
1024 : : * @hw: pointer to the HW structure
1025 : : * @offset: the 32-bit offset in which to write the value to.
1026 : : * @value: the 32-bit value to write at location offset.
1027 : : *
1028 : : * This writes a 32-bit value to a 32-bit offset in the VLAN filter
1029 : : * table. This is a function pointer entry point called by drivers.
1030 : : **/
1031 : 0 : void igc_write_vfta(struct igc_hw *hw, u32 offset, u32 value)
1032 : : {
1033 [ # # ]: 0 : if (hw->mac.ops.write_vfta)
1034 : 0 : hw->mac.ops.write_vfta(hw, offset, value);
1035 : 0 : }
1036 : :
1037 : : /**
1038 : : * igc_update_mc_addr_list - Update Multicast addresses
1039 : : * @hw: pointer to the HW structure
1040 : : * @mc_addr_list: array of multicast addresses to program
1041 : : * @mc_addr_count: number of multicast addresses to program
1042 : : *
1043 : : * Updates the Multicast Table Array.
1044 : : * The caller must have a packed mc_addr_list of multicast addresses.
1045 : : **/
1046 : 0 : void igc_update_mc_addr_list(struct igc_hw *hw, u8 *mc_addr_list,
1047 : : u32 mc_addr_count)
1048 : : {
1049 [ # # ]: 0 : if (hw->mac.ops.update_mc_addr_list)
1050 : 0 : hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
1051 : : mc_addr_count);
1052 : 0 : }
1053 : :
1054 : : /**
1055 : : * igc_force_mac_fc - Force MAC flow control
1056 : : * @hw: pointer to the HW structure
1057 : : *
1058 : : * Force the MAC's flow control settings. Currently no func pointer exists
1059 : : * and all implementations are handled in the generic version of this
1060 : : * function.
1061 : : **/
1062 : 0 : s32 igc_force_mac_fc(struct igc_hw *hw)
1063 : : {
1064 : 0 : return igc_force_mac_fc_generic(hw);
1065 : : }
1066 : :
1067 : : /**
1068 : : * igc_check_for_link - Check/Store link connection
1069 : : * @hw: pointer to the HW structure
1070 : : *
1071 : : * This checks the link condition of the adapter and stores the
1072 : : * results in the hw->mac structure. This is a function pointer entry
1073 : : * point called by drivers.
1074 : : **/
1075 : 0 : s32 igc_check_for_link(struct igc_hw *hw)
1076 : : {
1077 [ # # ]: 0 : if (hw->mac.ops.check_for_link)
1078 : 0 : return hw->mac.ops.check_for_link(hw);
1079 : :
1080 : : return -IGC_ERR_CONFIG;
1081 : : }
1082 : :
1083 : : /**
1084 : : * igc_check_mng_mode - Check management mode
1085 : : * @hw: pointer to the HW structure
1086 : : *
1087 : : * This checks if the adapter has manageability enabled.
1088 : : * This is a function pointer entry point called by drivers.
1089 : : **/
1090 : 0 : bool igc_check_mng_mode(struct igc_hw *hw)
1091 : : {
1092 [ # # ]: 0 : if (hw->mac.ops.check_mng_mode)
1093 : 0 : return hw->mac.ops.check_mng_mode(hw);
1094 : :
1095 : : return false;
1096 : : }
1097 : :
1098 : : /**
1099 : : * igc_mng_write_dhcp_info - Writes DHCP info to host interface
1100 : : * @hw: pointer to the HW structure
1101 : : * @buffer: pointer to the host interface
1102 : : * @length: size of the buffer
1103 : : *
1104 : : * Writes the DHCP information to the host interface.
1105 : : **/
1106 : 0 : s32 igc_mng_write_dhcp_info(struct igc_hw *hw, u8 *buffer, u16 length)
1107 : : {
1108 : 0 : return igc_mng_write_dhcp_info_generic(hw, buffer, length);
1109 : : }
1110 : :
1111 : : /**
1112 : : * igc_reset_hw - Reset hardware
1113 : : * @hw: pointer to the HW structure
1114 : : *
1115 : : * This resets the hardware into a known state. This is a function pointer
1116 : : * entry point called by drivers.
1117 : : **/
1118 : 0 : s32 igc_reset_hw(struct igc_hw *hw)
1119 : : {
1120 [ # # ]: 0 : if (hw->mac.ops.reset_hw)
1121 : 0 : return hw->mac.ops.reset_hw(hw);
1122 : :
1123 : : return -IGC_ERR_CONFIG;
1124 : : }
1125 : :
1126 : : /**
1127 : : * igc_init_hw - Initialize hardware
1128 : : * @hw: pointer to the HW structure
1129 : : *
1130 : : * This inits the hardware readying it for operation. This is a function
1131 : : * pointer entry point called by drivers.
1132 : : **/
1133 : 0 : s32 igc_init_hw(struct igc_hw *hw)
1134 : : {
1135 [ # # ]: 0 : if (hw->mac.ops.init_hw)
1136 : 0 : return hw->mac.ops.init_hw(hw);
1137 : :
1138 : : return -IGC_ERR_CONFIG;
1139 : : }
1140 : :
1141 : : /**
1142 : : * igc_setup_link - Configures link and flow control
1143 : : * @hw: pointer to the HW structure
1144 : : *
1145 : : * This configures link and flow control settings for the adapter. This
1146 : : * is a function pointer entry point called by drivers. While modules can
1147 : : * also call this, they probably call their own version of this function.
1148 : : **/
1149 : 0 : s32 igc_setup_link(struct igc_hw *hw)
1150 : : {
1151 [ # # ]: 0 : if (hw->mac.ops.setup_link)
1152 : 0 : return hw->mac.ops.setup_link(hw);
1153 : :
1154 : : return -IGC_ERR_CONFIG;
1155 : : }
1156 : :
1157 : : /**
1158 : : * igc_get_speed_and_duplex - Returns current speed and duplex
1159 : : * @hw: pointer to the HW structure
1160 : : * @speed: pointer to a 16-bit value to store the speed
1161 : : * @duplex: pointer to a 16-bit value to store the duplex.
1162 : : *
1163 : : * This returns the speed and duplex of the adapter in the two 'out'
1164 : : * variables passed in. This is a function pointer entry point called
1165 : : * by drivers.
1166 : : **/
1167 : 0 : s32 igc_get_speed_and_duplex(struct igc_hw *hw, u16 *speed, u16 *duplex)
1168 : : {
1169 [ # # ]: 0 : if (hw->mac.ops.get_link_up_info)
1170 : 0 : return hw->mac.ops.get_link_up_info(hw, speed, duplex);
1171 : :
1172 : : return -IGC_ERR_CONFIG;
1173 : : }
1174 : :
1175 : : /**
1176 : : * igc_setup_led - Configures SW controllable LED
1177 : : * @hw: pointer to the HW structure
1178 : : *
1179 : : * This prepares the SW controllable LED for use and saves the current state
1180 : : * of the LED so it can be later restored. This is a function pointer entry
1181 : : * point called by drivers.
1182 : : **/
1183 : 0 : s32 igc_setup_led(struct igc_hw *hw)
1184 : : {
1185 [ # # ]: 0 : if (hw->mac.ops.setup_led)
1186 : 0 : return hw->mac.ops.setup_led(hw);
1187 : :
1188 : : return IGC_SUCCESS;
1189 : : }
1190 : :
1191 : : /**
1192 : : * igc_cleanup_led - Restores SW controllable LED
1193 : : * @hw: pointer to the HW structure
1194 : : *
1195 : : * This restores the SW controllable LED to the value saved off by
1196 : : * igc_setup_led. This is a function pointer entry point called by drivers.
1197 : : **/
1198 : 0 : s32 igc_cleanup_led(struct igc_hw *hw)
1199 : : {
1200 [ # # ]: 0 : if (hw->mac.ops.cleanup_led)
1201 : 0 : return hw->mac.ops.cleanup_led(hw);
1202 : :
1203 : : return IGC_SUCCESS;
1204 : : }
1205 : :
1206 : : /**
1207 : : * igc_blink_led - Blink SW controllable LED
1208 : : * @hw: pointer to the HW structure
1209 : : *
1210 : : * This starts the adapter LED blinking. Request the LED to be setup first
1211 : : * and cleaned up after. This is a function pointer entry point called by
1212 : : * drivers.
1213 : : **/
1214 : 0 : s32 igc_blink_led(struct igc_hw *hw)
1215 : : {
1216 [ # # ]: 0 : if (hw->mac.ops.blink_led)
1217 : 0 : return hw->mac.ops.blink_led(hw);
1218 : :
1219 : : return IGC_SUCCESS;
1220 : : }
1221 : :
1222 : : /**
1223 : : * igc_id_led_init - store LED configurations in SW
1224 : : * @hw: pointer to the HW structure
1225 : : *
1226 : : * Initializes the LED config in SW. This is a function pointer entry point
1227 : : * called by drivers.
1228 : : **/
1229 : 0 : s32 igc_id_led_init(struct igc_hw *hw)
1230 : : {
1231 [ # # ]: 0 : if (hw->mac.ops.id_led_init)
1232 : 0 : return hw->mac.ops.id_led_init(hw);
1233 : :
1234 : : return IGC_SUCCESS;
1235 : : }
1236 : :
1237 : : /**
1238 : : * igc_led_on - Turn on SW controllable LED
1239 : : * @hw: pointer to the HW structure
1240 : : *
1241 : : * Turns the SW defined LED on. This is a function pointer entry point
1242 : : * called by drivers.
1243 : : **/
1244 : 0 : s32 igc_led_on(struct igc_hw *hw)
1245 : : {
1246 [ # # ]: 0 : if (hw->mac.ops.led_on)
1247 : 0 : return hw->mac.ops.led_on(hw);
1248 : :
1249 : : return IGC_SUCCESS;
1250 : : }
1251 : :
1252 : : /**
1253 : : * igc_led_off - Turn off SW controllable LED
1254 : : * @hw: pointer to the HW structure
1255 : : *
1256 : : * Turns the SW defined LED off. This is a function pointer entry point
1257 : : * called by drivers.
1258 : : **/
1259 : 0 : s32 igc_led_off(struct igc_hw *hw)
1260 : : {
1261 [ # # ]: 0 : if (hw->mac.ops.led_off)
1262 : 0 : return hw->mac.ops.led_off(hw);
1263 : :
1264 : : return IGC_SUCCESS;
1265 : : }
1266 : :
1267 : : /**
1268 : : * igc_reset_adaptive - Reset adaptive IFS
1269 : : * @hw: pointer to the HW structure
1270 : : *
1271 : : * Resets the adaptive IFS. Currently no func pointer exists and all
1272 : : * implementations are handled in the generic version of this function.
1273 : : **/
1274 : 0 : void igc_reset_adaptive(struct igc_hw *hw)
1275 : : {
1276 : 0 : igc_reset_adaptive_generic(hw);
1277 : 0 : }
1278 : :
1279 : : /**
1280 : : * igc_update_adaptive - Update adaptive IFS
1281 : : * @hw: pointer to the HW structure
1282 : : *
1283 : : * Updates adapter IFS. Currently no func pointer exists and all
1284 : : * implementations are handled in the generic version of this function.
1285 : : **/
1286 : 0 : void igc_update_adaptive(struct igc_hw *hw)
1287 : : {
1288 : 0 : igc_update_adaptive_generic(hw);
1289 : 0 : }
1290 : :
1291 : : /**
1292 : : * igc_disable_pcie_master - Disable PCI-Express master access
1293 : : * @hw: pointer to the HW structure
1294 : : *
1295 : : * Disables PCI-Express master access and verifies there are no pending
1296 : : * requests. Currently no func pointer exists and all implementations are
1297 : : * handled in the generic version of this function.
1298 : : **/
1299 : 0 : s32 igc_disable_pcie_master(struct igc_hw *hw)
1300 : : {
1301 : 0 : return igc_disable_pcie_master_generic(hw);
1302 : : }
1303 : :
1304 : : /**
1305 : : * igc_config_collision_dist - Configure collision distance
1306 : : * @hw: pointer to the HW structure
1307 : : *
1308 : : * Configures the collision distance to the default value and is used
1309 : : * during link setup.
1310 : : **/
1311 : 0 : void igc_config_collision_dist(struct igc_hw *hw)
1312 : : {
1313 [ # # ]: 0 : if (hw->mac.ops.config_collision_dist)
1314 : 0 : hw->mac.ops.config_collision_dist(hw);
1315 : 0 : }
1316 : :
1317 : : /**
1318 : : * igc_rar_set - Sets a receive address register
1319 : : * @hw: pointer to the HW structure
1320 : : * @addr: address to set the RAR to
1321 : : * @index: the RAR to set
1322 : : *
1323 : : * Sets a Receive Address Register (RAR) to the specified address.
1324 : : **/
1325 : 0 : int igc_rar_set(struct igc_hw *hw, u8 *addr, u32 index)
1326 : : {
1327 [ # # ]: 0 : if (hw->mac.ops.rar_set)
1328 : 0 : return hw->mac.ops.rar_set(hw, addr, index);
1329 : :
1330 : : return IGC_SUCCESS;
1331 : : }
1332 : :
1333 : : /**
1334 : : * igc_validate_mdi_setting - Ensures valid MDI/MDIX SW state
1335 : : * @hw: pointer to the HW structure
1336 : : *
1337 : : * Ensures that the MDI/MDIX SW state is valid.
1338 : : **/
1339 : 0 : s32 igc_validate_mdi_setting(struct igc_hw *hw)
1340 : : {
1341 [ # # ]: 0 : if (hw->mac.ops.validate_mdi_setting)
1342 : 0 : return hw->mac.ops.validate_mdi_setting(hw);
1343 : :
1344 : : return IGC_SUCCESS;
1345 : : }
1346 : :
1347 : : /**
1348 : : * igc_hash_mc_addr - Determines address location in multicast table
1349 : : * @hw: pointer to the HW structure
1350 : : * @mc_addr: Multicast address to hash.
1351 : : *
1352 : : * This hashes an address to determine its location in the multicast
1353 : : * table. Currently no func pointer exists and all implementations
1354 : : * are handled in the generic version of this function.
1355 : : **/
1356 : 0 : u32 igc_hash_mc_addr(struct igc_hw *hw, u8 *mc_addr)
1357 : : {
1358 : 0 : return igc_hash_mc_addr_generic(hw, mc_addr);
1359 : : }
1360 : :
1361 : : /**
1362 : : * igc_enable_tx_pkt_filtering - Enable packet filtering on TX
1363 : : * @hw: pointer to the HW structure
1364 : : *
1365 : : * Enables packet filtering on transmit packets if manageability is enabled
1366 : : * and host interface is enabled.
1367 : : * Currently no func pointer exists and all implementations are handled in the
1368 : : * generic version of this function.
1369 : : **/
1370 : 0 : bool igc_enable_tx_pkt_filtering(struct igc_hw *hw)
1371 : : {
1372 : 0 : return igc_enable_tx_pkt_filtering_generic(hw);
1373 : : }
1374 : :
1375 : : /**
1376 : : * igc_mng_host_if_write - Writes to the manageability host interface
1377 : : * @hw: pointer to the HW structure
1378 : : * @buffer: pointer to the host interface buffer
1379 : : * @length: size of the buffer
1380 : : * @offset: location in the buffer to write to
1381 : : * @sum: sum of the data (not checksum)
1382 : : *
1383 : : * This function writes the buffer content at the offset given on the host if.
1384 : : * It also does alignment considerations to do the writes in most efficient
1385 : : * way. Also fills up the sum of the buffer in *buffer parameter.
1386 : : **/
1387 : 0 : s32 igc_mng_host_if_write(struct igc_hw *hw, u8 *buffer, u16 length,
1388 : : u16 offset, u8 *sum)
1389 : : {
1390 : 0 : return igc_mng_host_if_write_generic(hw, buffer, length, offset, sum);
1391 : : }
1392 : :
1393 : : /**
1394 : : * igc_mng_write_cmd_header - Writes manageability command header
1395 : : * @hw: pointer to the HW structure
1396 : : * @hdr: pointer to the host interface command header
1397 : : *
1398 : : * Writes the command header after does the checksum calculation.
1399 : : **/
1400 : 0 : s32 igc_mng_write_cmd_header(struct igc_hw *hw,
1401 : : struct igc_host_mng_command_header *hdr)
1402 : : {
1403 : 0 : return igc_mng_write_cmd_header_generic(hw, hdr);
1404 : : }
1405 : :
1406 : : /**
1407 : : * igc_mng_enable_host_if - Checks host interface is enabled
1408 : : * @hw: pointer to the HW structure
1409 : : *
1410 : : * Returns IGC_success upon success, else IGC_ERR_HOST_INTERFACE_COMMAND
1411 : : *
1412 : : * This function checks whether the HOST IF is enabled for command operation
1413 : : * and also checks whether the previous command is completed. It busy waits
1414 : : * in case of previous command is not completed.
1415 : : **/
1416 : 0 : s32 igc_mng_enable_host_if(struct igc_hw *hw)
1417 : : {
1418 : 0 : return igc_mng_enable_host_if_generic(hw);
1419 : : }
1420 : :
1421 : : /**
1422 : : * igc_check_reset_block - Verifies PHY can be reset
1423 : : * @hw: pointer to the HW structure
1424 : : *
1425 : : * Checks if the PHY is in a state that can be reset or if manageability
1426 : : * has it tied up. This is a function pointer entry point called by drivers.
1427 : : **/
1428 : 0 : s32 igc_check_reset_block(struct igc_hw *hw)
1429 : : {
1430 [ # # ]: 0 : if (hw->phy.ops.check_reset_block)
1431 : 0 : return hw->phy.ops.check_reset_block(hw);
1432 : :
1433 : : return IGC_SUCCESS;
1434 : : }
1435 : :
1436 : : /**
1437 : : * igc_read_phy_reg - Reads PHY register
1438 : : * @hw: pointer to the HW structure
1439 : : * @offset: the register to read
1440 : : * @data: the buffer to store the 16-bit read.
1441 : : *
1442 : : * Reads the PHY register and returns the value in data.
1443 : : * This is a function pointer entry point called by drivers.
1444 : : **/
1445 : 0 : s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data)
1446 : : {
1447 [ # # ]: 0 : if (hw->phy.ops.read_reg)
1448 : 0 : return hw->phy.ops.read_reg(hw, offset, data);
1449 : :
1450 : : return IGC_SUCCESS;
1451 : : }
1452 : :
1453 : : /**
1454 : : * igc_write_phy_reg - Writes PHY register
1455 : : * @hw: pointer to the HW structure
1456 : : * @offset: the register to write
1457 : : * @data: the value to write.
1458 : : *
1459 : : * Writes the PHY register at offset with the value in data.
1460 : : * This is a function pointer entry point called by drivers.
1461 : : **/
1462 : 0 : s32 igc_write_phy_reg(struct igc_hw *hw, u32 offset, u16 data)
1463 : : {
1464 [ # # ]: 0 : if (hw->phy.ops.write_reg)
1465 : 0 : return hw->phy.ops.write_reg(hw, offset, data);
1466 : :
1467 : : return IGC_SUCCESS;
1468 : : }
1469 : :
1470 : : /**
1471 : : * igc_release_phy - Generic release PHY
1472 : : * @hw: pointer to the HW structure
1473 : : *
1474 : : * Return if silicon family does not require a semaphore when accessing the
1475 : : * PHY.
1476 : : **/
1477 : 0 : void igc_release_phy(struct igc_hw *hw)
1478 : : {
1479 [ # # ]: 0 : if (hw->phy.ops.release)
1480 : 0 : hw->phy.ops.release(hw);
1481 : 0 : }
1482 : :
1483 : : /**
1484 : : * igc_acquire_phy - Generic acquire PHY
1485 : : * @hw: pointer to the HW structure
1486 : : *
1487 : : * Return success if silicon family does not require a semaphore when
1488 : : * accessing the PHY.
1489 : : **/
1490 : 0 : s32 igc_acquire_phy(struct igc_hw *hw)
1491 : : {
1492 [ # # ]: 0 : if (hw->phy.ops.acquire)
1493 : 0 : return hw->phy.ops.acquire(hw);
1494 : :
1495 : : return IGC_SUCCESS;
1496 : : }
1497 : :
1498 : : /**
1499 : : * igc_cfg_on_link_up - Configure PHY upon link up
1500 : : * @hw: pointer to the HW structure
1501 : : **/
1502 : 0 : s32 igc_cfg_on_link_up(struct igc_hw *hw)
1503 : : {
1504 [ # # ]: 0 : if (hw->phy.ops.cfg_on_link_up)
1505 : 0 : return hw->phy.ops.cfg_on_link_up(hw);
1506 : :
1507 : : return IGC_SUCCESS;
1508 : : }
1509 : :
1510 : : /**
1511 : : * igc_read_kmrn_reg - Reads register using Kumeran interface
1512 : : * @hw: pointer to the HW structure
1513 : : * @offset: the register to read
1514 : : * @data: the location to store the 16-bit value read.
1515 : : *
1516 : : * Reads a register out of the Kumeran interface. Currently no func pointer
1517 : : * exists and all implementations are handled in the generic version of
1518 : : * this function.
1519 : : **/
1520 : 0 : s32 igc_read_kmrn_reg(struct igc_hw *hw, u32 offset, u16 *data)
1521 : : {
1522 : 0 : return igc_read_kmrn_reg_generic(hw, offset, data);
1523 : : }
1524 : :
1525 : : /**
1526 : : * igc_write_kmrn_reg - Writes register using Kumeran interface
1527 : : * @hw: pointer to the HW structure
1528 : : * @offset: the register to write
1529 : : * @data: the value to write.
1530 : : *
1531 : : * Writes a register to the Kumeran interface. Currently no func pointer
1532 : : * exists and all implementations are handled in the generic version of
1533 : : * this function.
1534 : : **/
1535 : 0 : s32 igc_write_kmrn_reg(struct igc_hw *hw, u32 offset, u16 data)
1536 : : {
1537 : 0 : return igc_write_kmrn_reg_generic(hw, offset, data);
1538 : : }
1539 : :
1540 : : /**
1541 : : * igc_get_cable_length - Retrieves cable length estimation
1542 : : * @hw: pointer to the HW structure
1543 : : *
1544 : : * This function estimates the cable length and stores them in
1545 : : * hw->phy.min_length and hw->phy.max_length. This is a function pointer
1546 : : * entry point called by drivers.
1547 : : **/
1548 : 0 : s32 igc_get_cable_length(struct igc_hw *hw)
1549 : : {
1550 [ # # ]: 0 : if (hw->phy.ops.get_cable_length)
1551 : 0 : return hw->phy.ops.get_cable_length(hw);
1552 : :
1553 : : return IGC_SUCCESS;
1554 : : }
1555 : :
1556 : : /**
1557 : : * igc_get_phy_info - Retrieves PHY information from registers
1558 : : * @hw: pointer to the HW structure
1559 : : *
1560 : : * This function gets some information from various PHY registers and
1561 : : * populates hw->phy values with it. This is a function pointer entry
1562 : : * point called by drivers.
1563 : : **/
1564 : 0 : s32 igc_get_phy_info(struct igc_hw *hw)
1565 : : {
1566 [ # # ]: 0 : if (hw->phy.ops.get_info)
1567 : 0 : return hw->phy.ops.get_info(hw);
1568 : :
1569 : : return IGC_SUCCESS;
1570 : : }
1571 : :
1572 : : /**
1573 : : * igc_phy_hw_reset - Hard PHY reset
1574 : : * @hw: pointer to the HW structure
1575 : : *
1576 : : * Performs a hard PHY reset. This is a function pointer entry point called
1577 : : * by drivers.
1578 : : **/
1579 : 0 : s32 igc_phy_hw_reset(struct igc_hw *hw)
1580 : : {
1581 [ # # ]: 0 : if (hw->phy.ops.reset)
1582 : 0 : return hw->phy.ops.reset(hw);
1583 : :
1584 : : return IGC_SUCCESS;
1585 : : }
1586 : :
1587 : : /**
1588 : : * igc_phy_commit - Soft PHY reset
1589 : : * @hw: pointer to the HW structure
1590 : : *
1591 : : * Performs a soft PHY reset on those that apply. This is a function pointer
1592 : : * entry point called by drivers.
1593 : : **/
1594 : 0 : s32 igc_phy_commit(struct igc_hw *hw)
1595 : : {
1596 [ # # ]: 0 : if (hw->phy.ops.commit)
1597 : 0 : return hw->phy.ops.commit(hw);
1598 : :
1599 : : return IGC_SUCCESS;
1600 : : }
1601 : :
1602 : : /**
1603 : : * igc_set_d0_lplu_state - Sets low power link up state for D0
1604 : : * @hw: pointer to the HW structure
1605 : : * @active: boolean used to enable/disable lplu
1606 : : *
1607 : : * Success returns 0, Failure returns 1
1608 : : *
1609 : : * The low power link up (lplu) state is set to the power management level D0
1610 : : * and SmartSpeed is disabled when active is true, else clear lplu for D0
1611 : : * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
1612 : : * is used during Dx states where the power conservation is most important.
1613 : : * During driver activity, SmartSpeed should be enabled so performance is
1614 : : * maintained. This is a function pointer entry point called by drivers.
1615 : : **/
1616 : 0 : s32 igc_set_d0_lplu_state(struct igc_hw *hw, bool active)
1617 : : {
1618 [ # # ]: 0 : if (hw->phy.ops.set_d0_lplu_state)
1619 : 0 : return hw->phy.ops.set_d0_lplu_state(hw, active);
1620 : :
1621 : : return IGC_SUCCESS;
1622 : : }
1623 : :
1624 : : /**
1625 : : * igc_set_d3_lplu_state - Sets low power link up state for D3
1626 : : * @hw: pointer to the HW structure
1627 : : * @active: boolean used to enable/disable lplu
1628 : : *
1629 : : * Success returns 0, Failure returns 1
1630 : : *
1631 : : * The low power link up (lplu) state is set to the power management level D3
1632 : : * and SmartSpeed is disabled when active is true, else clear lplu for D3
1633 : : * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
1634 : : * is used during Dx states where the power conservation is most important.
1635 : : * During driver activity, SmartSpeed should be enabled so performance is
1636 : : * maintained. This is a function pointer entry point called by drivers.
1637 : : **/
1638 : 0 : s32 igc_set_d3_lplu_state(struct igc_hw *hw, bool active)
1639 : : {
1640 [ # # ]: 0 : if (hw->phy.ops.set_d3_lplu_state)
1641 : 0 : return hw->phy.ops.set_d3_lplu_state(hw, active);
1642 : :
1643 : : return IGC_SUCCESS;
1644 : : }
1645 : :
1646 : : /**
1647 : : * igc_read_mac_addr - Reads MAC address
1648 : : * @hw: pointer to the HW structure
1649 : : *
1650 : : * Reads the MAC address out of the adapter and stores it in the HW structure.
1651 : : * Currently no func pointer exists and all implementations are handled in the
1652 : : * generic version of this function.
1653 : : **/
1654 : 0 : s32 igc_read_mac_addr(struct igc_hw *hw)
1655 : : {
1656 [ # # ]: 0 : if (hw->mac.ops.read_mac_addr)
1657 : 0 : return hw->mac.ops.read_mac_addr(hw);
1658 : :
1659 : 0 : return igc_read_mac_addr_generic(hw);
1660 : : }
1661 : :
1662 : : /**
1663 : : * igc_read_pba_string - Read device part number string
1664 : : * @hw: pointer to the HW structure
1665 : : * @pba_num: pointer to device part number
1666 : : * @pba_num_size: size of part number buffer
1667 : : *
1668 : : * Reads the product board assembly (PBA) number from the EEPROM and stores
1669 : : * the value in pba_num.
1670 : : * Currently no func pointer exists and all implementations are handled in the
1671 : : * generic version of this function.
1672 : : **/
1673 : 0 : s32 igc_read_pba_string(struct igc_hw *hw, u8 *pba_num, u32 pba_num_size)
1674 : : {
1675 : 0 : return igc_read_pba_string_generic(hw, pba_num, pba_num_size);
1676 : : }
1677 : :
1678 : : /**
1679 : : * igc_read_pba_length - Read device part number string length
1680 : : * @hw: pointer to the HW structure
1681 : : * @pba_num_size: size of part number buffer
1682 : : *
1683 : : * Reads the product board assembly (PBA) number length from the EEPROM and
1684 : : * stores the value in pba_num.
1685 : : * Currently no func pointer exists and all implementations are handled in the
1686 : : * generic version of this function.
1687 : : **/
1688 : 0 : s32 igc_read_pba_length(struct igc_hw *hw, u32 *pba_num_size)
1689 : : {
1690 : 0 : return igc_read_pba_length_generic(hw, pba_num_size);
1691 : : }
1692 : :
1693 : : /**
1694 : : * igc_read_pba_num - Read device part number
1695 : : * @hw: pointer to the HW structure
1696 : : * @pba_num: pointer to device part number
1697 : : *
1698 : : * Reads the product board assembly (PBA) number from the EEPROM and stores
1699 : : * the value in pba_num.
1700 : : * Currently no func pointer exists and all implementations are handled in the
1701 : : * generic version of this function.
1702 : : **/
1703 : 0 : s32 igc_read_pba_num(struct igc_hw *hw, u32 *pba_num)
1704 : : {
1705 : 0 : return igc_read_pba_num_generic(hw, pba_num);
1706 : : }
1707 : :
1708 : : /**
1709 : : * igc_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1710 : : * @hw: pointer to the HW structure
1711 : : *
1712 : : * Validates the NVM checksum is correct. This is a function pointer entry
1713 : : * point called by drivers.
1714 : : **/
1715 : 0 : s32 igc_validate_nvm_checksum(struct igc_hw *hw)
1716 : : {
1717 [ # # ]: 0 : if (hw->nvm.ops.validate)
1718 : 0 : return hw->nvm.ops.validate(hw);
1719 : :
1720 : : return -IGC_ERR_CONFIG;
1721 : : }
1722 : :
1723 : : /**
1724 : : * igc_update_nvm_checksum - Updates NVM (EEPROM) checksum
1725 : : * @hw: pointer to the HW structure
1726 : : *
1727 : : * Updates the NVM checksum. Currently no func pointer exists and all
1728 : : * implementations are handled in the generic version of this function.
1729 : : **/
1730 : 0 : s32 igc_update_nvm_checksum(struct igc_hw *hw)
1731 : : {
1732 [ # # ]: 0 : if (hw->nvm.ops.update)
1733 : 0 : return hw->nvm.ops.update(hw);
1734 : :
1735 : : return -IGC_ERR_CONFIG;
1736 : : }
1737 : :
1738 : : /**
1739 : : * igc_reload_nvm - Reloads EEPROM
1740 : : * @hw: pointer to the HW structure
1741 : : *
1742 : : * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1743 : : * extended control register.
1744 : : **/
1745 : 0 : void igc_reload_nvm(struct igc_hw *hw)
1746 : : {
1747 [ # # ]: 0 : if (hw->nvm.ops.reload)
1748 : 0 : hw->nvm.ops.reload(hw);
1749 : 0 : }
1750 : :
1751 : : /**
1752 : : * igc_read_nvm - Reads NVM (EEPROM)
1753 : : * @hw: pointer to the HW structure
1754 : : * @offset: the word offset to read
1755 : : * @words: number of 16-bit words to read
1756 : : * @data: pointer to the properly sized buffer for the data.
1757 : : *
1758 : : * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1759 : : * pointer entry point called by drivers.
1760 : : **/
1761 : 0 : s32 igc_read_nvm(struct igc_hw *hw, u16 offset, u16 words, u16 *data)
1762 : : {
1763 [ # # ]: 0 : if (hw->nvm.ops.read)
1764 : 0 : return hw->nvm.ops.read(hw, offset, words, data);
1765 : :
1766 : : return -IGC_ERR_CONFIG;
1767 : : }
1768 : :
1769 : : /**
1770 : : * igc_write_nvm - Writes to NVM (EEPROM)
1771 : : * @hw: pointer to the HW structure
1772 : : * @offset: the word offset to read
1773 : : * @words: number of 16-bit words to write
1774 : : * @data: pointer to the properly sized buffer for the data.
1775 : : *
1776 : : * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1777 : : * pointer entry point called by drivers.
1778 : : **/
1779 : 0 : s32 igc_write_nvm(struct igc_hw *hw, u16 offset, u16 words, u16 *data)
1780 : : {
1781 [ # # ]: 0 : if (hw->nvm.ops.write)
1782 : 0 : return hw->nvm.ops.write(hw, offset, words, data);
1783 : :
1784 : : return IGC_SUCCESS;
1785 : : }
1786 : :
1787 : : /**
1788 : : * igc_write_8bit_ctrl_reg - Writes 8bit Control register
1789 : : * @hw: pointer to the HW structure
1790 : : * @reg: 32bit register offset
1791 : : * @offset: the register to write
1792 : : * @data: the value to write.
1793 : : *
1794 : : * Writes the PHY register at offset with the value in data.
1795 : : * This is a function pointer entry point called by drivers.
1796 : : **/
1797 : 0 : s32 igc_write_8bit_ctrl_reg(struct igc_hw *hw, u32 reg, u32 offset,
1798 : : u8 data)
1799 : : {
1800 : 0 : return igc_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
1801 : : }
1802 : :
1803 : : /**
1804 : : * igc_power_up_phy - Restores link in case of PHY power down
1805 : : * @hw: pointer to the HW structure
1806 : : *
1807 : : * The phy may be powered down to save power, to turn off link when the
1808 : : * driver is unloaded, or wake on lan is not enabled (among others).
1809 : : **/
1810 : 0 : void igc_power_up_phy(struct igc_hw *hw)
1811 : : {
1812 [ # # ]: 0 : if (hw->phy.ops.power_up)
1813 : 0 : hw->phy.ops.power_up(hw);
1814 : :
1815 : 0 : igc_setup_link(hw);
1816 : 0 : }
1817 : :
1818 : : /**
1819 : : * igc_power_down_phy - Power down PHY
1820 : : * @hw: pointer to the HW structure
1821 : : *
1822 : : * The phy may be powered down to save power, to turn off link when the
1823 : : * driver is unloaded, or wake on lan is not enabled (among others).
1824 : : **/
1825 : 0 : void igc_power_down_phy(struct igc_hw *hw)
1826 : : {
1827 [ # # ]: 0 : if (hw->phy.ops.power_down)
1828 : 0 : hw->phy.ops.power_down(hw);
1829 : 0 : }
1830 : :
1831 : : /**
1832 : : * igc_power_up_fiber_serdes_link - Power up serdes link
1833 : : * @hw: pointer to the HW structure
1834 : : *
1835 : : * Power on the optics and PCS.
1836 : : **/
1837 : 0 : void igc_power_up_fiber_serdes_link(struct igc_hw *hw)
1838 : : {
1839 [ # # ]: 0 : if (hw->mac.ops.power_up_serdes)
1840 : 0 : hw->mac.ops.power_up_serdes(hw);
1841 : 0 : }
1842 : :
1843 : : /**
1844 : : * igc_shutdown_fiber_serdes_link - Remove link during power down
1845 : : * @hw: pointer to the HW structure
1846 : : *
1847 : : * Shutdown the optics and PCS on driver unload.
1848 : : **/
1849 : 0 : void igc_shutdown_fiber_serdes_link(struct igc_hw *hw)
1850 : : {
1851 [ # # ]: 0 : if (hw->mac.ops.shutdown_serdes)
1852 : 0 : hw->mac.ops.shutdown_serdes(hw);
1853 : 0 : }
|