From patchwork Mon Nov 16 15:19:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 7628361 Return-Path: X-Original-To: patchwork-linux-arm@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 A97CB9F2EC for ; Mon, 16 Nov 2015 15:22:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C994320481 for ; Mon, 16 Nov 2015 15:22:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 264ED20456 for ; Mon, 16 Nov 2015 15:22:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyLZQ-0002Ue-FH; Mon, 16 Nov 2015 15:19:52 +0000 Received: from ibawizard.net ([82.208.49.253] helo=mengele.ibawizard.net) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyLZL-0002Q0-9O for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2015 15:19:49 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by mengele.ibawizard.net (Postfix) with ESMTP id B08501D36050; Mon, 16 Nov 2015 16:19:19 +0100 (CET) From: =?UTF-8?q?Petr=20=C5=A0tetiar?= To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] PCI: imx6: Fix reset-gpio to work with active low GPIO Date: Mon, 16 Nov 2015 16:19:07 +0100 Message-Id: <1447687147-19436-1-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_071947_543796_334F5DFB X-CRM114-Status: GOOD ( 11.87 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, =?UTF-8?q?Petr=20=C5=A0tetiar?= , Richard Zhu , Lucas Stach Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 It's currently not possible to use reset-gpio on board where the GPIO is active low as the code incorrectly assumes, that reset-gpio will be always active high. In my case the broken behavior was observed on Toradex Apalis SoM with Ixora base board. Signed-off-by: Petr Štetiar --- drivers/pci/host/pci-imx6.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index fdb9536..cd7ed71 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -293,9 +293,11 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) /* Some boards don't have PCIe reset GPIO. */ if (gpio_is_valid(imx6_pcie->reset_gpio)) { - gpio_set_value(imx6_pcie->reset_gpio, 0); + struct gpio_desc *gd = gpio_to_desc(imx6_pcie->reset_gpio); + + gpiod_set_value(gd, 0); msleep(100); - gpio_set_value(imx6_pcie->reset_gpio, 1); + gpiod_set_value(gd, 1); } return 0; @@ -559,6 +561,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) struct pcie_port *pp; struct device_node *np = pdev->dev.of_node; struct resource *dbi_base; + enum of_gpio_flags of_flags; + int flags = GPIOF_OUT_INIT_LOW; int ret; imx6_pcie = devm_kzalloc(&pdev->dev, sizeof(*imx6_pcie), GFP_KERNEL); @@ -578,10 +582,13 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) return PTR_ERR(pp->dbi_base); /* Fetch GPIOs */ - imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); + imx6_pcie->reset_gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, + &of_flags); if (gpio_is_valid(imx6_pcie->reset_gpio)) { + if (of_flags & OF_GPIO_ACTIVE_LOW) + flags |= GPIOF_ACTIVE_LOW; ret = devm_gpio_request_one(&pdev->dev, imx6_pcie->reset_gpio, - GPIOF_OUT_INIT_LOW, "PCIe reset"); + flags, "PCIe reset"); if (ret) { dev_err(&pdev->dev, "unable to get reset gpio\n"); return ret;