~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/igb/e1000_nvm.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
}
319
319
 
320
320
/**
 
321
 *  igb_read_nvm_spi - Read EEPROM's using SPI
 
322
 *  @hw: pointer to the HW structure
 
323
 *  @offset: offset of word in the EEPROM to read
 
324
 *  @words: number of words to read
 
325
 *  @data: word read from the EEPROM
 
326
 *
 
327
 *  Reads a 16 bit word from the EEPROM.
 
328
 **/
 
329
s32 igb_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 
330
{
 
331
        struct e1000_nvm_info *nvm = &hw->nvm;
 
332
        u32 i = 0;
 
333
        s32 ret_val;
 
334
        u16 word_in;
 
335
        u8 read_opcode = NVM_READ_OPCODE_SPI;
 
336
 
 
337
        /*
 
338
         * A check for invalid values:  offset too large, too many words,
 
339
         * and not enough words.
 
340
         */
 
341
        if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
 
342
            (words == 0)) {
 
343
                hw_dbg("nvm parameter(s) out of bounds\n");
 
344
                ret_val = -E1000_ERR_NVM;
 
345
                goto out;
 
346
        }
 
347
 
 
348
        ret_val = nvm->ops.acquire(hw);
 
349
        if (ret_val)
 
350
                goto out;
 
351
 
 
352
        ret_val = igb_ready_nvm_eeprom(hw);
 
353
        if (ret_val)
 
354
                goto release;
 
355
 
 
356
        igb_standby_nvm(hw);
 
357
 
 
358
        if ((nvm->address_bits == 8) && (offset >= 128))
 
359
                read_opcode |= NVM_A8_OPCODE_SPI;
 
360
 
 
361
        /* Send the READ command (opcode + addr) */
 
362
        igb_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
 
363
        igb_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
 
364
 
 
365
        /*
 
366
         * Read the data.  SPI NVMs increment the address with each byte
 
367
         * read and will roll over if reading beyond the end.  This allows
 
368
         * us to read the whole NVM from any offset
 
369
         */
 
370
        for (i = 0; i < words; i++) {
 
371
                word_in = igb_shift_in_eec_bits(hw, 16);
 
372
                data[i] = (word_in >> 8) | (word_in << 8);
 
373
        }
 
374
 
 
375
release:
 
376
        nvm->ops.release(hw);
 
377
 
 
378
out:
 
379
        return ret_val;
 
380
}
 
381
 
 
382
/**
321
383
 *  igb_read_nvm_eerd - Reads EEPROM using EERD register
322
384
 *  @hw: pointer to the HW structure
323
385
 *  @offset: offset of word in the EEPROM to read
353
415
                        break;
354
416
 
355
417
                data[i] = (rd32(E1000_EERD) >>
356
 
                           E1000_NVM_RW_REG_DATA);
 
418
                        E1000_NVM_RW_REG_DATA);
357
419
        }
358
420
 
359
421
out: