From patchwork Fri Nov 29 23:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13889003 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 128B3D735E5 for ; Fri, 29 Nov 2024 23:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ekN2FmLX3G/kZeuCqxSVgKj2vevteSafNqBaWzKLj88=; b=bhuXtdXk1Bh87OHCtddnoRYhnJ zzkYbjS3FmU972eSB20kxs/VLrhB5RWw5I7R3EUZrvNJkyD+Ltnu7LcmcUubT1SaJT4WsobqUiMnz w95NKU2Oz9JYkEVi8g2vqMj9+umzt7yr1BQZ4/H0/bZWQawn2yt2DoHs70sH0RDYuA7tBWukRQQyG j9T55uPeAN6HpFQI0G2ksFQIX+EQMcc20i69h2hWfDAN0UxMtuQRPWhvAuREr+Krm/bU4sjsVZ+UD +MSPbkhtsFClava36fkZrOfXOxGM2n6Y1z0puJDR9PHPP1CTt7X45bCT6t+5rzJIyP9MuMOHddLQo gt0yNBKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tHALm-000000016R7-1O9J; Fri, 29 Nov 2024 23:24:38 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tHAIv-000000015yC-3TnS; Fri, 29 Nov 2024 23:21:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 34578A43871; Fri, 29 Nov 2024 23:19:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29233C4CECF; Fri, 29 Nov 2024 23:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732922500; bh=ugku9pso3x81u0glSHvCY10Yvp4iU8R62ycqNYCHwBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=V1b5l6Nmc075l4sr3Ys4TGuhI/3wI2OjE9pxwEjjZUcmwm59Zf1FgZLqX3bODkdhk QECDC+oE0ZxU67esPyIQH9Soa0TZnakJTTLOviybcBVL0+hHCIYn+VgTv/IYczOETj WQiFvRnsOsBzf+FktVBkuf7GKbq8Mh1ceEtqBud+4vCp7vfWjUrCgnuXSH9LjI+2rl e5fMMgnCNUkHDS4ZG/f8x7EPupqW1OiSzXTkYSwLCRJFbS2xvUWiHbpQbwJihsLrMl u4IRdzWqEGGnwEfoulS5dtutxsrSSuhtPxUkx1Fh6vAQL6PqN+gQbcmr+PTf+kfrcq 5NyT+J7B33zsw== From: Lorenzo Bianconi Date: Sat, 30 Nov 2024 00:20:12 +0100 Subject: [PATCH v5 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() MIME-Version: 1.0 Message-Id: <20241130-pcie-en7581-fixes-v5-3-dbffe41566b3@kernel.org> References: <20241130-pcie-en7581-fixes-v5-0-dbffe41566b3@kernel.org> In-Reply-To: <20241130-pcie-en7581-fixes-v5-0-dbffe41566b3@kernel.org> To: Ryder Lee , Jianjun Wang , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Michael Turquette , Stephen Boyd Cc: linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Lorenzo Bianconi X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241129_152142_003708_A40EB18D X-CRM114-Status: GOOD ( 14.59 ) 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 In order to make the code more readable, the reset_control_bulk_assert() for PHY reset lines is moved to make it pair with reset_control_bulk_deassert() in mtk_pcie_power_up() and mtk_pcie_en7581_power_up(). The same change is done for reset_control_assert() used to assert MAC reset line. Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to complete PCIe reset on MediaTek controller. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Manivannan Sadhasivam Signed-off-by: Lorenzo Bianconi --- drivers/pci/controller/pcie-mediatek-gen3.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 3cfcb45d31508142d28d338ff213f70de9b4e608..6c5e1fb16d17de0325d66277e0508b781fe45112 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -125,6 +125,8 @@ #define MAX_NUM_PHY_RESETS 3 +#define PCIE_MTK_RESET_TIME_US 10 + /* Time in ms needed to complete PCIe reset on EN7581 SoC */ #define PCIE_EN7581_RESET_TIME_MS 100 @@ -913,9 +915,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie) u32 val; /* - * Wait for the time needed to complete the bulk assert in - * mtk_pcie_setup for EN7581 SoC. + * The controller may have been left out of reset by the bootloader + * so make sure that we get a clean start by asserting resets here. */ + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, + pcie->phy_resets); + reset_control_assert(pcie->mac_reset); + + /* Wait for the time needed to complete the reset lines assert. */ mdelay(PCIE_EN7581_RESET_TIME_MS); err = phy_init(pcie->phy); @@ -986,6 +993,15 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie) struct device *dev = pcie->dev; int err; + /* + * The controller may have been left out of reset by the bootloader + * so make sure that we get a clean start by asserting resets here. + */ + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, + pcie->phy_resets); + reset_control_assert(pcie->mac_reset); + usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US); + /* PHY power on and enable pipe clock */ err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets); if (err) { @@ -1070,14 +1086,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie) * counter since the bulk is shared. */ reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets); - /* - * The controller may have been left out of reset by the bootloader - * so make sure that we get a clean start by asserting resets here. - */ - reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets); - - reset_control_assert(pcie->mac_reset); - usleep_range(10, 20); /* Don't touch the hardware registers before power up */ err = pcie->soc->power_up(pcie);