From patchwork Thu Jan 10 12:26:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 10755677 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC75D91E for ; Thu, 10 Jan 2019 12:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB3F2294A8 for ; Thu, 10 Jan 2019 12:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBA37295D5; Thu, 10 Jan 2019 12:28:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000C0294A8 for ; Thu, 10 Jan 2019 12:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727623AbfAJM17 (ORCPT ); Thu, 10 Jan 2019 07:27:59 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:52769 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727214AbfAJM16 (ORCPT ); Thu, 10 Jan 2019 07:27:58 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id D820B44011A; Thu, 10 Jan 2019 14:27:54 +0200 (IST) From: Baruch Siach To: Linus Walleij , Bartosz Golaszewski , Thierry Reding , Thomas Petazzoni , Lorenzo Pieralisi , Bjorn Helgaas Cc: Sven Auhagen , linux-pwm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Baruch Siach Subject: [PATCH 1/2] gpio: mvebu: implement get_direction Date: Thu, 10 Jan 2019 14:26:21 +0200 Message-Id: <024cc24efa7b99186750f90c91880b29357d379d.1547123182.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct gpio_chip documentation recommends to always implement this callback function. A more concrete motivation is to be able (in combination with GPIOD_ASIS) to detect whether the bootloader has changed the state of a GPIO signal. Signed-off-by: Baruch Siach --- drivers/gpio/gpio-mvebu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 7d5c55494ccd..f97ed32b8beb 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -376,6 +376,16 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned int pin, return 0; } +static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin) +{ + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); + u32 u; + + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); + + return !!(u & BIT(pin)); +} + static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) { struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); @@ -1130,6 +1140,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) mvchip->chip.parent = &pdev->dev; mvchip->chip.request = gpiochip_generic_request; mvchip->chip.free = gpiochip_generic_free; + mvchip->chip.get_direction = mvebu_gpio_get_direction; mvchip->chip.direction_input = mvebu_gpio_direction_input; mvchip->chip.get = mvebu_gpio_get; mvchip->chip.direction_output = mvebu_gpio_direction_output; From patchwork Thu Jan 10 12:26:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 10755679 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 748131399 for ; Thu, 10 Jan 2019 12:28:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64356294A8 for ; Thu, 10 Jan 2019 12:28:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5747F295C4; Thu, 10 Jan 2019 12:28:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6329294D4 for ; Thu, 10 Jan 2019 12:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbfAJM17 (ORCPT ); Thu, 10 Jan 2019 07:27:59 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:52784 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbfAJM17 (ORCPT ); Thu, 10 Jan 2019 07:27:59 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id 806E544087E; Thu, 10 Jan 2019 14:27:55 +0200 (IST) From: Baruch Siach To: Linus Walleij , Bartosz Golaszewski , Thierry Reding , Thomas Petazzoni , Lorenzo Pieralisi , Bjorn Helgaas Cc: Sven Auhagen , linux-pwm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Baruch Siach Subject: [PATCH 2/2] PCI: armada8k: don't toggle reset twice Date: Thu, 10 Jan 2019 14:26:22 +0200 Message-Id: <94cd23a60c647020dd87a923684b59255b89f02c.1547123182.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.20.1 In-Reply-To: <024cc24efa7b99186750f90c91880b29357d379d.1547123182.git.baruch@tkos.co.il> References: <024cc24efa7b99186750f90c91880b29357d379d.1547123182.git.baruch@tkos.co.il> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 3d71746c42 ("PCI: armada8k: Add support for gpio controlled reset signal") added reset signal support. Reset is unconditionally asserted and deasserted. Unfortunately, that commit breaks boot on Macchiatobin when a Mellanox NIC is in the PCIe slot. It turns out that you can toggle the reset signal only once. Another reset signal toggle makes access to PCI configuration registers stall indefinitely. U-Boot toggles the Macchiatobin PCIe reset line already at boot. Detect whether the bootloader changed the reset signal state using the get_direction operation. If direction is output don't touch the reset signal again. Otherwise, set direction to output and keep the reset asserted. Reported-by: Sven Auhagen Signed-off-by: Baruch Siach --- This patch depends on the mvebu get_direction implementation in the patch #1 of this series. Since get_direction implementation is not a pure fix it might be considered unfit for v5.0. In that case I'm OK with reverting 3d71746c42 in v5.0 to fix the Macchiatobin regression, and postpone this series to v5.1. --- drivers/pci/controller/dwc/pcie-armada8k.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-armada8k.c b/drivers/pci/controller/dwc/pcie-armada8k.c index b171b6bc15c8..132a86a1e1e7 100644 --- a/drivers/pci/controller/dwc/pcie-armada8k.c +++ b/drivers/pci/controller/dwc/pcie-armada8k.c @@ -257,12 +257,23 @@ static int armada8k_pcie_probe(struct platform_device *pdev) goto fail_clkreg; } - /* Get reset gpio signal and hold asserted (logically high) */ + /* Get reset gpio signal, don't change its setting */ pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", - GPIOD_OUT_HIGH); + GPIOD_ASIS); if (IS_ERR(pcie->reset_gpio)) { ret = PTR_ERR(pcie->reset_gpio); goto fail_clkreg; + } else if (pcie->reset_gpio && + gpiod_get_direction(pcie->reset_gpio) == 0) { + /* Reset signal is output. The bootloader has deasserted reset + * signal already. Don't do it again. + */ + dev_info(dev, "%s: leave reset signal unchanged\n", __func__); + devm_gpiod_put(dev, pcie->reset_gpio); + pcie->reset_gpio = NULL; + } else if (pcie->reset_gpio) { + /* Assert reset */ + gpiod_direction_output(pcie->reset_gpio, 1); } platform_set_drvdata(pdev, pcie);