From patchwork Sun Apr 15 18:56:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Nilsson X-Patchwork-Id: 898300 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axis.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40PLMp1jDKz9s1R for ; Mon, 16 Apr 2018 04:56:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbeDOS4Z (ORCPT ); Sun, 15 Apr 2018 14:56:25 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:53623 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554AbeDOS4Y (ORCPT ); Sun, 15 Apr 2018 14:56:24 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 49ADC182B2; Sun, 15 Apr 2018 20:56:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id TmSDfxc1qqD0; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 70E8B1814A; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C6041A069; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FF0D1A067; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: from lnxjespern3.se.axis.com (lnxjespern3.se.axis.com [10.88.4.8]) by seth.se.axis.com (Postfix) with ESMTP id 32F76301F; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Received: by lnxjespern3.se.axis.com (Postfix, from userid 363) id 2E5A8800EE; Sun, 15 Apr 2018 20:56:21 +0200 (CEST) Date: Sun, 15 Apr 2018 20:56:21 +0200 From: Jesper Nilsson To: Bjorn Helgaas , Rob Herring , Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@axis.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI: dwc: artpec6: Add reset-gpios for PERST# control Message-ID: <20180415185621.GR16746@axis.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some devices need an optional external gpio for controlling the PERST# signal to bring up for example a PCIe switch after a soft reset. Without this, some boards (the ARTPEC-6 master devboard) would not get the PCIe link back after a soft reset. Signed-off-by: Jesper Nilsson Reviewed-by: Rob Herring --- .../devicetree/bindings/pci/axis,artpec6-pcie.txt | 4 ++++ drivers/pci/dwc/pcie-artpec6.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/pci/axis,artpec6-pcie.txt b/Documentation/devicetree/bindings/pci/axis,artpec6-pcie.txt index 979dc7b6cfe8..810bd461e81c 100644 --- a/Documentation/devicetree/bindings/pci/axis,artpec6-pcie.txt +++ b/Documentation/devicetree/bindings/pci/axis,artpec6-pcie.txt @@ -21,6 +21,10 @@ and thus inherits all the common properties defined in designware-pcie.txt. - axis,syscon-pcie: A phandle pointing to the ARTPEC-6 system controller, used to enable and control the Synopsys IP. +Optional properties: + +- reset-gpios: GPIO to generate PCIe PERST# assert and deassert signal. + Example: pcie@f8050000 { diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index 93b3df9ed1b5..1eada6d1a381 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "pcie-designware.h" @@ -35,6 +37,7 @@ struct artpec6_pcie { void __iomem *phy_base; /* DT phy */ enum artpec_pcie_variants variant; enum dw_pcie_device_mode mode; + struct gpio_desc *reset; }; struct artpec_pcie_of_data { @@ -350,6 +353,13 @@ static void artpec6_pcie_deassert_core_reset(struct artpec6_pcie *artpec6_pcie) } artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); usleep_range(100, 200); + + /* Some boards don't have PCIe reset hardwired, use a GPIO insted. */ + if (artpec6_pcie->reset) { + gpiod_set_value_cansleep(artpec6_pcie->reset, 1); + msleep(100); + gpiod_set_value_cansleep(artpec6_pcie->reset, 0); + } } static void artpec6_pcie_enable_interrupts(struct artpec6_pcie *artpec6_pcie) @@ -513,6 +523,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev) const struct artpec_pcie_of_data *data; enum artpec_pcie_variants variant; enum dw_pcie_device_mode mode; + struct device_node *node = dev->of_node; match = of_match_device(artpec6_pcie_of_match, dev); if (!match) @@ -548,11 +559,18 @@ static int artpec6_pcie_probe(struct platform_device *pdev) return PTR_ERR(artpec6_pcie->phy_base); artpec6_pcie->regmap = - syscon_regmap_lookup_by_phandle(dev->of_node, + syscon_regmap_lookup_by_phandle(node, "axis,syscon-pcie"); if (IS_ERR(artpec6_pcie->regmap)) return PTR_ERR(artpec6_pcie->regmap); + artpec6_pcie->reset = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(artpec6_pcie->reset)) { + dev_err(dev, "Failed to request reset gpio\n"); + return PTR_ERR(artpec6_pcie->reset); + } + platform_set_drvdata(pdev, artpec6_pcie); switch (artpec6_pcie->mode) {