From patchwork Mon Aug 12 18:46:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 2843264 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31C82BF546 for ; Mon, 12 Aug 2013 18:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1413F20587 for ; Mon, 12 Aug 2013 18:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88B682058E for ; Mon, 12 Aug 2013 18:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597Ab3HLStm (ORCPT ); Mon, 12 Aug 2013 14:49:42 -0400 Received: from mail-ea0-f171.google.com ([209.85.215.171]:42865 "EHLO mail-ea0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961Ab3HLSrE (ORCPT ); Mon, 12 Aug 2013 14:47:04 -0400 Received: by mail-ea0-f171.google.com with SMTP id n15so3588557ead.16 for ; Mon, 12 Aug 2013 11:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8cVoWBlPh2O2c6RB4ADQ96HRj5aESJeChwOfBHPJDCU=; b=wwv4gqEZIkdVoNJsvI5lPl+QsVZoskaa6vjfYbASyT3r1TSf6WVeryBow5hr8gjUNF 3BcgQWpllmCMT0tJG4VN7f83+vC0xs6ZNCtMlYu+MX4xtM5W/2m7Osr/jGxRdmw6ZRQw 1iNWDqlswINZAOprCoxvGHQV154lyu2AlIpoa6Np38EJfkZVmdecaMYVmnCVeu5SAxCv AdHxhqFe0NKchAuRyKgvuRd+GA6AvKPllIdtBTzucGHenQKWMeySRzAyYwgPgJ9Q68Yd xRfExEg+7kybzVhKQljk5hRu+kzND+t1BpvJVMYQxWQM0XdnMFhHSFYXrx0o2Bvxdj6o d5fA== X-Received: by 10.14.4.137 with SMTP id 9mr28477eej.124.1376333222342; Mon, 12 Aug 2013 11:47:02 -0700 (PDT) Received: from topkick.lan (dslc-082-083-214-189.pools.arcor-ip.net. [82.83.214.189]) by mx.google.com with ESMTPSA id j2sm59575588eep.6.2013.08.12.11.46.59 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 Aug 2013 11:47:00 -0700 (PDT) Received: from edge.lan (magicgate.lan [192.168.1.1]) by topkick.lan (Postfix) with ESMTPSA id C318A605ED; Mon, 12 Aug 2013 20:44:31 +0200 (CEST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Cc: Russell King , Jason Cooper , Andrew Lunn , Bjorn Helgaas , Thomas Petazzoni , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH 4/9] PCI: mvebu: add support for reset on GPIO Date: Mon, 12 Aug 2013 20:46:50 +0200 Message-Id: <1376333215-12885-5-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376333215-12885-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1376333215-12885-1-git-send-email-sebastian.hesselbarth@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 This patch adds a check for DT passed reset-gpios property and deasserts/ asserts reset pin on probe/remove with configurable delay. Corresponding binding documentation is also updated. Signed-off-by: Sebastian Hesselbarth --- Cc: Russell King Cc: Jason Cooper Cc: Andrew Lunn Cc: Bjorn Helgaas Cc: Thomas Petazzoni Cc: devicetree@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-pci@vger.kernel.org --- .../devicetree/bindings/pci/mvebu-pci.txt | 2 ++ drivers/pci/host/pci-mvebu.c | 33 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/pci/mvebu-pci.txt b/Documentation/devicetree/bindings/pci/mvebu-pci.txt index 638673a..f2fa261 100644 --- a/Documentation/devicetree/bindings/pci/mvebu-pci.txt +++ b/Documentation/devicetree/bindings/pci/mvebu-pci.txt @@ -76,6 +76,8 @@ and the following optional properties: - marvell,pcie-lane: the physical PCIe lane number, for ports having multiple lanes. If this property is not found, we assume that the value is 0. +- reset-gpios: optional gpio to PERST# +- reset-delay-ms: delay in ms to wait after reset de-assertion Example: diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 2370b59..bdad4d4 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -9,14 +9,17 @@ #include #include #include +#include +#include #include #include #include #include #include #include -#include #include +#include +#include #include /* @@ -126,6 +129,9 @@ struct mvebu_pcie_port { unsigned int io_target; unsigned int io_attr; struct clk *clk; + int reset_gpio; + int reset_active_low; + char *reset_name; struct mvebu_sw_pci_bridge bridge; struct device_node *dn; struct mvebu_pcie *pcie; @@ -856,6 +862,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) for_each_child_of_node(pdev->dev.of_node, child) { struct mvebu_pcie_port *port = &pcie->ports[pcie->nports]; + enum of_gpio_flags flags; if (!of_device_is_available(child)) continue; @@ -896,6 +903,25 @@ static int mvebu_pcie_probe(struct platform_device *pdev) continue; } + port->reset_gpio = of_get_named_gpio_flags(child, + "reset-gpios", 0, &flags); + if (gpio_is_valid(port->reset_gpio)) { + u32 reset_mdelay = 20; + port->reset_active_low = flags & OF_GPIO_ACTIVE_LOW; + port->reset_name = kasprintf(GFP_KERNEL, + "pcie%d.%d-reset", port->port, port->lane); + ret = devm_gpio_request_one(&pdev->dev, + port->reset_gpio, GPIOF_DIR_OUT, port->reset_name); + if (ret) + return ret; + gpio_set_value(port->reset_gpio, + (port->reset_active_low) ? 1 : 0); + + of_property_read_u32(child, "reset-delay-ms", + &reset_mdelay); + mdelay(reset_mdelay); + } + port->clk = of_clk_get_by_name(child, NULL); if (IS_ERR(port->clk)) { dev_err(&pdev->dev, "PCIe%d.%d: cannot get clock\n", @@ -945,6 +971,11 @@ static int mvebu_pcie_remove(struct platform_device *pdev) int i; for (i = 0; i < pcie->nports; i++, port++) { + if (gpio_is_valid(port->reset_gpio)) { + gpio_set_value(port->reset_gpio, + (port->reset_active_low) ? 0 : 1); + kfree(port->reset_name); + } clk_disable_unprepare(port->clk); kfree(port->name); }