Lines Matching +full:ports +full:- +full:word +full:- +full:length
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
7 * e1000_raise_eec_clk - Raise EEPROM clock
18 udelay(hw->nvm.delay_usec); in e1000_raise_eec_clk()
22 * e1000_lower_eec_clk - Lower EEPROM clock
33 udelay(hw->nvm.delay_usec); in e1000_lower_eec_clk()
37 * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
48 struct e1000_nvm_info *nvm = &hw->nvm; in e1000_shift_out_eec_bits()
52 mask = BIT(count - 1); in e1000_shift_out_eec_bits()
53 if (nvm->type == e1000_nvm_eeprom_spi) in e1000_shift_out_eec_bits()
65 udelay(nvm->delay_usec); in e1000_shift_out_eec_bits()
78 * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
115 * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
139 return -E1000_ERR_NVM; in e1000e_poll_eerd_eewr_done()
143 * e1000e_acquire_nvm - Generic request for access to EEPROM
148 * EEPROM access and return -E1000_ERR_NVM (-1).
163 timeout--; in e1000e_acquire_nvm()
170 return -E1000_ERR_NVM; in e1000e_acquire_nvm()
177 * e1000_standby_nvm - Return EEPROM to standby state
184 struct e1000_nvm_info *nvm = &hw->nvm; in e1000_standby_nvm()
187 if (nvm->type == e1000_nvm_eeprom_spi) { in e1000_standby_nvm()
192 udelay(nvm->delay_usec); in e1000_standby_nvm()
196 udelay(nvm->delay_usec); in e1000_standby_nvm()
201 * e1000_stop_nvm - Terminate EEPROM command
211 if (hw->nvm.type == e1000_nvm_eeprom_spi) { in e1000_stop_nvm()
219 * e1000e_release_nvm - Release exclusive access to EEPROM
236 * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
243 struct e1000_nvm_info *nvm = &hw->nvm; in e1000_ready_nvm_eeprom()
247 if (nvm->type == e1000_nvm_eeprom_spi) { in e1000_ready_nvm_eeprom()
263 hw->nvm.opcode_bits); in e1000_ready_nvm_eeprom()
270 timeout--; in e1000_ready_nvm_eeprom()
275 return -E1000_ERR_NVM; in e1000_ready_nvm_eeprom()
283 * e1000e_read_nvm_eerd - Reads EEPROM using EERD register
285 * @offset: offset of word in the EEPROM to read
287 * @data: word read from the EEPROM
289 * Reads a 16 bit word from the EEPROM using the EERD register.
293 struct e1000_nvm_info *nvm = &hw->nvm; in e1000e_read_nvm_eerd()
300 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || in e1000e_read_nvm_eerd()
303 return -E1000_ERR_NVM; in e1000e_read_nvm_eerd()
324 * e1000e_write_nvm_spi - Write to EEPROM using SPI
328 * @data: 16 bit word(s) to be written to the EEPROM
337 struct e1000_nvm_info *nvm = &hw->nvm; in e1000e_write_nvm_spi()
338 s32 ret_val = -E1000_ERR_NVM; in e1000e_write_nvm_spi()
344 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || in e1000e_write_nvm_spi()
347 return -E1000_ERR_NVM; in e1000e_write_nvm_spi()
353 ret_val = nvm->ops.acquire(hw); in e1000e_write_nvm_spi()
359 nvm->ops.release(hw); in e1000e_write_nvm_spi()
367 nvm->opcode_bits); in e1000e_write_nvm_spi()
374 if ((nvm->address_bits == 8) && (offset >= 128)) in e1000e_write_nvm_spi()
377 /* Send the Write command (8-bit opcode + addr) */ in e1000e_write_nvm_spi()
378 e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits); in e1000e_write_nvm_spi()
380 nvm->address_bits); in e1000e_write_nvm_spi()
390 if ((((offset + widx) * 2) % nvm->page_size) == 0) { in e1000e_write_nvm_spi()
396 nvm->ops.release(hw); in e1000e_write_nvm_spi()
403 * e1000_read_pba_string_generic - Read device part number
418 u16 length; in e1000_read_pba_string_generic() local
422 return -E1000_ERR_INVALID_ARGUMENT; in e1000_read_pba_string_generic()
438 * means pba_ptr is actually our second data word for the PBA number in e1000_read_pba_string_generic()
457 pba_num[6] = '-'; in e1000_read_pba_string_generic()
465 /* switch all the data but the '-' to hex char */ in e1000_read_pba_string_generic()
470 pba_num[offset] += 'A' - 0xA; in e1000_read_pba_string_generic()
476 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); in e1000_read_pba_string_generic()
482 if (length == 0xFFFF || length == 0) { in e1000_read_pba_string_generic()
483 e_dbg("NVM PBA number section invalid length\n"); in e1000_read_pba_string_generic()
484 return -E1000_ERR_NVM_PBA_SECTION; in e1000_read_pba_string_generic()
487 if (pba_num_size < (((u32)length * 2) - 1)) { in e1000_read_pba_string_generic()
489 return -E1000_ERR_NO_SPACE; in e1000_read_pba_string_generic()
492 /* trim pba length from start of string */ in e1000_read_pba_string_generic()
494 length--; in e1000_read_pba_string_generic()
496 for (offset = 0; offset < length; offset++) { in e1000_read_pba_string_generic()
511 * e1000_read_mac_addr_generic - Read device MAC address
515 * Since devices with two ports use the same EEPROM, we increment the
528 hw->mac.perm_addr[i] = (u8)(rar_low >> (i * 8)); in e1000_read_mac_addr_generic()
531 hw->mac.perm_addr[i + 4] = (u8)(rar_high >> (i * 8)); in e1000_read_mac_addr_generic()
534 hw->mac.addr[i] = hw->mac.perm_addr[i]; in e1000_read_mac_addr_generic()
540 * e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum
543 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
563 return -E1000_ERR_NVM; in e1000e_validate_nvm_checksum_generic()
570 * e1000e_update_nvm_checksum_generic - Update EEPROM checksum
573 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
591 checksum = (u16)NVM_SUM - checksum; in e1000e_update_nvm_checksum_generic()
600 * e1000e_reload_nvm_generic - Reloads EEPROM