From patchwork Sun Feb 20 19:33:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12752863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC64DC433EF for ; Sun, 20 Feb 2022 19:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xvYq+v5qVmByOtgNUxs+6v1xgYR/WdJv9CXQZsG5ZIY=; b=YKvfThaVA5v3+P zLOBSAy0j7H+nbPBkB8+aEAp/BzGRkWma9R3cNN9cv4TA7PeHOc+euiaJ8geuB2oTarLN6zbdqeQY DUzVy0c2xtb5cpeJViUpciC/WRb/h30xfVdePUhGLT5mIcb6ObWfdYnXsgDEenoeM+KviqekJQ924 RQx5CbP7jqDXx3POTb54VbO0c+oVJZcr2ruwTMzHz+hLlB/Zkm2Pn0Vxl70f29ytPrfwilHrtyMgO jRH4+VMoLu3HV4chuVA23OHPH8+wCRFBeNqiglXasjMeGI/FZ0QsmMh+iXDhy4KDcTS5rA/axBguo 5kRSUkZ7WnbBREfIT6Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLs6c-002FI8-H6; Sun, 20 Feb 2022 19:42:51 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLrye-002BQF-K3 for linux-arm-kernel@lists.infradead.org; Sun, 20 Feb 2022 19:34:38 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4BE14B80DB6; Sun, 20 Feb 2022 19:34:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2327DC36AE2; Sun, 20 Feb 2022 19:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645385674; bh=Yk4h7+6wOvhJPfvPdF/6j11Ecoy3msqIfaKocxRvsyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c2O5paZfjIqr9KmrrhqvUKnxdmaa0wPzAODPkX7SAOnrIYl09uLJaEjTib1Nky3GL +i9Ahri204IGa3IG+pBEqyNCj/h7ISO3NOb3axU0vloT9vASJbythfcpN7zd6Bna80 PCeUoEyqLIdQLG6/F6g57XstrY/ryFhkjPxDu9BWp3vA+5DnDQOIXLV/fnoQo/DtFm I/VnuIui2zFetFljgdjAqkQbvwsr6a1P5OxKlFv51bMD9LYNgwkIyuc+73Z3YDOgzM lMWBckMDA7nHHVzzW9GCoEWpKv3edCJm97+RH2MGqtRkKz+bRfRknuL5LcpRxTlFkA eH7bU3lAlwggg== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi , Bjorn Helgaas Cc: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Marc Zyngier , pali@kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Gregory CLEMENT , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH 18/18] PCI: aardvark: Optimize PCIe card reset via GPIO Date: Sun, 20 Feb 2022 20:33:46 +0100 Message-Id: <20220220193346.23789-19-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220193346.23789-1-kabel@kernel.org> References: <20220220193346.23789-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220220_113436_858498_96D99098 X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Pali Rohár Currently we always assert reset GPIO (if it is available) for ~10ms. But if the GPIO was asserted before driver probe (by bootloader for example), we do not need to wait these 10ms. Assert reset GPIO for 10ms only if it wasn't asserted. We need to get the GPIO with flag GPIOD_FLAGS_BIT_DIR_OUT instead of GPIOD_OUT_LOW, so that it's value isn't changed when getting it. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 056f49d0e3a4..80eb6e98923f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -431,10 +431,17 @@ static void advk_pcie_issue_perst(struct advk_pcie *pcie) if (!pcie->reset_gpio) return; - /* 10ms delay is needed for some cards */ - dev_info(&pcie->pdev->dev, "issuing PERST via reset GPIO for 10ms\n"); - gpiod_set_value_cansleep(pcie->reset_gpio, 1); - usleep_range(10000, 11000); + /* + * Assert PERST# for at least 10ms if it wasn't asserted yet (it could + * have been asserted by bootloader or by GPIO driver, for example). + */ + if (!gpiod_get_value(pcie->reset_gpio)) { + dev_info(&pcie->pdev->dev, "issuing PERST via reset GPIO for 10ms\n"); + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + usleep_range(10000, 11000); + } + + /* De-assert PERST# */ gpiod_set_value_cansleep(pcie->reset_gpio, 0); } @@ -2049,7 +2056,7 @@ static int advk_pcie_probe(struct platform_device *pdev) pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0, - GPIOD_OUT_LOW, + GPIOD_FLAGS_BIT_DIR_OUT, "pcie1-reset"); ret = PTR_ERR_OR_ZERO(pcie->reset_gpio); if (ret) {