2 * This file is provided under a CDDLv1 license. When using or
3 * redistributing this file, you may do so under this license.
4 * In redistributing this file this license must be included
5 * and no other modification of this header file is permitted.
9 * Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved.
11 * The contents of this file are subject to the terms of Version
12 * 1.0 of the Common Development and Distribution License (the "License").
14 * You should have received a copy of the License with this software.
15 * You can obtain a copy of the License at
16 * http://www.opensolaris.org/os/licensing.
17 * See the License for the specific language governing permissions
18 * and limitations under the License.
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms of the CDDLv1.
27 * IntelVersion: 1.49 v3-1-10-1_2009-9-18_Release14-6
29 #include "e1000_api.h"
31 static void e1000_reload_nvm_generic(struct e1000_hw
*hw
);
34 * e1000_init_nvm_ops_generic - Initialize NVM function pointers
35 * @hw: pointer to the HW structure
37 * Setups up the function pointers to no-op functions
40 e1000_init_nvm_ops_generic(struct e1000_hw
*hw
)
42 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
43 DEBUGFUNC("e1000_init_nvm_ops_generic");
45 /* Initialize function pointers */
46 nvm
->ops
.init_params
= e1000_null_ops_generic
;
47 nvm
->ops
.acquire
= e1000_null_ops_generic
;
48 nvm
->ops
.read
= e1000_null_read_nvm
;
49 nvm
->ops
.release
= e1000_null_nvm_generic
;
50 nvm
->ops
.reload
= e1000_reload_nvm_generic
;
51 nvm
->ops
.update
= e1000_null_ops_generic
;
52 nvm
->ops
.valid_led_default
= e1000_null_led_default
;
53 nvm
->ops
.validate
= e1000_null_ops_generic
;
54 nvm
->ops
.write
= e1000_null_write_nvm
;
58 * e1000_null_nvm_read - No-op function, return 0
59 * @hw: pointer to the HW structure
62 e1000_null_read_nvm(struct e1000_hw
*hw
, u16 a
, u16 b
, u16
*c
)
64 DEBUGFUNC("e1000_null_read_nvm");
65 UNREFERENCED_4PARAMETER(hw
, a
, b
, c
);
66 return (E1000_SUCCESS
);
70 * e1000_null_nvm_generic - No-op function, return void
71 * @hw: pointer to the HW structure
74 e1000_null_nvm_generic(struct e1000_hw
*hw
)
76 DEBUGFUNC("e1000_null_nvm_generic");
77 UNREFERENCED_1PARAMETER(hw
);
81 * e1000_null_led_default - No-op function, return 0
82 * @hw: pointer to the HW structure
85 e1000_null_led_default(struct e1000_hw
*hw
, u16
*data
)
87 DEBUGFUNC("e1000_null_led_default");
88 UNREFERENCED_2PARAMETER(hw
, data
);
89 return (E1000_SUCCESS
);
93 * e1000_null_write_nvm - No-op function, return 0
94 * @hw: pointer to the HW structure
97 e1000_null_write_nvm(struct e1000_hw
*hw
, u16 a
, u16 b
, u16
*c
)
99 DEBUGFUNC("e1000_null_write_nvm");
100 UNREFERENCED_4PARAMETER(hw
, a
, b
, c
);
101 return (E1000_SUCCESS
);
105 * e1000_raise_eec_clk - Raise EEPROM clock
106 * @hw: pointer to the HW structure
107 * @eecd: pointer to the EEPROM
109 * Enable/Raise the EEPROM clock bit.
112 e1000_raise_eec_clk(struct e1000_hw
*hw
, u32
*eecd
)
114 *eecd
= *eecd
| E1000_EECD_SK
;
115 E1000_WRITE_REG(hw
, E1000_EECD
, *eecd
);
116 E1000_WRITE_FLUSH(hw
);
117 usec_delay(hw
->nvm
.delay_usec
);
121 * e1000_lower_eec_clk - Lower EEPROM clock
122 * @hw: pointer to the HW structure
123 * @eecd: pointer to the EEPROM
125 * Clear/Lower the EEPROM clock bit.
128 e1000_lower_eec_clk(struct e1000_hw
*hw
, u32
*eecd
)
130 *eecd
= *eecd
& ~E1000_EECD_SK
;
131 E1000_WRITE_REG(hw
, E1000_EECD
, *eecd
);
132 E1000_WRITE_FLUSH(hw
);
133 usec_delay(hw
->nvm
.delay_usec
);
137 * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
138 * @hw: pointer to the HW structure
139 * @data: data to send to the EEPROM
140 * @count: number of bits to shift out
142 * We need to shift 'count' bits out to the EEPROM. So, the value in the
143 * "data" parameter will be shifted out to the EEPROM one bit at a time.
144 * In order to do this, "data" must be broken down into bits.
147 e1000_shift_out_eec_bits(struct e1000_hw
*hw
, u16 data
, u16 count
)
149 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
150 u32 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
153 DEBUGFUNC("e1000_shift_out_eec_bits");
155 mask
= 0x01 << (count
- 1);
156 if (nvm
->type
== e1000_nvm_eeprom_microwire
)
157 eecd
&= ~E1000_EECD_DO
;
158 else if (nvm
->type
== e1000_nvm_eeprom_spi
)
159 eecd
|= E1000_EECD_DO
;
162 eecd
&= ~E1000_EECD_DI
;
165 eecd
|= E1000_EECD_DI
;
167 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
168 E1000_WRITE_FLUSH(hw
);
170 usec_delay(nvm
->delay_usec
);
172 e1000_raise_eec_clk(hw
, &eecd
);
173 e1000_lower_eec_clk(hw
, &eecd
);
178 eecd
&= ~E1000_EECD_DI
;
179 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
183 * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
184 * @hw: pointer to the HW structure
185 * @count: number of bits to shift in
187 * In order to read a register from the EEPROM, we need to shift 'count' bits
188 * in from the EEPROM. Bits are "shifted in" by raising the clock input to
189 * the EEPROM (setting the SK bit), and then reading the value of the data out
190 * "DO" bit. During this "shifting in" process the data in "DI" bit should
194 e1000_shift_in_eec_bits(struct e1000_hw
*hw
, u16 count
)
200 DEBUGFUNC("e1000_shift_in_eec_bits");
202 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
204 eecd
&= ~(E1000_EECD_DO
| E1000_EECD_DI
);
207 for (i
= 0; i
< count
; i
++) {
209 e1000_raise_eec_clk(hw
, &eecd
);
211 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
213 eecd
&= ~E1000_EECD_DI
;
214 if (eecd
& E1000_EECD_DO
)
217 e1000_lower_eec_clk(hw
, &eecd
);
224 * e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion
225 * @hw: pointer to the HW structure
226 * @ee_reg: EEPROM flag for polling
228 * Polls the EEPROM status bit for either read or write completion based
229 * upon the value of 'ee_reg'.
232 e1000_poll_eerd_eewr_done(struct e1000_hw
*hw
, int ee_reg
)
234 u32 attempts
= 100000;
236 s32 ret_val
= -E1000_ERR_NVM
;
238 DEBUGFUNC("e1000_poll_eerd_eewr_done");
240 for (i
= 0; i
< attempts
; i
++) {
241 if (ee_reg
== E1000_NVM_POLL_READ
)
242 reg
= E1000_READ_REG(hw
, E1000_EERD
);
244 reg
= E1000_READ_REG(hw
, E1000_EEWR
);
246 if (reg
& E1000_NVM_RW_REG_DONE
) {
247 ret_val
= E1000_SUCCESS
;
258 * e1000_acquire_nvm_generic - Generic request for access to EEPROM
259 * @hw: pointer to the HW structure
261 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
262 * Return successful if access grant bit set, else clear the request for
263 * EEPROM access and return -E1000_ERR_NVM (-1).
266 e1000_acquire_nvm_generic(struct e1000_hw
*hw
)
268 u32 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
269 s32 timeout
= E1000_NVM_GRANT_ATTEMPTS
;
270 s32 ret_val
= E1000_SUCCESS
;
272 DEBUGFUNC("e1000_acquire_nvm_generic");
274 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
| E1000_EECD_REQ
);
275 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
278 if (eecd
& E1000_EECD_GNT
)
281 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
286 eecd
&= ~E1000_EECD_REQ
;
287 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
288 DEBUGOUT("Could not acquire NVM grant\n");
289 ret_val
= -E1000_ERR_NVM
;
295 * e1000_standby_nvm - Return EEPROM to standby state
296 * @hw: pointer to the HW structure
298 * Return the EEPROM to a standby state.
301 e1000_standby_nvm(struct e1000_hw
*hw
)
303 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
304 u32 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
306 DEBUGFUNC("e1000_standby_nvm");
308 if (nvm
->type
== e1000_nvm_eeprom_microwire
) {
309 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
310 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
311 E1000_WRITE_FLUSH(hw
);
312 usec_delay(nvm
->delay_usec
);
314 e1000_raise_eec_clk(hw
, &eecd
);
317 eecd
|= E1000_EECD_CS
;
318 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
319 E1000_WRITE_FLUSH(hw
);
320 usec_delay(nvm
->delay_usec
);
322 e1000_lower_eec_clk(hw
, &eecd
);
323 } else if (nvm
->type
== e1000_nvm_eeprom_spi
) {
324 /* Toggle CS to flush commands */
325 eecd
|= E1000_EECD_CS
;
326 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
327 E1000_WRITE_FLUSH(hw
);
328 usec_delay(nvm
->delay_usec
);
329 eecd
&= ~E1000_EECD_CS
;
330 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
331 E1000_WRITE_FLUSH(hw
);
332 usec_delay(nvm
->delay_usec
);
337 * e1000_stop_nvm - Terminate EEPROM command
338 * @hw: pointer to the HW structure
340 * Terminates the current command by inverting the EEPROM's chip select pin.
343 e1000_stop_nvm(struct e1000_hw
*hw
)
347 DEBUGFUNC("e1000_stop_nvm");
349 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
350 if (hw
->nvm
.type
== e1000_nvm_eeprom_spi
) {
352 eecd
|= E1000_EECD_CS
;
353 e1000_lower_eec_clk(hw
, &eecd
);
354 } else if (hw
->nvm
.type
== e1000_nvm_eeprom_microwire
) {
355 /* CS on Microwire is active-high */
356 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_DI
);
357 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
358 e1000_raise_eec_clk(hw
, &eecd
);
359 e1000_lower_eec_clk(hw
, &eecd
);
364 * e1000_release_nvm_generic - Release exclusive access to EEPROM
365 * @hw: pointer to the HW structure
367 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
370 e1000_release_nvm_generic(struct e1000_hw
*hw
)
374 DEBUGFUNC("e1000_release_nvm_generic");
378 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
379 eecd
&= ~E1000_EECD_REQ
;
380 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
384 * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
385 * @hw: pointer to the HW structure
387 * Setups the EEPROM for reading and writing.
390 e1000_ready_nvm_eeprom(struct e1000_hw
*hw
)
392 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
393 u32 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
394 s32 ret_val
= E1000_SUCCESS
;
398 DEBUGFUNC("e1000_ready_nvm_eeprom");
400 if (nvm
->type
== e1000_nvm_eeprom_microwire
) {
401 /* Clear SK and DI */
402 eecd
&= ~(E1000_EECD_DI
| E1000_EECD_SK
);
403 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
405 eecd
|= E1000_EECD_CS
;
406 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
407 } else if (nvm
->type
== e1000_nvm_eeprom_spi
) {
408 /* Clear SK and CS */
409 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
410 E1000_WRITE_REG(hw
, E1000_EECD
, eecd
);
412 timeout
= NVM_MAX_RETRY_SPI
;
415 * Read "Status Register" repeatedly until the LSB is cleared.
416 * The EEPROM will signal that the command has been completed
417 * by clearing bit 0 of the internal status register. If it's
418 * not cleared within 'timeout', then error out.
421 e1000_shift_out_eec_bits(hw
, NVM_RDSR_OPCODE_SPI
,
422 hw
->nvm
.opcode_bits
);
423 spi_stat_reg
= (u8
)e1000_shift_in_eec_bits(hw
, 8);
424 if (!(spi_stat_reg
& NVM_STATUS_RDY_SPI
))
428 e1000_standby_nvm(hw
);
433 DEBUGOUT("SPI NVM Status error\n");
434 ret_val
= -E1000_ERR_NVM
;
444 * e1000_read_nvm_spi - Read EEPROM's using SPI
445 * @hw: pointer to the HW structure
446 * @offset: offset of word in the EEPROM to read
447 * @words: number of words to read
448 * @data: word read from the EEPROM
450 * Reads a 16 bit word from the EEPROM.
453 e1000_read_nvm_spi(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
* data
)
455 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
459 u8 read_opcode
= NVM_READ_OPCODE_SPI
;
461 DEBUGFUNC("e1000_read_nvm_spi");
464 * A check for invalid values: offset too large, too many words, and
467 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
469 DEBUGOUT("nvm parameter(s) out of bounds\n");
470 ret_val
= -E1000_ERR_NVM
;
474 ret_val
= nvm
->ops
.acquire(hw
);
478 ret_val
= e1000_ready_nvm_eeprom(hw
);
482 e1000_standby_nvm(hw
);
484 if ((nvm
->address_bits
== 8) && (offset
>= 128))
485 read_opcode
|= NVM_A8_OPCODE_SPI
;
487 /* Send the READ command (opcode + addr) */
488 e1000_shift_out_eec_bits(hw
, read_opcode
, nvm
->opcode_bits
);
489 e1000_shift_out_eec_bits(hw
, (u16
)(offset
* 2), nvm
->address_bits
);
492 * Read the data. SPI NVMs increment the address with each byte read
493 * and will roll over if reading beyond the end. This allows us to
494 * read the whole NVM from any offset
496 for (i
= 0; i
< words
; i
++) {
497 word_in
= e1000_shift_in_eec_bits(hw
, 16);
498 data
[i
] = (word_in
>> 8) | (word_in
<< 8);
502 nvm
->ops
.release(hw
);
509 * e1000_read_nvm_microwire - Reads EEPROM's using microwire
510 * @hw: pointer to the HW structure
511 * @offset: offset of word in the EEPROM to read
512 * @words: number of words to read
513 * @data: word read from the EEPROM
515 * Reads a 16 bit word from the EEPROM.
518 e1000_read_nvm_microwire(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
520 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
523 u8 read_opcode
= NVM_READ_OPCODE_MICROWIRE
;
525 DEBUGFUNC("e1000_read_nvm_microwire");
528 * A check for invalid values: offset too large, too many words, and
531 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
533 DEBUGOUT("nvm parameter(s) out of bounds\n");
534 ret_val
= -E1000_ERR_NVM
;
538 ret_val
= nvm
->ops
.acquire(hw
);
542 ret_val
= e1000_ready_nvm_eeprom(hw
);
546 for (i
= 0; i
< words
; i
++) {
547 /* Send the READ command (opcode + addr) */
548 e1000_shift_out_eec_bits(hw
, read_opcode
, nvm
->opcode_bits
);
549 e1000_shift_out_eec_bits(hw
, (u16
)(offset
+ i
),
553 * Read the data. For microwire, each word requires the
554 * overhead of setup and tear-down.
556 data
[i
] = e1000_shift_in_eec_bits(hw
, 16);
557 e1000_standby_nvm(hw
);
561 nvm
->ops
.release(hw
);
568 * e1000_read_nvm_eerd - Reads EEPROM using EERD register
569 * @hw: pointer to the HW structure
570 * @offset: offset of word in the EEPROM to read
571 * @words: number of words to read
572 * @data: word read from the EEPROM
574 * Reads a 16 bit word from the EEPROM using the EERD register.
577 e1000_read_nvm_eerd(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
579 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
581 s32 ret_val
= E1000_SUCCESS
;
583 DEBUGFUNC("e1000_read_nvm_eerd");
586 * A check for invalid values: offset too large, too many words,
587 * too many words for the offset, and not enough words.
589 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
591 DEBUGOUT("nvm parameter(s) out of bounds\n");
592 ret_val
= -E1000_ERR_NVM
;
596 for (i
= 0; i
< words
; i
++) {
597 eerd
= ((offset
+ i
) << E1000_NVM_RW_ADDR_SHIFT
) +
598 E1000_NVM_RW_REG_START
;
600 E1000_WRITE_REG(hw
, E1000_EERD
, eerd
);
601 ret_val
= e1000_poll_eerd_eewr_done(hw
, E1000_NVM_POLL_READ
);
605 data
[i
] = (E1000_READ_REG(hw
, E1000_EERD
) >>
606 E1000_NVM_RW_REG_DATA
);
614 * e1000_write_nvm_spi - Write to EEPROM using SPI
615 * @hw: pointer to the HW structure
616 * @offset: offset within the EEPROM to be written to
617 * @words: number of words to write
618 * @data: 16 bit word(s) to be written to the EEPROM
620 * Writes data to EEPROM at offset using SPI interface.
622 * If e1000_update_nvm_checksum is not called after this function , the
623 * EEPROM will most likely contain an invalid checksum.
626 e1000_write_nvm_spi(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
628 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
632 DEBUGFUNC("e1000_write_nvm_spi");
635 * A check for invalid values: offset too large, too many words, and
638 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
640 DEBUGOUT("nvm parameter(s) out of bounds\n");
641 ret_val
= -E1000_ERR_NVM
;
645 ret_val
= nvm
->ops
.acquire(hw
);
649 while (widx
< words
) {
650 u8 write_opcode
= NVM_WRITE_OPCODE_SPI
;
652 ret_val
= e1000_ready_nvm_eeprom(hw
);
656 e1000_standby_nvm(hw
);
658 /* Send the WRITE ENABLE command (8 bit opcode) */
659 e1000_shift_out_eec_bits(hw
, NVM_WREN_OPCODE_SPI
,
662 e1000_standby_nvm(hw
);
665 * Some SPI eeproms use the 8th address bit embedded in the
668 if ((nvm
->address_bits
== 8) && (offset
>= 128))
669 write_opcode
|= NVM_A8_OPCODE_SPI
;
671 /* Send the Write command (8-bit opcode + addr) */
672 e1000_shift_out_eec_bits(hw
, write_opcode
, nvm
->opcode_bits
);
673 e1000_shift_out_eec_bits(hw
, (u16
)((offset
+ widx
) * 2),
676 /* Loop to allow for up to whole page write of eeprom */
677 while (widx
< words
) {
678 u16 word_out
= data
[widx
];
680 word_out
= (word_out
>> 8) | (word_out
<< 8);
681 e1000_shift_out_eec_bits(hw
, word_out
, 16);
684 if ((((offset
+ widx
) * 2) % nvm
->page_size
) == 0) {
685 e1000_standby_nvm(hw
);
693 nvm
->ops
.release(hw
);
700 * e1000_write_nvm_microwire - Writes EEPROM using microwire
701 * @hw: pointer to the HW structure
702 * @offset: offset within the EEPROM to be written to
703 * @words: number of words to write
704 * @data: 16 bit word(s) to be written to the EEPROM
706 * Writes data to EEPROM at offset using microwire interface.
708 * If e1000_update_nvm_checksum is not called after this function , the
709 * EEPROM will most likely contain an invalid checksum.
712 e1000_write_nvm_microwire(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
714 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
717 u16 words_written
= 0;
720 DEBUGFUNC("e1000_write_nvm_microwire");
723 * A check for invalid values: offset too large, too many words, and
726 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
728 DEBUGOUT("nvm parameter(s) out of bounds\n");
729 ret_val
= -E1000_ERR_NVM
;
733 ret_val
= nvm
->ops
.acquire(hw
);
737 ret_val
= e1000_ready_nvm_eeprom(hw
);
741 e1000_shift_out_eec_bits(hw
, NVM_EWEN_OPCODE_MICROWIRE
,
742 (u16
)(nvm
->opcode_bits
+ 2));
744 e1000_shift_out_eec_bits(hw
, 0, (u16
)(nvm
->address_bits
- 2));
746 e1000_standby_nvm(hw
);
748 while (words_written
< words
) {
749 e1000_shift_out_eec_bits(hw
, NVM_WRITE_OPCODE_MICROWIRE
,
752 e1000_shift_out_eec_bits(hw
, (u16
)(offset
+ words_written
),
755 e1000_shift_out_eec_bits(hw
, data
[words_written
], 16);
757 e1000_standby_nvm(hw
);
759 for (widx
= 0; widx
< 200; widx
++) {
760 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
761 if (eecd
& E1000_EECD_DO
)
767 DEBUGOUT("NVM Write did not complete\n");
768 ret_val
= -E1000_ERR_NVM
;
772 e1000_standby_nvm(hw
);
777 e1000_shift_out_eec_bits(hw
, NVM_EWDS_OPCODE_MICROWIRE
,
778 (u16
)(nvm
->opcode_bits
+ 2));
780 e1000_shift_out_eec_bits(hw
, 0, (u16
)(nvm
->address_bits
- 2));
783 nvm
->ops
.release(hw
);
790 * e1000_read_pba_num_generic - Read device part number
791 * @hw: pointer to the HW structure
792 * @pba_num: pointer to device part number
794 * Reads the product board assembly (PBA) number from the EEPROM and stores
795 * the value in pba_num.
798 e1000_read_pba_num_generic(struct e1000_hw
*hw
, u32
*pba_num
)
803 DEBUGFUNC("e1000_read_pba_num_generic");
805 ret_val
= hw
->nvm
.ops
.read(hw
, NVM_PBA_OFFSET_0
, 1, &nvm_data
);
807 DEBUGOUT("NVM Read Error\n");
810 *pba_num
= (u32
)(nvm_data
<< 16);
812 ret_val
= hw
->nvm
.ops
.read(hw
, NVM_PBA_OFFSET_1
, 1, &nvm_data
);
814 DEBUGOUT("NVM Read Error\n");
817 *pba_num
|= nvm_data
;
824 * e1000_read_mac_addr_generic - Read device MAC address
825 * @hw: pointer to the HW structure
827 * Reads the device MAC address from the EEPROM and stores the value.
828 * Since devices with two ports use the same EEPROM, we increment the
829 * last bit in the MAC address for the second port.
832 e1000_read_mac_addr_generic(struct e1000_hw
*hw
)
838 rar_high
= E1000_READ_REG(hw
, E1000_RAH(0));
839 rar_low
= E1000_READ_REG(hw
, E1000_RAL(0));
841 for (i
= 0; i
< E1000_RAL_MAC_ADDR_LEN
; i
++)
842 hw
->mac
.perm_addr
[i
] = (u8
)(rar_low
>> (i
*8));
844 for (i
= 0; i
< E1000_RAH_MAC_ADDR_LEN
; i
++)
845 hw
->mac
.perm_addr
[i
+4] = (u8
)(rar_high
>> (i
*8));
847 for (i
= 0; i
< ETH_ADDR_LEN
; i
++)
848 hw
->mac
.addr
[i
] = hw
->mac
.perm_addr
[i
];
850 return (E1000_SUCCESS
);
854 * e1000_validate_nvm_checksum_generic - Validate EEPROM checksum
855 * @hw: pointer to the HW structure
857 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
858 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
861 e1000_validate_nvm_checksum_generic(struct e1000_hw
*hw
)
863 s32 ret_val
= E1000_SUCCESS
;
867 DEBUGFUNC("e1000_validate_nvm_checksum_generic");
869 for (i
= 0; i
< (NVM_CHECKSUM_REG
+ 1); i
++) {
870 ret_val
= hw
->nvm
.ops
.read(hw
, i
, 1, &nvm_data
);
872 DEBUGOUT("NVM Read Error\n");
875 checksum
+= nvm_data
;
878 if (checksum
!= (u16
)NVM_SUM
) {
879 DEBUGOUT("NVM Checksum Invalid\n");
880 ret_val
= -E1000_ERR_NVM
;
889 * e1000_update_nvm_checksum_generic - Update EEPROM checksum
890 * @hw: pointer to the HW structure
892 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
893 * up to the checksum. Then calculates the EEPROM checksum and writes the
894 * value to the EEPROM.
897 e1000_update_nvm_checksum_generic(struct e1000_hw
*hw
)
903 DEBUGFUNC("e1000_update_nvm_checksum");
905 for (i
= 0; i
< NVM_CHECKSUM_REG
; i
++) {
906 ret_val
= hw
->nvm
.ops
.read(hw
, i
, 1, &nvm_data
);
908 DEBUGOUT("NVM Read Error while updating checksum.\n");
911 checksum
+= nvm_data
;
913 checksum
= (u16
)NVM_SUM
- checksum
;
914 ret_val
= hw
->nvm
.ops
.write(hw
, NVM_CHECKSUM_REG
, 1, &checksum
);
917 DEBUGOUT("NVM Write Error while updating checksum.\n");
925 * e1000_reload_nvm_generic - Reloads EEPROM
926 * @hw: pointer to the HW structure
928 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
929 * extended control register.
932 e1000_reload_nvm_generic(struct e1000_hw
*hw
)
936 DEBUGFUNC("e1000_reload_nvm_generic");
939 ctrl_ext
= E1000_READ_REG(hw
, E1000_CTRL_EXT
);
940 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
941 E1000_WRITE_REG(hw
, E1000_CTRL_EXT
, ctrl_ext
);
942 E1000_WRITE_FLUSH(hw
);