From patchwork Thu Nov 12 16:48:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 7603811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F098ABF90C for ; Thu, 12 Nov 2015 16:48:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CA2920828 for ; Thu, 12 Nov 2015 16:48:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1206420822 for ; Thu, 12 Nov 2015 16:48:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E26856E3A0; Thu, 12 Nov 2015 08:48:26 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f46.google.com (mail-qg0-f46.google.com [209.85.192.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC5CF6EDDB for ; Thu, 12 Nov 2015 08:48:25 -0800 (PST) Received: by qgad10 with SMTP id d10so51098066qga.3 for ; Thu, 12 Nov 2015 08:48:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=J+q8Dm/PSNUwg6FdEYvBPPnUC4oa7yjrW4z2EQvQew4=; b=Tc+l+xOqB9IgwvUiVBs9nKbi1UAZJttdJC99sX4T5Ish4ALvZCInz27eMKIqMmP5fa i3/btjLTfiB7kDGUNbSUmSkhn99ivDgNML6cd+3c9X5r0oYlyT0Sv3briZXcEAY0gJyq xmgjtXQ4tEIDsXyWaYQ1UBSWSRR/cv2Ho13n1+OD20Y0OeJ7VwHjPJaAFsENHUhmdvdP /HGY+VwawR0Laewp4CoSUxHFWXwGipmN75SJafJZeCR2h2y4ON2EDwvZdfzz1c+2xHpj ptNApU52DCytlBrZc3U6hsYbjiPEXi/FS7xKiuXn/rbx0goLIxutvw2CqqxJ5LNPy+LE qXcw== X-Received: by 10.140.101.73 with SMTP id t67mr17619940qge.71.1447346904737; Thu, 12 Nov 2015 08:48:24 -0800 (PST) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id c48sm4230000qge.49.2015.11.12.08.48.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Nov 2015 08:48:24 -0800 (PST) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] drm: add drm_pcie_get_max_link_width helper Date: Thu, 12 Nov 2015 11:48:12 -0500 Message-Id: <1447346896-1577-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 Cc: Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a helper to get the make link width of the port. Similar to the helper to get the max link speed. Signed-off-by: Alex Deucher --- drivers/gpu/drm/drm_pci.c | 20 ++++++++++++++++++++ include/drm/drmP.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index fcd2a86..a1fff11 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -410,6 +410,26 @@ int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask) } EXPORT_SYMBOL(drm_pcie_get_speed_cap_mask); +int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw) +{ + struct pci_dev *root; + u32 lnkcap; + + *mlw = 0; + if (!dev->pdev) + return -EINVAL; + + root = dev->pdev->bus->self; + + pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); + + *mlw = (lnkcap & PCI_EXP_LNKCAP_MLW) >> 4; + + DRM_INFO("probing mlw for device %x:%x = %x\n", root->vendor, root->device, lnkcap); + return 0; +} +EXPORT_SYMBOL(drm_pcie_get_max_link_width); + #else int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 0b921ae..97348eb 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1098,6 +1098,7 @@ static inline int drm_pci_set_busid(struct drm_device *dev, #define DRM_PCIE_SPEED_80 4 extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); +extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw); /* platform section */ extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);