summaryrefslogtreecommitdiff
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorBecky Bruce <beckyb@kernel.crashing.org>2009-02-03 18:10:50 -0600
committerWolfgang Denk <wd@denx.de>2009-02-10 00:27:13 +0100
commit6e61fae4d360a1380b63e7d007b31477e366bcce (patch)
tree4cbd95c1652fa3aad0ceb4a7956b33489a569bf6 /drivers/pci/pci.c
parent2ecca3401775b125c3b9ff65766befb23989414b (diff)
downloadu-boot-imx-6e61fae4d360a1380b63e7d007b31477e366bcce.zip
u-boot-imx-6e61fae4d360a1380b63e7d007b31477e366bcce.tar.gz
u-boot-imx-6e61fae4d360a1380b63e7d007b31477e366bcce.tar.bz2
drivers/pci: Create pci_map_bar function
It is no longer always true that the pci bus address can be used as the virtual address for pci accesses. pci_map_bar() is created to return the virtual address for a pci region. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 06b56b0..fffca49 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -116,6 +116,25 @@ PCI_READ_VIA_DWORD_OP(word, u16 *, 0x02)
PCI_WRITE_VIA_DWORD_OP(byte, u8, 0x03, 0x000000ff)
PCI_WRITE_VIA_DWORD_OP(word, u16, 0x02, 0x0000ffff)
+/* Get a virtual address associated with a BAR region */
+void *pci_map_bar(pci_dev_t pdev, int bar, int flags)
+{
+ pci_addr_t pci_bus_addr;
+ u32 bar_response;
+
+ /* read BAR address */
+ pci_read_config_dword(pdev, bar, &bar_response);
+ pci_bus_addr = (pci_addr_t)(bar_response & ~0xf);
+
+ /*
+ * Pass "0" as the length argument to pci_bus_to_virt. The arg
+ * isn't actualy used on any platform because u-boot assumes a static
+ * linear mapping. In the future, this could read the BAR size
+ * and pass that as the size if needed.
+ */
+ return pci_bus_to_virt(pdev, pci_bus_addr, flags, 0, MAP_NOCACHE);
+}
+
/*
*
*/