|
@@ -5146,6 +5146,50 @@ int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
|
|
|
}
|
|
|
EXPORT_SYMBOL(pcie_get_minimum_link);
|
|
|
|
|
|
+/**
|
|
|
+ * pcie_get_speed_cap - query for the PCI device's link speed capability
|
|
|
+ * @dev: PCI device to query
|
|
|
+ *
|
|
|
+ * Query the PCI device speed capability. Return the maximum link speed
|
|
|
+ * supported by the device.
|
|
|
+ */
|
|
|
+enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev)
|
|
|
+{
|
|
|
+ u32 lnkcap2, lnkcap;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * PCIe r4.0 sec 7.5.3.18 recommends using the Supported Link
|
|
|
+ * Speeds Vector in Link Capabilities 2 when supported, falling
|
|
|
+ * back to Max Link Speed in Link Capabilities otherwise.
|
|
|
+ */
|
|
|
+ pcie_capability_read_dword(dev, PCI_EXP_LNKCAP2, &lnkcap2);
|
|
|
+ if (lnkcap2) { /* PCIe r3.0-compliant */
|
|
|
+ if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_16_0GB)
|
|
|
+ return PCIE_SPEED_16_0GT;
|
|
|
+ else if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_8_0GB)
|
|
|
+ return PCIE_SPEED_8_0GT;
|
|
|
+ else if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_5_0GB)
|
|
|
+ return PCIE_SPEED_5_0GT;
|
|
|
+ else if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_2_5GB)
|
|
|
+ return PCIE_SPEED_2_5GT;
|
|
|
+ return PCI_SPEED_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap);
|
|
|
+ if (lnkcap) {
|
|
|
+ if (lnkcap & PCI_EXP_LNKCAP_SLS_16_0GB)
|
|
|
+ return PCIE_SPEED_16_0GT;
|
|
|
+ else if (lnkcap & PCI_EXP_LNKCAP_SLS_8_0GB)
|
|
|
+ return PCIE_SPEED_8_0GT;
|
|
|
+ else if (lnkcap & PCI_EXP_LNKCAP_SLS_5_0GB)
|
|
|
+ return PCIE_SPEED_5_0GT;
|
|
|
+ else if (lnkcap & PCI_EXP_LNKCAP_SLS_2_5GB)
|
|
|
+ return PCIE_SPEED_2_5GT;
|
|
|
+ }
|
|
|
+
|
|
|
+ return PCI_SPEED_UNKNOWN;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* pci_select_bars - Make BAR mask from the type of resource
|
|
|
* @dev: the PCI device for which BAR mask is made
|