patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / net / ixgb / ixgb_ee.c
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
5   
6   This program is free software; you can redistribute it and/or modify it 
7   under the terms of the GNU General Public License as published by the Free 
8   Software Foundation; either version 2 of the License, or (at your option) 
9   any later version.
10   
11   This program is distributed in the hope that it will be useful, but WITHOUT 
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
14   more details.
15   
16   You should have received a copy of the GNU General Public License along with
17   this program; if not, write to the Free Software Foundation, Inc., 59 
18   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19   
20   The full GNU General Public License is included in this distribution in the
21   file called LICENSE.
22   
23   Contact Information:
24   Linux NICS <linux.nics@intel.com>
25   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27 *******************************************************************************/
28
29 #include "ixgb_hw.h"
30 #include "ixgb_ee.h"
31 /* Local prototypes */
32 static uint16_t ixgb_shift_in_bits(struct ixgb_hw *hw);
33
34 static void ixgb_shift_out_bits(struct ixgb_hw *hw,
35                                 uint16_t data, uint16_t count);
36 static void ixgb_standby_eeprom(struct ixgb_hw *hw);
37
38 static boolean_t ixgb_wait_eeprom_command(struct ixgb_hw *hw);
39
40 static void ixgb_cleanup_eeprom(struct ixgb_hw *hw);
41
42 /******************************************************************************
43  * Raises the EEPROM's clock input.
44  *
45  * hw - Struct containing variables accessed by shared code
46  * eecd_reg - EECD's current value
47  *****************************************************************************/
48 static void ixgb_raise_clock(struct ixgb_hw *hw, uint32_t * eecd_reg)
49 {
50         /* Raise the clock input to the EEPROM (by setting the SK bit), and then
51          *  wait 50 microseconds.
52          */
53         *eecd_reg = *eecd_reg | IXGB_EECD_SK;
54         IXGB_WRITE_REG(hw, EECD, *eecd_reg);
55         udelay(50);
56         return;
57 }
58
59 /******************************************************************************
60  * Lowers the EEPROM's clock input.
61  *
62  * hw - Struct containing variables accessed by shared code
63  * eecd_reg - EECD's current value
64  *****************************************************************************/
65 static void ixgb_lower_clock(struct ixgb_hw *hw, uint32_t * eecd_reg)
66 {
67         /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
68          * wait 50 microseconds.
69          */
70         *eecd_reg = *eecd_reg & ~IXGB_EECD_SK;
71         IXGB_WRITE_REG(hw, EECD, *eecd_reg);
72         udelay(50);
73         return;
74 }
75
76 /******************************************************************************
77  * Shift data bits out to the EEPROM.
78  *
79  * hw - Struct containing variables accessed by shared code
80  * data - data to send to the EEPROM
81  * count - number of bits to shift out
82  *****************************************************************************/
83 static void
84 ixgb_shift_out_bits(struct ixgb_hw *hw, uint16_t data, uint16_t count)
85 {
86         uint32_t eecd_reg;
87         uint32_t mask;
88
89         /* We need to shift "count" bits out to the EEPROM. So, value in the
90          * "data" parameter will be shifted out to the EEPROM one bit at a time.
91          * In order to do this, "data" must be broken down into bits.
92          */
93         mask = 0x01 << (count - 1);
94         eecd_reg = IXGB_READ_REG(hw, EECD);
95         eecd_reg &= ~(IXGB_EECD_DO | IXGB_EECD_DI);
96         do {
97                 /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
98                  * and then raising and then lowering the clock (the SK bit controls
99                  * the clock input to the EEPROM).  A "0" is shifted out to the EEPROM
100                  * by setting "DI" to "0" and then raising and then lowering the clock.
101                  */
102                 eecd_reg &= ~IXGB_EECD_DI;
103
104                 if (data & mask)
105                         eecd_reg |= IXGB_EECD_DI;
106
107                 IXGB_WRITE_REG(hw, EECD, eecd_reg);
108
109                 udelay(50);
110
111                 ixgb_raise_clock(hw, &eecd_reg);
112                 ixgb_lower_clock(hw, &eecd_reg);
113
114                 mask = mask >> 1;
115
116         } while (mask);
117
118         /* We leave the "DI" bit set to "0" when we leave this routine. */
119         eecd_reg &= ~IXGB_EECD_DI;
120         IXGB_WRITE_REG(hw, EECD, eecd_reg);
121         return;
122 }
123
124 /******************************************************************************
125  * Shift data bits in from the EEPROM
126  *
127  * hw - Struct containing variables accessed by shared code
128  *****************************************************************************/
129 static uint16_t ixgb_shift_in_bits(struct ixgb_hw *hw)
130 {
131         uint32_t eecd_reg;
132         uint32_t i;
133         uint16_t data;
134
135         /* In order to read a register from the EEPROM, we need to shift 16 bits
136          * in from the EEPROM. Bits are "shifted in" by raising the clock input to
137          * the EEPROM (setting the SK bit), and then reading the value of the "DO"
138          * bit.  During this "shifting in" process the "DI" bit should always be
139          * clear..
140          */
141
142         eecd_reg = IXGB_READ_REG(hw, EECD);
143
144         eecd_reg &= ~(IXGB_EECD_DO | IXGB_EECD_DI);
145         data = 0;
146
147         for (i = 0; i < 16; i++) {
148                 data = data << 1;
149                 ixgb_raise_clock(hw, &eecd_reg);
150
151                 eecd_reg = IXGB_READ_REG(hw, EECD);
152
153                 eecd_reg &= ~(IXGB_EECD_DI);
154                 if (eecd_reg & IXGB_EECD_DO)
155                         data |= 1;
156
157                 ixgb_lower_clock(hw, &eecd_reg);
158         }
159
160         return data;
161 }
162
163 /******************************************************************************
164  * Prepares EEPROM for access
165  *
166  * hw - Struct containing variables accessed by shared code
167  *
168  * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
169  * function should be called before issuing a command to the EEPROM.
170  *****************************************************************************/
171 static void ixgb_setup_eeprom(struct ixgb_hw *hw)
172 {
173         uint32_t eecd_reg;
174
175         eecd_reg = IXGB_READ_REG(hw, EECD);
176
177         /*  Clear SK and DI  */
178         eecd_reg &= ~(IXGB_EECD_SK | IXGB_EECD_DI);
179         IXGB_WRITE_REG(hw, EECD, eecd_reg);
180
181         /*  Set CS  */
182         eecd_reg |= IXGB_EECD_CS;
183         IXGB_WRITE_REG(hw, EECD, eecd_reg);
184         return;
185 }
186
187 /******************************************************************************
188  * Returns EEPROM to a "standby" state
189  *
190  * hw - Struct containing variables accessed by shared code
191  *****************************************************************************/
192 static void ixgb_standby_eeprom(struct ixgb_hw *hw)
193 {
194         uint32_t eecd_reg;
195
196         eecd_reg = IXGB_READ_REG(hw, EECD);
197
198         /*  Deselct EEPROM  */
199         eecd_reg &= ~(IXGB_EECD_CS | IXGB_EECD_SK);
200         IXGB_WRITE_REG(hw, EECD, eecd_reg);
201         udelay(50);
202
203         /*  Clock high  */
204         eecd_reg |= IXGB_EECD_SK;
205         IXGB_WRITE_REG(hw, EECD, eecd_reg);
206         udelay(50);
207
208         /*  Select EEPROM  */
209         eecd_reg |= IXGB_EECD_CS;
210         IXGB_WRITE_REG(hw, EECD, eecd_reg);
211         udelay(50);
212
213         /*  Clock low  */
214         eecd_reg &= ~IXGB_EECD_SK;
215         IXGB_WRITE_REG(hw, EECD, eecd_reg);
216         udelay(50);
217         return;
218 }
219
220 /******************************************************************************
221  * Raises then lowers the EEPROM's clock pin
222  *
223  * hw - Struct containing variables accessed by shared code
224  *****************************************************************************/
225 static void ixgb_clock_eeprom(struct ixgb_hw *hw)
226 {
227         uint32_t eecd_reg;
228
229         eecd_reg = IXGB_READ_REG(hw, EECD);
230
231         /*  Rising edge of clock  */
232         eecd_reg |= IXGB_EECD_SK;
233         IXGB_WRITE_REG(hw, EECD, eecd_reg);
234         udelay(50);
235
236         /*  Falling edge of clock  */
237         eecd_reg &= ~IXGB_EECD_SK;
238         IXGB_WRITE_REG(hw, EECD, eecd_reg);
239         udelay(50);
240         return;
241 }
242
243 /******************************************************************************
244  * Terminates a command by lowering the EEPROM's chip select pin
245  *
246  * hw - Struct containing variables accessed by shared code
247  *****************************************************************************/
248 static void ixgb_cleanup_eeprom(struct ixgb_hw *hw)
249 {
250         uint32_t eecd_reg;
251
252         eecd_reg = IXGB_READ_REG(hw, EECD);
253
254         eecd_reg &= ~(IXGB_EECD_CS | IXGB_EECD_DI);
255
256         IXGB_WRITE_REG(hw, EECD, eecd_reg);
257
258         ixgb_clock_eeprom(hw);
259         return;
260 }
261
262 /******************************************************************************
263  * Waits for the EEPROM to finish the current command.
264  *
265  * hw - Struct containing variables accessed by shared code
266  *
267  * The command is done when the EEPROM's data out pin goes high.
268  *
269  * Returns:
270  *      TRUE: EEPROM data pin is high before timeout.
271  *      FALSE:  Time expired.
272  *****************************************************************************/
273 static boolean_t ixgb_wait_eeprom_command(struct ixgb_hw *hw)
274 {
275         uint32_t eecd_reg;
276         uint32_t i;
277
278         /* Toggle the CS line.  This in effect tells to EEPROM to actually execute
279          * the command in question.
280          */
281         ixgb_standby_eeprom(hw);
282
283         /* Now read DO repeatedly until is high (equal to '1').  The EEEPROM will
284          * signal that the command has been completed by raising the DO signal.
285          * If DO does not go high in 10 milliseconds, then error out.
286          */
287         for (i = 0; i < 200; i++) {
288                 eecd_reg = IXGB_READ_REG(hw, EECD);
289
290                 if (eecd_reg & IXGB_EECD_DO)
291                         return (TRUE);
292
293                 udelay(50);
294         }
295         ASSERT(0);
296         return (FALSE);
297 }
298
299 /******************************************************************************
300  * Verifies that the EEPROM has a valid checksum
301  *
302  * hw - Struct containing variables accessed by shared code
303  *
304  * Reads the first 64 16 bit words of the EEPROM and sums the values read.
305  * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
306  * valid.
307  *
308  * Returns:
309  *  TRUE: Checksum is valid
310  *  FALSE: Checksum is not valid.
311  *****************************************************************************/
312 boolean_t ixgb_validate_eeprom_checksum(struct ixgb_hw * hw)
313 {
314         uint16_t checksum = 0;
315         uint16_t i;
316
317         for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++)
318                 checksum += ixgb_read_eeprom(hw, i);
319
320         if (checksum == (uint16_t) EEPROM_SUM)
321                 return (TRUE);
322         else
323                 return (FALSE);
324 }
325
326 /******************************************************************************
327  * Calculates the EEPROM checksum and writes it to the EEPROM
328  *
329  * hw - Struct containing variables accessed by shared code
330  *
331  * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
332  * Writes the difference to word offset 63 of the EEPROM.
333  *****************************************************************************/
334 void ixgb_update_eeprom_checksum(struct ixgb_hw *hw)
335 {
336         uint16_t checksum = 0;
337         uint16_t i;
338
339         for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
340                 checksum += ixgb_read_eeprom(hw, i);
341
342         checksum = (uint16_t) EEPROM_SUM - checksum;
343
344         ixgb_write_eeprom(hw, EEPROM_CHECKSUM_REG, checksum);
345         return;
346 }
347
348 /******************************************************************************
349  * Writes a 16 bit word to a given offset in the EEPROM.
350  *
351  * hw - Struct containing variables accessed by shared code
352  * reg - offset within the EEPROM to be written to
353  * data - 16 bit word to be writen to the EEPROM
354  *
355  * If ixgb_update_eeprom_checksum is not called after this function, the
356  * EEPROM will most likely contain an invalid checksum.
357  *
358  *****************************************************************************/
359 void ixgb_write_eeprom(struct ixgb_hw *hw, uint16_t offset, uint16_t data)
360 {
361         /*  Prepare the EEPROM for writing  */
362         ixgb_setup_eeprom(hw);
363
364         /*  Send the 9-bit EWEN (write enable) command to the EEPROM (5-bit opcode
365          *  plus 4-bit dummy).  This puts the EEPROM into write/erase mode.
366          */
367         ixgb_shift_out_bits(hw, EEPROM_EWEN_OPCODE, 5);
368         ixgb_shift_out_bits(hw, 0, 4);
369
370         /*  Prepare the EEPROM  */
371         ixgb_standby_eeprom(hw);
372
373         /*  Send the Write command (3-bit opcode + 6-bit addr)  */
374         ixgb_shift_out_bits(hw, EEPROM_WRITE_OPCODE, 3);
375         ixgb_shift_out_bits(hw, offset, 6);
376
377         /*  Send the data  */
378         ixgb_shift_out_bits(hw, data, 16);
379
380         ixgb_wait_eeprom_command(hw);
381
382         /*  Recover from write  */
383         ixgb_standby_eeprom(hw);
384
385         /* Send the 9-bit EWDS (write disable) command to the EEPROM (5-bit
386          * opcode plus 4-bit dummy).  This takes the EEPROM out of write/erase
387          * mode.
388          */
389         ixgb_shift_out_bits(hw, EEPROM_EWDS_OPCODE, 5);
390         ixgb_shift_out_bits(hw, 0, 4);
391
392         /*  Done with writing  */
393         ixgb_cleanup_eeprom(hw);
394
395         return;
396 }
397
398 /******************************************************************************
399  * Reads a 16 bit word from the EEPROM.
400  *
401  * hw - Struct containing variables accessed by shared code
402  * offset - offset of 16 bit word in the EEPROM to read
403  *
404  * Returns:
405  *  The 16-bit value read from the eeprom
406  *****************************************************************************/
407 uint16_t ixgb_read_eeprom(struct ixgb_hw * hw, uint16_t offset)
408 {
409         uint16_t data;
410
411         /*  Prepare the EEPROM for reading  */
412         ixgb_setup_eeprom(hw);
413
414         /*  Send the READ command (opcode + addr)  */
415         ixgb_shift_out_bits(hw, EEPROM_READ_OPCODE, 3);
416         /*
417          * We have a 64 word EEPROM, there are 6 address bits
418          */
419         ixgb_shift_out_bits(hw, offset, 6);
420
421         /*  Read the data  */
422         data = ixgb_shift_in_bits(hw);
423
424         /*  End this read operation  */
425         ixgb_standby_eeprom(hw);
426
427         return (data);
428 }
429
430 /******************************************************************************
431  * Reads eeprom and stores data in shared structure.
432  * Validates eeprom checksum and eeprom signature.
433  *
434  * hw - Struct containing variables accessed by shared code
435  *
436  * Returns:
437  *      TRUE: if eeprom read is successful
438  *      FALSE: otherwise.
439  *****************************************************************************/
440 boolean_t ixgb_get_eeprom_data(struct ixgb_hw * hw)
441 {
442         uint16_t i;
443         uint16_t checksum = 0;
444         struct ixgb_ee_map_type *ee_map;
445
446         DEBUGFUNC("ixgb_get_eeprom_data");
447
448         ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
449
450         DEBUGOUT("ixgb_ee: Reading eeprom data\n");
451         for (i = 0; i < IXGB_EEPROM_SIZE; i++) {
452                 uint16_t ee_data;
453                 ee_data = ixgb_read_eeprom(hw, i);
454                 checksum += ee_data;
455                 hw->eeprom[i] = le16_to_cpu(ee_data);
456         }
457
458         if (checksum != (uint16_t) EEPROM_SUM) {
459                 DEBUGOUT("ixgb_ee: Checksum invalid.\n");
460                 return (FALSE);
461         }
462
463         if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK))
464             != le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) {
465                 DEBUGOUT("ixgb_ee: Signature invalid.\n");
466                 return (FALSE);
467         }
468
469         return (TRUE);
470 }
471
472 /******************************************************************************
473  * Local function to check if the eeprom signature is good
474  * If the eeprom signature is good, calls ixgb)get_eeprom_data.
475  *
476  * hw - Struct containing variables accessed by shared code
477  *
478  * Returns:
479  *      TRUE: eeprom signature was good and the eeprom read was successful
480  *      FALSE: otherwise.
481  ******************************************************************************/
482 static boolean_t ixgb_check_and_get_eeprom_data(struct ixgb_hw *hw)
483 {
484         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
485
486         if ((ee_map->init_ctrl_reg_1 & le16_to_cpu(EEPROM_ICW1_SIGNATURE_MASK))
487             == le16_to_cpu(EEPROM_ICW1_SIGNATURE_VALID)) {
488                 return (TRUE);
489         } else {
490                 return ixgb_get_eeprom_data(hw);
491         }
492 }
493
494 /******************************************************************************
495  * return a word from the eeprom
496  *
497  * hw - Struct containing variables accessed by shared code
498  * index - Offset of eeprom word
499  *
500  * Returns:
501  *          Word at indexed offset in eeprom, if valid, 0 otherwise.
502  ******************************************************************************/
503 uint16_t ixgb_get_eeprom_word(struct ixgb_hw * hw, uint16_t index)
504 {
505
506         if ((index < IXGB_EEPROM_SIZE) &&
507             (ixgb_check_and_get_eeprom_data(hw) == TRUE)) {
508                 return (hw->eeprom[index]);
509         }
510
511         return (0);
512 }
513
514 /******************************************************************************
515  * return the mac address from EEPROM
516  *
517  * hw       - Struct containing variables accessed by shared code
518  * mac_addr - Ethernet Address if EEPROM contents are valid, 0 otherwise
519  *
520  * Returns: None.
521  ******************************************************************************/
522 void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t * mac_addr)
523 {
524         int i;
525         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
526
527         DEBUGFUNC("ixgb_get_ee_mac_addr");
528
529         if (ixgb_check_and_get_eeprom_data(hw) == TRUE) {
530                 for (i = 0; i < IXGB_ETH_LENGTH_OF_ADDRESS; i++) {
531                         mac_addr[i] = ee_map->mac_addr[i];
532                         DEBUGOUT2("mac(%d) = %.2X\n", i, mac_addr[i]);
533                 }
534         }
535 }
536
537 /******************************************************************************
538  * return the compatibility flags from EEPROM
539  *
540  * hw - Struct containing variables accessed by shared code
541  *
542  * Returns:
543  *          compatibility flags if EEPROM contents are valid, 0 otherwise
544  ******************************************************************************/
545 uint16_t ixgb_get_ee_compatibility(struct ixgb_hw *hw)
546 {
547         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
548
549         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
550                 return (ee_map->compatibility);
551
552         return (0);
553 }
554
555 /******************************************************************************
556  * return the Printed Board Assembly number from EEPROM
557  *
558  * hw - Struct containing variables accessed by shared code
559  *
560  * Returns:
561  *          PBA number if EEPROM contents are valid, 0 otherwise
562  ******************************************************************************/
563 uint32_t ixgb_get_ee_pba_number(struct ixgb_hw * hw)
564 {
565         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
566                 return (le16_to_cpu(hw->eeprom[EEPROM_PBA_1_2_REG])
567                         | (le16_to_cpu(hw->eeprom[EEPROM_PBA_3_4_REG]) << 16));
568
569         return (0);
570 }
571
572 /******************************************************************************
573  * return the Initialization Control Word 1 from EEPROM
574  *
575  * hw - Struct containing variables accessed by shared code
576  *
577  * Returns:
578  *          Initialization Control Word 1 if EEPROM contents are valid, 0 otherwise
579  ******************************************************************************/
580 uint16_t ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw * hw)
581 {
582         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
583
584         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
585                 return (ee_map->init_ctrl_reg_1);
586
587         return (0);
588 }
589
590 /******************************************************************************
591  * return the Initialization Control Word 2 from EEPROM
592  *
593  * hw - Struct containing variables accessed by shared code
594  *
595  * Returns:
596  *          Initialization Control Word 2 if EEPROM contents are valid, 0 otherwise
597  ******************************************************************************/
598 uint16_t ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw * hw)
599 {
600         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
601
602         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
603                 return (ee_map->init_ctrl_reg_2);
604
605         return (0);
606 }
607
608 /******************************************************************************
609  * return the Subsystem Id from EEPROM
610  *
611  * hw - Struct containing variables accessed by shared code
612  *
613  * Returns:
614  *          Subsystem Id if EEPROM contents are valid, 0 otherwise
615  ******************************************************************************/
616 uint16_t ixgb_get_ee_subsystem_id(struct ixgb_hw * hw)
617 {
618         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
619
620         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
621                 return (ee_map->subsystem_id);
622
623         return (0);
624 }
625
626 /******************************************************************************
627  * return the Sub Vendor Id from EEPROM
628  *
629  * hw - Struct containing variables accessed by shared code
630  *
631  * Returns:
632  *          Sub Vendor Id if EEPROM contents are valid, 0 otherwise
633  ******************************************************************************/
634 uint16_t ixgb_get_ee_subvendor_id(struct ixgb_hw * hw)
635 {
636         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
637
638         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
639                 return (ee_map->subvendor_id);
640
641         return (0);
642 }
643
644 /******************************************************************************
645  * return the Device Id from EEPROM
646  *
647  * hw - Struct containing variables accessed by shared code
648  *
649  * Returns:
650  *          Device Id if EEPROM contents are valid, 0 otherwise
651  ******************************************************************************/
652 uint16_t ixgb_get_ee_device_id(struct ixgb_hw * hw)
653 {
654         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
655
656         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
657                 return (ee_map->device_id);
658
659         return (0);
660 }
661
662 /******************************************************************************
663  * return the Vendor Id from EEPROM
664  *
665  * hw - Struct containing variables accessed by shared code
666  *
667  * Returns:
668  *          Device Id if EEPROM contents are valid, 0 otherwise
669  ******************************************************************************/
670 uint16_t ixgb_get_ee_vendor_id(struct ixgb_hw * hw)
671 {
672         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
673
674         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
675                 return (ee_map->vendor_id);
676
677         return (0);
678 }
679
680 /******************************************************************************
681  * return the Software Defined Pins Register from EEPROM
682  *
683  * hw - Struct containing variables accessed by shared code
684  *
685  * Returns:
686  *          SDP Register if EEPROM contents are valid, 0 otherwise
687  ******************************************************************************/
688 uint16_t ixgb_get_ee_swdpins_reg(struct ixgb_hw * hw)
689 {
690         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
691
692         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
693                 return (ee_map->swdpins_reg);
694
695         return (0);
696 }
697
698 /******************************************************************************
699  * return the D3 Power Management Bits from EEPROM
700  *
701  * hw - Struct containing variables accessed by shared code
702  *
703  * Returns:
704  *          D3 Power Management Bits if EEPROM contents are valid, 0 otherwise
705  ******************************************************************************/
706 uint8_t ixgb_get_ee_d3_power(struct ixgb_hw * hw)
707 {
708         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
709
710         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
711                 return (ee_map->d3_power);
712
713         return (0);
714 }
715
716 /******************************************************************************
717  * return the D0 Power Management Bits from EEPROM
718  *
719  * hw - Struct containing variables accessed by shared code
720  *
721  * Returns:
722  *          D0 Power Management Bits if EEPROM contents are valid, 0 otherwise
723  ******************************************************************************/
724 uint8_t ixgb_get_ee_d0_power(struct ixgb_hw * hw)
725 {
726         struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom;
727
728         if (ixgb_check_and_get_eeprom_data(hw) == TRUE)
729                 return (ee_map->d0_power);
730
731         return (0);
732 }