linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lucaskt@linux.vnet.ibm.com
To: dri-devel@lists.freedesktop.org
Cc: linux-pci@vger.kernel.org,
	Alex Deucher <alexander.deucher@amd.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	brking@linux.vnet.ibm.com, cascardo@linux.vnet.ibm.com,
	Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>
Subject: [PATCH 2/2] ppc64: Add arch-specific pcie_get_speed_cap_mask
Date: Thu, 14 Mar 2013 14:45:47 -0300	[thread overview]
Message-ID: <1363283147-8852-3-git-send-email-lucaskt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1363283147-8852-1-git-send-email-lucaskt@linux.vnet.ibm.com>

From: Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>

Betters support for gen2 speed detections on PCI buses on ppc64
architectures.

Signed-off-by: Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/pci.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 0b580f4..58469fe 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/string.h>
+#include <linux/device.h>
 
 #include <asm/eeh.h>
 #include <asm/pci-bridge.h>
@@ -108,3 +109,34 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 			 fixup_winbond_82c105);
+
+int pcibios_get_speed_cap_mask(struct pci_dev *dev, u32 *mask)
+{
+	struct device_node *dn, *pdn;
+	const uint32_t *pcie_link_speed_stats = NULL;
+
+	*mask = 0;
+	dn = pci_bus_to_OF_node(dev->bus);
+
+	/* Find nearest ibm,pcie-link-speed-stats, walking up the device tree */
+	for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
+		pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn,
+			"ibm,pcie-link-speed-stats", NULL);
+		if (pcie_link_speed_stats != NULL)
+			break;
+	}
+
+	if (pcie_link_speed_stats == NULL) {
+		dev_info(&dev->dev, "no ibm,pcie-link-speed-stats property\n");
+		return -EINVAL;
+	}
+
+	switch (pcie_link_speed_stats[0]) {
+		case 0x02:
+		*mask |= PCIE_SPEED_50;
+		case 0x01:
+		*mask |= PCIE_SPEED_25;
+	}
+
+	return 0;
+}
-- 
1.7.4.4


  parent reply	other threads:[~2013-03-14 17:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 17:45 PCI Speed Cap Fixes for ppc64 lucaskt
2013-03-14 17:45 ` [PATCH 1/2] drm: Move drm_pcie_get_speed_cap_mask to PCI lucaskt
2013-03-14 18:55   ` Thadeu Lima de Souza Cascardo
2013-03-14 17:45 ` lucaskt [this message]
2013-03-14 18:52   ` [PATCH 2/2] ppc64: Add arch-specific pcie_get_speed_cap_mask Thadeu Lima de Souza Cascardo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363283147-8852-3-git-send-email-lucaskt@linux.vnet.ibm.com \
    --to=lucaskt@linux.vnet.ibm.com \
    --cc=alexander.deucher@amd.com \
    --cc=bhelgaas@google.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=cascardo@linux.vnet.ibm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).