FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_seeprom_write - write a VPD EEPROM location
 *	@adapter: adapter to write
 *	@addr: EEPROM address
 *	@data: value to write
 *
 *	Write a 32-bit word to a location in VPD EEPROM using the card's PCI
 *	VPD ROM capability.
 */
write a VPD EEPROM location
@adapter: adapter to write
@addr: EEPROM address
@data: value to write

Write a 32-bit word to a location in VPD EEPROM using the card's PCI
VPD ROM capability.
write a VPD EEPROM location @adapter : adapter to write @addr : EEPROM address @data : value to write Write a 32 - bit word to a location in VPD EEPROM using the card ' s PCI VPD ROM capability .
int t3_seeprom_write(adapter_t *adapter, u32 addr, u32 data)
{
	u16 val;
	int attempts = EEPROM_MAX_POLL;
	unsigned int base = adapter->params.pci.vpd_cap_addr;
	if ((addr >= EEPROMSIZE && addr != EEPROM_STAT_ADDR) || (addr & 3))
		return -EINVAL;
	t3_os_pci_write_config_4(adapter, base + PCI_VPD_DATA,
				 cpu_to_le32(data));
	t3_os_pci_write_config_2(adapter, base + PCI_VPD_ADDR,
				 (u16)addr | PCI_VPD_ADDR_F);
	do {
		msleep(1);
		t3_os_pci_read_config_2(adapter, base + PCI_VPD_ADDR, &val);
	} while ((val & PCI_VPD_ADDR_F) && --attempts);
	if (val & PCI_VPD_ADDR_F) {
		CH_ERR(adapter, "write to EEPROM address 0x%x failed\n", addr);
		return -EIO;
	}
	return 0;
}
int t3_seeprom_write ( adapter_t * adapter , u32 addr , u32 data ) { u16 val ; int attempts = EEPROM_MAX_POLL ; unsigned int base = adapter -> params . pci . vpd_cap_addr ; if ( ( addr >= EEPROMSIZE && addr != EEPROM_STAT_ADDR ) || ( addr & 3 ) ) return - EINVAL ; t3_os_pci_write_config_4 ( adapter , base + PCI_VPD_DATA , cpu_to_le32 ( data ) ) ; t3_os_pci_write_config_2 ( adapter , base + PCI_VPD_ADDR , ( u16 ) addr | PCI_VPD_ADDR_F ) ; do { msleep ( 1 ) ; t3_os_pci_read_config_2 ( adapter , base + PCI_VPD_ADDR , & val ) ; } while ( ( val & PCI_VPD_ADDR_F ) && -- attempts ) ; if ( val & PCI_VPD_ADDR_F ) { CH_ERR ( adapter , " \n " , addr ) ; return - EIO ; } return 0 ; }
t3_seeprom_write - write a VPD EEPROM location
      @adapter: adapter to write
      @addr: EEPROM address
      @data: value to write
t3_seeprom_write - write a VPD EEPROM location @adapter : adapter to write @addr : EEPROM address @data : value to write