From patchwork Tue Feb 25 08:04:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13989463 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 A77C5C021BC for ; Tue, 25 Feb 2025 08:14:35 +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=5S7OzKm73jH9LwR5vYRGJ8Itz0tdca2CuuEiMhSv7WY=; b=bkDjaezh+LJG3PVCylDoBw6ykg QvqL1hyvTHqQmT0ngfS2t105Nds5yjOkqTlnK+9LE50z7SSqCqY6PlQg0conxG6X8C4v+oA4bX2cy OQHj/5P63xldQTgd1YWUPzZn+f8AiRVvoLhboKSkc+RKlVTW3eSNuz0hKJ3fy4Oex0yNzeHqoF+go R2x7E+r6Ip39AMTpPwenrd/q4pk7c39EKsPPQDz3DIoKUzDRtesfXgCpBFPbeEIMQ7HSayW+Row56 ykRL+m1fZ2bager24/vmPaH+YO5hd2udYcnGCQv+G/7/dyX/dodPPSRcDB07FLLlDu6CVjaDeB5xB 2VVe2+tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmq5I-0000000GL1G-2tJb; Tue, 25 Feb 2025 08:14:32 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmpvJ-0000000GJZe-2pL3; Tue, 25 Feb 2025 08:04:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 27E895C6668; Tue, 25 Feb 2025 08:03:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D596C4CEE2; Tue, 25 Feb 2025 08:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740470652; bh=9KVXWc8stYPpZlIbVSdXAfaPi9fFh/5ieJlqnGagLLU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VpXbLunl6/8IB3r01XBqTcYmSUeZ/CortIR3eiQTx8B7bHYs11bLt+WbFoAnpKqWd Qq24B5fsGZS84YUpM6ScHIfy6LazheD4VMH4yveFQyEvIIaKJ2KGN2MUFQK59fXBou UbeWE4TJ4B6tSwe3FVzbH/s8qlot1rm/JNhqwG34reaFG1zupwzDYU4+yTgFC1eV1z oRcmeydRSpotdij74XsbtX6p/pBwXTnEcFrz/VTMlotWivj+wysztkMtEbQGQdn4EI 0nsgkjZ4I0KHXl//0j5DWSnkT23PxyVQ5t9FF4pJqQpF5SMx1VLm+E1+oy+tyusjPm L9uhGM5WC/kNQ== From: Lorenzo Bianconi Date: Tue, 25 Feb 2025 09:04:06 +0100 Subject: [PATCH v4 1/2] dt-bindings: PCI: mediatek-gen3: Add mediatek,pbus-csr phandle array property MIME-Version: 1.0 Message-Id: <20250225-en7581-pcie-pbus-csr-v4-1-24324382424a@kernel.org> References: <20250225-en7581-pcie-pbus-csr-v4-0-24324382424a@kernel.org> In-Reply-To: <20250225-en7581-pcie-pbus-csr-v4-0-24324382424a@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 , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Lorenzo Bianconi Cc: linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250225_000413_830715_1BAD54CD X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Introduce the mediatek,pbus-csr property for the pbus-csr syscon node available on EN7581 SoC. The airoha pbus-csr block provides a configuration interface for the PBUS controller used to detect if a given address is accessible on PCIe controller. Reviewed-by: Krzysztof Kozlowski Reviewed-by: Manivannan Sadhasivam Signed-off-by: Lorenzo Bianconi --- .../devicetree/bindings/pci/mediatek-pcie-gen3.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml index f05aab2b1addcac91d4685d7d94f421814822b92..162406e0691a81044406aa8f9e60605d0d917811 100644 --- a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml @@ -109,6 +109,17 @@ properties: power-domains: maxItems: 1 + mediatek,pbus-csr: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle to pbus-csr syscon + - description: offset of pbus-csr base address register + - description: offset of pbus-csr base address mask register + description: + Phandle with two arguments to the syscon node used to detect if + a given address is accessible on PCIe controller. + '#interrupt-cells': const: 1 @@ -168,6 +179,8 @@ allOf: minItems: 1 maxItems: 2 + mediatek,pbus-csr: false + - if: properties: compatible: @@ -197,6 +210,8 @@ allOf: minItems: 1 maxItems: 2 + mediatek,pbus-csr: false + - if: properties: compatible: @@ -224,6 +239,8 @@ allOf: minItems: 1 maxItems: 2 + mediatek,pbus-csr: false + - if: properties: compatible: From patchwork Tue Feb 25 08:04:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13989464 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 A3AA0C3DA4A for ; Tue, 25 Feb 2025 08:14:35 +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=Vo+YK8GwUXppsrfkC1Lxtn4q/YlGVDS7GUOb54fs1rg=; b=ZoKfZ1A0ueTvhEJgUHa+DNBWmc lnCNPWaluCcSD3tMw9r/fDPoy+bV3r2URBoN9Ehmg5M+dH2WFJUeinRD3OlBMBSH92GB1mQiPqzG/ Htd5CQ2/pMciRoDH41t4rcNa4rDSf006OUpFFEMMmZItKfIvg0a5JUULpFMUEwtYSn4FVkYAMkMHm tQ7F1WAMSKSYFCy+eFsl9hKnSeggoWZIEbqeX0HxoXa6/UtXFWT0PtZFTob28qjJTYgwJi2kPttRd bf/pXBrHSZtPFngCgb6uSAP5NVMSX8MMTQTLGfoh8k4USBxKjcyiCvxRceTWiEMFKuSy4H+mBvDIm AGi/rpFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmq5J-0000000GL25-2F31; Tue, 25 Feb 2025 08:14:33 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmpvM-0000000GJa9-2FDr; Tue, 25 Feb 2025 08:04:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0E0F25C6521; Tue, 25 Feb 2025 08:03:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EA54C4CEE2; Tue, 25 Feb 2025 08:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740470655; bh=UIr6nl14PNT9O4sqrjXYAxiPPUTsIADVOWslxLJu8eE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HazrX7jcNWGDWPn00kfwIVFAZrjrOIBlHvF+GFuYvJW8uoqNS3ZZRIdbOhlVlMZlX X3Op2ucNDqG6zvoE/1kq8WIEibknLRURU287GeRnMXwegTD6rBSZDv+0vOs2xF3UW1 AeEA9ZrFrsJh/Ke3stfrdxT7GPdxnHATTSCx3AU3HJVOonvZLgLz7amEVY+sD06SGu 0KbZqydZzhF/vAzBsf7V3m8s7ZE2jgTnBzF36r8mK2jGdrTPjBHXBJa2FA5Zlvzj9h 5l+ib7csstl5fMKyONEYosEt5Fqw/SNWUDIbQmLZnsq5FJ1HawjZ46XmzlLqBMzdPz vEgzTqDtIV36A== From: Lorenzo Bianconi Date: Tue, 25 Feb 2025 09:04:07 +0100 Subject: [PATCH v4 2/2] PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581 SoC MIME-Version: 1.0 Message-Id: <20250225-en7581-pcie-pbus-csr-v4-2-24324382424a@kernel.org> References: <20250225-en7581-pcie-pbus-csr-v4-0-24324382424a@kernel.org> In-Reply-To: <20250225-en7581-pcie-pbus-csr-v4-0-24324382424a@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 , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Lorenzo Bianconi Cc: linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250225_000416_664690_340B8C1E X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Configure PBus base address and address mask to allow the hw to detect if a given address is accessible on PCIe controller. Fixes: f6ab898356dd ("PCI: mediatek-gen3: Add Airoha EN7581 support") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Lorenzo Bianconi --- drivers/pci/controller/pcie-mediatek-gen3.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 0f64e76e2111468e6a453889ead7fbc75804faf7..3583e5481dc8a6a357738048fc341c22204527d9 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include "../pci.h" @@ -930,9 +932,13 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie) { + struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); struct device *dev = pcie->dev; + struct resource_entry *entry; + struct regmap *pbus_regmap; + u32 val, args[2], size; + resource_size_t addr; int err; - u32 val; /* * The controller may have been left out of reset by the bootloader @@ -944,6 +950,26 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie) /* Wait for the time needed to complete the reset lines assert. */ msleep(PCIE_EN7581_RESET_TIME_MS); + /* + * Configure PBus base address and base address mask to allow the + * hw to detect if a given address is accessible on PCIe controller. + */ + pbus_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "mediatek,pbus-csr", + ARRAY_SIZE(args), + args); + if (IS_ERR(pbus_regmap)) + return PTR_ERR(pbus_regmap); + + entry = resource_list_first_type(&host->windows, IORESOURCE_MEM); + if (!entry) + return -ENODEV; + + addr = entry->res->start - entry->offset; + regmap_write(pbus_regmap, args[0], lower_32_bits(addr)); + size = lower_32_bits(resource_size(entry->res)); + regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size))); + /* * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581 * requires PHY initialization and power-on before PHY reset deassert.