anbu anbu - 1 year ago 98
C Question

What is the difference ioread32 and pci_bus_read_config_word wrapper function? Which is one is safer to use in pci device driver?

In pci device driver, I am trying to read PCI_COMMAND register using ioread32 in MIPS platform but Data bus error is thrown. I ve verified for valid parameter before passing into ioread32. Any help on this? Does using pci_bus_read_config_word in this case prevent Data bus error?

Answer Source

It depends on your platform on what kind of support it has for configuration space access. There two types of access -

1 - Legacy PCI configuration mechanism - This uses IO port address to access the endpoint configuration space. You can use ioread32() for this.
2 - Enhanced PCI configuration mechanism - This uses memory mapped IO. You can use simple pointer operations to read from this.

Since its difficult to find out the access mechanism support, its better to use pci API's (which in this case is pci_bus_read_config_word) than use ioread32().

pci_*() API will take care of the access method valid for that platform.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download