summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorTal Gilboa <talgi@mellanox.com>2018-03-30 08:24:36 -0500
committerBjorn Helgaas <bhelgaas@google.com>2018-03-30 15:33:38 -0500
commitc70b65fb7f121da7d01f62588ce6abb4741f513f (patch)
tree383cdda6cad94b1ef9b3f116382221c3a379089e /drivers/pci/pci.c
parent6cf57be0f78e289aaf236f8bc55c40ea6c422c75 (diff)
downloadlinux-c70b65fb7f121da7d01f62588ce6abb4741f513f.tar.bz2
PCI: Add pcie_get_width_cap() to find max supported link width
Add pcie_get_width_cap() to find the max link width supported by a device. Change max_link_width_show() to use pcie_get_width_cap(). Signed-off-by: Tal Gilboa <talgi@mellanox.com> [bhelgaas: return width directly instead of error and *width, don't export outside drivers/pci] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b29d3436ee9f..43075be79388 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5191,6 +5191,24 @@ enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev)
}
/**
+ * pcie_get_width_cap - query for the PCI device's link width capability
+ * @dev: PCI device to query
+ *
+ * Query the PCI device width capability. Return the maximum link width
+ * supported by the device.
+ */
+enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev)
+{
+ u32 lnkcap;
+
+ pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap);
+ if (lnkcap)
+ return (lnkcap & PCI_EXP_LNKCAP_MLW) >> 4;
+
+ return PCIE_LNK_WIDTH_UNKNOWN;
+}
+
+/**
* pci_select_bars - Make BAR mask from the type of resource
* @dev: the PCI device for which BAR mask is made
* @flags: resource type mask to be selected