src/dpdk/drivers/net/e1000/base/e1000_82575.c
s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
{
	struct e1000_nvm_info *nvm = &hw->nvm;
	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
	u16 size;

	DEBUGFUNC("e1000_init_nvm_params_82575");

	size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
		     E1000_EECD_SIZE_EX_SHIFT);
	/* Added to a constant, "size" becomes the left-shift value
	 * for setting word_size.
	 */
	size += NVM_WORD_SIZE_BASE_SHIFT;

	/* Just in case size is out of range, cap it to the largest
	 * EEPROM size supported
	 */
	if (size > 15)
		size = 15;

	nvm->word_size = 1 << size;
	if (hw->mac.type < e1000_i210) {
		nvm->opcode_bits = 8;
		nvm->delay_usec = 1;

		switch (nvm->override) {
		case e1000_nvm_override_spi_large:
			nvm->page_size = 32;
			nvm->address_bits = 16;
			break;
		case e1000_nvm_override_spi_small:
			nvm->page_size = 8;
			nvm->address_bits = 8;
			break;
		default:
			nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
			nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
					    16 : 8;
			break;
		}
		if (nvm->word_size == (1 << 15))
			nvm->page_size = 128;

		nvm->type = e1000_nvm_eeprom_spi;
	} else {
		nvm->type = e1000_nvm_flash_hw;
	}

	/* Function Pointers */
	nvm->ops.acquire = e1000_acquire_nvm_82575;
	nvm->ops.release = e1000_release_nvm_82575;
	if (nvm->word_size < (1 << 15))
		nvm->ops.read = e1000_read_nvm_eerd;
	else
		nvm->ops.read = e1000_read_nvm_spi;

	nvm->ops.write = e1000_write_nvm_spi;
	nvm->ops.validate = e1000_validate_nvm_checksum_generic;
	nvm->ops.update = e1000_update_nvm_checksum_generic;
	nvm->ops.valid_led_default = e1000_valid_led_default_82575;

	/* override generic family function pointers for specific descendants */
	switch (hw->mac.type) {
	case e1000_82580:
		nvm->ops.validate = e1000_validate_nvm_checksum_82580;
		nvm->ops.update = e1000_update_nvm_checksum_82580;
		break;
	case e1000_i350:
		nvm->ops.validate = e1000_validate_nvm_checksum_i350;
		nvm->ops.update = e1000_update_nvm_checksum_i350;
		break;
	default:
		break;
	}

	return E1000_SUCCESS;
}
/**
 * e1000_init_nvm_params_82575 - Initialize NVM function ptrs
 * @hw: pointer to the HW structure
 **/
Initialize NVM function ptrs
@hw: pointer to the HW structure
Initialize NVM function ptrs @hw : pointer to the HW structure
s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
{
	struct e1000_nvm_info *nvm = &hw->nvm;
	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
	u16 size;
	DEBUGFUNC("e1000_init_nvm_params_82575");
	size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
		     E1000_EECD_SIZE_EX_SHIFT);
	size += NVM_WORD_SIZE_BASE_SHIFT;
	if (size > 15)
		size = 15;
	nvm->word_size = 1 << size;
	if (hw->mac.type < e1000_i210) {
		nvm->opcode_bits = 8;
		nvm->delay_usec = 1;
		switch (nvm->override) {
		case e1000_nvm_override_spi_large:
			nvm->page_size = 32;
			nvm->address_bits = 16;
			break;
		case e1000_nvm_override_spi_small:
			nvm->page_size = 8;
			nvm->address_bits = 8;
			break;
		default:
			nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
			nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
					    16 : 8;
			break;
		}
		if (nvm->word_size == (1 << 15))
			nvm->page_size = 128;
		nvm->type = e1000_nvm_eeprom_spi;
	} else {
		nvm->type = e1000_nvm_flash_hw;
	}
	nvm->ops.acquire = e1000_acquire_nvm_82575;
	nvm->ops.release = e1000_release_nvm_82575;
	if (nvm->word_size < (1 << 15))
		nvm->ops.read = e1000_read_nvm_eerd;
	else
		nvm->ops.read = e1000_read_nvm_spi;
	nvm->ops.write = e1000_write_nvm_spi;
	nvm->ops.validate = e1000_validate_nvm_checksum_generic;
	nvm->ops.update = e1000_update_nvm_checksum_generic;
	nvm->ops.valid_led_default = e1000_valid_led_default_82575;
	switch (hw->mac.type) {
	case e1000_82580:
		nvm->ops.validate = e1000_validate_nvm_checksum_82580;
		nvm->ops.update = e1000_update_nvm_checksum_82580;
		break;
	case e1000_i350:
		nvm->ops.validate = e1000_validate_nvm_checksum_i350;
		nvm->ops.update = e1000_update_nvm_checksum_i350;
		break;
	default:
		break;
	}
	return E1000_SUCCESS;
}
s32 e1000_init_nvm_params_82575 ( struct e1000_hw * hw ) { struct e1000_nvm_info * nvm = & hw -> nvm ; u32 eecd = E1000_READ_REG ( hw , E1000_EECD ) ; u16 size ; DEBUGFUNC ( " " ) ; size = ( u16 ) ( ( eecd & E1000_EECD_SIZE_EX_MASK ) >> E1000_EECD_SIZE_EX_SHIFT ) ; size += NVM_WORD_SIZE_BASE_SHIFT ; if ( size > 15 ) size = 15 ; nvm -> word_size = 1 << size ; if ( hw -> mac . type < e1000_i210 ) { nvm -> opcode_bits = 8 ; nvm -> delay_usec = 1 ; switch ( nvm -> override ) { case e1000_nvm_override_spi_large : nvm -> page_size = 32 ; nvm -> address_bits = 16 ; break ; case e1000_nvm_override_spi_small : nvm -> page_size = 8 ; nvm -> address_bits = 8 ; break ; default : nvm -> page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8 ; nvm -> address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8 ; break ; } if ( nvm -> word_size == ( 1 << 15 ) ) nvm -> page_size = 128 ; nvm -> type = e1000_nvm_eeprom_spi ; } else { nvm -> type = e1000_nvm_flash_hw ; } nvm -> ops . acquire = e1000_acquire_nvm_82575 ; nvm -> ops . release = e1000_release_nvm_82575 ; if ( nvm -> word_size < ( 1 << 15 ) ) nvm -> ops . read = e1000_read_nvm_eerd ; else nvm -> ops . read = e1000_read_nvm_spi ; nvm -> ops . write = e1000_write_nvm_spi ; nvm -> ops . validate = e1000_validate_nvm_checksum_generic ; nvm -> ops . update = e1000_update_nvm_checksum_generic ; nvm -> ops . valid_led_default = e1000_valid_led_default_82575 ; switch ( hw -> mac . type ) { case e1000_82580 : nvm -> ops . validate = e1000_validate_nvm_checksum_82580 ; nvm -> ops . update = e1000_update_nvm_checksum_82580 ; break ; case e1000_i350 : nvm -> ops . validate = e1000_validate_nvm_checksum_i350 ; nvm -> ops . update = e1000_update_nvm_checksum_i350 ; break ; default : break ; } return E1000_SUCCESS ; }
e1000_init_nvm_params_82575 - Initialize NVM function ptrs
 @hw: pointer to the HW structure
e1000_init_nvm_params_82575 - Initialize NVM function ptrs @hw : pointer to the HW structure
/* Added to a constant, "size" becomes the left-shift value
	 * for setting word_size.
	 */ /* Just in case size is out of range, cap it to the largest
	 * EEPROM size supported
	 */ /* Function Pointers */ /* override generic family function pointers for specific descendants */