Read chip-id from pci- / pcie-card

A few months ago I had to write a small tool for programming the eeprom card rtl8139. It is basically rtl8139-diag tool shot for eeprom read / write.

This tool needs to be extended to be able to program the eeprom of the rtl8101 cards. This was not a problem since the interface to the eeprom is similar to the rtl8139 interface. Actually, the only difference is the content of the eeprom file.

What I want to implement is auto-detection, which checks if the card at a given port address is rtl8139 or rtl8101 and picks the appropriate eeprom-dump. I cannot tell the difference between these chips by reading the eeprom, since the cards to be programmed are "virgin" and the eeprom content is mostly 0xffff

.

I noticed that Linux always loads the install driver for these cards, regardless of the eeprom content. So I think I just need to read the chip ID of the card.

How to do it?

+2


source to share


1 answer


I think you can find lspci

or lspci -vv

. (You may need to be root.)

That is, if the PCI ID is set on the card and is not detected by the eeprom, you can use lspci

to get the PCI card ID and determine which card you are working with.



The parameter -n

will give you raw numbers, which will probably be more useful if you do scripting.

Alternatively, you can read from / sys / devices / pci * / * / device and vendor to find these values.

+3


source







All Articles