summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci_iomap.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-04 17:26:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-04 17:26:05 +0200
commit45d593bc5ec78e26e3a967517ed7a51f27c8b91f (patch)
tree197cc45c686dc86b4537ce55313d5ec074671918 /drivers/pci/pci_iomap.c
parent6724928c6972842b73962dc5af70d26de9969582 (diff)
parent988ecf42691e101a35ecae83d26253e9590d14c6 (diff)
downloadbarebox-45d593bc5ec78e26e3a967517ed7a51f27c8b91f.tar.gz
barebox-45d593bc5ec78e26e3a967517ed7a51f27c8b91f.tar.xz
Merge branch 'for-next/mips'
Diffstat (limited to 'drivers/pci/pci_iomap.c')
-rw-r--r--drivers/pci/pci_iomap.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/pci/pci_iomap.c b/drivers/pci/pci_iomap.c
new file mode 100644
index 0000000000..a56f61dc1a
--- /dev/null
+++ b/drivers/pci/pci_iomap.c
@@ -0,0 +1,29 @@
+/*
+ * Implement the default iomap interfaces
+ *
+ * (C) Copyright 2004 Linus Torvalds
+ */
+#include <linux/pci.h>
+#include <io.h>
+
+#include <module.h>
+
+/**
+ * pci_iomap - create a virtual mapping cookie for a PCI BAR
+ * @dev: PCI device that owns the BAR
+ * @bar: BAR number
+ *
+ * Using this function you will get a __iomem address to your device BAR.
+ * You can access it using ioread*() and iowrite*(). These functions hide
+ * the details if this is a MMIO or PIO address space and will just do what
+ * you expect from them in the correct way.
+ *
+ */
+void __iomem *pci_iomap(struct pci_dev *dev, int bar)
+{
+ struct pci_bus *bus = dev->bus;
+ resource_size_t start = pci_resource_start(dev, bar);
+
+ return (void *)bus->ops->res_start(bus, start);
+}
+EXPORT_SYMBOL(pci_iomap);