~ubuntu-branches/ubuntu/raring/ipxe/raring

« back to all changes in this revision

Viewing changes to src/drivers/net/e1000e/e1000e_nvm.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-11-14 15:47:31 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20121114154731-jhuy5d1h2jw75qe9
Tags: 1.0.0+git-4.d6b0b76-0ubuntu1
* New upstream snapshot:
  - d/p/iscsi*.patch: Dropped - included in snapshot.
  - Refreshed all other patches.
* d/p/enable-https.patch: Enable HTTPS support (LP: #1025239).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 
3
 
  Intel PRO/1000 Linux driver
4
 
  Copyright(c) 1999 - 2009 Intel Corporation.
5
 
 
6
 
  This program is free software; you can redistribute it and/or modify it
7
 
  under the terms and conditions of the GNU General Public License,
8
 
  version 2, as published by the Free Software Foundation.
9
 
 
10
 
  This program is distributed in the hope it will be useful, but WITHOUT
11
 
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
 
  more details.
14
 
 
15
 
  You should have received a copy of the GNU General Public License along with
16
 
  this program; if not, write to the Free Software Foundation, Inc.,
17
 
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
 
 
19
 
  The full GNU General Public License is included in this distribution in
20
 
  the file called "COPYING".
21
 
 
22
 
  Contact Information:
23
 
  Linux NICS <linux.nics@intel.com>
24
 
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
 
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
 
 
27
 
*******************************************************************************/
28
 
 
29
 
FILE_LICENCE ( GPL2_OR_LATER );
30
 
 
31
 
#include "e1000e.h"
32
 
 
33
 
static void e1000e_stop_nvm(struct e1000_hw *hw);
34
 
static void e1000e_reload_nvm(struct e1000_hw *hw);
35
 
 
36
 
/**
37
 
 *  e1000e_init_nvm_ops_generic - Initialize NVM function pointers
38
 
 *  @hw: pointer to the HW structure
39
 
 *
40
 
 *  Setups up the function pointers to no-op functions
41
 
 **/
42
 
void e1000e_init_nvm_ops_generic(struct e1000_hw *hw)
43
 
{
44
 
        struct e1000_nvm_info *nvm = &hw->nvm;
45
 
        /* Initialize function pointers */
46
 
        nvm->ops.reload = e1000e_reload_nvm;
47
 
}
48
 
 
49
 
/**
50
 
 *  e1000e_raise_eec_clk - Raise EEPROM clock
51
 
 *  @hw: pointer to the HW structure
52
 
 *  @eecd: pointer to the EEPROM
53
 
 *
54
 
 *  Enable/Raise the EEPROM clock bit.
55
 
 **/
56
 
static void e1000e_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
57
 
{
58
 
        *eecd = *eecd | E1000_EECD_SK;
59
 
        ew32(EECD, *eecd);
60
 
        e1e_flush();
61
 
        udelay(hw->nvm.delay_usec);
62
 
}
63
 
 
64
 
/**
65
 
 *  e1000e_lower_eec_clk - Lower EEPROM clock
66
 
 *  @hw: pointer to the HW structure
67
 
 *  @eecd: pointer to the EEPROM
68
 
 *
69
 
 *  Clear/Lower the EEPROM clock bit.
70
 
 **/
71
 
static void e1000e_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
72
 
{
73
 
        *eecd = *eecd & ~E1000_EECD_SK;
74
 
        ew32(EECD, *eecd);
75
 
        e1e_flush();
76
 
        udelay(hw->nvm.delay_usec);
77
 
}
78
 
 
79
 
/**
80
 
 *  e1000e_shift_out_eec_bits - Shift data bits our to the EEPROM
81
 
 *  @hw: pointer to the HW structure
82
 
 *  @data: data to send to the EEPROM
83
 
 *  @count: number of bits to shift out
84
 
 *
85
 
 *  We need to shift 'count' bits out to the EEPROM.  So, the value in the
86
 
 *  "data" parameter will be shifted out to the EEPROM one bit at a time.
87
 
 *  In order to do this, "data" must be broken down into bits.
88
 
 **/
89
 
static void e1000e_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
90
 
{
91
 
        struct e1000_nvm_info *nvm = &hw->nvm;
92
 
        u32 eecd = er32(EECD);
93
 
        u32 mask;
94
 
 
95
 
        mask = 0x01 << (count - 1);
96
 
        if (nvm->type == e1000_nvm_eeprom_spi)
97
 
                eecd |= E1000_EECD_DO;
98
 
 
99
 
        do {
100
 
                eecd &= ~E1000_EECD_DI;
101
 
 
102
 
                if (data & mask)
103
 
                        eecd |= E1000_EECD_DI;
104
 
 
105
 
                ew32(EECD, eecd);
106
 
                e1e_flush();
107
 
 
108
 
                udelay(nvm->delay_usec);
109
 
 
110
 
                e1000e_raise_eec_clk(hw, &eecd);
111
 
                e1000e_lower_eec_clk(hw, &eecd);
112
 
 
113
 
                mask >>= 1;
114
 
        } while (mask);
115
 
 
116
 
        eecd &= ~E1000_EECD_DI;
117
 
        ew32(EECD, eecd);
118
 
}
119
 
 
120
 
/**
121
 
 *  e1000e_shift_in_eec_bits - Shift data bits in from the EEPROM
122
 
 *  @hw: pointer to the HW structure
123
 
 *  @count: number of bits to shift in
124
 
 *
125
 
 *  In order to read a register from the EEPROM, we need to shift 'count' bits
126
 
 *  in from the EEPROM.  Bits are "shifted in" by raising the clock input to
127
 
 *  the EEPROM (setting the SK bit), and then reading the value of the data out
128
 
 *  "DO" bit.  During this "shifting in" process the data in "DI" bit should
129
 
 *  always be clear.
130
 
 **/
131
 
static u16 e1000e_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
132
 
{
133
 
        u32 eecd;
134
 
        u32 i;
135
 
        u16 data;
136
 
 
137
 
        eecd = er32(EECD);
138
 
        eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
139
 
        data = 0;
140
 
 
141
 
        for (i = 0; i < count; i++) {
142
 
                data <<= 1;
143
 
                e1000e_raise_eec_clk(hw, &eecd);
144
 
 
145
 
                eecd = er32(EECD);
146
 
 
147
 
                eecd &= ~E1000_EECD_DI;
148
 
                if (eecd & E1000_EECD_DO)
149
 
                        data |= 1;
150
 
 
151
 
                e1000e_lower_eec_clk(hw, &eecd);
152
 
        }
153
 
 
154
 
        return data;
155
 
}
156
 
 
157
 
/**
158
 
 *  e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
159
 
 *  @hw: pointer to the HW structure
160
 
 *  @ee_reg: EEPROM flag for polling
161
 
 *
162
 
 *  Polls the EEPROM status bit for either read or write completion based
163
 
 *  upon the value of 'ee_reg'.
164
 
 **/
165
 
s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
166
 
{
167
 
        u32 attempts = 100000;
168
 
        u32 i, reg = 0;
169
 
        s32 ret_val = -E1000_ERR_NVM;
170
 
 
171
 
        for (i = 0; i < attempts; i++) {
172
 
                if (ee_reg == E1000_NVM_POLL_READ)
173
 
                        reg = er32(EERD);
174
 
                else
175
 
                        reg = er32(EEWR);
176
 
 
177
 
                if (reg & E1000_NVM_RW_REG_DONE) {
178
 
                        ret_val = E1000_SUCCESS;
179
 
                        break;
180
 
                }
181
 
 
182
 
                udelay(5);
183
 
        }
184
 
 
185
 
        return ret_val;
186
 
}
187
 
 
188
 
/**
189
 
 *  e1000e_acquire_nvm - Generic request for access to EEPROM
190
 
 *  @hw: pointer to the HW structure
191
 
 *
192
 
 *  Set the EEPROM access request bit and wait for EEPROM access grant bit.
193
 
 *  Return successful if access grant bit set, else clear the request for
194
 
 *  EEPROM access and return -E1000_ERR_NVM (-1).
195
 
 **/
196
 
s32 e1000e_acquire_nvm(struct e1000_hw *hw)
197
 
{
198
 
        u32 eecd = er32(EECD);
199
 
        s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
200
 
        s32 ret_val = E1000_SUCCESS;
201
 
 
202
 
        ew32(EECD, eecd | E1000_EECD_REQ);
203
 
        eecd = er32(EECD);
204
 
        while (timeout) {
205
 
                if (eecd & E1000_EECD_GNT)
206
 
                        break;
207
 
                udelay(5);
208
 
                eecd = er32(EECD);
209
 
                timeout--;
210
 
        }
211
 
 
212
 
        if (!timeout) {
213
 
                eecd &= ~E1000_EECD_REQ;
214
 
                ew32(EECD, eecd);
215
 
                e_dbg("Could not acquire NVM grant\n");
216
 
                ret_val = -E1000_ERR_NVM;
217
 
        }
218
 
 
219
 
        return ret_val;
220
 
}
221
 
 
222
 
/**
223
 
 *  e1000e_standby_nvm - Return EEPROM to standby state
224
 
 *  @hw: pointer to the HW structure
225
 
 *
226
 
 *  Return the EEPROM to a standby state.
227
 
 **/
228
 
static void e1000e_standby_nvm(struct e1000_hw *hw)
229
 
{
230
 
        struct e1000_nvm_info *nvm = &hw->nvm;
231
 
        u32 eecd = er32(EECD);
232
 
 
233
 
        if (nvm->type == e1000_nvm_eeprom_spi) {
234
 
                /* Toggle CS to flush commands */
235
 
                eecd |= E1000_EECD_CS;
236
 
                ew32(EECD, eecd);
237
 
                e1e_flush();
238
 
                udelay(nvm->delay_usec);
239
 
                eecd &= ~E1000_EECD_CS;
240
 
                ew32(EECD, eecd);
241
 
                e1e_flush();
242
 
                udelay(nvm->delay_usec);
243
 
        }
244
 
}
245
 
 
246
 
/**
247
 
 *  e1000e_stop_nvm - Terminate EEPROM command
248
 
 *  @hw: pointer to the HW structure
249
 
 *
250
 
 *  Terminates the current command by inverting the EEPROM's chip select pin.
251
 
 **/
252
 
static void e1000e_stop_nvm(struct e1000_hw *hw)
253
 
{
254
 
        u32 eecd;
255
 
 
256
 
        eecd = er32(EECD);
257
 
        if (hw->nvm.type == e1000_nvm_eeprom_spi) {
258
 
                /* Pull CS high */
259
 
                eecd |= E1000_EECD_CS;
260
 
                e1000e_lower_eec_clk(hw, &eecd);
261
 
        }
262
 
}
263
 
 
264
 
/**
265
 
 *  e1000e_release_nvm - Release exclusive access to EEPROM
266
 
 *  @hw: pointer to the HW structure
267
 
 *
268
 
 *  Stop any current commands to the EEPROM and clear the EEPROM request bit.
269
 
 **/
270
 
void e1000e_release_nvm(struct e1000_hw *hw)
271
 
{
272
 
        u32 eecd;
273
 
 
274
 
        e1000e_stop_nvm(hw);
275
 
 
276
 
        eecd = er32(EECD);
277
 
        eecd &= ~E1000_EECD_REQ;
278
 
        ew32(EECD, eecd);
279
 
}
280
 
 
281
 
/**
282
 
 *  e1000e_ready_nvm_eeprom - Prepares EEPROM for read/write
283
 
 *  @hw: pointer to the HW structure
284
 
 *
285
 
 *  Setups the EEPROM for reading and writing.
286
 
 **/
287
 
static s32 e1000e_ready_nvm_eeprom(struct e1000_hw *hw)
288
 
{
289
 
        struct e1000_nvm_info *nvm = &hw->nvm;
290
 
        u32 eecd = er32(EECD);
291
 
        s32 ret_val = E1000_SUCCESS;
292
 
        u16 timeout = 0;
293
 
        u8 spi_stat_reg;
294
 
 
295
 
        if (nvm->type == e1000_nvm_eeprom_spi) {
296
 
                /* Clear SK and CS */
297
 
                eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
298
 
                ew32(EECD, eecd);
299
 
                udelay(1);
300
 
                timeout = NVM_MAX_RETRY_SPI;
301
 
 
302
 
                /*
303
 
                 * Read "Status Register" repeatedly until the LSB is cleared.
304
 
                 * The EEPROM will signal that the command has been completed
305
 
                 * by clearing bit 0 of the internal status register.  If it's
306
 
                 * not cleared within 'timeout', then error out.
307
 
                 */
308
 
                while (timeout) {
309
 
                        e1000e_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
310
 
                                                 hw->nvm.opcode_bits);
311
 
                        spi_stat_reg = (u8)e1000e_shift_in_eec_bits(hw, 8);
312
 
                        if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
313
 
                                break;
314
 
 
315
 
                        udelay(5);
316
 
                        e1000e_standby_nvm(hw);
317
 
                        timeout--;
318
 
                }
319
 
 
320
 
                if (!timeout) {
321
 
                        e_dbg("SPI NVM Status error\n");
322
 
                        ret_val = -E1000_ERR_NVM;
323
 
                        goto out;
324
 
                }
325
 
        }
326
 
 
327
 
out:
328
 
        return ret_val;
329
 
}
330
 
 
331
 
