diff options
-rw-r--r-- | drivers/gpu/drm/drm_pci.c | 49 | ||||
-rw-r--r-- | include/drm/drmP.h | 5 |
2 files changed, 54 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index 13f3d936472..5320364582c 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c | |||
@@ -465,3 +465,52 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) | |||
465 | DRM_INFO("Module unloaded\n"); | 465 | DRM_INFO("Module unloaded\n"); |
466 | } | 466 | } |
467 | EXPORT_SYMBOL(drm_pci_exit); | 467 | EXPORT_SYMBOL(drm_pci_exit); |
468 | |||
469 | int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask) | ||
470 | { | ||
471 | struct pci_dev *root; | ||
472 | int pos; | ||
473 | u32 lnkcap, lnkcap2; | ||
474 | |||
475 | *mask = 0; | ||
476 | if (!dev->pdev) | ||
477 | return -EINVAL; | ||
478 | |||
479 | if (!pci_is_pcie(dev->pdev)) | ||
480 | return -EINVAL; | ||
481 | |||
482 | root = dev->pdev->bus->self; | ||
483 | |||
484 | pos = pci_pcie_cap(root); | ||
485 | if (!pos) | ||
486 | return -EINVAL; | ||
487 | |||
488 | /* we've been informed via and serverworks don't make the cut */ | ||
489 | if (root->vendor == PCI_VENDOR_ID_VIA || | ||
490 | root->vendor == PCI_VENDOR_ID_SERVERWORKS) | ||
491 | return -EINVAL; | ||
492 | |||
493 | pci_read_config_dword(root, pos + PCI_EXP_LNKCAP, &lnkcap); | ||
494 | pci_read_config_dword(root, pos + PCI_EXP_LNKCAP2, &lnkcap2); | ||
495 | |||
496 | lnkcap &= PCI_EXP_LNKCAP_SLS; | ||
497 | lnkcap2 &= 0xfe; | ||
498 | |||
499 | if (lnkcap2) { /* PCIE GEN 3.0 */ | ||
500 | if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_2_5GB) | ||
501 | *mask |= DRM_PCIE_SPEED_25; | ||
502 | if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_5_0GB) | ||
503 | *mask |= DRM_PCIE_SPEED_50; | ||
504 | if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_8_0GB) | ||
505 | *mask |= DRM_PCIE_SPEED_80; | ||
506 | } else { | ||
507 | if (lnkcap & 1) | ||
508 | *mask |= DRM_PCIE_SPEED_25; | ||
509 | if (lnkcap & 2) | ||
510 | *mask |= DRM_PCIE_SPEED_50; | ||
511 | } | ||
512 | |||
513 | DRM_INFO("probing gen 2 caps for device %x:%x = %x/%x\n", root->vendor, root->device, lnkcap, lnkcap2); | ||
514 | return 0; | ||
515 | } | ||
516 | EXPORT_SYMBOL(drm_pcie_get_speed_cap_mask); | ||
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 31ad880ca2e..e4e3be3b946 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1761,6 +1761,11 @@ extern int drm_get_pci_dev(struct pci_dev *pdev, | |||
1761 | const struct pci_device_id *ent, | 1761 | const struct pci_device_id *ent, |
1762 | struct drm_driver *driver); | 1762 | struct drm_driver *driver); |
1763 | 1763 | ||
1764 | #define DRM_PCIE_SPEED_25 1 | ||
1765 | #define DRM_PCIE_SPEED_50 2 | ||
1766 | #define DRM_PCIE_SPEED_80 4 | ||
1767 | |||
1768 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); | ||
1764 | 1769 | ||
1765 | /* platform section */ | 1770 | /* platform section */ |
1766 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); | 1771 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |