summaryrefslogtreecommitdiffstats
path: root/driver/pcibus.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2016-03-02 19:37:30 +0100
committerSuren A. Chilingaryan <csa@suren.me>2016-03-02 19:37:30 +0100
commit1120e8745ccd3e512fe2016c9e5092fcd378490a (patch)
tree0e89ac6cd82c213a78d79d10d3fecff06f21127d /driver/pcibus.c
parent01e857cca352e73243d00b62a0c248a35cea6b71 (diff)
downloadpcitool-1120e8745ccd3e512fe2016c9e5092fcd378490a.tar.gz
pcitool-1120e8745ccd3e512fe2016c9e5092fcd378490a.tar.bz2
pcitool-1120e8745ccd3e512fe2016c9e5092fcd378490a.tar.xz
pcitool-1120e8745ccd3e512fe2016c9e5092fcd378490a.zip
Restructure driver headers
Diffstat (limited to 'driver/pcibus.c')
-rw-r--r--driver/pcibus.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/driver/pcibus.c b/driver/pcibus.c
new file mode 100644
index 0000000..f28f527
--- /dev/null
+++ b/driver/pcibus.c
@@ -0,0 +1,25 @@
+#include <linux/pci.h>
+
+int pcidriver_pcie_get_mps(struct pci_dev *dev)
+{
+ u16 ctl;
+
+ pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl);
+
+ return 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
+}
+
+int pcidriver_pcie_set_mps(struct pci_dev *dev, int mps)
+{
+ u16 v;
+
+ if (mps < 128 || mps > 4096 || !is_power_of_2(mps))
+ return -EINVAL;
+
+ v = ffs(mps) - 8;
+ if (v > dev->pcie_mpss)
+ return -EINVAL;
+ v <<= 5;
+
+ return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_PAYLOAD, v);
+}