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