From patchwork Thu Nov 5 14:58:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 7562111 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 C254FBEEA4 for ; Thu, 5 Nov 2015 14:57:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D1082085E for ; Thu, 5 Nov 2015 14:57:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0843E2084E for ; Thu, 5 Nov 2015 14:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161410AbbKEO5y (ORCPT ); Thu, 5 Nov 2015 09:57:54 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:35352 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032776AbbKEO5v (ORCPT ); Thu, 5 Nov 2015 09:57:51 -0500 Received: by pasz6 with SMTP id z6so93238649pas.2 for ; Thu, 05 Nov 2015 06:57:50 -0800 (PST) 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=lGT3hhu8JYNusL74++ieN4fEsvGV7wX/M7nbqvUt5DE=; b=i2EghaBdlZf+RB3K8nZRKI6LZhvA15rxF3ngbfIfnD9Ey/inkkS205XKfHuo45nsJP SGoR6pq3se49mYVQ4Ks62q+Dd/BlhWRSAlu6uBCEkNXqZIURc2zzCfX2fmlJQL1X9RBB 1NDIC81PHOd3vUB4HPeXL26eGv7EoMjPsLHoPS1QS0vllCb+wrLOeySKVUKR5jvYWo63 SYRRx7Cf8RkiCHecse5Mz7Z1DwW9OemF7qWaAfHXSgc0iC7cw018UFex4jYqTWitX0Pc DQgbSD2EzdxIKpEXfye8B8QXCnNFKtevXfxbZ4PtW2VCVhR9PcyS2jeWwoS9obwyAQ2i kQSg== 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=lGT3hhu8JYNusL74++ieN4fEsvGV7wX/M7nbqvUt5DE=; b=WKou2WbQqMyExx/Dz2BUUnzaHJq/5vj/RomEB9M5w/EQNoJnc106Os2sUDb36he/i/ zqNG3XUnqFC6A43GzHicZTkEMYeaPKh97s5HdBxzHa6C1YQZnkKEWcLQstxi8rJG4FoS O9mseTSrY1A1nW3IbsIERh+4xzVzI559FzlBYy3zfCln5SxVcC53OdP1BupKtYstEW0I 5wwjYcQzNAjewCTto4SbOtsBp9MhrTJWi9a6kpco/Q6R0yK9LOroW6Dc+AmHQFu7W+Dv tXYtT8kz0/U5Kw+WDnTaWm1TI7XYYRWbI1blgGoIxdu6DfSiDwJyqMHLRCTwJGK0UH9T jllQ== X-Gm-Message-State: ALoCoQkFVzeWlnZzuHxGazP5mzVBJTkN47bI3mbTZr/aQkyTvJXiukdyptilVswvLXKS7QtflMUg X-Received: by 10.66.172.6 with SMTP id ay6mr9916478pac.44.1446735470771; Thu, 05 Nov 2015 06:57:50 -0800 (PST) Received: from tharvey.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by smtp.gmail.com with ESMTPSA id yz3sm8459971pbb.37.2015.11.05.06.57.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 06:57:50 -0800 (PST) From: Tim Harvey To: Lucas Stach , Bjorn Helgaas , linux-pci@vger.kernel.org Cc: Fabio Estevam Subject: [PATCH RFC] PCI: imx6: add dt prop for link gen, default to gen1 Date: Thu, 5 Nov 2015 06:58:01 -0800 Message-Id: <1446735481-27326-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=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 Signed-off-by: Tim Harvey This is an RFC because I'm assuming the decision to default to Gen1 link only is going to ruffle some feathers. My understanding is that if you do not use an external Gen2 compliant clockgen for peripepherals 'and' the IMX6 core you should not claim Gen2 compliance. This was not obvious on original IMX6 reference designs and I believe the jitter issue was discovered by Freescale later and future reference designs were modified to state you need an ext clockgen for Gen2 compliance. Reviewed-by: Fabio Estevam --- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 3 +++ drivers/pci/host/pci-imx6.c | 22 ++++++++++++++++------ 2 files changed, 19 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..7dff332 100644 --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt @@ -12,6 +12,8 @@ Required properties: - "msi": The interrupt that is asserted when an MSI is received - clock-names: Must include the following additional entries: - "pcie_phy" +- fsl,max-link-speed: Specify PCI gen. Defaults to 1, can be 2 if board has + an external clock generator fed back to PCIe core. Example: @@ -37,4 +39,5 @@ Example: <0 0 0 4 &intc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks 144>, <&clks 206>, <&clks 189>; clock-names = "pcie", "pcie_bus", "pcie_phy"; + fsl,max-link-speed = <2>; }; diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 22e8224..16412c4 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_cap; }; /* 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_cap == 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; } @@ -591,6 +596,11 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) } } + /* default link capability to gen1 */ + imx6_pcie->link_cap = 1; + if (of_property_read_u32(np, "fsl,max-link-speed", &ret) == 0) + imx6_pcie->link_cap = ret; + /* Fetch clocks */ imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy"); if (IS_ERR(imx6_pcie->pcie_phy)) {