1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
8 STATIC s32 e1000_acquire_nvm_i210(struct e1000_hw *hw);
9 STATIC void e1000_release_nvm_i210(struct e1000_hw *hw);
10 STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
11 STATIC s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
13 STATIC s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw);
14 STATIC s32 e1000_valid_led_default_i210(struct e1000_hw *hw, u16 *data);
17 * e1000_acquire_nvm_i210 - Request for access to EEPROM
18 * @hw: pointer to the HW structure
20 * Acquire the necessary semaphores for exclusive access to the EEPROM.
21 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
22 * Return successful if access grant bit set, else clear the request for
23 * EEPROM access and return -E1000_ERR_NVM (-1).
25 STATIC s32 e1000_acquire_nvm_i210(struct e1000_hw *hw)
29 DEBUGFUNC("e1000_acquire_nvm_i210");
31 ret_val = e1000_acquire_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
37 * e1000_release_nvm_i210 - Release exclusive access to EEPROM
38 * @hw: pointer to the HW structure
40 * Stop any current commands to the EEPROM and clear the EEPROM request bit,
41 * then release the semaphores acquired.
43 STATIC void e1000_release_nvm_i210(struct e1000_hw *hw)
45 DEBUGFUNC("e1000_release_nvm_i210");
47 e1000_release_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
51 * e1000_acquire_swfw_sync_i210 - Acquire SW/FW semaphore
52 * @hw: pointer to the HW structure
53 * @mask: specifies which semaphore to acquire
55 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
56 * will also specify which port we're acquiring the lock for.
58 s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
62 u32 fwmask = mask << 16;
63 s32 ret_val = E1000_SUCCESS;
64 s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
66 DEBUGFUNC("e1000_acquire_swfw_sync_i210");
69 if (e1000_get_hw_semaphore_i210(hw)) {
70 ret_val = -E1000_ERR_SWFW_SYNC;
74 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
75 if (!(swfw_sync & (fwmask | swmask)))
79 * Firmware currently using resource (fwmask)
80 * or other software thread using resource (swmask)
82 e1000_put_hw_semaphore_generic(hw);
88 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
89 ret_val = -E1000_ERR_SWFW_SYNC;
94 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
96 e1000_put_hw_semaphore_generic(hw);
103 * e1000_release_swfw_sync_i210 - Release SW/FW semaphore
104 * @hw: pointer to the HW structure
105 * @mask: specifies which semaphore to acquire
107 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
108 * will also specify which port we're releasing the lock for.
110 void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
114 DEBUGFUNC("e1000_release_swfw_sync_i210");
116 while (e1000_get_hw_semaphore_i210(hw) != E1000_SUCCESS)
119 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
120 swfw_sync &= (u32)~mask;
121 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
123 e1000_put_hw_semaphore_generic(hw);
127 * e1000_get_hw_semaphore_i210 - Acquire hardware semaphore
128 * @hw: pointer to the HW structure
130 * Acquire the HW semaphore to access the PHY or NVM
132 STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
135 s32 timeout = hw->nvm.word_size + 1;
138 DEBUGFUNC("e1000_get_hw_semaphore_i210");
140 /* Get the SW semaphore */
141 while (i < timeout) {
142 swsm = E1000_READ_REG(hw, E1000_SWSM);
143 if (!(swsm & E1000_SWSM_SMBI))
151 /* In rare circumstances, the SW semaphore may already be held
152 * unintentionally. Clear the semaphore once before giving up.
154 if (hw->dev_spec._82575.clear_semaphore_once) {
155 hw->dev_spec._82575.clear_semaphore_once = false;
156 e1000_put_hw_semaphore_generic(hw);
157 for (i = 0; i < timeout; i++) {
158 swsm = E1000_READ_REG(hw, E1000_SWSM);
159 if (!(swsm & E1000_SWSM_SMBI))
166 /* If we do not have the semaphore here, we have to give up. */
168 DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
169 return -E1000_ERR_NVM;
173 /* Get the FW semaphore. */
174 for (i = 0; i < timeout; i++) {
175 swsm = E1000_READ_REG(hw, E1000_SWSM);
176 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
178 /* Semaphore acquired if bit latched */
179 if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
186 /* Release semaphores */
187 e1000_put_hw_semaphore_generic(hw);
188 DEBUGOUT("Driver can't access the NVM\n");
189 return -E1000_ERR_NVM;
192 return E1000_SUCCESS;
196 * e1000_read_nvm_srrd_i210 - Reads Shadow Ram using EERD register
197 * @hw: pointer to the HW structure
198 * @offset: offset of word in the Shadow Ram to read
199 * @words: number of words to read
200 * @data: word read from the Shadow Ram
202 * Reads a 16 bit word from the Shadow Ram using the EERD register.
203 * Uses necessary synchronization semaphores.
205 s32 e1000_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words,
208 s32 status = E1000_SUCCESS;
211 DEBUGFUNC("e1000_read_nvm_srrd_i210");
213 /* We cannot hold synchronization semaphores for too long,
214 * because of forceful takeover procedure. However it is more efficient
215 * to read in bursts than synchronizing access for each word. */
216 for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
217 count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
218 E1000_EERD_EEWR_MAX_COUNT : (words - i);
219 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
220 status = e1000_read_nvm_eerd(hw, offset, count,
222 hw->nvm.ops.release(hw);
224 status = E1000_ERR_SWFW_SYNC;
227 if (status != E1000_SUCCESS)
235 * e1000_write_nvm_srwr_i210 - Write to Shadow RAM using EEWR
236 * @hw: pointer to the HW structure
237 * @offset: offset within the Shadow RAM to be written to
238 * @words: number of words to write
239 * @data: 16 bit word(s) to be written to the Shadow RAM
241 * Writes data to Shadow RAM at offset using EEWR register.
243 * If e1000_update_nvm_checksum is not called after this function , the
244 * data will not be committed to FLASH and also Shadow RAM will most likely
245 * contain an invalid checksum.
247 * If error code is returned, data and Shadow RAM may be inconsistent - buffer
250 s32 e1000_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
253 s32 status = E1000_SUCCESS;
256 DEBUGFUNC("e1000_write_nvm_srwr_i210");
258 /* We cannot hold synchronization semaphores for too long,
259 * because of forceful takeover procedure. However it is more efficient
260 * to write in bursts than synchronizing access for each word. */
261 for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
262 count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
263 E1000_EERD_EEWR_MAX_COUNT : (words - i);
264 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
265 status = e1000_write_nvm_srwr(hw, offset, count,
267 hw->nvm.ops.release(hw);
269 status = E1000_ERR_SWFW_SYNC;
272 if (status != E1000_SUCCESS)
280 * e1000_write_nvm_srwr - Write to Shadow Ram using EEWR
281 * @hw: pointer to the HW structure
282 * @offset: offset within the Shadow Ram to be written to
283 * @words: number of words to write
284 * @data: 16 bit word(s) to be written to the Shadow Ram
286 * Writes data to Shadow Ram at offset using EEWR register.
288 * If e1000_update_nvm_checksum is not called after this function , the
289 * Shadow Ram will most likely contain an invalid checksum.
291 STATIC s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
294 struct e1000_nvm_info *nvm = &hw->nvm;
296 u32 attempts = 100000;
297 s32 ret_val = E1000_SUCCESS;
299 DEBUGFUNC("e1000_write_nvm_srwr");
302 * A check for invalid values: offset too large, too many words,
303 * too many words for the offset, and not enough words.
305 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
307 DEBUGOUT("nvm parameter(s) out of bounds\n");
308 ret_val = -E1000_ERR_NVM;
312 for (i = 0; i < words; i++) {
313 ret_val = -E1000_ERR_NVM;
315 eewr = ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) |
316 (data[i] << E1000_NVM_RW_REG_DATA) |
317 E1000_NVM_RW_REG_START;
319 E1000_WRITE_REG(hw, E1000_SRWR, eewr);
321 for (k = 0; k < attempts; k++) {
322 if (E1000_NVM_RW_REG_DONE &
323 E1000_READ_REG(hw, E1000_SRWR)) {
324 ret_val = E1000_SUCCESS;
330 if (ret_val != E1000_SUCCESS) {
331 DEBUGOUT("Shadow RAM write EEWR timed out\n");
340 /** e1000_read_invm_word_i210 - Reads OTP
341 * @hw: pointer to the HW structure
342 * @address: the word address (aka eeprom offset) to read
343 * @data: pointer to the data read
345 * Reads 16-bit words from the OTP. Return error when the word is not
348 STATIC s32 e1000_read_invm_word_i210(struct e1000_hw *hw, u8 address, u16 *data)
350 s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
353 u8 record_type, word_address;
355 DEBUGFUNC("e1000_read_invm_word_i210");
357 for (i = 0; i < E1000_INVM_SIZE; i++) {
358 invm_dword = E1000_READ_REG(hw, E1000_INVM_DATA_REG(i));
359 /* Get record type */
360 record_type = INVM_DWORD_TO_RECORD_TYPE(invm_dword);
361 if (record_type == E1000_INVM_UNINITIALIZED_STRUCTURE)
363 if (record_type == E1000_INVM_CSR_AUTOLOAD_STRUCTURE)
364 i += E1000_INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS;
365 if (record_type == E1000_INVM_RSA_KEY_SHA256_STRUCTURE)
366 i += E1000_INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS;
367 if (record_type == E1000_INVM_WORD_AUTOLOAD_STRUCTURE) {
368 word_address = INVM_DWORD_TO_WORD_ADDRESS(invm_dword);
369 if (word_address == address) {
370 *data = INVM_DWORD_TO_WORD_DATA(invm_dword);
371 DEBUGOUT2("Read INVM Word 0x%02x = %x",
373 status = E1000_SUCCESS;
378 if (status != E1000_SUCCESS)
379 DEBUGOUT1("Requested word 0x%02x not found in OTP\n", address);
383 /** e1000_read_invm_i210 - Read invm wrapper function for I210/I211
384 * @hw: pointer to the HW structure
385 * @address: the word address (aka eeprom offset) to read
386 * @data: pointer to the data read
388 * Wrapper function to return data formerly found in the NVM.
390 STATIC s32 e1000_read_invm_i210(struct e1000_hw *hw, u16 offset,
391 u16 E1000_UNUSEDARG words, u16 *data)
393 s32 ret_val = E1000_SUCCESS;
394 UNREFERENCED_1PARAMETER(words);
396 DEBUGFUNC("e1000_read_invm_i210");
398 /* Only the MAC addr is required to be present in the iNVM */
401 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, &data[0]);
402 ret_val |= e1000_read_invm_word_i210(hw, (u8)offset + 1,
404 ret_val |= e1000_read_invm_word_i210(hw, (u8)offset + 2,
406 if (ret_val != E1000_SUCCESS)
407 DEBUGOUT("MAC Addr not found in iNVM\n");
409 case NVM_INIT_CTRL_2:
410 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
411 if (ret_val != E1000_SUCCESS) {
412 *data = NVM_INIT_CTRL_2_DEFAULT_I211;
413 ret_val = E1000_SUCCESS;
416 case NVM_INIT_CTRL_4:
417 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
418 if (ret_val != E1000_SUCCESS) {
419 *data = NVM_INIT_CTRL_4_DEFAULT_I211;
420 ret_val = E1000_SUCCESS;
424 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
425 if (ret_val != E1000_SUCCESS) {
426 *data = NVM_LED_1_CFG_DEFAULT_I211;
427 ret_val = E1000_SUCCESS;
430 case NVM_LED_0_2_CFG:
431 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
432 if (ret_val != E1000_SUCCESS) {
433 *data = NVM_LED_0_2_CFG_DEFAULT_I211;
434 ret_val = E1000_SUCCESS;
437 case NVM_ID_LED_SETTINGS:
438 ret_val = e1000_read_invm_word_i210(hw, (u8)offset, data);
439 if (ret_val != E1000_SUCCESS) {
440 *data = ID_LED_RESERVED_FFFF;
441 ret_val = E1000_SUCCESS;
445 *data = hw->subsystem_device_id;
448 *data = hw->subsystem_vendor_id;
451 *data = hw->device_id;
454 *data = hw->vendor_id;
457 DEBUGOUT1("NVM word 0x%02x is not mapped.\n", offset);
458 *data = NVM_RESERVED_WORD;
465 * e1000_read_invm_version - Reads iNVM version and image type
466 * @hw: pointer to the HW structure
467 * @invm_ver: version structure for the version read
469 * Reads iNVM version and image type.
471 s32 e1000_read_invm_version(struct e1000_hw *hw,
472 struct e1000_fw_version *invm_ver)
475 u32 *next_record = NULL;
478 u32 invm_blocks = E1000_INVM_SIZE - (E1000_INVM_ULT_BYTES_SIZE /
479 E1000_INVM_RECORD_SIZE_IN_BYTES);
480 u32 buffer[E1000_INVM_SIZE];
481 s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
484 DEBUGFUNC("e1000_read_invm_version");
486 /* Read iNVM memory */
487 for (i = 0; i < E1000_INVM_SIZE; i++) {
488 invm_dword = E1000_READ_REG(hw, E1000_INVM_DATA_REG(i));
489 buffer[i] = invm_dword;
492 /* Read version number */
493 for (i = 1; i < invm_blocks; i++) {
494 record = &buffer[invm_blocks - i];
495 next_record = &buffer[invm_blocks - i + 1];
497 /* Check if we have first version location used */
498 if ((i == 1) && ((*record & E1000_INVM_VER_FIELD_ONE) == 0)) {
500 status = E1000_SUCCESS;
503 /* Check if we have second version location used */
505 ((*record & E1000_INVM_VER_FIELD_TWO) == 0)) {
506 version = (*record & E1000_INVM_VER_FIELD_ONE) >> 3;
507 status = E1000_SUCCESS;
511 * Check if we have odd version location
512 * used and it is the last one used
514 else if ((((*record & E1000_INVM_VER_FIELD_ONE) == 0) &&
515 ((*record & 0x3) == 0)) || (((*record & 0x3) != 0) &&
517 version = (*next_record & E1000_INVM_VER_FIELD_TWO)
519 status = E1000_SUCCESS;
523 * Check if we have even version location
524 * used and it is the last one used
526 else if (((*record & E1000_INVM_VER_FIELD_TWO) == 0) &&
527 ((*record & 0x3) == 0)) {
528 version = (*record & E1000_INVM_VER_FIELD_ONE) >> 3;
529 status = E1000_SUCCESS;
534 if (status == E1000_SUCCESS) {
535 invm_ver->invm_major = (version & E1000_INVM_MAJOR_MASK)
536 >> E1000_INVM_MAJOR_SHIFT;
537 invm_ver->invm_minor = version & E1000_INVM_MINOR_MASK;
539 /* Read Image Type */
540 for (i = 1; i < invm_blocks; i++) {
541 record = &buffer[invm_blocks - i];
542 next_record = &buffer[invm_blocks - i + 1];
544 /* Check if we have image type in first location used */
545 if ((i == 1) && ((*record & E1000_INVM_IMGTYPE_FIELD) == 0)) {
546 invm_ver->invm_img_type = 0;
547 status = E1000_SUCCESS;
550 /* Check if we have image type in first location used */
551 else if ((((*record & 0x3) == 0) &&
552 ((*record & E1000_INVM_IMGTYPE_FIELD) == 0)) ||
553 ((((*record & 0x3) != 0) && (i != 1)))) {
554 invm_ver->invm_img_type =
555 (*next_record & E1000_INVM_IMGTYPE_FIELD) >> 23;
556 status = E1000_SUCCESS;
564 * e1000_validate_nvm_checksum_i210 - Validate EEPROM checksum
565 * @hw: pointer to the HW structure
567 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
568 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
570 s32 e1000_validate_nvm_checksum_i210(struct e1000_hw *hw)
572 s32 status = E1000_SUCCESS;
573 s32 (*read_op_ptr)(struct e1000_hw *, u16, u16, u16 *);
575 DEBUGFUNC("e1000_validate_nvm_checksum_i210");
577 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
580 * Replace the read function with semaphore grabbing with
581 * the one that skips this for a while.
582 * We have semaphore taken already here.
584 read_op_ptr = hw->nvm.ops.read;
585 hw->nvm.ops.read = e1000_read_nvm_eerd;
587 status = e1000_validate_nvm_checksum_generic(hw);
589 /* Revert original read operation. */
590 hw->nvm.ops.read = read_op_ptr;
592 hw->nvm.ops.release(hw);
594 status = E1000_ERR_SWFW_SYNC;
602 * e1000_update_nvm_checksum_i210 - Update EEPROM checksum
603 * @hw: pointer to the HW structure
605 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
606 * up to the checksum. Then calculates the EEPROM checksum and writes the
607 * value to the EEPROM. Next commit EEPROM data onto the Flash.
609 s32 e1000_update_nvm_checksum_i210(struct e1000_hw *hw)
615 DEBUGFUNC("e1000_update_nvm_checksum_i210");
618 * Read the first word from the EEPROM. If this times out or fails, do
619 * not continue or we could be in for a very long wait while every
622 ret_val = e1000_read_nvm_eerd(hw, 0, 1, &nvm_data);
623 if (ret_val != E1000_SUCCESS) {
624 DEBUGOUT("EEPROM read failed\n");
628 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
630 * Do not use hw->nvm.ops.write, hw->nvm.ops.read
631 * because we do not want to take the synchronization
632 * semaphores twice here.
635 for (i = 0; i < NVM_CHECKSUM_REG; i++) {
636 ret_val = e1000_read_nvm_eerd(hw, i, 1, &nvm_data);
638 hw->nvm.ops.release(hw);
639 DEBUGOUT("NVM Read Error while updating checksum.\n");
642 checksum += nvm_data;
644 checksum = (u16) NVM_SUM - checksum;
645 ret_val = e1000_write_nvm_srwr(hw, NVM_CHECKSUM_REG, 1,
647 if (ret_val != E1000_SUCCESS) {
648 hw->nvm.ops.release(hw);
649 DEBUGOUT("NVM Write Error while updating checksum.\n");
653 hw->nvm.ops.release(hw);
655 ret_val = e1000_update_flash_i210(hw);
657 ret_val = E1000_ERR_SWFW_SYNC;
664 * e1000_get_flash_presence_i210 - Check if flash device is detected.
665 * @hw: pointer to the HW structure
668 bool e1000_get_flash_presence_i210(struct e1000_hw *hw)
671 bool ret_val = false;
673 DEBUGFUNC("e1000_get_flash_presence_i210");
675 eec = E1000_READ_REG(hw, E1000_EECD);
677 if (eec & E1000_EECD_FLASH_DETECTED_I210)
684 * e1000_update_flash_i210 - Commit EEPROM to the flash
685 * @hw: pointer to the HW structure
688 s32 e1000_update_flash_i210(struct e1000_hw *hw)
693 DEBUGFUNC("e1000_update_flash_i210");
695 ret_val = e1000_pool_flash_update_done_i210(hw);
696 if (ret_val == -E1000_ERR_NVM) {
697 DEBUGOUT("Flash update time out\n");
701 flup = E1000_READ_REG(hw, E1000_EECD) | E1000_EECD_FLUPD_I210;
702 E1000_WRITE_REG(hw, E1000_EECD, flup);
704 ret_val = e1000_pool_flash_update_done_i210(hw);
705 if (ret_val == E1000_SUCCESS)
706 DEBUGOUT("Flash update complete\n");
708 DEBUGOUT("Flash update time out\n");
715 * e1000_pool_flash_update_done_i210 - Pool FLUDONE status.
716 * @hw: pointer to the HW structure
719 s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw)
721 s32 ret_val = -E1000_ERR_NVM;
724 DEBUGFUNC("e1000_pool_flash_update_done_i210");
726 for (i = 0; i < E1000_FLUDONE_ATTEMPTS; i++) {
727 reg = E1000_READ_REG(hw, E1000_EECD);
728 if (reg & E1000_EECD_FLUDONE_I210) {
729 ret_val = E1000_SUCCESS;
739 * e1000_init_nvm_params_i210 - Initialize i210 NVM function pointers
740 * @hw: pointer to the HW structure
742 * Initialize the i210/i211 NVM parameters and function pointers.
744 STATIC s32 e1000_init_nvm_params_i210(struct e1000_hw *hw)
747 struct e1000_nvm_info *nvm = &hw->nvm;
749 DEBUGFUNC("e1000_init_nvm_params_i210");
751 ret_val = e1000_init_nvm_params_82575(hw);
752 nvm->ops.acquire = e1000_acquire_nvm_i210;
753 nvm->ops.release = e1000_release_nvm_i210;
754 nvm->ops.valid_led_default = e1000_valid_led_default_i210;
755 if (e1000_get_flash_presence_i210(hw)) {
756 hw->nvm.type = e1000_nvm_flash_hw;
757 nvm->ops.read = e1000_read_nvm_srrd_i210;
758 nvm->ops.write = e1000_write_nvm_srwr_i210;
759 nvm->ops.validate = e1000_validate_nvm_checksum_i210;
760 nvm->ops.update = e1000_update_nvm_checksum_i210;
762 hw->nvm.type = e1000_nvm_invm;
763 nvm->ops.read = e1000_read_invm_i210;
764 nvm->ops.write = e1000_null_write_nvm;
765 nvm->ops.validate = e1000_null_ops_generic;
766 nvm->ops.update = e1000_null_ops_generic;
772 * e1000_init_function_pointers_i210 - Init func ptrs.
773 * @hw: pointer to the HW structure
775 * Called to initialize all function pointers and parameters.
777 void e1000_init_function_pointers_i210(struct e1000_hw *hw)
779 e1000_init_function_pointers_82575(hw);
780 hw->nvm.ops.init_params = e1000_init_nvm_params_i210;
784 * e1000_valid_led_default_i210 - Verify a valid default LED config
785 * @hw: pointer to the HW structure
786 * @data: pointer to the NVM (EEPROM)
788 * Read the EEPROM for the current default LED configuration. If the
789 * LED configuration is not valid, set to a valid LED configuration.
791 STATIC s32 e1000_valid_led_default_i210(struct e1000_hw *hw, u16 *data)
795 DEBUGFUNC("e1000_valid_led_default_i210");
797 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
799 DEBUGOUT("NVM Read Error\n");
803 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) {
804 switch (hw->phy.media_type) {
805 case e1000_media_type_internal_serdes:
806 *data = ID_LED_DEFAULT_I210_SERDES;
808 case e1000_media_type_copper:
810 *data = ID_LED_DEFAULT_I210;
819 * e1000_pll_workaround_i210
820 * @hw: pointer to the HW structure
822 * Works around an errata in the PLL circuit where it occasionally
823 * provides the wrong clock frequency after power up.
825 STATIC s32 e1000_pll_workaround_i210(struct e1000_hw *hw)
828 u32 wuc, mdicnfg, ctrl, ctrl_ext, reg_val;
829 u16 nvm_word, phy_word, pci_word, tmp_nvm;
832 /* Get PHY semaphore */
833 hw->phy.ops.acquire(hw);
834 /* Get and set needed register values */
835 wuc = E1000_READ_REG(hw, E1000_WUC);
836 mdicnfg = E1000_READ_REG(hw, E1000_MDICNFG);
837 reg_val = mdicnfg & ~E1000_MDICNFG_EXT_MDIO;
838 E1000_WRITE_REG(hw, E1000_MDICNFG, reg_val);
840 /* Get data from NVM, or set default */
841 ret_val = e1000_read_invm_word_i210(hw, E1000_INVM_AUTOLOAD,
843 if (ret_val != E1000_SUCCESS)
844 nvm_word = E1000_INVM_DEFAULT_AL;
845 tmp_nvm = nvm_word | E1000_INVM_PLL_WO_VAL;
846 phy_word = E1000_PHY_PLL_UNCONF;
847 for (i = 0; i < E1000_MAX_PLL_TRIES; i++) {
848 /* check current state directly from internal PHY */
849 e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, 0xFC);
851 e1000_read_phy_reg_mdic(hw, E1000_PHY_PLL_FREQ_REG, &phy_word);
853 e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, 0);
854 if ((phy_word & E1000_PHY_PLL_UNCONF)
855 != E1000_PHY_PLL_UNCONF) {
856 ret_val = E1000_SUCCESS;
859 ret_val = -E1000_ERR_PHY;
861 /* directly reset the internal PHY */
862 ctrl = E1000_READ_REG(hw, E1000_CTRL);
863 E1000_WRITE_REG(hw, E1000_CTRL, ctrl|E1000_CTRL_PHY_RST);
865 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
866 ctrl_ext |= (E1000_CTRL_EXT_PHYPDEN | E1000_CTRL_EXT_SDLPE);
867 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
869 E1000_WRITE_REG(hw, E1000_WUC, 0);
870 reg_val = (E1000_INVM_AUTOLOAD << 4) | (tmp_nvm << 16);
871 E1000_WRITE_REG(hw, E1000_EEARBC_I210, reg_val);
873 e1000_read_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
874 pci_word |= E1000_PCI_PMCSR_D3;
875 e1000_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
877 pci_word &= ~E1000_PCI_PMCSR_D3;
878 e1000_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word);
879 reg_val = (E1000_INVM_AUTOLOAD << 4) | (nvm_word << 16);
880 E1000_WRITE_REG(hw, E1000_EEARBC_I210, reg_val);
882 /* restore WUC register */
883 E1000_WRITE_REG(hw, E1000_WUC, wuc);
885 /* restore MDICNFG setting */
886 E1000_WRITE_REG(hw, E1000_MDICNFG, mdicnfg);
887 /* Release PHY semaphore */
888 hw->phy.ops.release(hw);
893 * e1000_get_cfg_done_i210 - Read config done bit
894 * @hw: pointer to the HW structure
896 * Read the management control register for the config done bit for
897 * completion status. NOTE: silicon which is EEPROM-less will fail trying
898 * to read the config done bit, so an error is *ONLY* logged and returns
899 * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon
900 * would not be able to be reset or change link.
902 STATIC s32 e1000_get_cfg_done_i210(struct e1000_hw *hw)
904 s32 timeout = PHY_CFG_TIMEOUT;
905 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
907 DEBUGFUNC("e1000_get_cfg_done_i210");
910 if (E1000_READ_REG(hw, E1000_EEMNGCTL_I210) & mask)
916 DEBUGOUT("MNG configuration cycle has not completed.\n");
918 return E1000_SUCCESS;
922 * e1000_init_hw_i210 - Init hw for I210/I211
923 * @hw: pointer to the HW structure
925 * Called to initialize hw for i210 hw family.
927 s32 e1000_init_hw_i210(struct e1000_hw *hw)
930 struct e1000_mac_info *mac = &hw->mac;
932 DEBUGFUNC("e1000_init_hw_i210");
933 if ((hw->mac.type >= e1000_i210) &&
934 !(e1000_get_flash_presence_i210(hw))) {
935 ret_val = e1000_pll_workaround_i210(hw);
936 if (ret_val != E1000_SUCCESS)
939 hw->phy.ops.get_cfg_done = e1000_get_cfg_done_i210;
941 /* Initialize identification LED */
942 ret_val = mac->ops.id_led_init(hw);
944 ret_val = e1000_init_hw_base(hw);