/**
332
 
 *  e1000e_read_nvm_eerd - Reads EEPROM using EERD register
333
 
 *  @hw: pointer to the HW structure
334
 
 *  @offset: offset of word in the EEPROM to read
335
 
 *  @words: number of words to read
336
 
 *  @data: word read from the EEPROM
337
 
 *
338
 
 *  Reads a 16 bit word from the EEPROM using the EERD register.
339
 
 **/
340
 
s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
341
 
{
342
 
        struct e1000_nvm_info *nvm = &hw->nvm;
343
 
        u32 i, eerd = 0;
344
 
        s32 ret_val = E1000_SUCCESS;
345
 
 
346
 
        /*
347
 
         * A check for invalid values:  offset too large, too many words,
348
 
         * too many words for the offset, and not enough words.
349
 
         */
350
 
        if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
351
 
            (words == 0)) {
352
 
                e_dbg("nvm parameter(s) out of bounds\n");
353
 
                ret_val = -E1000_ERR_NVM;
354
 
                goto out;
355
 
        }
356
 
 
357
 
        for (i = 0; i < words; i++) {
358
 
                eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
359
 
                       E1000_NVM_RW_REG_START;
360
 
 
361
 
                ew32(EERD, eerd);
362
 
                ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
363
 
                if (ret_val)
364
 
                        break;
365
 
 
366
 
                data[i] = (er32(EERD) >>
367
 
                           E1000_NVM_RW_REG_DATA);
368
 
        }
