From patchwork Fri Apr 1 17:17:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 8726901 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9EA019F38C for ; Fri, 1 Apr 2016 17:14:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0C0B203B6 for ; Fri, 1 Apr 2016 17:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A58472022A for ; Fri, 1 Apr 2016 17:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752360AbcDAROa (ORCPT ); Fri, 1 Apr 2016 13:14:30 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35388 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbcDARO3 (ORCPT ); Fri, 1 Apr 2016 13:14:29 -0400 Received: by mail-pf0-f175.google.com with SMTP id n5so95549709pfn.2 for ; Fri, 01 Apr 2016 10:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=1a1ddeBbxrQfFglzpoIlv7NGBzCVA+iK/JmHJ0vLGIU=; b=w2cf5FTi4RZHq1uuKzhxlQiVx7+WkW7pCmgmhES8jBFcMl52sQrjbA1NwIQu3y5ZZ+ xzcxVlDzvl/6blpyroiNdU8snD7Lnur1BkM73dZn3U78n88BdNA28FLiKXRDi73KIv1t iwjdeuU7uDAJggRiYNxMlYZ+22Hb78KP12sLiBbFgGlwbDZFIE/6ZkV1MC2csUqxIw23 bYyLONsshCc6qypIAAUDvjfhSKFui9vmjjBdZmFlj3SHlKqJ2m0PxI0fnLY7IAC7ubS2 5jgNCAWOb5KucqKbCXiEm70DXf0+A9jMpPmXZr73/XcHmfKLli1mpNZdoWAz9AR3pZXG VfeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1a1ddeBbxrQfFglzpoIlv7NGBzCVA+iK/JmHJ0vLGIU=; b=NjmlHbN6JsCfDqcWKyFguzSD5fmy8zeL/2cPUgGwMaKbWZOeYiS2/bQUoJVcXdNlhW G1oXzUL8lEJ1QXA8VZMAZHgvvASe+whXo2nFsWlvzmio3w94zldHl7TZ2DW0zPQQlKo/ Xww6NtABVi5HMt1zV3JQg77DaeUbJ1AhfxgpicynsPkBRbkLQwwmAY+BNsUEZfM4j0Oa VtMzveGcTIXTzyNwNIBmDWVCw+bYtkqxZc4TGP2cGzyZuVhId/gR3fNOW50PwA7dlBrq SXkjVtfscdz5a9isOrWF5P9EH7MgIk8hg07tqY3EydkXf1HZHXRMjRyJ1fdoOqsOgPWZ hNwQ== X-Gm-Message-State: AD7BkJI9SbrrxAP2/t8EpxCOoZImdkF064+XgCL1VJTJ+babYDS/RA/45XHNV4beSZnD3A== X-Received: by 10.98.34.200 with SMTP id p69mr170450pfj.114.1459530868628; Fri, 01 Apr 2016 10:14:28 -0700 (PDT) Received: from tharvey.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by smtp.gmail.com with ESMTPSA id dy6sm23346308pab.48.2016.04.01.10.14.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 10:14:27 -0700 (PDT) From: Tim Harvey To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Lucas Stach , Fabio Estevam , Zhu Richard , Akshay Bhat , Rob Herring , Shawn Guo Subject: [PATCH v3] PCI: imx6: add dt prop for link gen, default to gen1 Date: Fri, 1 Apr 2016 10:17:09 -0700 Message-Id: <1459531029-16208-1-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 Freescale has stated [1] that the LVDS clock source of the IMX6 does not pass the PCI Gen2 clock jitter test, therefore unless an external Gen2 compliant external clock source is present and supplied back to the IMX6 PCIe core via LVDS CLK1/CLK2 you can not claim Gen2 compliance. Add a dt property to specify gen1 vs gen2 and check this before allowing a Gen2 link. We default to Gen1 if the property is not present because at this time there are no IMX6 boards in mainline that 'input' a clock on LVDS CLK1/CLK2. In order to be Gen2 compliant on IMX6 you need to: - have a Gen2 compliant external clock generator and route that clock back to either LVDS CLK1 or LVDS CLK2 as an input. (see IMX6SX-SabreSD reference design) - specify this clock in the pcie node in the dt (ie IMX6QDL_CLK_LVDS1_IN or IMX6QDL_CLK_LVDS2_IN instead of IMX6QDL_CLK_LVDS1_GATE which configures it as a CLK output) [1] https://community.freescale.com/message/453209 Cc: Lucas Stach Cc: Bjorn Helgaas Cc: Fabio Estevam Cc: Zhu Richard Cc: Akshay Bhat Cc: Rob Herring Cc: Shawn Guo Signed-off-by: Tim Harvey --- v3: - added note in dt bindings doc that we limit to gen1 unless this is specified as gen2 capable - move property to imx6 pcie phy instead of designware core - don't use &ret as temp storage as of_property_read_u32() doesn't change the outval if property isn't found v2: - moved dt property to designware core Signed-off-by: Tim Harvey --- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 6 ++++++ drivers/pci/host/pci-imx6.c | 23 ++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt index 6fbba53..4ffaf19 100644 --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt @@ -13,6 +13,12 @@ Required properties: - clock-names: Must include the following additional entries: - "pcie_phy" +Optional properties: +- max-link-speed: Specify PCI gen for link capability. Must be '2' for + gen2, otherwise will default to gen1. Note that the IMX6 LVDS clock outputs + do not meet gen2 jitter requirements and thus for gen2 capability a gen2 + compliant clock generator should be used and configured. + Example: pcie@0x01000000 { diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 88ccfea..d1bfcff 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -39,6 +39,7 @@ struct imx6_pcie { struct pcie_port pp; struct regmap *iomuxc_gpr; void __iomem *mem_base; + int link_gen; }; /* PCIe Root Complex registers (memory-mapped) */ @@ -393,11 +394,15 @@ static int imx6_pcie_establish_link(struct pcie_port *pp) if (ret) return ret; - /* Allow Gen2 mode after the link is up. */ - tmp = readl(pp->dbi_base + PCIE_RC_LCR); - tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK; - tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2; - writel(tmp, pp->dbi_base + PCIE_RC_LCR); + if (imx6_pcie->link_gen == 2) { + /* Allow Gen2 mode after the link is up. */ + tmp = readl(pp->dbi_base + PCIE_RC_LCR); + tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK; + tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2; + writel(tmp, pp->dbi_base + PCIE_RC_LCR); + } else { + dev_info(pp->dev, "Link: Gen2 disabled\n"); + } /* * Start Directed Speed Change so the best possible speed both link @@ -421,7 +426,7 @@ static int imx6_pcie_establish_link(struct pcie_port *pp) } tmp = readl(pp->dbi_base + PCIE_RC_LCSR); - dev_dbg(pp->dev, "Link up, Gen=%i\n", (tmp >> 16) & 0xf); + dev_info(pp->dev, "Link up, Gen%i\n", (tmp >> 16) & 0xf); return 0; } @@ -622,6 +627,12 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) return PTR_ERR(imx6_pcie->iomuxc_gpr); } + /* Limit link speed */ + ret = of_property_read_u32(pp->dev->of_node, "max-link-speed", + &imx6_pcie->link_gen); + if (ret) + imx6_pcie->link_gen = -1; + ret = imx6_add_pcie_port(pp, pdev); if (ret < 0) return ret;