summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-11-29 13:17:53 -0700
committerSimon Glass <sjg@chromium.org>2016-01-12 10:19:09 -0700
commitbab17cf143c4888d03eb51f20aa6b86210448608 (patch)
tree8056619271bf91f76b5e76bb24bfc782321f21f0 /drivers/pci
parenta0eb835635abe0952529e3eb5207a24ac36fa000 (diff)
downloadu-boot-imx-bab17cf143c4888d03eb51f20aa6b86210448608.zip
u-boot-imx-bab17cf143c4888d03eb51f20aa6b86210448608.tar.gz
u-boot-imx-bab17cf143c4888d03eb51f20aa6b86210448608.tar.bz2
dm: pci: Add a function to read a PCI BAR
Add a driver-model function for reading the PCI BAR from a device. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-uclass.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index dea0cb6..7a886f2 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1055,6 +1055,19 @@ int pci_get_regions(struct udevice *dev, struct pci_region **iop,
return (*iop != NULL) + (*memp != NULL) + (*prefp != NULL);
}
+u32 dm_pci_read_bar32(struct udevice *dev, int barnum)
+{
+ u32 addr;
+ int bar;
+
+ bar = PCI_BASE_ADDRESS_0 + barnum * 4;
+ dm_pci_read_config32(dev, bar, &addr);
+ if (addr & PCI_BASE_ADDRESS_SPACE_IO)
+ return addr & PCI_BASE_ADDRESS_IO_MASK;
+ else
+ return addr & PCI_BASE_ADDRESS_MEM_MASK;
+}
+
UCLASS_DRIVER(pci) = {
.id = UCLASS_PCI,
.name = "pci",