FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_seeprom_read - read a VPD EEPROM location
 *	@adapter: adapter to read
 *	@addr: EEPROM address
 *	@data: where to store the read data
 *
 *	Read a 32-bit word from a location in VPD EEPROM using the card's PCI
 *	VPD ROM capability.  A zero is written to the flag bit when the
 *	address is written to the control register.  The hardware device will
 *	set the flag to 1 when 4 bytes have been read into the data register.
 */
read a VPD EEPROM location
@adapter: adapter to read
@addr: EEPROM address
@data: where to store the read data

Read a 32-bit word from a location in VPD EEPROM using the card's PCI
VPD ROM capability.  A zero is written to the flag bit when the
address is written to the control register.  The hardware device will
set the flag to 1 when 4 bytes have been read into the data register.
read a VPD EEPROM location @adapter : adapter to read @addr : EEPROM address @data : where to store the read data Read a 32 - bit word from a location in VPD EEPROM using the card ' s PCI VPD ROM capability . A zero is written to the flag bit when the address is written to the control register . The hardware device will set the flag to 1 when 4 bytes have been read into the data register .
int t3_seeprom_read(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_2(adapter, base + PCI_VPD_ADDR, (u16)addr);
	do {
		udelay(10);
		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, "reading EEPROM address 0x%x failed\n", addr);
		return -EIO;
	}
	t3_os_pci_read_config_4(adapter, base + PCI_VPD_DATA, data);
	*data = le32_to_cpu(*data);
	return 0;
}
int t3_seeprom_read ( 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_2 ( adapter , base + PCI_VPD_ADDR , ( u16 ) addr ) ; do { udelay ( 10 ) ; 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 ; } t3_os_pci_read_config_4 ( adapter , base + PCI_VPD_DATA , data ) ; * data = le32_to_cpu ( * data ) ; return 0 ; }
t3_seeprom_read - read a VPD EEPROM location
      @adapter: adapter to read
      @addr: EEPROM address
      @data: where to store the read data
t3_seeprom_read - read a VPD EEPROM location @adapter : adapter to read @addr : EEPROM address @data : where to store the read data