369
 
 
370
 
out:
371
 
        return ret_val;
372
 
}
373
 
 
374
 
/**
375
 
 *  e1000e_write_nvm_spi - Write to EEPROM using SPI
376
 
 *  @hw: pointer to the HW structure
377
 
 *  @offset: offset within the EEPROM to be written to
378
 
 *  @words: number of words to write
379
 
 *  @data: 16 bit word(s) to be written to the EEPROM
380
 
 *
381
 
 *  Writes data to EEPROM at offset using SPI interface.
382
 
 *
383
 
 *  If e1000e_update_nvm_checksum is not called after this function , the
384
 
 *  EEPROM will most likely contain an invalid checksum.
385
 
 **/
386
 
s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
387
 
{
388
 
        struct e1000_nvm_info *nvm = &hw->nvm;
389
 
        s32 ret_val;
390
 
        u16 widx = 0;
391
 
 
392
 
        /*
393
 
         * A check for invalid values:  offset too large, too many words,
394
 
         * and not enough words.
395
 
         */
396
 
        if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
397
 
            (words == 0)) {
398
 
                e_dbg("nvm parameter(s) out of bounds\n");
399
 
                ret_val = -E1000_ERR_NVM;
400
 
                goto out;
401
 
        }
402
 
 
403
 
        ret_val = nvm->ops.acquire(hw);
