Lines Matching +full:eeprom +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
7 * e1000_raise_eec_clk - Raise EEPROM clock
9 * @eecd: pointer to the EEPROM
11 * Enable/Raise the EEPROM clock bit.
18 udelay(hw->nvm.delay_usec); in e1000_raise_eec_clk()
22 * e1000_lower_eec_clk - Lower EEPROM clock
24 * @eecd: pointer to the EEPROM
26 * Clear/Lower the EEPROM clock bit.
33 udelay(hw->nvm.delay_usec); in e1000_lower_eec_clk()
37 * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
39 * @data: data to send to the EEPROM
42 * We need to shift 'count' bits out to the EEPROM. So, the value in the
43 * "data" parameter will be shifted out to the EEPROM one bit at a time.
44 * In order to do this, "data" must be broken down into bits.
46 static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count) in e1000_shift_out_eec_bits() argument
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()
59 if (data & mask) 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
82 * In order to read a register from the EEPROM, we need to shift 'count' bits
83 * in from the EEPROM. Bits are "shifted in" by raising the clock input to
84 * the EEPROM (setting the SK bit), and then reading the value of the data out
85 * "DO" bit. During this "shifting in" process the data in "DI" bit should
92 u16 data; in e1000_shift_in_eec_bits() local
96 data = 0; in e1000_shift_in_eec_bits()
99 data <<= 1; in e1000_shift_in_eec_bits()
106 data |= 1; in e1000_shift_in_eec_bits()
111 return data; in e1000_shift_in_eec_bits()
115 * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
117 * @ee_reg: EEPROM flag for polling
119 * Polls the EEPROM status bit for either read or write completion based
139 return -E1000_ERR_NVM; in e1000e_poll_eerd_eewr_done()
143 * e1000e_acquire_nvm - Generic request for access to EEPROM
146 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
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
180 * Return the EEPROM to a 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
204 * Terminates the current command by inverting the EEPROM's chip select pin.
211 if (hw->nvm.type == e1000_nvm_eeprom_spi) { in e1000_stop_nvm()
219 * e1000e_release_nvm - Release exclusive access to EEPROM
222 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
236 * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
239 * Setups the EEPROM for reading and writing.
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()
257 * The EEPROM will signal that the command has been completed 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.
291 s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) in e1000e_read_nvm_eerd() argument
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()
317 data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA); in e1000e_read_nvm_eerd()
324 * e1000e_write_nvm_spi - Write to EEPROM using SPI
326 * @offset: offset within the EEPROM to be written to
328 * @data: 16 bit word(s) to be written to the EEPROM
330 * Writes data to EEPROM at offset using SPI interface.
333 * EEPROM will most likely contain an invalid checksum.
335 s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) in e1000e_write_nvm_spi() argument
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()
382 /* Loop to allow for up to whole page write of eeprom */ in e1000e_write_nvm_spi()
384 u16 word_out = data[widx]; 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
408 * Reads the product board assembly (PBA) number from the EEPROM and stores
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()
450 /* extract hex string from data and pba_ptr */ 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()
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()
494 length--; in e1000_read_pba_string_generic()
511 * e1000_read_mac_addr_generic - Read device MAC address
514 * Reads the device MAC address from the EEPROM and stores the value.
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
544 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
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
574 * up to the checksum. Then calculates the EEPROM checksum and writes the
575 * value to the EEPROM.
591 checksum = (u16)NVM_SUM - checksum; in e1000e_update_nvm_checksum_generic()
600 * e1000e_reload_nvm_generic - Reloads EEPROM
603 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the