diff options
author | Yu Zhao <yu.zhao@intel.com> | 2008-11-22 02:41:27 +0800 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-01-07 11:13:04 -0800 |
commit | 613e7ed6f72b1a115f7ece8ce1b66cf095de1348 (patch) | |
tree | 2af16f01cbf78f1de6b858788091a72fa57af6c8 /drivers/pci/pci.c | |
parent | 3789fa8a2e534523c896a32a9f27f78d52ad7d82 (diff) | |
download | op-kernel-dev-613e7ed6f72b1a115f7ece8ce1b66cf095de1348.zip op-kernel-dev-613e7ed6f72b1a115f7ece8ce1b66cf095de1348.tar.gz |
PCI: add a new function to map BAR offsets
Add a function to map a given resource number to a corresponding
register so drivers can get the offset and type of device specific BARs.
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index deeab19..7e9c0f3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2201,6 +2201,28 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags) return bars; } +/** + * pci_resource_bar - get position of the BAR associated with a resource + * @dev: the PCI device + * @resno: the resource number + * @type: the BAR type to be filled in + * + * Returns BAR position in config space, or 0 if the BAR is invalid. + */ +int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type) +{ + if (resno < PCI_ROM_RESOURCE) { + *type = pci_bar_unknown; + return PCI_BASE_ADDRESS_0 + 4 * resno; + } else if (resno == PCI_ROM_RESOURCE) { + *type = pci_bar_mem32; + return dev->rom_base_reg; + } + + dev_err(&dev->dev, "BAR: invalid resource #%d\n", resno); + return 0; +} + static void __devinit pci_no_domains(void) { #ifdef CONFIG_PCI_DOMAINS |