404
 
        if (ret_val)
405
 
                goto out;
406
 
 
407
 
        while (widx < words) {
408
 
                u8 write_opcode = NVM_WRITE_OPCODE_SPI;
409
 
 
410
 
                ret_val = e1000e_ready_nvm_eeprom(hw);
411
 
                if (ret_val)
412
 
                        goto release;
413
 
 
414
 
                e1000e_standby_nvm(hw);
415
 
 
416
 
                /* Send the WRITE ENABLE command (8 bit opcode) */
417
 
                e1000e_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
418
 
                                         nvm->opcode_bits);
419
 
 
420
 
                e1000e_standby_nvm(hw);
421
 
 
422
 
                /*
423
 
                 * Some SPI eeproms use the 8th address bit embedded in the
424
 
                 * opcode
425
 
                 */
426
 
                if ((nvm->address_bits == 8) && (offset >= 128))
427
 
                        write_opcode |= NVM_A8_OPCODE_SPI;
428
 
 
429
 
                /* Send the Write command (8-bit opcode + addr) */
430
 
                e1000e_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
431
 
                e1000e_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
432
 
                                         nvm->address_bits);
433
 
 
434
 
                /* Loop to allow for up to whole page write of eeprom */
435
 
                while (widx < words) {
436
 
                        u16 word_out = data[widx];
437
 
                        word_out = (word_out >> 8) | (word_out << 8);
438
 
                        e1000e_shift_out_eec_bits(hw, word_out, 16);
439
 
                        widx++;
440
 
 
441
 
                        if ((((offset + widx) * 2) % nvm->page_size) == 0) {
442
 
                                e1000e_standby_nvm(hw);
443
 
                                break;
444
 
                        }
445
 
                }
