From patchwork Thu Aug 15 22:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13765270 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 B3ED1C52D7D for ; Thu, 15 Aug 2024 23:06:22 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yepWRpPrn7HuVRjGcYCbpeID1UICJE17S+GyZCTYTS8=; b=BqjQuIT6qLgn48eJKe/6mGZ8IL Q0D3xQ9R7NypC7HhF+GskBnHWtEn5H1BoKNiT070R5AKlkuBJHD+/I/0bA4EKxpX+zQCJzMZfpTbp XOhZhNsIU+vvLV8VBs1II8ntJnrDXjYCHr0IxNgl2tPf+7BVCFoKbF5kP86J9U7044GRvjLnoZ7Vt 68ndib8didQPJsUU2bqBvX+lKiq6Bw9YNRs3jZsuWaGpkz+K0RmDNJGku2h9a+ujJaTaJwxh8OQnq auuAKb8x2QfTvKb5lL4crFNHvG3lTyoaYp7Vk2x5XNYOE6HLmCZ9aaK/let3ljO1/GgEIUJVsv7Nx scSY1JPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sejXp-0000000BG7S-1srp; Thu, 15 Aug 2024 23:06:13 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sejPr-0000000BE3g-3NJ4 for linux-arm-kernel@lists.infradead.org; Thu, 15 Aug 2024 22:58:01 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-7a10b293432so1013957a12.0 for ; Thu, 15 Aug 2024 15:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723762679; x=1724367479; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=yepWRpPrn7HuVRjGcYCbpeID1UICJE17S+GyZCTYTS8=; b=EgeX2fzmrvamafXB7NSSZWFOMBZOkKWWxpjNkpsHfg5t9A0zP/t04lmKfY2ajDVYBq EjTM7aZCDkOwoabQie4D39qbijZjVRhftvu0Xy9bTPEYeJ+DgqNrVzffMIukbcrkgj37 kCj/08OldPjVrdbx5vBxxE6aezgG99mKqusb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723762679; x=1724367479; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yepWRpPrn7HuVRjGcYCbpeID1UICJE17S+GyZCTYTS8=; b=l3g600fT32yn/Jj5WNLNTroHnIXBSOd/EYmAwKf3naP4k5xQkPolttt8kD/2MgRwwn kgbl8oL+4HoePGRqHFzR1hLRpu/8Px/3Hl2qwwMBBvETnb98LI7+jJx49X1xWBep5+5v LdfM/itn70aAIkK0xY8eANbXxbhWqOIfE8QRUSermINvRRBXd3oGq7H7177Q3yJFn/p1 9XgBH7Sg2fMyZptH6bK7ZpCnvsyKoRtggbmAxBBKrrwEWgnXSO/ls0G3e5ymR4xDfPGs yj/1rbqK4kiImpX1wSBfEZWMcXzvjfGc97sbDRMrmmJRNNjIfOFBqdKBy0DUBcCA6Tyt 7KDA== X-Forwarded-Encrypted: i=1; AJvYcCVUgGBrqRAv7MBqfHQayuIYjhpR772i3ikCqNIFenxGG1Iha1pXCorPxuv24iOMEzzuBn30eS6atnUjPBBXsuwTLQQtXSaJN+pNxPpvc3zVqn5NcH4= X-Gm-Message-State: AOJu0YwP3Qkkl7cD7yAgxvAZlNO0AWKoD/H5gad9A9/PLHrR52XuA3Lt CfLWCGpzBQahYxnTGwXUlE6zOrX/JzzO9JcVmPpUtbnfANwCGrde8ZTbQ5138w== X-Google-Smtp-Source: AGHT+IGxbnG/uJ/U4/fycutE6POjlc+iPF9Zv5jiqIHVnaRSgcMsZaJbzzeuyxOqvw3zYCkzgINdcA== X-Received: by 2002:a17:90a:1307:b0:2bf:8824:c043 with SMTP id 98e67ed59e1d1-2d3dfc66d3cmr1387247a91.18.1723762678545; Thu, 15 Aug 2024 15:57:58 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3e2e6b2d1sm373997a91.18.2024.08.15.15.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 15:57:58 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 05/13] PCI: brcmstb: Use bridge reset if available Date: Thu, 15 Aug 2024 18:57:18 -0400 Message-Id: <20240815225731.40276-6-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240815225731.40276-1-james.quinlan@broadcom.com> References: <20240815225731.40276-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240815_155759_916247_0D6417FC X-CRM114-Status: GOOD ( 16.34 ) 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 The 7712 SOC has a bridge reset which can be described in the device tree. Use it if present. Otherwise, continue to use the legacy method to reset the bridge. Signed-off-by: Jim Quinlan Reviewed-by: Manivannan Sadhasivam Reviewed-by: Florian Fainelli Reviewed-by: Stanimir Varbanov --- drivers/pci/controller/pcie-brcmstb.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 790a149f6581..af14debd81d0 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -265,6 +265,7 @@ struct brcm_pcie { enum pcie_type type; struct reset_control *rescal; struct reset_control *perst_reset; + struct reset_control *bridge_reset; int num_memc; u64 memc_size[PCIE_BRCM_MAX_MEMC]; u32 hw_rev; @@ -732,12 +733,19 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus, static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) { - u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; - u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT; + if (val) + reset_control_assert(pcie->bridge_reset); + else + reset_control_deassert(pcie->bridge_reset); - tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); - tmp = (tmp & ~mask) | ((val << shift) & mask); - writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + if (!pcie->bridge_reset) { + u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; + u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT; + + tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + tmp = (tmp & ~mask) | ((val << shift) & mask); + writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + } } static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) @@ -1621,10 +1629,16 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (IS_ERR(pcie->perst_reset)) return PTR_ERR(pcie->perst_reset); + pcie->bridge_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "bridge"); + if (IS_ERR(pcie->bridge_reset)) + return PTR_ERR(pcie->bridge_reset); + ret = clk_prepare_enable(pcie->clk); if (ret) return dev_err_probe(&pdev->dev, ret, "could not enable clock\n"); + pcie->bridge_sw_init_set(pcie, 0); + ret = reset_control_reset(pcie->rescal); if (ret) { clk_disable_unprepare(pcie->clk);