446
 
        }
447
 
 
448
 
        msleep(10);
449
 
release:
450
 
        nvm->ops.release(hw);
451
 
 
452
 
out:
453
 
        return ret_val;
454
 
}
455
 
 
456
 
/**
457
 
 *  e1000e_read_pba_num - Read device part number
458
 
 *  @hw: pointer to the HW structure
459
 
 *  @pba_num: pointer to device part number
460
 
 *
461
 
 *  Reads the product board assembly (PBA) number from the EEPROM and stores
462
 
 *  the value in pba_num.
463
 
 **/
464
 
s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
465
 
{
466
 
        s32  ret_val;
467
 
        u16 nvm_data;
468
 
 
469
 
        ret_val = e1000e_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
470
 
        if (ret_val) {
471
 
                e_dbg("NVM Read Error\n");
472
 
                goto out;
473
 
        }
474
 
        *pba_num = (u32)(nvm_data << 16);
475
 
 
476
 
        ret_val = e1000e_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
477
 
        if (ret_val) {
478
 
                e_dbg("NVM Read Error\n");
479
 
                goto out;
480
 
        }
481
 
        *pba_num |= nvm_data;
482
 
 
483
 
out:
484
 
        return ret_val;
485
 
}
486
 
 
487
 
/**
488
 
 *  e1000e_read_mac_addr_generic - Read device MAC address
489
 
 *  @hw: pointer to the HW structure
490
 
 *
491
 
 *  Reads the device MAC address from the EEPROM and stores the value.
492
 
 *  Since devices with two ports use the same EEPROM, we increment the
493
 
 *  last bit in the MAC address for the second port.
494
 
 **/
495
 
s32 e1000e_read_mac_addr_generic(struct e1000_hw *hw)
496
 
{
497
 
        u32 rar_high;
498
 
        u32 rar_low;
499
 
        u16 i;
500
 
 
501
 
        rar_high = er32(RAH(0));
502
 
        rar_low = er32(RAL(0));
503
 
 
504
 
        for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
505
 
                hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
506
 
 
507
 
        for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
508
 
                hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
509
 
 
510
 
        for (i = 0; i < ETH_ADDR_LEN; i++)
511
 
                hw->mac.addr[i] = hw->mac.perm_addr[i];
512
 
 
513
 
        return E1000_SUCCESS;
514
 
}
515
 
 
516
 
/**
517
 
 *  e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum
518
 
 *  @hw: pointer to the HW structure
519
 
 *
520
 
 *  Calculates the EEPROM checksum by reading/adding each word of the EEPROM
521
 
 *  and then verifies that the sum of the EEPROM is equal to 0xBABA.
522
 
 **/
523
 
s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw)
524
 
{
525
 
        s32 ret_val = E1000_SUCCESS;
526
 
        u16 checksum = 0;
527
 
        u16 i, nvm_data;
528
 
 
529
 
        for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
530
 
                ret_val = e1000e_read_nvm(hw, i, 1, &nvm_data);
531
 
                if (ret_val) {
532
 
                        e_dbg("NVM Read Error\n");
533
 
                        goto out;
534
 
                }
535
 
                checksum += nvm_data;
536
 
        }
537
 
 
538
 
        if (checksum != (u16) NVM_SUM) {
539
 
                e_dbg("NVM Checksum Invalid\n");
540
 
                ret_val = -E1000_ERR_NVM;
541
 
                goto out;
542
 
        }
543
 
 
544
 
out:
545
 
        return ret_val;
546
 
}
547
 
 
548
 
/**
549
 
 *  e1000e_update_nvm_checksum_generic - Update EEPROM checksum
550
 
 *  @hw: pointer to the HW structure
551
 
 *
552
 
 *  Updates the EEPROM checksum by reading/adding each word of the EEPROM
553
 
 *  up to the checksum.  Then calculates the EEPROM checksum and writes the
554
 
 *  value to the EEPROM.
555
 
 **/
556
 
s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw)
557
 
{
558
 
        s32  ret_val;
559
 
        u16 checksum = 0;
560
 
        u16 i, nvm_data;
561
 
 
562
 
        for (i = 0; i < NVM_CHECKSUM_REG; i++) {
563
 
                ret_val = e1000e_read_nvm(hw, i, 1, &nvm_data);
564
 
                if (ret_val) {
565
 
                        e_dbg("NVM Read Error while updating checksum.\n");
566
 
                        goto out;
567
 
                }
568
 
                checksum += nvm_data;
569
 
        }
570
 
        checksum = (u16) NVM_SUM - checksum;
571
 
        ret_val = e1000e_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
572
 
        if (ret_val)
573
 
                e_dbg("NVM Write Error while updating checksum.\n");
574
 
 
575
 
out:
576
 
        return ret_val;
577
 
}
578
 
 
579
 
/**
580
 
 *  e1000e_reload_nvm - Reloads EEPROM
581
 
 *  @hw: pointer to the HW structure
582
 
 *
583
 
 *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
584
 
 *  extended control register.
585
 
 **/
586
 
static void e1000e_reload_nvm(struct e1000_hw *hw)
587
 
{
588
 
        u32 ctrl_ext;
589
 
 
590
 
        udelay(10);
591
 
        ctrl_ext = er32(CTRL_EXT);
592
 
        ctrl_ext |= E1000_CTRL_EXT_EE_RST;
593
 
        ew32(CTRL_EXT, ctrl_ext);
594
 
        e1e_flush();
595
 
}
596