From patchwork Mon Jan 8 11:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513280 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 A9DCDC47079 for ; Mon, 8 Jan 2024 11:06:45 +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=zLxyLDETyyGXcdmNJROdsaGaUPhAG9dY+TOB6stR9zQ=; b=gjayyttQDysVlB j30oKpvHu3w7LKwVKB23aFLeGheeAAsmOM4Uk4Y/iBm1C4Qvjmfu9iwy1/orRp4gogJzdVhkdEMxl ml2FG3q735qrtGKbhZ/nO+OoyxbDUGH8Bjrlj1AJD8hpXQxvlgpQwgPUo9nknFj2t0cXSk97NJbEE Iyu8M2Q0vsJQgKHp5oDC5hrutZf1kbCCKGjUUCFD51kU5qbm9FIHrR0h1/EhPngqOl3YpnedeSBE0 R9KyzTil83QtdVR/TIxauS4FBbUVM4KLBXLX+1Hctwx0t9KmBjDLpu0/jFMXfImBPBBcJLK8CHw4e /7bBbG6EW/l6xbxHyQTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSn-004giK-0q; Mon, 08 Jan 2024 11:06:37 +0000 Received: from mail-bjschn02on20604.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::604] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSk-004ggT-1E for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DVIllv0uHg1yPsLMdvPgrwi6NhaGbxQp6f4rguV//IvKVC1zBEuBey+Y8/WpgVHMMLcc7xakiOn4kLAbVlgKrovrPMFTixx2MP7W3+5kGYoOb94oNYPEJ6vDBD8SgQ/tHwoIXJ4Gsd7GhdsY4yKE7Tdu4i3s6nk0glYF7uQWYqeNfPTXssEqe1XhDqDvc6BdTw57SS0kO7hHwrZjbaFPUupHZrjTzV9tv2r5GIRFHzZqgbiw/HgEaGhqWGtZA+bqjvZtic933MGqhPMifL3K5/Lgptwl2+5oCQM717TEwO/m3ruDZHcMNhSUN1YLs6HkMuNNlxHvbqubFv/agxZ01A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K7UZdmdyYz24tezUgGACcYCmJKOSO6Q04qEPwmoKWvY=; b=TSpt9sEs4JZmbW846TH0AOusfDwJqaGA1Y35sFzLO3jBauJ8BG/5K4mEYSC0os4avu7dPUPSUujZOb2/5NVSLyztYiGQPzIIeH/rP99qLSsWZCvUvvjsA80F3nxHde9tPHYTusA6XMlnOnu5oCrhNQFiZW3KoRMUuhz0i2GP3sO0WBMfVuAFobNF+lk5pkGRywaQWbMDpmdaK5w+T587ImOaU7/1iVnLofdt+32a5IMfVTjooD/qu8vcELqHy+9wr6P0tt6qsUIDY1/+yBdmPTvLS6/YCbZYGvSqiJaqB38UNfNcoz23ftxHBt3u0jZSnLPpPV+PBB//ke4kQY3URg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:24 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:24 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 01/22] dt-bindings: PCI: Add PLDA XpressRICH PCIe host common properties Date: Mon, 8 Jan 2024 19:05:51 +0800 Message-Id: <20240108110612.19048-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: d82fac8b-26e2-48dc-f819-08dc1039da3f X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lmmJ6j/R2JrGo5u7RcSTbgWLcb0xouOAWX+xfSv5qBe4t+kNx9RKNV8aYSrVTZIE24FoUNX6wagI1ZT0jA3nPtlOSTu39N+1cpixaBUKNuE6CuicJs1qG9tUYbL1Rk/Ltxkh0R7MgQjk+MIWJpOGvi5tKFyGj/TlS8Hhf+nBOZSWawz56GmgJvjrLrBwlRBGKJODnQcjBCon+oAh2k0edUdUTVsywmOaEx+KeVs6lcPsIm/0QGZlzZBZY0WrlanAU5FYvap1+Lhe3G6HCfGIbGDrtgQwny9WNXrraLIHp7t2ExbWQtWlcsweQ5YO2A/SleDLYJ+/CC2Z80O5hfCP692jd+Oh1KkJy0tW7W/hyJMnqapYI+QjD1IqRZAwWwtBEFAilsGSJcUHiyN6dDEqSvY4uU9HyAX4bExy3s9Ty4/77zEmkSoz3IXSL2TZxNgh4t/dX1j4K4b7UK8A4ET3H1HRBsy8N/10Cn21TF3IabyDr2FqGgYzy91qW/3ayyxiGzB7jKkQyUZV/slBeCPpmOz9p1U+3JIfOX3l1HWTjzqPj8gTtGnJLR1KwfjZbkvf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(966005)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7purYD93x77653IspJrBERTgyJ0x+nx07e7yLbMfILBSflAuOZA5HU2S/ms5BvRV08wJ0RMFkqkkXeb1lQqduqcoY4VSDqHZwjjQOC3wROYoO76gGq9goj3E3J9i/Ar+b9m9CCGQlNmNAzD1K+jk0KaXI9+tzGihGCb1OFj7edhsDkvNjERZYNvqgNF/KfztA7MEMMERABIY9ZJNwZ6+hmN01o2iVK925ykbMxdKyH2fF3oBZR+ps5Fl6DJYGa9jmOrENtlbf4twQunM5vuJxSRpKJphiNgd5GlxpvpY5ifhuWdiTq8KpDCZsp4B7iFkaeNhgXWrcx2zzvvi9SrNfBI3zg0Nov9ax4S37YAYAbisuW5CEGqCTazv6wtwk/01JY1P+SoxpY16ZfwCcazscPlyxzYclDc1olGJqjXSNayt46n1xM0gcCLcBBoOaHXbiXsWLQiLZRuJgDMecEa3sHuHVHWqcKRxZKfTR6VCddtlRq90AIRXCNcl5TTr4fWf9J0tWme+b7HElv+Aj8vRKUmwLhDWhFGG3xXp07HaDVBjtZrTnzhg+cQdXPxNK9PtrtjFhrZsR+cmdXuVdVdSMkgBnd2fflG6Xp35oYRjGdiaPmqY7glr8QJs95Up4o22q76P/Iz2l4IxMlXJTNjVxhVZZqIPzNZMqmOoUSCi/OJEey7MI+qBJ3x75Eh1s/lGbVPT8t1n+eb4G71M09yg1GCn1KWJazSClqFDAFJWNXhzpQa3+ZT8Ll+Dyg24Tp20w+3XoXdh2SQdhfB3UgGxUeghrEOSHCNpQtJSNJfXbRFalolDPEpx2PaFlVxVQit+Lust75IhzxMH/LEyFQ1pxneXF0RYyl47JhM9drOxdR1b/RTLV7Kz2uCxO8AW46DjSyaMf8g5AC8fOCxkQf5KH3RtbOl8/790yMTP8tvzVU52O4McZYyrqa7uO4KgHgJhSS15nPBvFjDAT+/mv0kravE3ibMU1x2i8dwiXf2GhUVo9Kl4VtmZf/Rf0nl3buV0Rty2lcWIQOvhSrxXOSUejjshk8buPeRb15CgoT46hputK5b2FGseJatQWRfK+3vRGMmPaI1IUR5Cpis+7IFCyWYbKVHkapwpNvpyKMo1W0Z2gj1yvjU1ERnuxxoNDcAP2CQdrXs7kziyJDNjbm5QxZl1xrXdkht/DuXfs0yJ8xPrB7Jar1gnL+0wqRyQAjbp+3i5TDVFElFLU/tIYoKAU0Uz3oyrhiL6vhk06hVlaonHuSnSE+EWe7n7SRbJxoVUHajjfOD/XGUupXs0ZDwOUcE1QmD+zvOQIgMa6CkDufgCMO2fBYNua5orkWnsEXr5LUKmbm/xHjMqaKpZr/z+U7Gsgg1k5j4iD+hsTOR5eNyKaee39PaalLZytdp67HwpvssP0ULr5dMzepSRpomDxRZ9DoAP7VFfEfWv+JTi3pxEdvvDDC/cSlUP2FWj1tnTFtUlkN0DtSqyuJigbQrlCcuy+1QB4TOAJMA21023uh8Shp9p/ICUDQ52f/ltGGWePDYpEM5t93oZhZXBgFgknXRERt0pr5J9F7YxkMdaYXQ63EIKjWI0+0K74wIyWpC5oikgnBYTFc4EbVYkmcJjmw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d82fac8b-26e2-48dc-f819-08dc1039da3f X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:24.2095 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y5nnYOdzh2gYmQwjpePYctWvdQyS3l1eSv2osTM3h6gGkx6ArfiEPY/OCZoavuIFPmsFUtYKzT2I/9PCXyizjz66sEpBmYQgDcgIu3cSYo8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030634_425088_D1998DCC X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PLDA XpressRICH PCIe host common properties dt-binding doc. PolarFire PCIe host using PLDA IP. Move common properties from Microchip PolarFire PCIe host to PLDA files. Signed-off-by: Minda Chen Reviewed-by: Hal Feng Reviewed-by: Conor Dooley Reviewed-by: Rob Herring Tested-by: John Clark --- .../bindings/pci/microchip,pcie-host.yaml | 55 +------------- .../pci/plda,xpressrich3-axi-common.yaml | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 54 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml diff --git a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml index f7a3c2636355..7c2d51221f65 100644 --- a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml +++ b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml @@ -10,21 +10,13 @@ maintainers: - Daire McNamara allOf: - - $ref: /schemas/pci/pci-bus.yaml# + - $ref: plda,xpressrich3-axi-common.yaml# - $ref: /schemas/interrupt-controller/msi-controller.yaml# properties: compatible: const: microchip,pcie-host-1.0 # PolarFire - reg: - maxItems: 2 - - reg-names: - items: - - const: cfg - - const: apb - clocks: description: Fabric Interface Controllers, FICs, are the interface between the FPGA @@ -52,18 +44,6 @@ properties: items: pattern: '^fic[0-3]$' - interrupts: - minItems: 1 - items: - - description: PCIe host controller - - description: builtin MSI controller - - interrupt-names: - minItems: 1 - items: - - const: pcie - - const: msi - ranges: maxItems: 1 @@ -71,39 +51,6 @@ properties: minItems: 1 maxItems: 6 - msi-controller: - description: Identifies the node as an MSI controller. - - msi-parent: - description: MSI controller the device is capable of using. - - interrupt-controller: - type: object - properties: - '#address-cells': - const: 0 - - '#interrupt-cells': - const: 1 - - interrupt-controller: true - - required: - - '#address-cells' - - '#interrupt-cells' - - interrupt-controller - - additionalProperties: false - -required: - - reg - - reg-names - - "#interrupt-cells" - - interrupts - - interrupt-map-mask - - interrupt-map - - msi-controller - unevaluatedProperties: false examples: diff --git a/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml b/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml new file mode 100644 index 000000000000..31bb17b11e58 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/plda,xpressrich3-axi-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PLDA XpressRICH PCIe host common properties + +maintainers: + - Daire McNamara + - Kevin Xie + +description: + Generic PLDA XpressRICH PCIe host common properties. + +allOf: + - $ref: /schemas/pci/pci-bus.yaml# + +properties: + reg: + maxItems: 2 + + reg-names: + items: + - const: cfg + - const: apb + + interrupts: + minItems: 1 + items: + - description: PCIe host controller + - description: builtin MSI controller + + interrupt-names: + minItems: 1 + items: + - const: pcie + - const: msi + + msi-controller: + description: Identifies the node as an MSI controller. + + msi-parent: + description: MSI controller the device is capable of using. + + interrupt-controller: + type: object + properties: + '#address-cells': + const: 0 + + '#interrupt-cells': + const: 1 + + interrupt-controller: true + + required: + - '#address-cells' + - '#interrupt-cells' + - interrupt-controller + + additionalProperties: false + +required: + - reg + - reg-names + - interrupts + - msi-controller + - "#interrupt-cells" + - interrupt-map-mask + - interrupt-map + +additionalProperties: true + +... From patchwork Mon Jan 8 11:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513281 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 46E57C47079 for ; Mon, 8 Jan 2024 11:06:48 +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=K9zZ7M+QIzqEIZD0FfBts5sg3q4ojvBaQdkvrusBEjU=; b=L0xrZQ/+KZHGCk wbgU9Fm+U/k2PY7+sCnQjmr6JViMYM9GYPVMunkxq92R5atK1vEFuZBYyi02VkYq/6ZGH38oBLetK wGuPiMlmC2jHXiwKEg0ZLsfCc08Vgmg4YMoR5WiHG+U6VoKAOh70TNjW+SpeU3LjYJ3jSM1pooTwv ZqDMy1FVOw5yIbxl5+LTIU3RMtmu6xWfL7dDBEFD/0uQ6bHUEDwFRpfUGdwC6Fw4XtfgDU7bJrA2b FZekBoKXp2aBJjFU38PhCNq2+YPgur/+AMf/RgdrqhenyZf/ap1rDhSi5vc901ughfR5arApmec7q aXj0wXqM0NOlp8leUIOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSo-004gj4-2u; Mon, 08 Jan 2024 11:06:38 +0000 Received: from mail-bjschn02on20604.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::604] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSm-004ggT-1d for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJXTxR1SH9bN2hfr1cDTbI932U+AUzGtWDUzmb80+/Bp38FRbhduz6bO+Hpo1ly+WEhHT3fMI5GH/ybKCfFVaqBtCf64yyknM6nDXJsEqnsEodkPincZsIcoSz1RIfEPGoZb9pbxJnyiylgj7pyrm0/Fk0jOn84BmwA4YbngsW1zukrQT+6pv7XjhkSBkarLHbhysXrhzVUpfMw4+gglGXfpzyw4N/phJzFqZPl5LEquopwmxZ8Cps2lXGgTJXc7mAsgcCJBvtN0uflrsgEE6nRSndRQpkwd4msvUfX6hSUQtIEds+AUeCh36zuywWVyJpP53vfAx+BCf5rU3AesXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mDUYi15QkcRDF9tWQLyEsrLGA70ww2ACaNBKCRL7qf0=; b=S/DQo4FCMdJExd0h+WKjeG1y6mJH1/HUletr1xDxhXceBlLQ7OxU3VDqnUuyAkEsM3433VIkMqiEpzw2k7HOEkAxzf4UaAiFoqUc1BBmk0TfEEl6vwR4dmdcc6CGtoxRXuQXrw5wlC7BaTeYdZSkXfT++HxUB8fCVygcz2ltAcQGYCubHfx+AsopXBYaqNxS8wsyxACD1416ntKVvXZMainrSJTnuWwxaG0Q7cq0UsBVfBJhPbVHC8I85yIWKDVAvOJm6UkpA0bEdvQH+ftYHeezj7IrBPJGiQnLDoNTvl5xUJv6WQEumVUrAslNCSA9ABa5aDa72+h9tdXG+mA/ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:26 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:26 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 02/22] PCI: microchip: Move pcie-microchip-host.c to plda directory Date: Mon, 8 Jan 2024 19:05:52 +0800 Message-Id: <20240108110612.19048-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e2ed726-5bdc-4c0c-bab8-08dc1039db8d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GS+Zo01bPiD24/5D/ZOHP9yx9/pHVWwavdKVc9nxwcfthq2+xxRc4Wm0Ass8RhNI5obdKd1o8Vva4a7nnSoHQOGvDfO7raXW48w/pj5fz+1hhA+dykHXLt+X0rKoZZZGAZwf4KWoOMgZsPMJQGAxrf5suJscqYVs9LgJ7hwCAVbFsAXwiaotVGSqG0IO0XauLEcnAfNPANyZq1hAfSIrwogg8StQ50btci7h3CDZxIGPlbMdqZdp+CTklV5JPznwRjpsLkRMMFsUDmopR852Kyji0JME6C3+nSS2Rm8pGwxmv4tlSJa6DGv3OqGhtOvTJ8Hz5iP04BNkclSaPiglghz5h8W5HuThZCcER2s4gNb95crNd0p4ZsxdYJ/yTxbVIxZDPX9OvXCX95hirpFFX9m+ozJngqUt8954no/44CdmpMYYar/t8HXEOIDbHLIfpBiv+AjRaI2IZBqaI5NPh/DSuhyaPWfEF1NlYJR+KuCUyqDV2a/WyCc4g72c2AJfN9ssiUS8Nk0TbVJfT39d9LkmZGzQD44IxtMguKjfHSE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001)(45080400002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fvd0XiE30q6lmrX8GndatvpkEtlRRCdBXP4XHfTi/645E88gYXn85yTuDg8VgfqSmx5gtdieFUUa0QOE4GWhEF2H1h/9GfMG3cj9ucFsfcvhb6xjeWD81yNGpKlPgLVD6aoxoXT9SxAU1Irc8xw0WqIfUcAVCouYfPG+i2jTnKU7pNpmbJjX5AknG4N+pIehpFqqR6MyYrDJ+UM2zQhjI44CylW76/oY9Cf3VzFNkCyeOhg/QOdK3eDCqR0+SNvZUX3lz3w2rWa0v2g3Sqh1IZKoLWDl/HrpYUIfGf/LcjgMIaLHJ0gS1hhwSsN1rXgHXqxU4jvMkbN/YRIhOdBiyCXpq8bmbBqyCZHD73uSOm/CT7TVSby6NoJRvmF/Qzz/v5VK66q/JQFpPAZ0u6qebFFQwY5n5NdJC2QqpZDeSdO1PhrWZbZGaQvb0HLmLE5S4NHfzZ86oYM1tS/DxweDKSpS4B5YW0ST4BxAkMCcsAm2npE3nwgWvUucEk9vc2nyDrVWsZ7ruDJ/wN4Tq4M9iUinxr+e3RxOaiNeik3zIBbr2m5wq9CsV6I1OTgPYLfdG/FAV2lyxIYwyxpd0DNTqyhCdX0RZeeQDj3TPunahU3GeTXKxzTm44kXgsr/h4te8S1I0NwA1Aw71E+RRqnstE7tDjjgEM5UKWar1g2CWg0dUD/WOzAnq+Br5gEul/d+9TD1KCboFm2wsvLGT2mg/sOvDkgYBoVUbArL9ZHscaIg9A0LHbYX2TCgTiOJqHfQFkA/FavBWcEC6BBHAEiCB8wb+WjSSWjAl/+fwl7wKodumV0tQdvWyPO9SzA/sWD7CKspmFkPkM3MsbmWfMPJGej6/ikLYUw4zpGMMuWck++8x8oy1PP9IaNLbxW2ngpOBzxAu7ZcZtMMlUDfIq0TvE72P0hyZfWH84m6ruwpJR85c/I1Bs85YJ0Mf3WT7qXUawoU+7jQTrbnTV99D8Z8v47JX6nzEadgUeEjjD1UWbsjkC7t0XTl9ihbABEGvB0DKkGxbekYRHf/NHeceR35Bev/O27Imx4BvVZDjz8IGj0n2SzIm5vqfCxrOVhoSS+0nz/iEQ42xbKOX23HtJw8yamhgWDx9f6pY17rj3Emt7mwttJsgsy4hH/LqpHbx2qjsGokYx/xeEahXqp571teNOHgqwZVnG1k3D/v0Nk7NoOW95PPtDz9+AoKPN674qjXyC6zkNNb6s4ou4Qwznj05Az/wnl+EYe7eo5MHNrMbNHVAY6/tPBaAvqEae6jARwCtCem0Ay2KgLcuixGnKJg16O4E9SYPAEM0SGB8yapfacCBLqqhaDeHPfzny/Gh7+nxCIY4cpzt2RboLpDCVGDijkmCUa0I+gITzwqbdqmkxUmoG1DuCMCITBo3681zacFQqyIZagxja1My89UWSEvqb/Bqrk/6d5YjxAgpX2+bu8DcQtnhjmvdtlqPxtWHa0M/cY9UzvnpUJeJ2iywoxpWv0cfDjv6JKUdWqD3rstAcgFn23sziv79Yh5YrFZe5MzlT6mM/+cYD3gq7iF5yojAA7GzjnpzYH4r2kWf/EWmPULpA1L9ZAG1Z+cg50VS2gfHA4Aydqd+WTno9H9/MLG6A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e2ed726-5bdc-4c0c-bab8-08dc1039db8d X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:26.3834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8pbzYQIymXzdkZ+CUofXY81hYUUI1qvwQJ02K/akrqOIuDpscSiX1yFhWT58MbUQ6nUlyd7+IDAXO9gUwGerEiA58oHx/6oVQPw3Zrn5w34= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030636_546404_1CFC3DDA X-CRM114-Status: GOOD ( 15.26 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org For Microchip Polarfire PCIe host is PLDA XpressRich IP, move to plda directory. Prepare for refactoring the codes. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- MAINTAINERS | 4 ++-- drivers/pci/controller/Kconfig | 9 +-------- drivers/pci/controller/Makefile | 2 +- drivers/pci/controller/plda/Kconfig | 14 ++++++++++++++ drivers/pci/controller/plda/Makefile | 2 ++ .../controller/{ => plda}/pcie-microchip-host.c | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 drivers/pci/controller/plda/Kconfig create mode 100644 drivers/pci/controller/plda/Makefile rename drivers/pci/controller/{ => plda}/pcie-microchip-host.c (99%) diff --git a/MAINTAINERS b/MAINTAINERS index a7c4cf8201e0..1a2a4d2fab74 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16789,7 +16789,7 @@ M: Daire McNamara L: linux-pci@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/pci/microchip* -F: drivers/pci/controller/*microchip* +F: drivers/pci/controller/plda/*microchip* PCIE DRIVER FOR QUALCOMM MSM M: Manivannan Sadhasivam @@ -18587,7 +18587,7 @@ F: drivers/char/hw_random/mpfs-rng.c F: drivers/clk/microchip/clk-mpfs*.c F: drivers/i2c/busses/i2c-microchip-corei2c.c F: drivers/mailbox/mailbox-mpfs.c -F: drivers/pci/controller/pcie-microchip-host.c +F: drivers/pci/controller/plda/pcie-microchip-host.c F: drivers/pwm/pwm-microchip-core.c F: drivers/reset/reset-mpfs.c F: drivers/rtc/rtc-mpfs.c diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index e534c02ee34f..4d2c188f5835 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -215,14 +215,6 @@ config PCIE_MT7621 help This selects a driver for the MediaTek MT7621 PCIe Controller. -config PCIE_MICROCHIP_HOST - tristate "Microchip AXI PCIe controller" - depends on PCI_MSI && OF - select PCI_HOST_COMMON - help - Say Y here if you want kernel to support the Microchip AXI PCIe - Host Bridge driver. - config PCI_HYPERV_INTERFACE tristate "Microsoft Hyper-V PCI Interface" depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI @@ -356,4 +348,5 @@ config PCIE_XILINX_CPM source "drivers/pci/controller/cadence/Kconfig" source "drivers/pci/controller/dwc/Kconfig" source "drivers/pci/controller/mobiveil/Kconfig" +source "drivers/pci/controller/plda/Kconfig" endmenu diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile index f2b19e6174af..038ccbd9e3ba 100644 --- a/drivers/pci/controller/Makefile +++ b/drivers/pci/controller/Makefile @@ -33,7 +33,6 @@ obj-$(CONFIG_PCIE_ROCKCHIP_EP) += pcie-rockchip-ep.o obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie-mediatek-gen3.o -obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o obj-$(CONFIG_VMD) += vmd.o obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o @@ -44,6 +43,7 @@ obj-$(CONFIG_PCIE_MT7621) += pcie-mt7621.o # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW obj-y += dwc/ obj-y += mobiveil/ +obj-y += plda/ # The following drivers are for devices that use the generic ACPI diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig new file mode 100644 index 000000000000..5cb3be4fc98c --- /dev/null +++ b/drivers/pci/controller/plda/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +menu "PLDA-based PCIe controllers" + depends on PCI + +config PCIE_MICROCHIP_HOST + tristate "Microchip AXI PCIe controller" + depends on PCI_MSI && OF + select PCI_HOST_COMMON + help + Say Y here if you want kernel to support the Microchip AXI PCIe + Host Bridge driver. + +endmenu diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile new file mode 100644 index 000000000000..e1a265cbf91c --- /dev/null +++ b/drivers/pci/controller/plda/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c similarity index 99% rename from drivers/pci/controller/pcie-microchip-host.c rename to drivers/pci/controller/plda/pcie-microchip-host.c index 137fb8570ba2..cb09a8137e25 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -18,7 +18,7 @@ #include #include -#include "../pci.h" +#include "../../pci.h" /* Number of MSI IRQs */ #define MC_MAX_NUM_MSI_IRQS 32 From patchwork Mon Jan 8 11:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513311 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 8C76BC3DA6E for ; Mon, 8 Jan 2024 11:21:17 +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=Vy7er0yT3D+aZDolqz1aB8LLccOR/PSZTdXkXx71+80=; b=GifqLFRsYrVgnl +75mmV6ti/6K39OmZDMCyARDaoyTFcfDWYiEdLx/HUna1phT5AjdEQizzeu2oK509Yq6oJMAbsGH7 AO9SOj0CA1DJbDZjO2Ta0kcDkGsQTeyfi4z9izZwpsw72OywpMKbWroBXMc5bIcqRBOFgMd5IHcXv uVwpHigftbYs4sWjilz/IV95i2kIC/Ie5Zzb4Gt0VWy/3eMXyOrAu7l40kR1nnZnHPWCwoKOTZ6d5 YRVKgBOqzNbihUqg9sJjrlZkkbTdYUltubiYhq5rzNM0tLWNMmndCWjhGvOb8GJjQdDZBtEDrnqa+ GKUdC7RB9qxrCjjF9kQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMngq-004liZ-0x; Mon, 08 Jan 2024 11:21:08 +0000 Received: from mail-bjschn02on2060f.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::60f] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMngk-004lby-1O for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:21:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iz84qJkKy5ccn4ziXRvay6D6H+3Y8EHtQ27sWMVXBZsnBO3hxztwuNVQUyJKwKeA7oN0gpXgxg7x63kHjbZYRPVZoH/f9MckmiOv7wtxE+Hz7Ic2fKR4CBK/hJR3e6CXifyDwfKmYJIP9MonmMDwMP9Ge7nM2Ber+SkckfHmjR1bYvXbBjlUQcvbfdaAIcsBO+wderii20KR65DagkYnp1L4/6JvvuEpr0HLZJodqOzuLCKRHa8WywNnY9p4ynYbflLL1NA43f2/rNVA3vTTjNZcIgJYbjIzZ9ixJMTK263eKsDzfo7uGmebFxErGdjwzGYPmXZDxoWrrtMgJPaHhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qyW4EAQbiZYuKYxXJVmGiy2m2BlKuB9GdjQyk91P2Kw=; b=ciWgSOS21hKjlD7EjWOcyVQ8H0rb5vJzynHpJ8gU4LyVPa59OpcuMFjOKJf5v7HIu7mnGnGMy7cK26SIixIgmDsMNSgGhGMk3+zGSE5mhQARrAS3z3cQAkEtC/CC/vgeY+G/xr6hwzJm7XXKFSkb8dAUV9yXgN1QVyMUiEH0Ps3a4NHaub16OOkBYXBCe6A5kQwnbH6ENKgCwSym7JwTzzj5/rBj8Vzhq1iIprSTb9FMiNYL2TSTNL7yX2/oAOFNoxdF1I2wRU+eqmU/jrRt59vjyDdmmMhLpNs5Qqke2i/qCiV8D6UPyu4xn2t5OkImvaCiDxN1bOA2/tV8QQszEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:28 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:28 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 03/22] PCI: microchip: Move PLDA IP register macros to pcie-plda.h Date: Mon, 8 Jan 2024 19:05:53 +0800 Message-Id: <20240108110612.19048-4-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: 896d77ab-ef72-4902-7f68-08dc1039dcbc X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n3RRlv7Qs/2LQXciW4gjR/3iSe/VCszG2LfeYKwi/bOVZTdOOxwtSg57ZIPwkSDdPc6pv0CNoaEkhf7KAYTNZGbDJyOEwHCeg3dtOf7MaDGreoBoFLZ0FD3ZjxzjfSjtSEqYCEKxZ4jcjJuEKezyT5UACDRHHFPugGBXKZsffKEtMpOuxW6nXFYszg2gevNktwfq2ddI5s8r12Es8wDfCAjJIqHbrZWAg/VkjSWD6TtO8NXzQ/o6UN4rycTrKuku4nINIL1MayJsRy8wLpnT02OYDSSy397ZFS/XgWiXJYw5/yF5iGOR4hFBiBXla8k1YCwjDF+oNkSgjQjLEC6uPrUIH4KAMhuXmnTJir1UAimsYjSdY+s1VtlrMdHbzrMXyEHWenXSdUcO3MyVEKf0AHCo+wtXZ/AJznOWAwfNsd8+U547KEFKENGE/bLDq20LEHmm3oE/KCESMrJYASiJgjmM4+sIxXVANNVm/5CQizDz/uOpZqh9kujueRdWWr0cd9FR9Flo9hx8dX05Mh8OJsrTlCi+TpRrd1yfv0YjfSgmfXh3VtDKYZIBW0JxSYXp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(30864003)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZzHVN2jk50FhDYUdk9oHDl4UWGBCVMLlxcVzMMrnCKdu6l1CWLz2PeshqYMDfJAJdw3r3oJYkGod5wpbXSc9ceFEUt7qmi1oT/JBJp9G4/8WH8kFCzmzzTERtjnNnIcmP9r+JLaoCDARb2wNHraF56JjemHU3z02eEJJjmhcAfmJwfU5KoDv7EhZLeFvTqi7oyXmOtDUylsAKoSgfsMhxc3fYuq59kdqiVL+Dm33FHYHjYp3TzD/LFlyzpgQyrzMKh2oZSK/IJz+LkypdAybRpXLB0KDzAZ+Ix2V2m3YT+pJi9pKwHe580PJfjrqTC9FxwEaqnog9IEaterbqxt6Z7opOd/YYhnr2RQXtqZVAYJJ1Ix15O6E4vGDFXDDcqBjhN8EgQjrajrsGfD8Jg70ZBBDxSjUn7USuJRgebfMydLR5OZjzFodCLnj2ncRCJ0S9VdvI6UWbTBtsifsP2xifQ9jTfuXuPAT5jbp4FC3wWush4yNqPBOZdjr0o3MwVmTaRmb3lNoxLBY0TNCRABTAWcbCQLo6jVFTQFCRb3DNJKrOo0ISh5MX9/Z2I2/va9y8tAC4yRSNcv9iHOmihaiuG1zXQso5NlTlIRhyzWUwLuB6sod8nLzb4IWCa9O5JXrF+hCBS3egw4jwP+KOvLCe8Qt/+mOzD1sXQgVt/mdswHUUkx3Sc9peFhyfAVVwG54O+kuUjdNmvXjRPoMVuyw3tFW/zip8A5/XL4g56UdTV5p25Kgw+Rrh4BuXtptBPWZkQ5FuKyoWJOzH1pAd1Zri6SLJW0apb2EaWOpYKKq5lPIxTH24Cz2B+7wTBkLnfjKrwFX6dqcCoPf7ZzGbBRVObOhsvcMpXVbgHkUcU+lulJu5ElFLbkuHVMxMzHc90Hxzm5Ca/B/allBQb+o8+yBZJehxJKhxP613enL1ZCk2npXJYYAjh65GIoIYbRIFhQG/Mj76U/7H8viCrewO3bKpmsvbSh13hq/IacZeMAshLbUOcKtPYG2haQt3V4twsHvdN0dkIEBFipO39wzpv3Qfx0wO3HoxyWrFu4UKlHF1hTVmLebxEKhBvJF3/RkgyXbW8r495KgCXRaz8LRE8OMAfR/mXwNmcAv3PXLTy7gTHh9k05qn3OPG/YduGUvC6/DxPNkLQl/ElM9hzlB21J+waOjV7zV5BIKTXLOat5QDwt43kLqQPDUhcn9eWb6Cm9TUhk5PjPvZjdtWexVkTnb5OVA+iBqg4f1InGWubulguYnhwRiDaT3B5pWBcm2f9s8ac7Jl5iMaKTDCttKUlgD06JhfpMzxjs8futmghDmUuTeWUkckJt2DnNDLofNQTy92O+7MFGoVsQBLRCj1LUeQI9qGKteax8m6lsEwy9HVlpuhcYh6m2Y/CV0CqW/WQtmU9Ww+st1U6poBjN4ueMqSqr7FTyNgWz6SEPb6nMztVhh76S3NuikM4abye9qzATpRCevCZsKGG+XXEXd7F5f/zA1umO0Juu8wSmET/04JiMVxpZFn1mknHh67ZevYMrnzt3t4Gqq3HwvWYq8aeazqq+QEhTZDlykefkU7eUy/vXCiWFvNehc3uLxrINEPeizRnnJUv2YliZ7ltxfnBMTeg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 896d77ab-ef72-4902-7f68-08dc1039dcbc X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:28.3766 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JB9lk4xJSnJ+dr6Ii+KixusnyCesvjaxu/ftO2FX+9sHe4ZtO8ieBFXksrElQdC1SJX8u2kLextZIkKjqBjut5IFghIyRP8Fz1e97548+tk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_032102_659542_53A9C3CE X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move PLDA PCIe host controller IP registers macros to pcie-plda.h, including bridge registers and local IRQ event number. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- MAINTAINERS | 8 ++ .../pci/controller/plda/pcie-microchip-host.c | 108 +++--------------- drivers/pci/controller/plda/pcie-plda.h | 108 ++++++++++++++++++ 3 files changed, 132 insertions(+), 92 deletions(-) create mode 100644 drivers/pci/controller/plda/pcie-plda.h diff --git a/MAINTAINERS b/MAINTAINERS index 1a2a4d2fab74..730fe2d640a1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16557,6 +16557,14 @@ S: Maintained F: Documentation/devicetree/bindings/pci/layerscape-pcie-gen4.txt F: drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c +PCI DRIVER FOR PLDA PCIE IP +M: Daire McNamara +M: Kevin Xie +L: linux-pci@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/plda,* +F: drivers/pci/controller/plda/*plda* + PCI DRIVER FOR RENESAS R-CAR M: Marek Vasut M: Yoshihiro Shimoda diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index cb09a8137e25..d9030d550482 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -19,6 +19,7 @@ #include #include "../../pci.h" +#include "pcie-plda.h" /* Number of MSI IRQs */ #define MC_MAX_NUM_MSI_IRQS 32 @@ -30,84 +31,6 @@ #define MC_PCIE_BRIDGE_ADDR (MC_PCIE1_BRIDGE_ADDR) #define MC_PCIE_CTRL_ADDR (MC_PCIE1_CTRL_ADDR) -/* PCIe Bridge Phy Regs */ -#define PCIE_PCI_IRQ_DW0 0xa8 -#define MSIX_CAP_MASK BIT(31) -#define NUM_MSI_MSGS_MASK GENMASK(6, 4) -#define NUM_MSI_MSGS_SHIFT 4 - -#define IMASK_LOCAL 0x180 -#define DMA_END_ENGINE_0_MASK 0x00000000u -#define DMA_END_ENGINE_0_SHIFT 0 -#define DMA_END_ENGINE_1_MASK 0x00000000u -#define DMA_END_ENGINE_1_SHIFT 1 -#define DMA_ERROR_ENGINE_0_MASK 0x00000100u -#define DMA_ERROR_ENGINE_0_SHIFT 8 -#define DMA_ERROR_ENGINE_1_MASK 0x00000200u -#define DMA_ERROR_ENGINE_1_SHIFT 9 -#define A_ATR_EVT_POST_ERR_MASK 0x00010000u -#define A_ATR_EVT_POST_ERR_SHIFT 16 -#define A_ATR_EVT_FETCH_ERR_MASK 0x00020000u -#define A_ATR_EVT_FETCH_ERR_SHIFT 17 -#define A_ATR_EVT_DISCARD_ERR_MASK 0x00040000u -#define A_ATR_EVT_DISCARD_ERR_SHIFT 18 -#define A_ATR_EVT_DOORBELL_MASK 0x00000000u -#define A_ATR_EVT_DOORBELL_SHIFT 19 -#define P_ATR_EVT_POST_ERR_MASK 0x00100000u -#define P_ATR_EVT_POST_ERR_SHIFT 20 -#define P_ATR_EVT_FETCH_ERR_MASK 0x00200000u -#define P_ATR_EVT_FETCH_ERR_SHIFT 21 -#define P_ATR_EVT_DISCARD_ERR_MASK 0x00400000u -#define P_ATR_EVT_DISCARD_ERR_SHIFT 22 -#define P_ATR_EVT_DOORBELL_MASK 0x00000000u -#define P_ATR_EVT_DOORBELL_SHIFT 23 -#define PM_MSI_INT_INTA_MASK 0x01000000u -#define PM_MSI_INT_INTA_SHIFT 24 -#define PM_MSI_INT_INTB_MASK 0x02000000u -#define PM_MSI_INT_INTB_SHIFT 25 -#define PM_MSI_INT_INTC_MASK 0x04000000u -#define PM_MSI_INT_INTC_SHIFT 26 -#define PM_MSI_INT_INTD_MASK 0x08000000u -#define PM_MSI_INT_INTD_SHIFT 27 -#define PM_MSI_INT_INTX_MASK 0x0f000000u -#define PM_MSI_INT_INTX_SHIFT 24 -#define PM_MSI_INT_MSI_MASK 0x10000000u -#define PM_MSI_INT_MSI_SHIFT 28 -#define PM_MSI_INT_AER_EVT_MASK 0x20000000u -#define PM_MSI_INT_AER_EVT_SHIFT 29 -#define PM_MSI_INT_EVENTS_MASK 0x40000000u -#define PM_MSI_INT_EVENTS_SHIFT 30 -#define PM_MSI_INT_SYS_ERR_MASK 0x80000000u -#define PM_MSI_INT_SYS_ERR_SHIFT 31 -#define NUM_LOCAL_EVENTS 15 -#define ISTATUS_LOCAL 0x184 -#define IMASK_HOST 0x188 -#define ISTATUS_HOST 0x18c -#define IMSI_ADDR 0x190 -#define ISTATUS_MSI 0x194 - -/* PCIe Master table init defines */ -#define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u -#define ATR0_PCIE_ATR_SIZE 0x25 -#define ATR0_PCIE_ATR_SIZE_SHIFT 1 -#define ATR0_PCIE_WIN0_SRC_ADDR 0x604u -#define ATR0_PCIE_WIN0_TRSL_ADDR_LSB 0x608u -#define ATR0_PCIE_WIN0_TRSL_ADDR_UDW 0x60cu -#define ATR0_PCIE_WIN0_TRSL_PARAM 0x610u - -/* PCIe AXI slave table init defines */ -#define ATR0_AXI4_SLV0_SRCADDR_PARAM 0x800u -#define ATR_SIZE_SHIFT 1 -#define ATR_IMPL_ENABLE 1 -#define ATR0_AXI4_SLV0_SRC_ADDR 0x804u -#define ATR0_AXI4_SLV0_TRSL_ADDR_LSB 0x808u -#define ATR0_AXI4_SLV0_TRSL_ADDR_UDW 0x80cu -#define ATR0_AXI4_SLV0_TRSL_PARAM 0x810u -#define PCIE_TX_RX_INTERFACE 0x00000000u -#define PCIE_CONFIG_INTERFACE 0x00000001u - -#define ATR_ENTRY_SIZE 32 - /* PCIe Controller Phy Regs */ #define SEC_ERROR_EVENT_CNT 0x20 #define DED_ERROR_EVENT_CNT 0x24 @@ -179,20 +102,21 @@ #define EVENT_LOCAL_DMA_END_ENGINE_1 12 #define EVENT_LOCAL_DMA_ERROR_ENGINE_0 13 #define EVENT_LOCAL_DMA_ERROR_ENGINE_1 14 -#define EVENT_LOCAL_A_ATR_EVT_POST_ERR 15 -#define EVENT_LOCAL_A_ATR_EVT_FETCH_ERR 16 -#define EVENT_LOCAL_A_ATR_EVT_DISCARD_ERR 17 -#define EVENT_LOCAL_A_ATR_EVT_DOORBELL 18 -#define EVENT_LOCAL_P_ATR_EVT_POST_ERR 19 -#define EVENT_LOCAL_P_ATR_EVT_FETCH_ERR 20 -#define EVENT_LOCAL_P_ATR_EVT_DISCARD_ERR 21 -#define EVENT_LOCAL_P_ATR_EVT_DOORBELL 22 -#define EVENT_LOCAL_PM_MSI_INT_INTX 23 -#define EVENT_LOCAL_PM_MSI_INT_MSI 24 -#define EVENT_LOCAL_PM_MSI_INT_AER_EVT 25 -#define EVENT_LOCAL_PM_MSI_INT_EVENTS 26 -#define EVENT_LOCAL_PM_MSI_INT_SYS_ERR 27 -#define NUM_EVENTS 28 +#define NUM_MC_EVENTS 15 +#define EVENT_LOCAL_A_ATR_EVT_POST_ERR (NUM_MC_EVENTS + PLDA_AXI_POST_ERR) +#define EVENT_LOCAL_A_ATR_EVT_FETCH_ERR (NUM_MC_EVENTS + PLDA_AXI_FETCH_ERR) +#define EVENT_LOCAL_A_ATR_EVT_DISCARD_ERR (NUM_MC_EVENTS + PLDA_AXI_DISCARD_ERR) +#define EVENT_LOCAL_A_ATR_EVT_DOORBELL (NUM_MC_EVENTS + PLDA_AXI_DOORBELL) +#define EVENT_LOCAL_P_ATR_EVT_POST_ERR (NUM_MC_EVENTS + PLDA_PCIE_POST_ERR) +#define EVENT_LOCAL_P_ATR_EVT_FETCH_ERR (NUM_MC_EVENTS + PLDA_PCIE_FETCH_ERR) +#define EVENT_LOCAL_P_ATR_EVT_DISCARD_ERR (NUM_MC_EVENTS + PLDA_PCIE_DISCARD_ERR) +#define EVENT_LOCAL_P_ATR_EVT_DOORBELL (NUM_MC_EVENTS + PLDA_PCIE_DOORBELL) +#define EVENT_LOCAL_PM_MSI_INT_INTX (NUM_MC_EVENTS + PLDA_INTX) +#define EVENT_LOCAL_PM_MSI_INT_MSI (NUM_MC_EVENTS + PLDA_MSI) +#define EVENT_LOCAL_PM_MSI_INT_AER_EVT (NUM_MC_EVENTS + PLDA_AER_EVENT) +#define EVENT_LOCAL_PM_MSI_INT_EVENTS (NUM_MC_EVENTS + PLDA_MISC_EVENTS) +#define EVENT_LOCAL_PM_MSI_INT_SYS_ERR (NUM_MC_EVENTS + PLDA_SYS_ERR) +#define NUM_EVENTS (NUM_MC_EVENTS + PLDA_INT_EVENT_NUM) #define PCIE_EVENT_CAUSE(x, s) \ [EVENT_PCIE_ ## x] = { __stringify(x), s } diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h new file mode 100644 index 000000000000..cad3a98d967e --- /dev/null +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * PLDA PCIe host controller driver + */ + +#ifndef _PCIE_PLDA_H +#define _PCIE_PLDA_H + +/* PCIe Bridge Phy Regs */ +#define PCIE_PCI_IRQ_DW0 0xa8 +#define MSIX_CAP_MASK BIT(31) +#define NUM_MSI_MSGS_MASK GENMASK(6, 4) +#define NUM_MSI_MSGS_SHIFT 4 + +#define IMASK_LOCAL 0x180 +#define DMA_END_ENGINE_0_MASK 0x00000000u +#define DMA_END_ENGINE_0_SHIFT 0 +#define DMA_END_ENGINE_1_MASK 0x00000000u +#define DMA_END_ENGINE_1_SHIFT 1 +#define DMA_ERROR_ENGINE_0_MASK 0x00000100u +#define DMA_ERROR_ENGINE_0_SHIFT 8 +#define DMA_ERROR_ENGINE_1_MASK 0x00000200u +#define DMA_ERROR_ENGINE_1_SHIFT 9 +#define A_ATR_EVT_POST_ERR_MASK 0x00010000u +#define A_ATR_EVT_POST_ERR_SHIFT 16 +#define A_ATR_EVT_FETCH_ERR_MASK 0x00020000u +#define A_ATR_EVT_FETCH_ERR_SHIFT 17 +#define A_ATR_EVT_DISCARD_ERR_MASK 0x00040000u +#define A_ATR_EVT_DISCARD_ERR_SHIFT 18 +#define A_ATR_EVT_DOORBELL_MASK 0x00000000u +#define A_ATR_EVT_DOORBELL_SHIFT 19 +#define P_ATR_EVT_POST_ERR_MASK 0x00100000u +#define P_ATR_EVT_POST_ERR_SHIFT 20 +#define P_ATR_EVT_FETCH_ERR_MASK 0x00200000u +#define P_ATR_EVT_FETCH_ERR_SHIFT 21 +#define P_ATR_EVT_DISCARD_ERR_MASK 0x00400000u +#define P_ATR_EVT_DISCARD_ERR_SHIFT 22 +#define P_ATR_EVT_DOORBELL_MASK 0x00000000u +#define P_ATR_EVT_DOORBELL_SHIFT 23 +#define PM_MSI_INT_INTA_MASK 0x01000000u +#define PM_MSI_INT_INTA_SHIFT 24 +#define PM_MSI_INT_INTB_MASK 0x02000000u +#define PM_MSI_INT_INTB_SHIFT 25 +#define PM_MSI_INT_INTC_MASK 0x04000000u +#define PM_MSI_INT_INTC_SHIFT 26 +#define PM_MSI_INT_INTD_MASK 0x08000000u +#define PM_MSI_INT_INTD_SHIFT 27 +#define PM_MSI_INT_INTX_MASK 0x0f000000u +#define PM_MSI_INT_INTX_SHIFT 24 +#define PM_MSI_INT_MSI_MASK 0x10000000u +#define PM_MSI_INT_MSI_SHIFT 28 +#define PM_MSI_INT_AER_EVT_MASK 0x20000000u +#define PM_MSI_INT_AER_EVT_SHIFT 29 +#define PM_MSI_INT_EVENTS_MASK 0x40000000u +#define PM_MSI_INT_EVENTS_SHIFT 30 +#define PM_MSI_INT_SYS_ERR_MASK 0x80000000u +#define PM_MSI_INT_SYS_ERR_SHIFT 31 +#define NUM_LOCAL_EVENTS 15 +#define ISTATUS_LOCAL 0x184 +#define IMASK_HOST 0x188 +#define ISTATUS_HOST 0x18c +#define IMSI_ADDR 0x190 +#define ISTATUS_MSI 0x194 + +/* PCIe Master table init defines */ +#define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u +#define ATR0_PCIE_ATR_SIZE 0x25 +#define ATR0_PCIE_ATR_SIZE_SHIFT 1 +#define ATR0_PCIE_WIN0_SRC_ADDR 0x604u +#define ATR0_PCIE_WIN0_TRSL_ADDR_LSB 0x608u +#define ATR0_PCIE_WIN0_TRSL_ADDR_UDW 0x60cu +#define ATR0_PCIE_WIN0_TRSL_PARAM 0x610u + +/* PCIe AXI slave table init defines */ +#define ATR0_AXI4_SLV0_SRCADDR_PARAM 0x800u +#define ATR_SIZE_SHIFT 1 +#define ATR_IMPL_ENABLE 1 +#define ATR0_AXI4_SLV0_SRC_ADDR 0x804u +#define ATR0_AXI4_SLV0_TRSL_ADDR_LSB 0x808u +#define ATR0_AXI4_SLV0_TRSL_ADDR_UDW 0x80cu +#define ATR0_AXI4_SLV0_TRSL_PARAM 0x810u +#define PCIE_TX_RX_INTERFACE 0x00000000u +#define PCIE_CONFIG_INTERFACE 0x00000001u + +#define ATR_ENTRY_SIZE 32 + +enum plda_int_event { + PLDA_AXI_POST_ERR, + PLDA_AXI_FETCH_ERR, + PLDA_AXI_DISCARD_ERR, + PLDA_AXI_DOORBELL, + PLDA_PCIE_POST_ERR, + PLDA_PCIE_FETCH_ERR, + PLDA_PCIE_DISCARD_ERR, + PLDA_PCIE_DOORBELL, + PLDA_INTX, + PLDA_MSI, + PLDA_AER_EVENT, + PLDA_MISC_EVENTS, + PLDA_SYS_ERR, + PLDA_INT_EVENT_NUM +}; + +#define PLDA_NUM_DMA_EVENTS 16 + +#define PLDA_MAX_INT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) + +#endif From patchwork Mon Jan 8 11:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513282 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 9812DC3DA6E for ; Mon, 8 Jan 2024 11:06:52 +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=g6FzgD7fUpv/D7ivZYWzPKNH6D26wnKXMe48BKrt7WU=; b=yVWYJSFLi4gfoL 7bxl4MOzBaIchOQws019iOVXtp3dvOe/JPTCujxBWoUOlJuAbSwCLFtsGSFFliVG2ayPSE6SrtoqM qCkAcYXKLEfljMcRCHdX1ilnmuUDUwA/eRnzxOaKtW1h8NbKosTicVpqTGsSg5kDsowSOq92aRz4Y ww6n7X/SWopOd3SY0p7YhEOPBqZHSWPqUIq8wXAiXsH2ajQIAd/74821ClRFgkSn9g8eChGBoXHaF WQ9PWdpKurTtZ7seFmejXccWl/LbulZw06UAp0Opz9rQeYNus2RCQgoUSwx/hpSWdVppJxcosvaWJ cKjgBJqgD2bTAEP2SidA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSt-004gl7-2E; Mon, 08 Jan 2024 11:06:43 +0000 Received: from mail-bjschn02on20604.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::604] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSq-004ggT-2S for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BODUrkhU0N/ylHT5ewSAdQkJg1O9VA0c+jhv0rAv3ulmjoEAu10aiON2BjNY96RhZk6aAX7g2V6DuxhlyiSSc6+3Rgi/41TjuZx29TFOBwvasEZm3nzge+8EazyYSgBly7UHT6Zl4ckdHO2oExArh/0F06EhWm+0Es0aSekhXyqEY2AyTL8URNcalEY+WuLxyB98wMv9rnlUEup1QokhO+3D939DR0ySmqYriSoKy5b8TewOf2PxQJjJ1qw+9B0NpPTXYLCKN+1zC7LY6CEJBfnI+OloMoru9U8gNuM/CD+2SCjROnPThaAk8sF0sGy2GuSfJc34w2Edp21w22Q1mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qx5Yb/mH7vkRlelY89RpGgyd0V1vSjgcQXjlTiRgDK8=; b=WbqQBrxfT8esIYdtfth1tyjgsq/IUpqysX6T5pamjz+aLq8C3Mm7CiPBlGzNcmtS3neOctDJt4tDCbtUuHd7cLEM/VQYnVaO7DLw1R5c0dusQXRFnkvhKuRZzImnm/Bbsx3Mh0CKKtGFH76HuEYeErWp3xUmsrB8+sWUfmdklkd5HBjTfq0/eX2mMNGxiaOJ/gGNfnpTdum3svjzvWHwBkoPjvgan66mKdHkwjq3pqSoevHs44Uc+3D0JjHOLxyXMa+QcwIsUvzbQc1JePkc9R720/g6NmEYqzPll4xv8SusHnhUGfYoxGlZMdicNjpGMqfsVWezydU0yCzsyeYscA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:30 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:30 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 04/22] PCI: microchip: Add bridge_addr field to struct mc_pcie Date: Mon, 8 Jan 2024 19:05:54 +0800 Message-Id: <20240108110612.19048-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: d69c881f-2a77-45d9-e1d4-08dc1039dde8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LlRXAkzP6esPo1JGDsT8mo4Zym+dzUuuZEFWIjkP3a4XiGaHHXjBPnmHhQjEFko17uczJWPGNV7d9G26XnxtaAm58XX5FpdRbY+p8N04LOyXwngSCDCiipXwg1a5gGkHt8BdQ+1HSFnxqEPrvvMpFnLqaVt+dgoyLIlj7OCgu7aV684i9C2u74xBM8puOamwZ0kmh3x9fMzHy1EiVtK/YvGgjrzNoGHrVmEn0enMcAq38Y1u952CgJcDDzfU/dNlixksPUFiGxrR6tYAb10bPrGCNACWdkAmL9mtqeA34RzIVLDm1ywKHv96v8ivWjJ/0VB+KsLwhs8T4d4KU3U3d5ljYhvTisJvkCq7tU9FLVUYpyRBCEdGUwSahgnWOltoVNDFqIbaHwK576kZIsCBlihqV64O3QfilrsQN397DOifSc+9dglbrIihv1xqL8lzBQBZPe9SBNwsazF3wDn0QydgHc6+bohb8Rr6Ezeixq/f0JdZICpHwqqhTOYHqIjwWafcCpQQLxqefZfqDkWg3XktKaEvw+WCijn1HpEylcTZyc9RWx/czL2YJub2+ZdM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BJJopD0hd92xIXw1XeoVFqXZVytQ621YN99/G1hklruIsgCXu5eMeGCUyi9aeVUM3G6ZgG3D+qRyqkQYe9Em/rD3WZ4oiwr3g9qfRun3khuMl6dJ7sbSUgMIuBhGU4dFi7o/x+9zRTcydsVbOW2DFcOgCxJRE+5R+jZg1leIR+qeSctBy99MOtI/obIbjeQvftwNt/K7+S8W+ZbvhoQhK62fCNnHa2A/M6NSCBUopEaQVeDQr/EZbtbCr3wdirlR46mOVMuMDKxuJdcM25F2FWLcqiNgePXxkfLqRlWVzMVb2lEAVcKHP8pfGUHfCsaR4ofdE0V8/eV2lrxz1dvh7j6x1zjepvALYMhkJBlbAR6cKg/0z4fsjI5trgWUQFER+gnX5KK6/UephwjWSP+YixCkkTIWQtTsMe4rEuUyeTX/QCGC5gOljWzvrO76B/X3UMqxjRufMg6D6TT3hDusaim64YpAwj7QDP2N3wE6tJZiP4Wa6mL4F1TlicqkNQ3gqA1aXHtXDlL3kN+/tn9IlviRwyZKYqBQ5+5ef0xCol18W0d2wzy5lXNJHigZdqBoW2XulVSQW+6NBJQ43/vg/emuyIdIro+okXZYaqGXmOPRJjZiZnyP771z/vpIq1xC90OiqDpaxJUdxDkvREO0o9SdNKJAm90PuuXRhscWm2yBfXbyjHB9eFqaOoH/2hCnKmWBYMko3gD2E3aDOHxMWcd2Z2LstLiS021i20CBKtyza1mLfuJw+IC7Q7hwI+CBGTqJY+OfZHFJhlaOumgQ7VBmt761fk31jlTNNS7/FhR6L2VEgfNXzTawZLNiK56v7VKwGmExE9nEhqe4G/R6b3mQNdrQYm43AhlFhOiNcIDaVkMIkYGjQEQYixO47PCXFtK9VeD176gP2IhbafWxQJG2XJdp0QpI/wqlQvbadxfrovhxXNedEsur6LFFvoFIiHM+ord/14dHDo28OmmHUCz3PFcrJEuONanzIXCNyPCoOTItsvrlsLBTd4Jnzty0NcAfzAK0OS4Zt5klsBt5gibbERCULMcZjlkhfSj9ywD27AVZS+X2llKzYT4L6jgDYNG/WRvCMxgCvhQOp7a92ZHUHhSJ0MWgMemis4ISD/yL/fk89AM/MDwFbJnTTWAvHaX1ChiDaep6uSqiqrtV7xRHVDqSsboOXnpg0lsBUkkFjysaajZObxfsUaL6MXjjQcfLdfmWGVF5UOpVed6l0q7sE4wdFcO5PZJVQDfnsNCwhrzl0t0WLZKMRHIxTwUmzHyJnVU1wJCbiaWI6RiQw+h4crOh1YhLDRKucgIXs2ZAYJiWZqIBIKX21GeUw/7Fn790hP96RQSiOTy3nfNpffZqgNNRTaw82LKPOXxzn/J4OISUtShfHrKEsME1SgNelUe/2yEPV9SwrXjsZDMLmfj03r+3ePej6OAbEy7ZIj1/46v872GJLIAyeV15w5fE5P3ivoQdC1prfMnyDdmDgMCsLhdqwoCUScmtYmCqtR5VQs+JRbs7uIQYYmM4zxtfMfzw8LTpnZdc8MukVMuJ0JQnZlGvChfykgIDU4bjbovIeHWjFYUnUjWPMs5PD1HmJQNNzNyaPHX2NXiTjYycDQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d69c881f-2a77-45d9-e1d4-08dc1039dde8 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:30.3311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4owNnNre7KIBa3J+FQS69MsqZukZf09dBStXuzILp/AcW8MWsqn9lF2aWPrIzP96wnIU4+Oj4GCoZo1ZAQmg9wfkhOgdiGG+vwhVxk3mPA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030640_800660_8AB1A51C X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org For bridge address base is common PLDA field, Add this to struct mc_pcie first. INTx and MSI codes interrupts codes will get the bridge base address from port->bridge_addr. These codes will be changed to common codes. axi_base_addr is Microchip its own data. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index d9030d550482..c55ede80a6d0 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -195,6 +195,7 @@ struct mc_pcie { struct irq_domain *event_domain; raw_spinlock_t lock; struct mc_msi msi; + void __iomem *bridge_addr; }; struct cause { @@ -339,8 +340,7 @@ static void mc_handle_msi(struct irq_desc *desc) struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; struct mc_msi *msi = &port->msi; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -365,8 +365,7 @@ static void mc_handle_msi(struct irq_desc *desc) static void mc_msi_bottom_irq_ack(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 bitpos = data->hwirq; writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); @@ -488,8 +487,7 @@ static void mc_handle_intx(struct irq_desc *desc) struct mc_pcie *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -514,8 +512,7 @@ static void mc_handle_intx(struct irq_desc *desc) static void mc_ack_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); @@ -524,8 +521,7 @@ static void mc_ack_intx_irq(struct irq_data *data) static void mc_mask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -540,8 +536,7 @@ static void mc_mask_intx_irq(struct irq_data *data) static void mc_unmask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -896,8 +891,7 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, static int mc_pcie_setup_windows(struct platform_device *pdev, struct mc_pcie *port) { - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; @@ -1081,6 +1075,7 @@ static int mc_host_probe(struct platform_device *pdev) mc_disable_interrupts(port); bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + port->bridge_addr = bridge_base_addr; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); From patchwork Mon Jan 8 11:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513283 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 247A4C47079 for ; Mon, 8 Jan 2024 11:06:54 +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=atpLB6JBPBzpFddLwg6zX/twIBpzMNkl1Fj42v5I404=; b=fmt1TB/GufxLH7 PF2vc9C1SuBl7otg9W40pO1bdORuG0gwARjp70axbM3XTd59ui0OWeWJlAEUQdXtr/x1/fhBtYDYz 8rLyIJpazz4ySd74C7LlE6loi98gQLCqwCwqqRxtC6OjhmAt2Uomtf6CiqaSqKmsokn9DcDXxv5ht UMzxJ5+wXYk2z7qFEMXtoNAuCFbGi7Gf5bq42nR+Ddc15SlGID/zawjYZBG5vp0SY8NPR8AckDoFC 64YszGGhJD5WqDMaT99oShOG8QgTjzhy7TqQ0ouwHFLvk0iL0qObilf9D8vOg224JVSANNVwB9ZHf tj8Hg/ziX2JjswLbxlQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSw-004gmg-1L; Mon, 08 Jan 2024 11:06:46 +0000 Received: from mail-bjschn02on20604.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::604] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSs-004ggT-1y for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iGPeE0ZdGrdv1wFiOj7kvn/YslIlsNEeF5Ylpc1LFBiHd8XK6snmXcfeHL4md3Ij0bsLs0cCSeZqNsOc6MjYzGHrqJ3UgiTrjNdObRDmpsHPpTHJeMVTz3fpFGZJwGh7OoS10FnDf2+S9W6tPCIY0E7MkSfKU4VLVQJt67fswRuI3MFCNyWF73oal9gjBowewlCfdXbNmU6QpX6Inilfq/Ml7AUz/qK5Q9lvF3zoD0EBV6vgSPo5YSv5sbLVrtxC1MdynL1qnn/uIEZt87KRsN8vcNJrlAiVxpfT3kvFoOk1nA1eGnSXoOVBcXgkg2g4hupcMV2GLEglSjTZGMLb6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ka7gQ18jYzgl7s0/ZhcM3h/EGmQOqNnXDwuI+C34490=; b=miv/KfjIF/ANNqWfu54Yq8dxyOn/ygkQjDsVSdXST5EsRaqUy8SIdAAHiRtnqwBWzM0hKFF/h7qVF+3FmSYmEFYOkIDE0dg+4PNMwSC0WX7DFkzTBV4YR/3wJy35fRLHGTmNQqdFmf5YGkYVxETIYYw+/xJ8EJPoZ56e+SWXbEX/s7jqul2J3iNaQCJc6VZPQYokK/1hj3qe5YJQWG3+i6cI6yv2Q10/sve+nZHc/H4Gr9xqhzA3mf9xey27kqY5a+fKojmhvMLd6DpIpn8lB8hDlnRS7Nm8s8KkgupIYkaXRYbvJskAsVTW6YDjmnf0H+ZCUKnz3IR402PX2TLrFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:32 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:32 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 05/22] PCI: microchip: Rename two PCIe data structures Date: Mon, 8 Jan 2024 19:05:55 +0800 Message-Id: <20240108110612.19048-6-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e1cd0c0-f8dd-4c7a-e1e1-08dc1039df12 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KN92FCEQWeKPDtWJxAJvEjikoeP4wjzvTEnMD7HAf+X626v4IiP3rdQEv7GV9SV4mQ++ybAV34kadoVCNy65V1jERFHj7D5+7vsW2BDcKN5dSGL6/8QflRyK7hIqmX642s5WJ6Ma8JYYOvoC4dckY1cNh4jWCvp4IPpKY+9uyfR0FAB+Ta5m6pKgH5XhMwZ56ylKswceRm+zRTi4dPl+50ARAqRxR2uCbHcM77s3B2um8I38fbhKCLipGL1dU6k4vjliVMMXt1is5wUzWFw6n32J0HoLy1lpkSpazBpI+J95J+AZNpYMGjRWM3/sMvFQNcqdHlEWLc7FR/ENouux37H2cXZAqUQVJA/hR1ZrewpqrYVuVl+m7Rrd4WxhQrDsEwqLMXXnDO5rSGYI3GW1VMxVXWyehJ7B+Ov/Rczg1D1zhat0UivjLEsQ/E29eH16pncOx/fQgr0Vp316S9MNCzFX93fidgIGqHidqXZLwZpCabEqeyAq4hTum+CQm8MFb7TeLEEsG52LkIyZNOGWAEKHQSavfQd4iAnJvK4BqOIMBFr08pZRak3nx4umwhjV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(30864003)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ip0HpvumOvHXffOvdA4Afmb+t1JeiLOUJSmvs6/0Op7BPtHFXCMH2Lzx7bEa+xpaFqFe33zlqSRLk/oa3CWoV5qTBbYGsunKoRiEBvzCIgdivenURsS7lIQLwdwr9HprFTlrKP6uUIUcq/mpbPswDXqnkxKzdZcb95hDCXtZNbgFodWmh8E4SrZT6rOc0380+Msf7lByPB5SU/7l8pFbWYtaSz0yh2v969zhthiCMRQG0ENfwKsoMzzRomYPVAn3chKIasi0yTYE/zC9uCNMJ9D6r82bSqtkXAkrC8JN9mexCJ5EEjEu+sbMLcuXD1UB+pZo3vLe6yWg1+1wIy+sCY7XHYEqX1GWX7eLnq5ymVd4Vf7tuL/s/iUGej3FZFkxYWSMzhBzoNkJMdv1T2OZEMMvV/iGTOnPtGvsVfw8j/s9IygCod1OAYT6DrxFzxaOEkJzxVYdxB9WsgH07MSzIgwUUuGUixvo3jnKzT79r4ufG0KFX9U0zVplMoTTQfB+3Pel7xwf1O3Eg1ci83q0HgZGh7eoVFbFVV8UJBABB62KzFcMZ4CcKHnSNy/AZT0EODJpuuZblLExpLp0uoLUl5VCaspmWxJIBv3ZLinMlF4HEyRzwxyVf6q+hC0sbygBi28RGoUQgQKKml69l/TtUuZtd+YP/M+xiif5FvmORdYqTKCP++3vGpwmXT2ZtQNQfAzOp5wew4PNuRa0rKBZRcBJMRjGUrjXKz9Tpw/1C+CMmAYx88NuX/+FzOPE7NpeDoiqsN0xkylsO5AS79B4yY37iSdwuvraaYFsyJE8XIxQEOnvnDo1ITRGKutvY27VXj+S54cTJ7njTfna1i0Vur0lEGrttbXD0/ByiVonOTT4uWI1ie9L1SGKzsK4+eXlB2H2phcL3og5k+u2Mh4MxNHAlpgtVAyh3Gr3YbuJo3AUKXNHU4F75NZXVvbdNjn7oL3NIw0Opx2tO4m2n+Vr5xzHWr5CpoExrc1/wj8iQFpIzWXfhN+JxBIZ8v+eTGAh88dQ0NSFavPIosvEtcswserYF9yyIrlh1MaZh4RQSmTheuFqFb1Ek8vt8yYeX2y4eSHeDA6Weh/CwjPHHOe2AnnRdbQLYEch2M8vvVpYnNo81zB6IjurnO154I5YaTnZ25b/4VSVuQGKxZQDkrNPeFUIiQMORDa5+hxeUZcs5tjmm684LcA2Widc3yB5CMBl8YABU/JmNBq95lMKztZ0ivNIDZVwBxvfb4B100e2WZNzVLAV5Dp2yVA6VlTeuewuQPEXakTbZAaXF/OGYRqb4nan3qxc7teIyR4Om0Ay20OFYrMK9wfZFZztxDAC3PJf0DkL4Cn7Tx03iXUkMqIW7xdfs+EWKNbOga/n/E7GnNN9yBIUvHmhoo0jRatsF9BRx57QQ4fmD9gcCLFSmc4DGtwmX4O/x8rKMHoQOletdkuv7Jmn/1YyVsmr7k5bxKFNWU5U1XMOGo5nHlk8nr1q5PGNUQ5AqK1JlqGb2sQ2GSKM5D8kdUrVflTulFnXL6szBo0qHCZYxUIKyQEPca+qp3dYO1nxLf92Gn8gavlINZL6BHpeVj+ZVV9UP7ZHGwE9X/RYmPIIRFv+kaOCC3Mmgg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1cd0c0-f8dd-4c7a-e1e1-08dc1039df12 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:32.3034 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kxRvXDHlWmVQTVgnlfy2fb76M9AMjKA/FfroAF5AOZ0xevZ0qUpPnsJAVAOMnIVAhYRZtiNJEltDSRGSQG94kO5Z1a84iyXaf+QwbPQvaIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030642_658784_EBD0CC62 X-CRM114-Status: GOOD ( 16.92 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PLDA PCIe related data structures by rename data structure name from mc_* to plda_*. axi_base_addr is stayed in struct mc_pcie for it's microchip its own data. The event interrupt codes is still using struct mc_pcie because the event interrupt codes can not be re-used. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index c55ede80a6d0..df0736f688ce 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -22,7 +22,7 @@ #include "pcie-plda.h" /* Number of MSI IRQs */ -#define MC_MAX_NUM_MSI_IRQS 32 +#define PLDA_MAX_NUM_MSI_IRQS 32 /* PCIe Bridge Phy and Controller Phy offsets */ #define MC_PCIE1_BRIDGE_ADDR 0x00008000u @@ -179,25 +179,29 @@ struct event_map { u32 event_bit; }; -struct mc_msi { +struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; struct irq_domain *dev_domain; u32 num_vectors; u64 vector_phy; - DECLARE_BITMAP(used, MC_MAX_NUM_MSI_IRQS); + DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); }; -struct mc_pcie { - void __iomem *axi_base_addr; +struct plda_pcie_rp { struct device *dev; struct irq_domain *intx_domain; struct irq_domain *event_domain; raw_spinlock_t lock; - struct mc_msi msi; + struct plda_msi msi; void __iomem *bridge_addr; }; +struct mc_pcie { + struct plda_pcie_rp plda; + void __iomem *axi_base_addr; +}; + struct cause { const char *sym; const char *str; @@ -313,7 +317,7 @@ static struct mc_pcie *port; static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) { - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->plda.msi; u16 reg; u8 queue_size; @@ -336,10 +340,10 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) static void mc_handle_msi(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->msi; void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; @@ -364,7 +368,7 @@ static void mc_handle_msi(struct irq_desc *desc) static void mc_msi_bottom_irq_ack(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; u32 bitpos = data->hwirq; @@ -373,7 +377,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); phys_addr_t addr = port->msi.vector_phy; msg->address_lo = lower_32_bits(addr); @@ -400,8 +404,8 @@ static struct irq_chip mc_msi_bottom_irq_chip = { static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *args) { - struct mc_pcie *port = domain->host_data; - struct mc_msi *msi = &port->msi; + struct plda_pcie_rp *port = domain->host_data; + struct plda_msi *msi = &port->msi; unsigned long bit; mutex_lock(&msi->lock); @@ -425,8 +429,8 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs) { struct irq_data *d = irq_domain_get_irq_data(domain, virq); - struct mc_pcie *port = irq_data_get_irq_chip_data(d); - struct mc_msi *msi = &port->msi; + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); + struct plda_msi *msi = &port->msi; mutex_lock(&msi->lock); @@ -456,11 +460,11 @@ static struct msi_domain_info mc_msi_domain_info = { .chip = &mc_msi_irq_chip, }; -static int mc_allocate_msi_domains(struct mc_pcie *port) +static int mc_allocate_msi_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->msi; mutex_init(&port->msi.lock); @@ -484,7 +488,7 @@ static int mc_allocate_msi_domains(struct mc_pcie *port) static void mc_handle_intx(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; void __iomem *bridge_base_addr = port->bridge_addr; @@ -511,7 +515,7 @@ static void mc_handle_intx(struct irq_desc *desc) static void mc_ack_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -520,7 +524,7 @@ static void mc_ack_intx_irq(struct irq_data *data) static void mc_mask_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -535,7 +539,7 @@ static void mc_mask_intx_irq(struct irq_data *data) static void mc_unmask_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -625,21 +629,22 @@ static u32 local_events(struct mc_pcie *port) return val; } -static u32 get_events(struct mc_pcie *port) +static u32 get_events(struct plda_pcie_rp *port) { + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 events = 0; - events |= pcie_events(port); - events |= sec_errors(port); - events |= ded_errors(port); - events |= local_events(port); + events |= pcie_events(mc_port); + events |= sec_errors(mc_port); + events |= ded_errors(mc_port); + events |= local_events(mc_port); return events; } static irqreturn_t mc_event_handler(int irq, void *dev_id) { - struct mc_pcie *port = dev_id; + struct plda_pcie_rp *port = dev_id; struct device *dev = port->dev; struct irq_data *data; @@ -655,7 +660,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) static void mc_handle_event(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); unsigned long events; u32 bit; struct irq_chip *chip = irq_desc_get_chip(desc); @@ -672,12 +677,13 @@ static void mc_handle_event(struct irq_desc *desc) static void mc_ack_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].offset; mask = event_descs[event].mask; mask |= event_descs[event].enb_mask; @@ -687,13 +693,14 @@ static void mc_ack_event_irq(struct irq_data *data) static void mc_mask_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; u32 val; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].mask_offset; mask = event_descs[event].mask; if (event_descs[event].enb_mask) { @@ -717,13 +724,14 @@ static void mc_mask_event_irq(struct irq_data *data) static void mc_unmask_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; u32 val; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].mask_offset; mask = event_descs[event].mask; @@ -811,7 +819,7 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } -static int mc_pcie_init_irq_domains(struct mc_pcie *port) +static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; @@ -889,7 +897,7 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, } static int mc_pcie_setup_windows(struct platform_device *pdev, - struct mc_pcie *port) + struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); @@ -970,7 +978,7 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int mc_init_interrupts(struct platform_device *pdev, struct mc_pcie *port) +static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) { struct device *dev = &pdev->dev; int irq; @@ -1043,12 +1051,12 @@ static int mc_platform_init(struct pci_config_window *cfg) mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = mc_pcie_setup_windows(pdev, port); + ret = mc_pcie_setup_windows(pdev, &port->plda); if (ret) return ret; /* Address translation is up; safe to enable interrupts */ - ret = mc_init_interrupts(pdev, port); + ret = mc_init_interrupts(pdev, &port->plda); if (ret) return ret; @@ -1059,6 +1067,7 @@ static int mc_host_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; void __iomem *bridge_base_addr; + struct plda_pcie_rp *plda; int ret; u32 val; @@ -1066,7 +1075,8 @@ static int mc_host_probe(struct platform_device *pdev) if (!port) return -ENOMEM; - port->dev = dev; + plda = &port->plda; + plda->dev = dev; port->axi_base_addr = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(port->axi_base_addr)) @@ -1075,7 +1085,7 @@ static int mc_host_probe(struct platform_device *pdev) mc_disable_interrupts(port); bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; - port->bridge_addr = bridge_base_addr; + plda->bridge_addr = bridge_base_addr; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); @@ -1087,10 +1097,10 @@ static int mc_host_probe(struct platform_device *pdev) val &= NUM_MSI_MSGS_MASK; val >>= NUM_MSI_MSGS_SHIFT; - port->msi.num_vectors = 1 << val; + plda->msi.num_vectors = 1 << val; /* Pick vector address from design */ - port->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR); + plda->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR); ret = mc_pcie_init_clks(dev); if (ret) { From patchwork Mon Jan 8 11:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513284 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 16245C4707B for ; Mon, 8 Jan 2024 11:06:55 +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=j76LBjZ01rGlDQ5oocOU5BjhwMJyuvrWND/joDBvaKw=; b=BaizIJpqUROCMO 1F2nT/+FNiYNVgmMorms0s7js5d4HRMgQee3CMaI6oEbm96pGIUrEm95RQm+pTpW+uY5yo/lPAdEQ CU76U/6rD/gWEhlbDSCDtKPkQ6xCmIhzTP4nMqJoymCBl7seZNhW4Z0iLhFI10TzADYecxuQ4iDrK vfKg1ivuaic7IIBNsn6uxuDLnpd032zG+sjgC3t4P0wYm/JobomjDmilQUEZIdPCR3rS3jigPIxlA 6TMhwXkv0wGJlmOrT+BVNt3ba10u7YkdVoo5dJaJQkTmWJLHnkooB6n8NNBpAzGgoYbqpL+gGD7fq woieSZbV8x/8WAqw6iIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSx-004gnY-0c; Mon, 08 Jan 2024 11:06:47 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSt-004gjK-10 for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GKGkb5Ph6xG7WPkzUdNNvg/PRKxvjOTQQIoQVCVJJ2FZ3MjIGv8WNo2gRq7JEY3m7D3r6BXtqfoUG2qfTMXwAREsd8eQ0+qcMiyi7xGqnA2idL2m9/e4R0GFoNPYOckiVwsIVQAkp3U4CmE/xtqXPO5FATcMCHbWx+Hz6S967R2xiuPKHp2p71kDKYO110jF3PQYBG23TNT7rE54UgAKaG5VRMeS9aCSlSqcysTXgtB5ZxhG/bDKDfr/IOnOMuiRoJLfuY+64mG3rY3TQUvFcGpb6AHn1+CPzUW89SAsgLLgFGISclLdWEXwc3RuX8MZl/hCENnsu9SaBn0HU9Q8dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VXXtaYWxPM3l50fI5furwsMZGzPDogGyg6F7i2V3hkY=; b=Q84sYDOtqnCpzqZ5X99uIw7JjlzlBo21bqi77tWdci2+6O+Qm5vfpq3mxo9CYKvkcST4GZP+pq0MkdsZL7XtNnQRasHzkv75537l3q+TNKpbQ/j4cWbG6WyVzkLw+XSza5PQNPJkQ4gYWknpsDNRaoWQ1aA7Ws5PHv8qYsuzRmaRpBvinGEJFrK07uNo0AxCS6xJ94GPQiNq8Jjayjsvsrq+dCxpktnGwJLG1ztJ5PnM9rGxhRdReOhuGf5rUcDT9y58Y4iKvrBO9bD5aJyE56e4EfCGGC1JSm+QXu02Z8884huy2vH58+U1ls7LzBrstbjbLPCK/KVSf0lUNOd+iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:34 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:34 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 06/22] PCI: microchip: Move PCIe host data structures to plda-pcie.h Date: Mon, 8 Jan 2024 19:05:56 +0800 Message-Id: <20240108110612.19048-7-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: f531cc61-3368-4f45-a6a0-08dc1039e041 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w/Pl5HjmTUrcIdKsZguWYYaPeyhS7N8bh5GibwCttgbmIDSHxWvz9Szch7Bw0MALMsfiAAZW7vWni+wf9lt59ZCUURwH+xsEoEJn69ooV7mt2wiCMCLfC2Tm7sLRg70bl71+ZtAbr27NwSm0AhCa3ilk9kF+UXchqoqwXA4tA/7+9ZAXRs+gd7K3cghvUbL30y53JxBp0dHRVGUYDkjWnvmqfK9BVRWQtU1QFiyKJcF7VcENq3jxVe0btBRaUXU8UaoHNIt3j68kdaPfDNZvDX7a59+cVVrcs3DwswcifZaahAydLqcCZ14Cerl7HRAAIla7NhP4Ncd5sQXxDPTiqQJz+SD/PZMcC9Ti+gg1Pp500yIIbeeeSO7ojPrUNBOAAkl85bRileiCTgVqp4sB61/LOi/C7rjvYOeHq9Q1X0KR5Q3rIaVH9ncZv5EOS0ucB5FaM9RbK7qMZOxoKgn3tfuucc5ejBXnsUBzPP5c/GzfIMiXitv6tsWN2yJwYMPVeNuLwh+R1aIEjerugbeyQN72bz2cyhXgGhU83947tIlccfuGv+kJxrnqzr89RsEm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TG+6TgETj91dIeuMPJNMn8JnnKo0yqf38mQB9kc9koaMbSwKe9WJR3aNpSLMd+Of9lyuyVYljbSHSOLC4Nb7N03ooiQyViGjoI5RA2HpJlSkAh2Q+MvVVb2zMCKP8qWDfAXCleGoQL2LHrtqh2Vs7DNrSjU1mYQuRzIkjEXeZMvbsrAg3Bh8tUvn7kdpbNI5tUrwTm4Jrf33L40bKkL/dWNscn69+i94ce2V8ykqM/kJi0Q9UEp577et98NqpABHkU3tvX+O0iZp5vYgKr5I0xUghUPukYXiWkY2xgLg0sZ2K41cJGOctnqoPyag68yJZoUF+pJejaTWgmfwig2X7M9irsfzo+2BFg1Axag67VRiwebPd7LjE7X3hD0SUQWuxa0oEK2BASBRE9Wf+8L1n25qVjwoddkR/eMBmjrEO05kjPmWWX6zUUsMnqxUr/lLszMAA2T0BIUVQq+X7lX2nF9/nIWvphihSM63IKXLRnepMGt/NmONe/tIuToIShyDDzAHS8Pm+K+nkXsUIu0NF/OCrvsmaHlGtC4z+5+B3xzSebRdVqqd18WNaa8dQgNAdmDT4SYhQ+vMzXBuGoWJ32zeoHeKpTs9bHKM0TrYoXCGpiuONXZPPdhjDnPRrfKgXcy8p4ZCdN0lxMqEcTIcjJ+A+1H4uortL2mdWPRD2/BNrSkevcDkZvs9EXKr6SyaOHwoFW0F7rw9R3ZLg/Ph84oSLATz4FReehhIS07CMJgVxmuTLKbkYyK17jurIYK8k+WxmAiJEmbNC2s4HdgVs7WVE87/kmwUhUS1BgBUOjZsmudZu1rGth+5mJ3HoJyWg84g3rgbbpDZY65hec0jaxcQLjsyfUKsAyLh3D9qZ55RuKMQ3aHGkfcqkMk4UiVnYWf+qFdrAITVFNYOP2d0UOmfjA0Jx971TFwN70fVlxfsyJS8S4VgHIxN5QOCTSBTBsFP9hdebtNNzAGzK6Xv5BSptdy2I8pe41KACZMcDEabWIpn+uzzf1QtBOXFNcYT9/dO8M/2Be52rnHVPfy3Vslt62Pf420kQc27TGSYZcxUKqYy1WKm+0p2gtQreVDW8CK/vaauGwdzdzm3VOsee+zDU5v2G3kk94mZrdV+jKDMD0yLztSLIO6ybiPD0k+KXX6Zwi6OG6iOosv2kPzUEbhU9PC12wM1qG1GHp3IRig4RXNu/X077KSGFiggr6QoDdwQAG1jCG5MvfRvAUE8ZkFyJAtzWtyVjKAuhNG7Kl//guL9VVQB0tPZRJVUiVfSAwtybpyIC9yFK83QCkCjQBQlpmMmCS20G46qzRqKZjBFAenMOJtFCuEq97d6xtgur7THFyNW+uerS30NWBjX6XnJadcpO0SUaGLLtbTAxqPBekdvIRTcHmEsIRTKTXO5C5bM3YkxsBGf2BSebC5RI9zETNSCJrEEWkoiCgm8C9/jl7is6WK/gVSbdMZlwJ2u7Q0POCtI1ApNYi21BqrX53d6vyrN0b8S/k+lSm3uIvK98pNbz2BTtS5LO1akUyY0BtRZYXvVELqNmD3ngjnsGBV4uQHZKtUfw+tuM9uzz9r9Xe6421ExEtSPOMhougvHuQOnd5hES4Li8DW7FzD4Ig== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f531cc61-3368-4f45-a6a0-08dc1039e041 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:34.2687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +NNgNxdOfRSIdxqGK0U38oL4/g0OI5mzsjxuDSJF2uV5vtjDNR6vWLdKC4RYpxIOuWl50dthkVDVonOFZVYl95d7jlLFILEIvXycqU+vKGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030643_350674_270CC662 X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move the common data structures definition to head file for these two data structures can be re-used. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 20 ------------------ drivers/pci/controller/plda/pcie-plda.h | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index df0736f688ce..a554a56cc0e8 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -21,9 +21,6 @@ #include "../../pci.h" #include "pcie-plda.h" -/* Number of MSI IRQs */ -#define PLDA_MAX_NUM_MSI_IRQS 32 - /* PCIe Bridge Phy and Controller Phy offsets */ #define MC_PCIE1_BRIDGE_ADDR 0x00008000u #define MC_PCIE1_CTRL_ADDR 0x0000a000u @@ -179,23 +176,6 @@ struct event_map { u32 event_bit; }; -struct plda_msi { - struct mutex lock; /* Protect used bitmap */ - struct irq_domain *msi_domain; - struct irq_domain *dev_domain; - u32 num_vectors; - u64 vector_phy; - DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); -}; - -struct plda_pcie_rp { - struct device *dev; - struct irq_domain *intx_domain; - struct irq_domain *event_domain; - raw_spinlock_t lock; - struct plda_msi msi; - void __iomem *bridge_addr; -}; struct mc_pcie { struct plda_pcie_rp plda; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index cad3a98d967e..7bec6a470758 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -6,6 +6,9 @@ #ifndef _PCIE_PLDA_H #define _PCIE_PLDA_H +/* Number of MSI IRQs */ +#define PLDA_MAX_NUM_MSI_IRQS 32 + /* PCIe Bridge Phy Regs */ #define PCIE_PCI_IRQ_DW0 0xa8 #define MSIX_CAP_MASK BIT(31) @@ -105,4 +108,22 @@ enum plda_int_event { #define PLDA_MAX_INT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) +struct plda_msi { + struct mutex lock; /* Protect used bitmap */ + struct irq_domain *msi_domain; + struct irq_domain *dev_domain; + u32 num_vectors; + u64 vector_phy; + DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); +}; + +struct plda_pcie_rp { + struct device *dev; + struct irq_domain *intx_domain; + struct irq_domain *event_domain; + raw_spinlock_t lock; + struct plda_msi msi; + void __iomem *bridge_addr; +}; + #endif From patchwork Mon Jan 8 11:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513286 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 BCA67C3DA6E for ; Mon, 8 Jan 2024 11:06:56 +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=e7colV521O8sosHzLY6giYOih67IVE76Q5oEd1t5UWk=; b=vsixYxaIa+CM27 NEb92iuq4pQFyY7FL1BGsi5wUonkahgrFQPGWIxA80oBY0p4Rz1YO720J9tYBfymYmYhfKICU2GoN u0zjTe8cPZdnRCO3dOSTYo0YE1F02cUYYLDvbVlsuCJra3syoG60pD6yBZLyEXe8FlAonIPQRwaxY 2cTkz0K/WEqkY6I+UZzWI6o9S+QbusEbNbBh4zsmciZq8X34Zc/NCf3BevU8rT1r/F3C91DwiTG4w izcWkTebNfJiGHHSBtuqHrImy/WOy3K/6A7hVra+612+fsvUeJbAtwFPeK+OBkx/1cUPYSpTigzz1 ec2gEio7CdmmErBH4X2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSx-004goY-34; Mon, 08 Jan 2024 11:06:47 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSv-004gjK-0D for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fnll+4r0l1nTz0/+ZOCrXR9lHwxEXMt+zIkUynhmrcLQkzEvuY2upGaGwYH1e7IMSBcBfmBV9rST05Rfe/GnUL8B+Bxb5YXLZ1LPJdzFDuGUOCxax+xSoMxdLDWABbiO+PlS4Qzjpf+idf+tBefCh9Tm/vbelChcLzCH6QJpAXgpFgoHyAj9UuZQsoa8+dPd05SmDdW+KhvFUy4cv071kkmMRxcIXoSz9zXzArSmSDLfvP2lPtEucafYs12M5B1ldARjum+5lqurCrZjjFEqWjLC/KdVVPTWdunCRsQ105VKvQlBLB1YVJvJph/YhTRWjaMKN34bcsyJUHLQ/YwgxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pc2T6SbVvFNGAc7jANlqkHZ/EYw1YXpAsFWAuojjcfk=; b=nEBWNET509afv5ZYoZzR+tMBQPNby11dT4b+qDRZKul9Headx+bGwNbuG3DwzQq73SPTDmmFcXGovZbT5P9Y03iK23bNfGpOI/v9zh+NWFZ4K3cESBvBWPX3oxZTaVThyPkSf9yb3iDdV5eRdrN3IhCtn9kiAXy6tqt7/ImTXPMu87D7kqJSKayEyTLxrJHN5zQfZzRtB7wYgSr8l/lMzgoGRqTd63JSvl6sGu38T+qTpKZrtRcEgCvP+qJGt8il+65ukQVG97f/TO9wNEeuYcejaNzccg8/2u7Y+8qLZZMHNHZXEbQ3QzsMqSjy2DV7Z6bpJRbt0fmw/0RIvNqu7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:36 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:36 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 07/22] PCI: microchip: Rename two setup functions Date: Mon, 8 Jan 2024 19:05:57 +0800 Message-Id: <20240108110612.19048-8-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: d990fe60-f60a-4683-a69f-08dc1039e16b X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Tsa9W6i36SJnTtdqbz0/lMWP5ZMfpA0HL++t0pzkQUdAs8DbDTdRiJtqOMxPApzapHkSeQ1xCHrJHkG430u6b3Y95L5Tbx0o2JAThtrfsRKCRgPNMRBT6KcYVIo1IfZl4AvA1S0b1r6VtbTvVUprHB467Kg/yqad80tBFI/CiyhY82b0SWCVo4j+nPF7ueBio4GKUhejcj+wLeC1RGk7nfmgF4pJM/nX3JTAIjKoQVvXznF3Ll8/qyPHchF35rrSamnlT8WwusXz9ijJg5Vj+BXiCUzJYnZoWsjyLz0B6sj8+j26SHIZQpw4OqTBP0SKTLIARJQymMJQfrdzGr1XeoAur7noQSu9wRcyY96b34WZQxc5+bXJJrJyUeR9bhcuRxnkVbA/1mECEAzPAJ+7slW/loZFfofHRe+oC3qlUVGGPunb1xgYODYbbzKcbARF+snqHsnVnkMmXeFHoCfm4n0hgKxIFOsTX6NSyXvSbthJp2zBppYk2cL+RF8A51orLEamo7Z7/muAk3H3ArQv7uv/M3OGSbtexJ9XuRPV4MsL9cmEoJUVSNrLrdfm1Fk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9J8nJdbFmKRHmMiEOlE9U/xzcszmKAWOVwA6kmfFJDkRjCmH172SmOGBqPuzd5GFiBbRqPqRcc5IE1Wz3T3oCk7Z84O5A1ItYNO/AkUAAdaOmKFsMhU14rwTauQwV9Gb+5JiT+X1V7DFyYUbM3CQQA77j/nfvbbukaM4wvh0Gwo/YM5WrD3Gte4VsTx/2sxwEK7A/ZF35K4TPFYirgFiaNll0YX9aoXpdAjeZI7T7RXQSinTUcKkWhMhiI9qsN69AFDjdvdaKNnKi64GxkkjcXj7iQIVdsSAcwUm5/V0pJMLP7vog9OuiGj35HIHY67MtMljadNsmbZL20pusjn67AokIUV9EAHXTBLII9lo8snJGXSDiBrD46GBjCaVKa47TSIG2WRIUxRuyrQBqOR+EQr3v6/YKrb/usHMlbkyS5cnMtxOE4W2JqlIMYBhLBs5gALwjTcRW8egQHBGJgvLNyTVzqOO0dHauUGWcM5N/mw1kYHJ53cryAAKZWDmWrT9UdaP1WO8iToPV54jHyAXswrbBIJAy44vrVhMTlj6CcZVcLPULwfpa2Oqk0pFBJ9uEPF1H9YxSqxB1X5hIC1Ikim8l2iHwnqzKM5MQ4sO0m2a+8yBhy3gGCWkT9fYKAIjxeyLzhC0RrzIXtTBOCS48rz+Ii6bWUnA5VPYCIPkUjyqNKjUtWPe5vn46vSbwxgBzpV1JT+3Tth3x2BhtgmKDH3EPlRcsMY/zBkGrpxRQSIuk7tQam9yDrlxyWpIu64IDZPJXk65zq9MQXmEHZudYDd0BB+3Oq/nuW6GXhXPgg6osT3uuvl3p1veQmqftFAoKI1d92KXuOpCbdP8r9+v0Tzl3+yB/cY7p/DmlvqAFRmVrjl5U6d7swrskGlXbeGW7HkYkSNWF/cv+OG5lGMq4c5IqPCJAPdZ9Yyv241TdIjgaMTYk4wODeT606yd/u8b+Auf8kY++3wtmvn+Nnwdr4CDfVaaWu7oU7ri5hzoBCtKUa5aLjtzCImjbgly3J+FB7R16iHcW86Y7ERThC7/7pP5OAgF+OTQy6NO9+Q4aL1zK0JPZgn7K+FBCM0gHhKsKA9jiuMxrWrSxgFoZJoPAsGsBeubPqtjtQ5/0QJ6r8Lg93/k+g6Ao4etm8QjcA//yMwf2wOVIQXJlBf3OH6NVujCo1U39lTtOySVi7WULxf6xi0DE/tjWYYrADGxcGK318FMZQk+FPmuOm8TeG+1c9jpXBqtlwpsrgOmUU9tlXg64ty9Qy7fI40JTdT4bJGEpUzhlH02jaeYiuYe3h1Gf8NzsOcIRqHoyw+QPEIhgznGL9ob82VkUK3eyg4XB1oUKIOWHIYwEDFXIJynnEVTAXHQ/XBWS5FvU++rer0rR2/mVISqdEw/TWfwIikfM0Lq/PNVU1Hv1YdAiWTHUPrmaAvYHXXipGGS2p2/0nViWWoB23bs4H2HrwcZCZ3Hzy5L2Z6/RSh2zX67Hxy2vONnL31XefXhWq3EJBCHgbPIz4naggNJk/Ir8AJKe+3jvMoz6Zwtk1f1BrlkG/SVhzA6aw+nMDRs3yOar0SYzoJqLZm4rt/1TXCcGroMoWpW3XP075Fr8eDp3fWYOupZiLXj9A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d990fe60-f60a-4683-a69f-08dc1039e16b X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:36.2244 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UPo3ikEas0OCFUubGrjmdRLi1bT1F/tREpoAqxff8zYAZv0B3LQiBA6Qcy0ttYQGxfWjl9sXybJ4v9xAzAZ9BGBOJPk0CBeKTXzYHQ9zPkc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030645_105262_CF31D2CA X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Rename two setup functions to plda prefix. Prepare to re-use these two setup function. For two setup functions names are similar, rename mc_pcie_setup_windows() to plda_pcie_setup_iomems(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index a554a56cc0e8..9b367927cd32 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -838,9 +838,9 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) return mc_allocate_msi_domains(port); } -static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, - phys_addr_t axi_addr, phys_addr_t pci_addr, - size_t size) +static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, + phys_addr_t axi_addr, phys_addr_t pci_addr, + size_t size) { u32 atr_sz = ilog2(size) - 1; u32 val; @@ -876,8 +876,8 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int mc_pcie_setup_windows(struct platform_device *pdev, - struct plda_pcie_rp *port) +static int plda_pcie_setup_iomems(struct platform_device *pdev, + struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); @@ -888,9 +888,9 @@ static int mc_pcie_setup_windows(struct platform_device *pdev, resource_list_for_each_entry(entry, &bridge->windows) { if (resource_type(entry->res) == IORESOURCE_MEM) { pci_addr = entry->res->start - entry->offset; - mc_pcie_setup_window(bridge_base_addr, index, - entry->res->start, pci_addr, - resource_size(entry->res)); + plda_pcie_setup_window(bridge_base_addr, index, + entry->res->start, pci_addr, + resource_size(entry->res)); index++; } } @@ -1023,15 +1023,15 @@ static int mc_platform_init(struct pci_config_window *cfg) int ret; /* Configure address translation table 0 for PCIe config space */ - mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, - cfg->res.start, - resource_size(&cfg->res)); + plda_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, + cfg->res.start, + resource_size(&cfg->res)); /* Need some fixups in config space */ mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = mc_pcie_setup_windows(pdev, &port->plda); + ret = plda_pcie_setup_iomems(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513285 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 C7CF4C47258 for ; Mon, 8 Jan 2024 11:06:56 +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=yNIB1ThaSInxtHDujaZ2F+moRlexDp9BAqMjKM3xqpI=; b=iXxwIB2Bz2KIcf e/JYCnXj+UXkkZS04IRMAT5JdpvMMcUCZbrF3mNyEGD9Q+8iziNYzwOZv4tDzax32SxxOVpmerq+h Kzd1H126kAANprpxg4gd5ydU/aWssfda+SXhTUJsrafMySv58SQ3z6DX6fxvOuT58CLsWcdqdilDQ mWig2u/kyG6OSKGcC8nRVty7zI+UEebLAoeIzWkD1XAyxKRdwYuuP8aB8QgD00TjpGC10yD5QSBbu Omd+hTWpSHYta0uMWp53y3spaoqXgTir1TaHecr1BjBjcJ5buwMmkESpXOzd57V+O7s5+hWsP0cDT WJUFLR35I7bbMWQ5wfkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSz-004gqL-2E; Mon, 08 Jan 2024 11:06:49 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSw-004gjK-38 for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b7S/yH5ofnUibDxx4aetjwq5fpHYBXvQe1l07zae+lEVRlFIyiqI1uEJYW0oZx7MxI/o8itOW4gkeuIs/6P36gwlHKnoTE6nGPC0Fx/KGwXKX3XX/bdI78hvEuROSTK92ogsSiHO5YZlcQdsEfPWZlBC6z8HXL9daAyQ32C6VQEIuAXF4A49E/CSqK/iA9gs9qd9rL6McuHAfYdbVsdbxVXfDTUAsUm/+19Yy3nt2BKtlJ/U9HaEMQlUPG5BraXvjdOHu2fTOWgJRPXhK4u9ykA3AuvVVE/F2ebZUgZOsIyId/AwBQmwve1K/bBGLPU5JY35+jex2K1r9re44HhXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H1L2zCinMaKZ61leC9g0xpthGdFxAFSQ7l+a9Zn1/VQ=; b=bbqixbJzxBdoyVWW9AJa6mcPHO8DLYo0Yf/2yy/Yh76JuUigcFx8gh5e0k1mVTcKFjMjI2UXwWmaGOHrXLKkHY/EScxaG3jqAzN0IDawLp96DKvagjmCVSdTosUqeGreUbGJjZvyQ4XCGkiTXwqbNVpiv4U5+m8W5+lCX2ZpJ+5hKu0FqpN7ihVb+9TrYl1bUMwyXGNUTlYKEuYx775I+NUJSk7IGqcyEvJcyU+g5x18DGoabRxSPTyU2QJfxEW0lB/CWnJdrs3wBDSOxCtXa+8Rdfuyajjps86z8qm5VfFCS5aGXzELQppd6V8f2sLJDH3FZr5zPdsGTVy2TGVTvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:38 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:38 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 08/22] PCI: microchip: Change the argument of plda_pcie_setup_iomems() Date: Mon, 8 Jan 2024 19:05:58 +0800 Message-Id: <20240108110612.19048-9-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 85a1babd-467a-44a9-a6b7-08dc1039e295 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lqApmGxLXWnlSVfl4w2R8KyOgqza8qlFmj1qrjukCYWfxbanHlUY8mYASdc2Lmbjrg3QMuk8by+eQiPHL/iyaL8hpkmetAs+eXXehocwO7TFUTO9WARdwsjiY2YY48Ph2jp/Ioyte3PGje0wVhwx3GdGZ7hRWucyo1e/kdtLn/0l9W76eyLhxr7JHtQ/Ll7UtghMzr6ylaTaifEWBdWKMxOb5LFZDese76OFrpRMy/BH+Kj6qmj1JahBzXzER+64ORabBe7G77aq/+7Sa2CUApvgVyePrmcI5EGORT/Qzjqk7QujJ97ggbbfe37s4lfoSAVY9aNkA1MzNqyPWB8P+ZmgYpxytZwDcQ2gUg4HcHGxrppH3nGiX86GSG7wRH+ukbbCvOo7AxoiuRDMn6jD0CIqqB0n2ys9MZSr/Nag/fKvZ87A3QCn3Xw/aDfsYvZ6TxWAaP+D50QbunVBrWaxk7iRvzcVolxALG8NaDsdZVja4PnhlfyHOMSdda3NW1uZS0gdbzwvzGf8gfW2re3CsCUX7YITsPAs/sEZMArrbXRT3pU29o6Y+OK4WaeTI9J/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lun/eo3MEVjzpcU+1qQJPXUk/LHhiIFlfgnvun1a8eeARf0B4Gn8OvQlDYc103szhJ1VVTK1z08WiVUls8nixYcXBEA4X5eFjngvQ3o1xdtc87KjB7sz0rSVZzUYHblKVn3cB4/wdois/k5IamrOfh09OyLLS1jNhMSj9UP/fL5p/UkQdlPQiVoHoqM/wwGWbGY1fuu13s7+n4+BMiPNr5a8pXhJK9dxuCoduKU3LdwYpnlF7Ej8vQoPWeY+PLEv56e5rckoE2q+ppsoyrQWUGlUazt9tBY3gZgz1Py5Vj2w0j1Q6wgObKrGbIodc9fDvwIaSOYYw7Pfvv1hpNiaAIucfNTuCFh5yaEjwTzhhhka+/NflRNxeQ8yyCAYf2ktCk0f0We7j5iMsfOaRXX3QJrCV6uyx5H9HpjrJyojUNrt95H9ya5hyFbPJljLF0F8IdegcIGu/QfcT3I2cLn31Pmb6GsLUfgly0+ogiMK/zHBs6Qw5TYbLbHC9chJjcGHUBm3pxN4XYAFNvl6Qy2AOt3WGYFwoUsARjo8UfBjm1UhDYm42fvFcU9pot9FxG7aw7xePE7qEzG05ZqWeKmmJPJtjfmudXPzwcF/Z63Q6ZSyNfnn3uezyJHhMyk8n3k6FPBtBaPhcl7ivcjvBwW2fRTcqWeU9+9iRBV4hPn/S6wHOO6IDoCDzB1W6gYyNvb/vZPXdpkK1vLE56JYoZJD4tqNe7/hMDeA6B0oDt83XWMg39Bv0V+j+TGBgP/ludk7++Ok01wm1Q+XjDD+aVkMrTNp9adB7C2qEPKW6zr+SN6G+iTl4wzTweDrloZKqZ31jWAQwZdGRDgvR50D1Ud3Z9ZygJ1FANv2mzKPzor8qCaZhRr4TxDd0kji0Vz+Qdaotumidd1hVtAFMc4uxUCKY9ttX+lWkaJDWoB3xqm/ca1zYk6ftU2O4mbApIrIyrfP0skUdmcqdIrI3CcIikAQQkGqLTq5CD30cmpn5+hZ/SIExk2Du+yeptby2XRrRwgIrORjpOtXGk5m2H/uzjQmO+/i2ttdlpVI3FJhSktNC1zbQRr3esztyH94kLCbyL8C56Fr4oZaJBDMcXw5r2px0kZ3oVqWpFNb1n+9TSNhKy5cT5zGc7NA1j2ezqlCDpRDbCnpeRczX34H5g5g8eA0OTD5yXToQ+5we0D/y5qRI09D0Yt2Qa/SFm8D7SNNsmhJidOtcwL2/PjiAjOf/5CBXEXI4diswKfYLSTni90vFk0jZQeNx1Z1HotHlA8bxao/CoscZe2q3lJz8SwahAdI11hVC5pBNGncWm2NYGeohQsF7kMFc6jqqequnlUgHf4IlLFrGcv/ZFJpz60/p9/EbtLFlpwWFI+vm5AcyWZIt5GMsf/YJEe8UBu11EzWUBqH8Cfs2mFExnqd2uZbe/CKjE4YaFxcTTZRb/+IMLSa1VpRY9cr1uuJxI5oastAWMvhtTJZ9V6+JmAtmhYjKZY/3ZpXPrBWUpJlTMjc10W2dSefzQt6/H4MSVL0heRgPxn0VcEOEynpMTx5T+RLGfrOWUvJiO6tpabZxg1d4QDON/byr9dzfBq4SvJMuo4xjruclyZs+meQodaZO+pKJRDGAQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85a1babd-467a-44a9-a6b7-08dc1039e295 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:38.1278 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r4RgA0aNN2ayus94RNdHAZ7pmffkjX5wZfEcrvaoPLa4NqKorSt/KX/++vLwKxBoSYbSoJGCI+AbgB9co1WvqhhWKRsL0vre/r6s2ma/fzk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030647_015538_2F394987 X-CRM114-Status: GOOD ( 11.48 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org If other vendor do not select PCI_HOST_COMMON, the driver data is not struct pci_host_bridge. Move calling platform_get_drvdata() to mc_platform_init(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 9b367927cd32..805870aed61d 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -876,11 +876,10 @@ static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int plda_pcie_setup_iomems(struct platform_device *pdev, +static int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; - struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; u32 index = 1; @@ -1018,6 +1017,7 @@ static int mc_platform_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; struct platform_device *pdev = to_platform_device(dev); + struct pci_host_bridge *bridge = platform_get_drvdata(pdev); void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; int ret; @@ -1031,7 +1031,7 @@ static int mc_platform_init(struct pci_config_window *cfg) mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = plda_pcie_setup_iomems(pdev, &port->plda); + ret = plda_pcie_setup_iomems(bridge, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513287 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 4EBDDC3DA6E for ; Mon, 8 Jan 2024 11:07:00 +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=qE/LPdE+9BgVGVnVVYGhbAAtluxxH+FoyZ2cUhEvJgU=; b=D3fB0wp7Is2vQv xA9Ka1VTO7qLdsjsf1DtT1x8abzTwbeuBVkHmhFcUEpOR51lRBd0Q0P4SIAa1r24G7g6SN5FFw0dF Zc5V1zUdFCevvnSDgN25IxRCq4u8uq5cW/ErC5fJh6cvBFHmXKu2/3kFJFXp+5n/C8pJfW2PYrUjO VrGO9ZA4rZop2DGcNpyC1JNyRtMDnTL80Z/dIzut3nDlYhMQWBn+gQbkMJe4YdAwxMfP/igzDYl+Z aLOY3Tt+Hc0XwKaWOOkxgbsDcWAkaSg57TFYwoaYxe2iY+IvkeK4+mYrBPLzXUxrEU8OO8uCVFPl1 tVPdGpON8oYE8tvQgEig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT2-004gss-1S; Mon, 08 Jan 2024 11:06:52 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnSy-004gjK-2E for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M/LjQvFQ2W6Ev7KkfMvU0SALTc4j3CmkfsezL7hxWyEZNkhjOHK8Kw50UlADKD8ReQy+bptrw8paj2/bHYANnKR0XDhhrKLdd9tnEEN7A1NMiESGNRXmn8UPAzM8TALCKFJWaHj53D0+oiNL4YkGKAB7j+eCnZhMyMVdiH44b40E8n13sBYqbXLu4RTvqB32B6JLtoczXpo4ELkjAjqfQu02qBc0zCeqr5wK23VNjgIeBxrfw6hjLGFMMSqhs03nw+kk7hDFdOsDDdJVffQvhQLToSB7delhNWg8ErcYLBswWZ4pInxvHHpjU6Zk+6lXFnv7Imr/GDBozdpgwUNrFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7fiHB4G130fEUHhYUU/w/UrdOiZUj/Jzca9amchxDU8=; b=VdVRWoipy4FUCuTTHJyJj0bOS79iLyZZguSzLW5i1LYcf2Ghi29ZHn8OoB/8Xk2FQ0SStEGuhjU9ZqjspDBCz6XY1OW3pzkiDKM7Jo3722aKL/pFmR+w6hI2VVhVSf6ESmjKQhiuYM9VznyqDZVerd/ivQAPe4pStHqR5jRd+h0HjTBgJdT0KhVlJj1D7duBApKDzcyceIqNLtRHt4fuYp83fo/rgvjCf5imLQRVPb5szc5qodznoGDZyBV2qkNi3zpa0SKCbHEzqUsZNzaeLB/OGd4YXXjmlHv5rPTXG2gFwMflL4w65glj24/FLt+jrk+isQv5iGn4RD48NxAWDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:40 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:40 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 09/22] PCI: microchip: Move setup functions to pcie-plda-host.c Date: Mon, 8 Jan 2024 19:05:59 +0800 Message-Id: <20240108110612.19048-10-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: a32ed29d-ab97-4a85-1d99-08dc1039e3b6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WQFBbXVYm2FzURzMN4QUEE+k+SWzNzIs9FnZ70Ev+ljIEekgDjsycFPz4niyznyQgQFkINGivx1dpMd4LiHDs3SDrrYPjIngjmi2n/VI4on6l9XrffdvDDjHXUuTIDEXbYh1jpsuUJ5gNgeEc6GMVsGviivpkK5BFsgrbu5rH+59vQ7mWixeflUw5KwIioLkiv5bjGk9HVuDZE5ywYz+4D2puxKqFkgxnqq691bmKOha6aTlVNq2W9V2pjM+Qyc+yILUecvIM7omfx5KnahDdxPBKjyoImgJJdwwpvy6knXFhR8wjFPyUacFXhrCdFICMzmygG39bQhrRbm0T7MBLEJtemAVV4+7b6YOpUlyDKN0HRC8pD12W3/rLe/rgdFxtI50CrwPZAgXScw3x+OwFqF9ZSUiq7bl6pslfEVjjyx/5g0JDePqukcjgtwwJFZbD8oQ4E8t6W2n+xxo26uC0CRkesYrkZg2oWIBCcJxLVHBHTlx7FY1TYtLyuA/9HsuZixejEpcN7rxd2rkaWLErMxVPFCDI+DYoTHotfa/LU2rp4EhjDDEFbLD9eALl6sG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CKOdCXYWe1EENvl3oMQLB4vvX+re0J/rv5l7IXydvlEpZX0YMurZrQy2PRab9ySIDEJKRUiuZd5LvvauhRmgQb3zcyO5Qwn2pQhz9zYrbPkNLYqmm4kkDP3xhhrqturEwmJoPOjQUUBy/r5k7WmX8vs6UglICEYEr95GFOUuFaWRpdar+tZsXB+LmqCxXkFTfFO85skcL6tivWfJ6A/Qh2MsFn+mdXtzDySZFiqXcR5oXSbazfl+DdpApfAo9Bqu1OrkeunOfgx5u4FZEsE4400Joz2kUPKHx9dJf8utUjNPXVCvCukmDkNkoOtE4GqYM8G80v/I0UdDd45qm+qOgfxLVBz/+r4EzBfzU2lzHIJpsC14o/kRdylOJ4bv+urVMmjdaWvi/R4vfSx3i8DOd+bu3wLS++oWpJtOzG9gYyW2RK/GHJOOqw8WT+O+2+VdZ5JEHSrB4LZTVVDzLfzW7lRe818GvoGyPPMjI4/k3HYi3gKQW5es9qdSJDNr3HjQ6BgEaGaBdTsDvbxwaRkHsl/fJPu+C5NkrsJVYshHonQ+gXYpN+0lGwVHGxoYp9IfL3a1Ob9qz8nFt+YJbO3wBkVmuOaeNdkDyQgEFTIfUo1g8dI6UK3o5EO0z5agT8anAIuOfy7zP6tq9aF1a8F8ov176+VC3h1Gkte+YeQfQXTcCPe55YQ+p2zvHwotjO5WdXS2eMGhInx6Ef5HlQesiQbLdKLFIM0GtERtSs7SsmXda/8zKl34Dlxi/41/zR+Z07CXFbuV1jw3r7dbcu2TrUAmPRZowhvl9b/KDHI3dUQ/Gc3cjANOLd7dV6vYsPqwx4pEaeXRog7unHIhnsTrYkqtf/sI1LHbPE0jC9X+p6qAI+m1vpTohyvV9sLrXDaM2N7pY/6wIOMcCtUwhH1gGNp8Ffm0pheRFiwZ8xUHbYgHirakYVBD3Qs3GBg8mKIERZiqelR1rjcoGk6/NxK5Far5Hkb2VOlPPB6kv4lPWrqEGFGerMa2CtbPhD6IhZtPVKM8hfOZSiU78Vfb67Wpvk8I7+zsjKlgLeyOmeKkXTMpnjF/TCItc6UrnAeMn56GG9StnOBQvarw+pFpY7jhAyDfXsf+CVp7884kDXeJHKuxif9hDPwzthX8wIojcZeBcDEqg4hajbL9jdBgoo3t+j9jqmHFKredVTsGYR8RRuar3NSNkzoksZkXQMUe+82xI9qGDc46mnZkKNT07lurc2Yp+PCs2l3qJVJooTg6jc3Va35M/iEHKJP77FqPkv8vkOjaefUrs+WC+cTu6YSeWw8/W6pU6DKeaxDkZZys19wLt8XuQb2DUhz9j7f+xT/EuQXOzIUtxwl1EHxffvACTfK0BLwK0J6fApEiX6b5v1yyjhf+8tJdh/ECPCoIUVGdex8YovBqJQhqrMcKlFOfz+WB2yMsGXGERfcd/153Hh1dCB+BULbA4hI2AFY+oi4SlBZP+D+bMFXbPeZj5zNAH6l5DDuKTGtqf12P/O0njxoiXK98cCxX9zEHSqAIlrUiBJmeasP1p0u1vXl1gJKR//0RRMzytA5YwpLofyXG8TqAqhYMu5l2nvSiLhrjjxw8FCLdyEepdXvy1LYpRha3Tw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: a32ed29d-ab97-4a85-1d99-08dc1039e3b6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:40.0934 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XYIfJx2ibJuSR3MczOcZmkw/nJm1fenZzfIwodFTHgH9igMcFqbc0ekVH6QLAuy0zkGxeNuWGP+ScXtKYaLWD43MI/gxeU1Ach31j+mcnVE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030648_734891_01512273 X-CRM114-Status: GOOD ( 16.92 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move setup functions to common pcie-plda-host.c. So these two functions can be re-used. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- drivers/pci/controller/plda/Kconfig | 4 + drivers/pci/controller/plda/Makefile | 1 + .../pci/controller/plda/pcie-microchip-host.c | 59 --------------- drivers/pci/controller/plda/pcie-plda-host.c | 74 +++++++++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 5 ++ 5 files changed, 84 insertions(+), 59 deletions(-) create mode 100644 drivers/pci/controller/plda/pcie-plda-host.c diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig index 5cb3be4fc98c..e54a82ee94f5 100644 --- a/drivers/pci/controller/plda/Kconfig +++ b/drivers/pci/controller/plda/Kconfig @@ -3,10 +3,14 @@ menu "PLDA-based PCIe controllers" depends on PCI +config PCIE_PLDA_HOST + bool + config PCIE_MICROCHIP_HOST tristate "Microchip AXI PCIe controller" depends on PCI_MSI && OF select PCI_HOST_COMMON + select PCIE_PLDA_HOST help Say Y here if you want kernel to support the Microchip AXI PCIe Host Bridge driver. diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile index e1a265cbf91c..4340ab007f44 100644 --- a/drivers/pci/controller/plda/Makefile +++ b/drivers/pci/controller/plda/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_PLDA_HOST) += pcie-plda-host.o obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 805870aed61d..573ad31c578a 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -838,65 +838,6 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) return mc_allocate_msi_domains(port); } -static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, - phys_addr_t axi_addr, phys_addr_t pci_addr, - size_t size) -{ - u32 atr_sz = ilog2(size) - 1; - u32 val; - - if (index == 0) - val = PCIE_CONFIG_INTERFACE; - else - val = PCIE_TX_RX_INTERFACE; - - writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + - ATR0_AXI4_SLV0_TRSL_PARAM); - - val = lower_32_bits(axi_addr) | (atr_sz << ATR_SIZE_SHIFT) | - ATR_IMPL_ENABLE; - writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + - ATR0_AXI4_SLV0_SRCADDR_PARAM); - - val = upper_32_bits(axi_addr); - writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + - ATR0_AXI4_SLV0_SRC_ADDR); - - val = lower_32_bits(pci_addr); - writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + - ATR0_AXI4_SLV0_TRSL_ADDR_LSB); - - val = upper_32_bits(pci_addr); - writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + - ATR0_AXI4_SLV0_TRSL_ADDR_UDW); - - val = readl(bridge_base_addr + ATR0_PCIE_WIN0_SRCADDR_PARAM); - val |= (ATR0_PCIE_ATR_SIZE << ATR0_PCIE_ATR_SIZE_SHIFT); - writel(val, bridge_base_addr + ATR0_PCIE_WIN0_SRCADDR_PARAM); - writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); -} - -static int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, - struct plda_pcie_rp *port) -{ - void __iomem *bridge_base_addr = port->bridge_addr; - struct resource_entry *entry; - u64 pci_addr; - u32 index = 1; - - resource_list_for_each_entry(entry, &bridge->windows) { - if (resource_type(entry->res) == IORESOURCE_MEM) { - pci_addr = entry->res->start - entry->offset; - plda_pcie_setup_window(bridge_base_addr, index, - entry->res->start, pci_addr, - resource_size(entry->res)); - index++; - } - } - - return 0; -} - static inline void mc_clear_secs(struct mc_pcie *port) { void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR; diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c new file mode 100644 index 000000000000..40139d998568 --- /dev/null +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLDA PCIe XpressRich host controller driver + * + * Copyright (C) 2023 Microchip Co. Ltd + * + * Author: Daire McNamara + */ + +#include +#include + +#include "pcie-plda.h" + +void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, + phys_addr_t axi_addr, phys_addr_t pci_addr, + size_t size) +{ + u32 atr_sz = ilog2(size) - 1; + u32 val; + + if (index == 0) + val = PCIE_CONFIG_INTERFACE; + else + val = PCIE_TX_RX_INTERFACE; + + writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + + ATR0_AXI4_SLV0_TRSL_PARAM); + + val = lower_32_bits(axi_addr) | (atr_sz << ATR_SIZE_SHIFT) | + ATR_IMPL_ENABLE; + writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + + ATR0_AXI4_SLV0_SRCADDR_PARAM); + + val = upper_32_bits(axi_addr); + writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + + ATR0_AXI4_SLV0_SRC_ADDR); + + val = lower_32_bits(pci_addr); + writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + + ATR0_AXI4_SLV0_TRSL_ADDR_LSB); + + val = upper_32_bits(pci_addr); + writel(val, bridge_base_addr + (index * ATR_ENTRY_SIZE) + + ATR0_AXI4_SLV0_TRSL_ADDR_UDW); + + val = readl(bridge_base_addr + ATR0_PCIE_WIN0_SRCADDR_PARAM); + val |= (ATR0_PCIE_ATR_SIZE << ATR0_PCIE_ATR_SIZE_SHIFT); + writel(val, bridge_base_addr + ATR0_PCIE_WIN0_SRCADDR_PARAM); + writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); +} +EXPORT_SYMBOL_GPL(plda_pcie_setup_window); + +int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, + struct plda_pcie_rp *port) +{ + void __iomem *bridge_base_addr = port->bridge_addr; + struct resource_entry *entry; + u64 pci_addr; + u32 index = 1; + + resource_list_for_each_entry(entry, &bridge->windows) { + if (resource_type(entry->res) == IORESOURCE_MEM) { + pci_addr = entry->res->start - entry->offset; + plda_pcie_setup_window(bridge_base_addr, index, + entry->res->start, pci_addr, + resource_size(entry->res)); + index++; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(plda_pcie_setup_iomems); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 7bec6a470758..3a17d8ab5bb2 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -126,4 +126,9 @@ struct plda_pcie_rp { void __iomem *bridge_addr; }; +void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, + phys_addr_t axi_addr, phys_addr_t pci_addr, + size_t size); +int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, + struct plda_pcie_rp *port); #endif From patchwork Mon Jan 8 11:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513289 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 5B4FAC4707C for ; Mon, 8 Jan 2024 11:07:03 +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=tWgJzIST66dl6PR3hgLeo21qVoDMwfGQLW7y1oV40Gw=; b=zEVn/r6cb/BBMt 5tcpgntbedOfe6DcJ11wgL75jLS627MhLkdHguPNCVhVFeZyd0kGrp2AQF8EII+Tqpu6FzULswNQx umGi3mJJGYyAemnCtnh/F4RIoBVIhAKzf+2zu0ok3DaBFV4F364igrA+3KfMLKfClpPnO6rfo06lb RS281onx6Temj1Da8ChW11w6wnfeOTdVsyXnoiZjx8eBN2uF9qtIr7sBWVkAU/2nZf8ysqBmMi5nO ypuBPk/i7VR/Uua1TA1ZsOvQ1C0V43F2BoAOoZ8TgnmKgMVtD/H2PR9q4JrgGjYsfe1SO1R2iZthN cm/S/9HH7QkhbadyzpbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT4-004guR-0P; Mon, 08 Jan 2024 11:06:54 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT1-004gjK-0E for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eypf3qPsGGFKm6B1Ru1MzSqnv/buIzNEq9hILanx8IwVBwQvGlCGWU81qsOk1HrATjPsM6wP6LThlzkz9nIQlXEyn9AXg7w13BS/zw+FoV5wFSjhHfrLmWmSBD8/10YxkyWNYbbi/iP6kPLGsA85+20ebZIrRLhHCaGBwDIKIZ/v0OS8thZR5qxrC0NOBQP0M1k34/mGUihO3v86DypLXmmNQya4So3nNVCgxaNHVXlmCVJrorf+MVpRKyVxjbK2c78S01cMqYhx0pYKlMeLHSO6OKoIN8vZPa7h+Sq7A6Uu67Xf/teY8pLeU8IcZkL1ev4HQMMONl9qxjVr70v7Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SvgzgZ+kCWJDW3yTlipB4uET3HJVJTZKxQ2LjTr36CU=; b=SCv5BMYTAsZKEPVEGGSXrTvauB4PbQ/dQTi69Hcuv/9KwvWdCAkMoASL0ZXr2w1AKpJga6aUzcB6eQykT/b6aibYykxco0UsqMzLVblClhAHY1BpVwvzN0dpTnQCpMFTbdB/0FVaFMWIFuIDi91T21PtA/b3/FulXSDTA+hYGQWlKFmWq20Y9awDjM5KrwfadLFIi5jQ1epTCfgO+b43jG/prQTpDHu9lyofr/ArZYcQGdqF+t0a6ogCOcCkniTssaF5GnrCPL3bHDxWeJ7svQEfZvoOXVC3CYO492aNVnVtMbPnHW+ejqgtkzPrpwLyRuCJlqpZUsbr+HGniuFLKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:42 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:42 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 10/22] PCI: microchip: Rename interrupt related functions Date: Mon, 8 Jan 2024 19:06:00 +0800 Message-Id: <20240108110612.19048-11-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 441e78fd-4514-4e35-e258-08dc1039e4e4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wxLDWAIy91dvjeXDLx+/cCftpWcJfEvA6ejWwtjcca6LhQS4TcXTcS2RyOIJUJ4jr8HLHoF5wbX2cMSy5rB421AhDcTTJDGKdef6cRxRj2m8XYMwTL9/Ji5mb9vU2toBF1J14GYBcLkR9ItxPczIsWDDDNOvipl/kbAyl4zhC90Tt6DC6AuAZKwbHdhqiE8Ci90yyr6FjdIUhVCCUZOCRHbgdf6bkPR+xvyhRq/awjyhrUpUChHFgYYkzVmxGcxv74yeJJARraSuGDHuXT5W24VHLmjd56mqREvtKKu3NmF5PuplBrSzK9NTL2IO3z2bWR/mrpsl21PZ8Q8XksAS4CK2zGQHLM2nJ1rObF/8QdgBN3Hofcefoiz/pjhYsFYZNvXXopAcPzhhJxAvp8BCS4b7gh3kUZ179N+biPbbtMf0sNZDfoLloQw2BbPbm+kc8vWBFIX/MQsqQzTvkWUw2izFzIGif7IElZJS6AZMvRN0PS5DNOJpGpHxavYppGUI21PsdyRE7+fe6suJSlVFB6+okl1xrYxt/RxnkIEdYAbjUPOYWKXVUcMGfuMa7YC1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: daMhXwQJZXUwh+QDvbK80okkUEjyPK50764vop5ZXLaheiH6MsV277uxMCgWmNUfrTa++/7tTRwjz76HT1p6MeKAc9DbQJYiWyBIg0xStx1XC/krJr7iBvU/MSg7bSUVM1Dac4cGa5e+YKLvklhi1tmzALh3LDGdLLxfgc77MGFjGqX2ARAu2T7hbWj37hF7B9EkEYC1wnIF1YWtDaBl7GG7e4o1J72IXuzs1u5vi2pXksh54WmYjvZp5sW4nKH0vyfBtpKrAYxwrYTEuyAikjj6jcfXzgGARVBH7r7m2uZxPZ9E8VooqOU9ULMKigdm/A2lNQpxzOJ2dObdwlJdFW4/32/GDIfsb9M1GthBsTy5f5Pp8Z00zGvEewWD9zdbgkT2WQVh1mgupttBYs7ieSRJzd93PDQpClpuy/3Knp5kTyLw/ZQCIdfXzUCRHHMss/3Qg3juZTxNwsN2tFv876+eisIm0NGzr/ESowKTGkiNXrtreYLL7z1cA5/3KBM+FoSxOF4YEhzEmwHj3QguS7e+kTA2gg5H38tcJXX19RCt1OVusXPKtL/0Lf9/YPZA/E1tg/808VGpwzu/0Tem+2QQ+REs8j3qKE5VVNw8v4cgMFOMgcSJrsQhN0bz8SvCyN8h8ji0BwV5lC0+EUcoMzb0NVdVKzWs18expO3P9vDHChFrwlEUP7dYJQBNGvpXsyJvYMjYWesiWewsys94KO9d9AXtwWCV9FzcvEwqZ6W45Mqo+gYJbJErkx5vM0cHGhVMEC+szBmtetBhqsDMow3KkLX7WJVeCb/9ay8x0lXUDcaV5SjAe5KgVcbImfPA75TQhbsYZ3P0UlCDDmrISh1e7bMQI6UiR7afn2900EL5bzBPLH8j0pZrEBVgWaUJjChM7VpiTNWQhQRSn27Zpb+/+9+X2InzD6JL3nINyUdKUGrBsYDkSuuyp/5V3rb9tAjqljV+MkohOCA0dPKTOWB4bV+tXostzGqJ7CWZNoZ3sOLF7PVCEaoPUEb6QmXWamJ9m56zm0UjZA6nP6U5uVClYPSZ1PQbW3eQCPQPpePkhjDG0kIrD5qUEFF4XASS34EUFkq0Xcn2Fo7dJhTpJAnqbTT4oj7ZFuAmbgolE0kdou2F0g3Ossn29MgNYuIxp+b4Yi9wCVFHXZlYEQCrXqcZx+NyXsaJvgXbgGJ9aftIzZMNea7mIGEBH/n4iCWLC6f8Ft+6HkElfm8APw8HLLAuBCO/1OOzPmLo/PugnFqowWNr4paWeZHPcRBvYjt8vbHmmJm1WPdmn0GDmxedxHWT3jjEPSfIhHd5ptHSgYkYBuEINc9ROV5sl09nqkFAU7hg7U/s4Vpo8g1xF7pAeeHZL6ZEVQHe7Jhbw61s/TWEuDGpYR7qLbsrpu430l1/RwB57ua8ra5+NJersv/1excoRHrniw1hChqvPEKZMMBVekzGTXCgP60IoiEEdhMqL59Jjp1UW/iDWNCTDjmM3WU2GTAz8te1cHGeUwSRDFwQcHZ3BhZYE/GbZA+kfuQtc+s5dc16InHgzcPXjjgzLR6JI8B5Z2c+eGnhHIRjlOk7+123BtrvQq73skjK+UTxIUaK5aLoCkbm/0SRptMMlg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 441e78fd-4514-4e35-e258-08dc1039e4e4 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:42.0764 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iF2lk3YNWagGba0I7iwJoZiIUxU6WE16Ty3lqK6W4CImE12QsYMCyZ4wm3QCkz2METwZTTZU93DKlRiWuC6UmUITblrDYvBIy+OeCjOEFkY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030651_161573_301D18C4 X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Rename mc_* to plda_* for IRQ functions and related IRQ domain ops data instances. MSI, INTx interrupt code and IRQ init code are all can be re-used. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 109 +++++++++--------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 573ad31c578a..18bc352db389 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -318,7 +318,7 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); } -static void mc_handle_msi(struct irq_desc *desc) +static void plda_handle_msi(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -346,7 +346,7 @@ static void mc_handle_msi(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_msi_bottom_irq_ack(struct irq_data *data) +static void plda_msi_bottom_irq_ack(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -355,7 +355,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); } -static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); phys_addr_t addr = port->msi.vector_phy; @@ -368,21 +368,23 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) (int)data->hwirq, msg->address_hi, msg->address_lo); } -static int mc_msi_set_affinity(struct irq_data *irq_data, - const struct cpumask *mask, bool force) +static int plda_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) { return -EINVAL; } -static struct irq_chip mc_msi_bottom_irq_chip = { - .name = "Microchip MSI", - .irq_ack = mc_msi_bottom_irq_ack, - .irq_compose_msi_msg = mc_compose_msi_msg, - .irq_set_affinity = mc_msi_set_affinity, +static struct irq_chip plda_msi_bottom_irq_chip = { + .name = "PLDA MSI", + .irq_ack = plda_msi_bottom_irq_ack, + .irq_compose_msi_msg = plda_compose_msi_msg, + .irq_set_affinity = plda_msi_set_affinity, }; -static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs, void *args) +static int plda_irq_msi_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) { struct plda_pcie_rp *port = domain->host_data; struct plda_msi *msi = &port->msi; @@ -397,7 +399,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, set_bit(bit, msi->used); - irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip, + irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, domain->host_data, handle_edge_irq, NULL, NULL); mutex_unlock(&msi->lock); @@ -405,8 +407,9 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, return 0; } -static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs) +static void plda_irq_msi_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) { struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); @@ -423,24 +426,24 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, } static const struct irq_domain_ops msi_domain_ops = { - .alloc = mc_irq_msi_domain_alloc, - .free = mc_irq_msi_domain_free, + .alloc = plda_irq_msi_domain_alloc, + .free = plda_irq_msi_domain_free, }; -static struct irq_chip mc_msi_irq_chip = { - .name = "Microchip PCIe MSI", +static struct irq_chip plda_msi_irq_chip = { + .name = "PLDA PCIe MSI", .irq_ack = irq_chip_ack_parent, .irq_mask = pci_msi_mask_irq, .irq_unmask = pci_msi_unmask_irq, }; -static struct msi_domain_info mc_msi_domain_info = { +static struct msi_domain_info plda_msi_domain_info = { .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | MSI_FLAG_PCI_MSIX), - .chip = &mc_msi_irq_chip, + .chip = &plda_msi_irq_chip, }; -static int mc_allocate_msi_domains(struct plda_pcie_rp *port) +static int plda_allocate_msi_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); @@ -455,7 +458,8 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return -ENOMEM; } - msi->msi_domain = pci_msi_create_irq_domain(fwnode, &mc_msi_domain_info, + msi->msi_domain = pci_msi_create_irq_domain(fwnode, + &plda_msi_domain_info, msi->dev_domain); if (!msi->msi_domain) { dev_err(dev, "failed to create MSI domain\n"); @@ -466,7 +470,7 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return 0; } -static void mc_handle_intx(struct irq_desc *desc) +static void plda_handle_intx(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -493,7 +497,7 @@ static void mc_handle_intx(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_ack_intx_irq(struct irq_data *data) +static void plda_ack_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -502,7 +506,7 @@ static void mc_ack_intx_irq(struct irq_data *data) writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); } -static void mc_mask_intx_irq(struct irq_data *data) +static void plda_mask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -517,7 +521,7 @@ static void mc_mask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static void mc_unmask_intx_irq(struct irq_data *data) +static void plda_unmask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -532,24 +536,24 @@ static void mc_unmask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static struct irq_chip mc_intx_irq_chip = { - .name = "Microchip PCIe INTx", - .irq_ack = mc_ack_intx_irq, - .irq_mask = mc_mask_intx_irq, - .irq_unmask = mc_unmask_intx_irq, +static struct irq_chip plda_intx_irq_chip = { + .name = "PLDA PCIe INTx", + .irq_ack = plda_ack_intx_irq, + .irq_mask = plda_mask_intx_irq, + .irq_unmask = plda_unmask_intx_irq, }; -static int mc_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_intx_irq_chip, handle_level_irq); + irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; } static const struct irq_domain_ops intx_domain_ops = { - .map = mc_pcie_intx_map, + .map = plda_pcie_intx_map, }; static inline u32 reg_to_event(u32 reg, struct event_map field) @@ -609,7 +613,7 @@ static u32 local_events(struct mc_pcie *port) return val; } -static u32 get_events(struct plda_pcie_rp *port) +static u32 mc_get_events(struct plda_pcie_rp *port) { struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 events = 0; @@ -638,7 +642,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static void mc_handle_event(struct irq_desc *desc) +static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); unsigned long events; @@ -647,7 +651,7 @@ static void mc_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = get_events(port); + events = mc_get_events(port); for_each_set_bit(bit, &events, NUM_EVENTS) generic_handle_domain_irq(port->event_domain, bit); @@ -741,8 +745,8 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; -static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); @@ -750,8 +754,8 @@ static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, return 0; } -static const struct irq_domain_ops event_domain_ops = { - .map = mc_pcie_event_map, +static const struct irq_domain_ops plda_event_domain_ops = { + .map = plda_pcie_event_map, }; static inline void mc_pcie_deinit_clk(void *data) @@ -799,7 +803,7 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } -static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) +static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; @@ -813,7 +817,8 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) } port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS, - &event_domain_ops, port); + &plda_event_domain_ops, + port); if (!port->event_domain) { dev_err(dev, "failed to get event domain\n"); of_node_put(pcie_intc_node); @@ -835,7 +840,7 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) of_node_put(pcie_intc_node); raw_spin_lock_init(&port->lock); - return mc_allocate_msi_domains(port); + return plda_allocate_msi_domains(port); } static inline void mc_clear_secs(struct mc_pcie *port) @@ -898,14 +903,14 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) { struct device *dev = &pdev->dev; int irq; int i, intx_irq, msi_irq, event_irq; int ret; - ret = mc_pcie_init_irq_domains(port); + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); return ret; @@ -938,7 +943,7 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp } /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, mc_handle_intx, port); + irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); msi_irq = irq_create_mapping(port->event_domain, EVENT_LOCAL_PM_MSI_INT_MSI); @@ -946,10 +951,10 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp return -ENXIO; /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, mc_handle_msi, port); + irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, mc_handle_event, port); + irq_set_chained_handler_and_data(irq, plda_handle_event, port); return 0; } @@ -977,7 +982,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = mc_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513288 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 3AF28C47079 for ; Mon, 8 Jan 2024 11:07:03 +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=8M9mHMgHL7JHWrn3tOoxcjKG2L5wS8jv3DacUt+KgPw=; b=hZHdvGdXaDw+ZF G4dzwy6owmNwnNZtEwClDltSlwnljIuR4X8bDLeR9LcY0jb0fZX97USbhieBUEZ/OxmizDpKs2up6 0mbeV77wrhSIZYVS9ln8xPSzGABnNerOJAUs/WjYAS2p/dztL6gyUMRbbYDgRrlyOyMrRDtDg+Jwg u5QFec0jF1gWvPvtTeYe3BL9w+gjWGU6A8tg6CWUd5cTRVm4vTLvEZg8ABjc6FdMNR/bmIAi8IsbF z31xA2b0RA48AcMRnPhL5y4lu508khW+FbJ4AL9SV7afokALnHYAy/JQnWXfRWRn+45sD9oVCjuYr l4VXaRaZdZIYG0s6m5Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT5-004gvj-2l; Mon, 08 Jan 2024 11:06:55 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT3-004gjK-1i for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/0N8jo5K2ZhRC0mR5xHTeYBV9vdKnP6T+0lpBuf6yS0yrnHegIvlLsl/UYkepVWYzhQTUrI4fVE0nepMBfENlqvgHhmUNY/Lv7SjNv/Kll/3HmWqrihTsnHwEy8tgswOem8MfPTJukzJHa4XgCGwPjWj8UozIhA+7Qwm3JALzWncPuDOZAvobc+aLOLrGPyjiJE99hEruNNEpUpopsj2045iSBbpbxaFAloEEn3zXFD/eTOQR3vIOs3pOHzxZy7Wwfj6S815NsTdGN2rpQVjBkpmhIBDiLi9KeAbW60LdeRxymUHfgCTxUKdwuF9YLjSEV3rpT69RLujWD8GR6Gow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QeVe7oJD2XTht38gIbXLRqOFThq4NByQNjE9LHlCG6o=; b=b+FAS0ahMWTYuq1/qjLgMF/06Y99TW7Sbbs4suko4xnMDrY5EBBDn3SjTM2O2h3UZgmHIaukqmAY6l+K7tFk1F18wAn3t7vAjykShy42pL7XE5axliYlgLhrcHW5ON7luiby+4pQQqOx/4yjIKzsC0Y4M6xFDobqbcj54ACjyFL4obcvYjtCPDWhNkzX8Unt+7EjyUSqtGjybYxAAaoCYHUXO1DEE4fQwuyAvlSYYtExguEEEotJDMMJrZ3qa1CvoKQoW3nTMBH25jKQ3xL9BHgvlBRyGXLaa8tu284JVKjKwK2Jf0/R8q1GEYRKs6OZhfmz6uugvKd1iMQ/UX66Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:44 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:44 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 11/22] PCI: microchip: Add num_events field to struct plda_pcie_rp Date: Mon, 8 Jan 2024 19:06:01 +0800 Message-Id: <20240108110612.19048-12-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: f5f32a3a-5eae-4af6-a6f2-08dc1039e613 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: flP+ZoALSXL+w2SLhXW0RW5IUVtloT07IU2kEt/CBFA621/3eZ+7wTDcjnTnkjpe296Qvnd9a2Hsft2OLYQC19QM3ORUfiagGz+F2sruXQuqBHiVIwvRJBgYvpqxa2PNJDhV8NyJJUYqnklWvcDHnHYejj3TU9vn3e0ptbTvg1us9zgzKNAB+6xhhDdQB+XR3RVDtpRhzKj8AqKDNJYbJO6jlXWjQLSpFHqGeXJP+OvfKvHsyiLwyUu1PQuEggQ9Od9OFdT96G2pGWdloOJdVpTxqt61eq45Im+o+uaXlT7ZIJItPAoNtnYYLquFZpt4uzuKxRoswsR14lWR5GtQ2pGNWhHoAuuM0xNy8blYpxxExwYQaLgPKHGJQaaAyswwOhUoNycqgsx2RCZe8t1/fWaQ4MndW+1VU+69oqKIjZRi4NZJJ7jd7zd9WtXQNGDkNFdP/yJ8Sx4rGqrVLMxFYGqWdhulnSLnK3fg7nGLLMBra5U0Z6jnNE2e0F6WWKdEzJkN5Swq+NwBcgPnUoWBbXxklYxgseK2ghBn3QkQ4xym5PUWSEaWdQST6rrGmekV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RClnib4o5ffBpZNjimNWGoMVx7b19IExxsno42+S+zZbN2z77veIXHpRKZbvU+xxYgkBXkqyOdpHz2u6b5HV6gCeMuUNaPUdbl3Eq4t5WDCZD11spOzNrwWPGFxkwXQSEF5fa9o/WTYonAGOYm3DurdkJhHvlzW9byHnAfXnzRHPLyz6tSi8zK7oM9AypdCwTP0dJgDByJxJyMn9Ukk4DlBjT8Ntz7c8SGmBPY4WUWWxxiAnXYp9/jSr3SmUjZwkTU67isacXVPEjnQFGeMc8o6Qb8nsvMHkVTjNdGGjz+2Swfy3zN4Yfa09ztlLCTACsYGeik9lhuGuPEXfDyNW5f0U2jFjqdSygWSkt6JKskpOCQBQEsVQ0cTFK2R5VJD8MGVwy9mlfLChVRLdQmZpo3MZz/LbXyBPF5/S2iuvt8Np3ypyiDATGDMoCBZWwympy5+2ShEcQm2hxuM8tpRayx5rFQp3/3L0Y7S7HOC2q8Qv6EsXFzRjYQ+Skalx9nB0DBQiYE89R/1HlQSeDAq7R3xi1whN5xEk8ISs98CUomv8GKSd1fQyJnBWWUg4rdcyyEKLxiTOILomu125LHEox8BGc2qO5eDpgyGdAg3ttHQ5T/y/IlhGVRHKHzvQqtaOhiH/lYGY5NFuIAj55zX+Lxd8e9dndpq5kKU6bi6CBZB7zNE0uoFev0ziPrpIf8Tsbl+P+iEKwxnZvMnkUADkOx/fvpG/yJyruvRQMFh7osZXoEJ5XxKDj43PN8o67GjXk1uuz+4b40f8fwsvG2sBJyV1LrwQ0XlGAXfPX0aG8subccTE7infD+zY61UuUzUi6APzLtjM0URwqOyAEgxow8WFVuygAZKvaRK7Ojnel9H7NYVeQkWICWZsjXXQBk+VWJ0uRMwdR/YCWzu+tNv0NeN8o/lICi3KPDVZO8idAnF+o/RrDbCd+JfpEYCytxGzPFes4eWgTsITf5NFOnX3UHCTzumEdvinnwMj5zLLw4cRC9tZs+NRmnBLwn7yyOsqtCwoYXv39XcELy+gC734v8QbceitUFg//MOfZnTkm44LiygIkHolCSqMpBbZMJqmF9EK1XUQaPzf9msnhZ5Hd5DzjoqUzJZUAVWBp+83GiqJbb3YROqEzwbRCed8SeV0uUr7bR5Mh0qlbie7ITi8b+dJM1XwFMQu/ae10PKqieG7JB8S3Hh+LHBEvRTGBh4zA6ljY8s4SLT56EErfVmUg0xzAqu7cPrV+RLBWj+yMJFbsn5dQtBsX2bZPYZnH5/xMyaeZoDkyERx8shm+MQfwxCM7Lin20uopKjt8QXnRDrcmZ9qs6hjyRWtwp5GcCKi/TYvvRcULhL3VAsJEeB03x/7dT5a2IhLKT2mh5sw7uqOdE0RCl9pKLuTE50l8Y4dpnAqB/qy3g/eFXHGgaY26/Zl/wRuqVN3jhdp3UEPPV2JgEPF22VljrTi9AUTv1zqBFe4MX9ENxFo4nMgjInaRCbU8SxDETPV/KZKBFreomk3Fra1HZHt2lxG0RpSl+KgwabBnUJ6CUbBo2CniQP7t+f0qyr6f31lPcwbiJX4fhT1Qr3PRGMVsuIAM+NKb36QsK2swpeBcVGWH2hyUpECFw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5f32a3a-5eae-4af6-a6f2-08dc1039e613 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:44.0404 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: twOnW1d8IQmB+s+hGMoMgt5apTt0jgnEhzJUMXdNIzuAsrLXfKTv7GpEigSZZf3YG/8cGL2z3RwDom0CdPjuRXTTqx9GkTO8clOJ7dzwBog= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030653_568885_78C14791 X-CRM114-Status: GOOD ( 14.59 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The number of events is different across platforms. In order to share interrupt processing code, add a variable that defines the number of events so that it can be set per-platform instead of hardcoding it. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 8 +++++--- drivers/pci/controller/plda/pcie-plda.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 18bc352db389..0a5cd8b214cd 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -653,7 +653,7 @@ static void plda_handle_event(struct irq_desc *desc) events = mc_get_events(port); - for_each_set_bit(bit, &events, NUM_EVENTS) + for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); chained_irq_exit(chip, desc); @@ -816,7 +816,8 @@ static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) return -EINVAL; } - port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS, + port->event_domain = irq_domain_add_linear(pcie_intc_node, + port->num_events, &plda_event_domain_ops, port); if (!port->event_domain) { @@ -920,7 +921,7 @@ static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_r if (irq < 0) return -ENODEV; - for (i = 0; i < NUM_EVENTS; i++) { + for (i = 0; i < port->num_events; i++) { event_irq = irq_create_mapping(port->event_domain, i); if (!event_irq) { dev_err(dev, "failed to map hwirq %d\n", i); @@ -1012,6 +1013,7 @@ static int mc_host_probe(struct platform_device *pdev) bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; plda->bridge_addr = bridge_base_addr; + plda->num_events = NUM_EVENTS; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 3a17d8ab5bb2..adfca9f28458 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -124,6 +124,7 @@ struct plda_pcie_rp { raw_spinlock_t lock; struct plda_msi msi; void __iomem *bridge_addr; + int num_events; }; void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, From patchwork Mon Jan 8 11:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513290 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 CA169C3DA6E for ; Mon, 8 Jan 2024 11:07:07 +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=/gm1bKwYujwmmmlgWVu29ctv3noFmFd8wDMUDtfBdb4=; b=gQrPqcoZNPCGPT y3GzZNzT2FgQfbmbVYUs5TCAHlvdHyja29eQzRXVuN11vTfzn8qgQYNTzRwGGkOymLMUmU7K5EQOG w4Brbe2b9pg1Kh3nflJLcCd5OoyKbiNehuW/iAdV7eEawh5U3t3xCRAapxAZnqL2f6Nc8Bz6ICWuN PdoPOoWXWPfn0rzEXMnnGibp4wPCuepS4tVsEjK46YN9x+kISIsd/ddKMpUxk62PpWheL16QCcnoa d71RUHp4xa/GdclYNjYRduKYp0FwHvfWFRjR64AvY4Tl0NehpPOrjRyfxRFAMpbKJ6tTegHGX029t xxPJI903+Gg+mNgUUP1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT7-004gxh-2F; Mon, 08 Jan 2024 11:06:57 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT5-004gjK-0d for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNSrxoW480dcSq2maj/fJ3SHoia9EDzinyXewvOLsOYBgr5VZzEyhzkZ6gBxea4WaWJh7E5HC3JV03mSapRSN0nxlhvnaVZIhSdvraIUj4eZMLkk6Z7tyE5ouBz7FK+FiNc8oVCZJ+EKVVe78OA6qEXQHfBOV2IY0RnwZxn0kVuY4LN6/vzIJPkdcVj+8+s6eAZjop7S9E9OyZXhr7aBpj6RWyvsY9AhZLoxYKp9mq6UCGO50He5h3j3S+fSa5xCLqTkGMldg9/YwNdfB96/VroSRrIoJxM0Dsn4s7S4Bw7NUk0PuyyHUHSXgk/vHIErXTWJw8GSKAw7jl6AXrCtaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pb6Em/BmQcD7nzISggViwkd990VUOTxwxw4eGNuviyQ=; b=gcSH8haaBzWI4PylBn+zm+gONHcY2r2l/Ik3UHZ/+EuaAoh/ucaTrHWZ/hkH5XtuGBx9gYSbxraOr5mYkKbwylPrFl6TfqDyD2/UXkLDaM8InSKaqyGdHYWhJq7LzTiefUxmlMf1vlnSSQ68Y12qxM3t3ejU3ZmOs9uQhRXTdLf6K9QbgVgKRuYnPCpH1a3BfE+csU5ykNEhVdotWlyk/0Ml7/3cQK6rHWoXOhe4WhoiRli9uD8QBQsbj+G7nYbL/m2kaBd8atGbaxIRSqJBCBm3p5NdbTe3Q7BPcIGOBufE3LcSAVMDkYKfssFelS/coETY1C1Ndt8z+yUaNaQM9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:46 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:46 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 12/22] PCI: microchip: Add request_event_irq() callback function Date: Mon, 8 Jan 2024 19:06:02 +0800 Message-Id: <20240108110612.19048-13-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b70f64c-6715-4a11-0958-08dc1039e740 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAkhzz77rVhxzkbhXFnt4rTTxoTgsGsZWGUVLm0/uyvuMUc3cAmAswXKsGMxURwQorp5huvP+E8KrXahzWrLRxZRfdlkZsfKXYjuGBH1zEq8VI8oKZgd1+jjb1L0gOgLrCb/SE0qITzH+J5eBZrMG4pPfv4m4BRIL2rkfm9YLF1I4z9JdLhNBpi08AbTKpKwgZsKLvo37r0o6Mdr/x58Qm2IBNSseHHhz4bbXPFkksTVhMP8lP9onUGTHMyGmgYM3SmBKH4GCuj9avI/wdWyzcw50Wi0WHFl8gZkE3yf2LZZ5VO9Q9AeKP4EZfvKjAr5IF9PqwRkkyoscSNztWt42Mm1MYtVvtDeZqjaAYOl7snp6mYADrrUeMxvc/lOWnC8BtokvzAvc7rspHLL4PWek8uQQjGY4NYsjo7HvSJTtVTCkVImUyNGBnYzXmsyu3iw5oJ7jTAwIebVtxj97JejgvXXu0WsRH4kjOhZ8GCIyjlAuDrKvNadpFco0ECibf9oN6O5gRRejqHApnlOLMU/odrjxzu3f9V2+TJJXOESVPFtiNSZGelfHHT5k+93eVRg X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5AmbcUv6nEMSnQ0O+Pw37Eh8xmxjRg/bJXknrRSxiUf5CCK/gBIO4C4ufU6RbmvfedzaO49dbhhFoAfkak1gl62DgFnWt8e2M5IEkbLQoyGycsmSoRthK74igmhK9s/jg8HXVXXwKFV0aj0vHenduj5g731j2WhLMRNaz98T2ac4v8F2seGwA3tAFhq0mvjCh2tck+/Slr3hSt6TW6+OmHPX6TGmgTeJu24nNC3X5hAEdVnvLbLw6DTr7K5pUGT4vTl0d4+FDyGgPeR/cmJ6VrwfLvs7w51Y4y8Ug4O96o7EOCSAW2P6h9Ukizt5mXQ602aVduO1KIO2wullWcbaY6G5lKptHEYdr45SedHv22fdgjSdqtXUPfb6WfCzYYLVNnAztOdAtQ6HdJ5zx6L3pOQijhIif7kL5MWpaM1jgWD/VuZGtiWTUL2ttcN6QvineU1ZPrmBe4+hELiBe2wjvZExeVFhb8B8DsDLJM5DDiaz+rxngv2fhEYPIkXt5S1/tTpamOw0C+1Z0BCCMliNPpUPHWWf5Gg7oSPW1RUzdHhLmp/QgxpWvipxC3SF13ntOt/Fwph6r7I07gwrjokrqay33IYpsqLlzs03/IRNJ/nMUXZgluUCxlkaqg4qUjndC9N8r09xhYP212+LttjjmiDZ0z1FkFBK7ge0fcYSSiOa3zNBLjUgyOmxqAAwVtVFv4eQ2ZEf9HtQra1JRmRO+9sVVojolAs1mMPYIiY8aOMXOV0e8JSd3BxVHnjPpEaylGb1CAoOjLj+vGamVmH7aWDDDpCCpmzhOLUNj7tMhFx5EfAd2B1BLLxW1SiXV60MaXWij1LBn/Pu5QsW8cPGdDvHpF6+sA5a345UEyZ35BD9CbHpwrzsv+MDFlK+R2rmTOhR8/jglM3l75DZ5Lev53XfJ7C+ZPntpIL9WALWxkvv0QgyFLw0sOsz0zUJqQdczixIVbl/rPmp00HlWvgRUnPs5tKf3+0GFoajFm+5ZSm57Na4luLpdPv20l41ff2weJdrcvJVuXhU+S+4MZQnlHvIiCRE94enitl1/bR/2AqkuWkua3C9gfsD4QYELqHRDyM9/WhrXUeK53qKfzGx4INFhuwxYMDpRQdQWkLaj1UJunrxY/6OFSf9ObYpqwfRCwxJx5DMV4UFf6G6u74rCKRJOwLb3GY+MyBKLUcei72DnyLRwAWA7T/cLZ7SqhTucAgyF+QI1Mwh3gnugfIysDb+/7tRIz9eRlHrjncnOEhHc0W9361CV26Vvi1p6ttk3o4icLbHcmKhFIeFsPi1y0UjqTInL5AamPuZ2GGvHMJrgWZKG9bZQwkI2TU2bx3UrV3COz+OmsbhThCe4tgmQVtn4sheQ/0oS7kj97+URsgj06VBKZtmqyIvZzGZNWXzHoShLLTLIgKecFbrQ23eQ++B5hAHTQ5RCXDhJ6v4/grgsFMAq3L8ejKephnkRdwlnqjdaRe7g5KXy7ijtHWvS3AwA6RP/R+Tz36XMRVd75MPPVdVe7lH+zOQ/YQgoeTG+glJxVDtfAYwWvVZvMZUq39gX8YdUfffeonM7r6sx/vvg7rFmFhGw/aJ41GKcHYo2Hl6R19L+rFDgLcpVbwHtw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b70f64c-6715-4a11-0958-08dc1039e740 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:46.0278 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cGfH8itZEs1gYQ8LbGuOL/Pi9viMeY80lx0ABocOhbgc78oSRf3wUn9i+pq7+2aYcawf+4vItxeykxENUzMFnD2v7ZYD/5ATz5iYKhR6DCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030655_233649_20AC72A6 X-CRM114-Status: GOOD ( 14.21 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showes, PLDA PCIe contains an interrupt controller. Microchip Polarfire PCIe add some PCIe interrupts base on PLDA IP interrupt controller. Microchip Polarfire PCIe additional intrerrupts: EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR .... Both codes of register interrupts and mc_event_handler() contain additional interrupts symbol names, these can not be re-used. So add a new plda_event_handler() functions, which implements PLDA interrupt defalt handler. Add request_event_irq() callback function to compat Microchip Polorfire PCIe additional interrupts. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 31 ++++++++++++++++--- drivers/pci/controller/plda/pcie-plda.h | 5 +++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 0a5cd8b214cd..bf5ce33ee275 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -642,6 +642,11 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t plda_event_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); @@ -803,6 +808,17 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } +static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, + int event) +{ + return devm_request_irq(plda->dev, event_irq, mc_event_handler, + 0, event_cause[event].sym, plda); +} + +static const struct plda_event mc_event = { + .request_event_irq = mc_request_event_irq, +}; + static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; @@ -904,7 +920,9 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event) { struct device *dev = &pdev->dev; int irq; @@ -928,8 +946,13 @@ static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_r return -ENXIO; } - ret = devm_request_irq(dev, event_irq, mc_event_handler, - 0, event_cause[i].sym, port); + if (event->request_event_irq) + ret = event->request_event_irq(port, event_irq, i); + else + ret = devm_request_irq(dev, event_irq, + plda_event_handler, + 0, NULL, port); + if (ret) { dev_err(dev, "failed to request IRQ %d\n", event_irq); return ret; @@ -983,7 +1006,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = plda_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda, &mc_event); if (ret) return ret; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index adfca9f28458..16b81b23c213 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -127,6 +127,11 @@ struct plda_pcie_rp { int num_events; }; +struct plda_event { + int (*request_event_irq)(struct plda_pcie_rp *pcie, + int event_irq, int event); +}; + void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size); From patchwork Mon Jan 8 11:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513292 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 6F94AC4707B for ; Mon, 8 Jan 2024 11:07:12 +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=wuao8k+2KtRwPpgCYN5M9FWYgAKsiFNRyQppCK/Um/0=; b=OECeMwTy9rlrzQ QBXuweMMCpcNlZFWpoKiqqqC3LXK+Mv0pZYdQQMcBNrApIHxZCKPo47YSGxEceVrHRK0YNXy5JLYI nao5U4970C4UB/Mfj2bd6KUKdXmeurQwLMxMR/N4eLL671YtWqGVXoXYjG62a63ROF0WvSGidyRi1 MaLK5jTtzs/9H6Fn1uu4q3HDSSIyqs/7y47CgmcPlBfVx+XTGTvLjxTq4LuKOvsg0noz2IVxUTN5X TnnDZk4FIlNPHAQeTWgho2c+FrAp6IB8v5p9qTYBa/kcZefC6ZPbyzNx5Ec0SR0KDOcU1dCu/94XC NXDxF/ymk3EhFaiXtNrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTF-004h5a-00; Mon, 08 Jan 2024 11:07:05 +0000 Received: from mail-sh0chn02on2060d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::60d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT9-004gwv-0u for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZEPKMo6gnsGBfIXXwHZOAR1FgavqhtO8x5OKmCK3LXfKvic4dCUv0C6mPZlmDf/jKF0P3BC+zt0y2FrrBRQmFGxonwlPe/16dTC7we6pFqP8uBvZT16yqo9iDmXMrgcRKskbzFQXdvW16YFrV5jCBcQmpOHkWbDDrezUc0KEkD8A6bq5jqOgb8V9ghaBHKZDRcgFRb5hUkgp/aYjl9YDLkLE+2/IwLn2iX126sOLcDE3v8y6XIm8hATMifj6siA9+si940Po54FVrxyQg0bCOcXnl0ep6A7PilmSNX+wx3r8QG3+rwgyIXW5t8+Z/HQUaNWLQUBEaKRpj89RrJjJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nkG8h4qt+ikCnMOfDNuKvK03jp9mjC84c+mENU+9eY0=; b=R4t5KlfvB22hH1J/QoCrx1Abb4s+cNZYRembb/a63sNmM6Q8WocNl4Jsb6+FQG2Mmnai5tPf9wgi6lXyJVWjBoZIVJg9LabSnQe7rR1GwFxAav7b6RbKZ1W1VT8EMIyBc9I4T2hlxPFg0HHqMn7pU80jQm120o3+7QFqSNPw7/2lYOwczWINi0PRrdwTe9x4Jmq4FXCaBOV2nboHxIMHXM7VnODNeah7sPFZ3IfrgkX4uiNMQZnKuwG/8ttWd0nChGXpYKh4ym2tfHSxIlPemqkArmOWscWjL7oX0AlzfDOeJ8VAsNirb/ReGrZhnJi+lWYXrjJbGG1Ljo6o0Fn/1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:48 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:48 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 13/22] PCI: microchip: Add INTx and MSI event num to struct plda_event Date: Mon, 8 Jan 2024 19:06:03 +0800 Message-Id: <20240108110612.19048-14-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 7269e5c9-e233-40bd-ce10-08dc1039e86e X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AFncDXgSIhPMe+9mfYBofhNjpJwrumPujnht0XZjJyU6aOgZSawepop0Fa7dJApkQVmt/KxkthMwfxaMPk4yUHFJnItaj4ELhWuVWqOfc7+f6WoU7cUAiR2PBk/v/hYO+Tw6+IiQUH2iUn962/pn7ki0fzr6GdDjZd4oQ8TPY6vuUTJf3HUpEocxZpOgjuZHot7VhCQGkv928Zq0PWpG4WhFlrZ+dyk+wIrFF+WQvRGsUcKwinLm7Xo6z0Ot/kjK4E8ubc1//q9JYp6IqlpvW0sIlI22Xb3VN+laG22+CzB9Tg/dQtbE8uGFcM8h3I+Sm/F8mS3KSUZ3FW2jyfu1r2XXlTn8i5qqX/j/A7ecIMcy11b2UXISLXzx8dGYYfQcgFIq4uKp/48VRHHhoPwqPsRXpjLstUk8EpurKACZbbegC3usjhz37WrUnDpBsjkD5wPLKxBwhRsiXllw0D8wAY8HipgpsOzjs8F2pr+Q9yfGp/9WdL5vADDOdhFE4TboQd3gtbR6QIsvwNjkTMFBIyU/in+ZxrVOr8/ujME2Vq0xdFwesvgk18b580LpWI3o X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lDELTZ3+VelIhNr7grYYxVwp2bUBxwpJ2rE/WkOhcuMmLH2K4lcOqBbSx/3zLqAW8BNQV5UTcuVUivZQypLhqP5h2MZERIOcrzaEAgroEFO29q8BFnSBprP4wzjBkOSSpeSUfQcbysSgl8fSv8kr5nBObYC6BCUCCKsu59UyzM+zw6k1jFnjzQ7TKqHrVNymN6gAm5uLqdeuqZZB631+BNFpmJp5hUgICWjv7U3O/ejNiIbjDF8biB79hjqYmlI/6cKt2rpLDz8g1qih55Gq8bQz7avalT0JsRe/2MXD+9Zp/CrzvfSqZzJycoI7bI6msYJtwcFfjfKLSJn2DhWVN4xPk5RRZAe0kAot6zCQTc34WtRjtmfJ4DZUJm7J4NxTJuNAiFaoMPBb8cxqdkROC+Xbcjqtxo0A9e+NQKEilHL44eUAGUm/qKB/9o1RWlRHL0UxxBkWytZvQBmE3zp3C/SbF4oM4dzp92efcCnVcZe1I1474TKktNvAy09GpVS7rRJ8M+lV2W1CeZFNnvJ33tYSSUo/0utewehduFfhY7JNpEUa03KT01cIKsnyfC4B2fkyE4kSZwSNsIw/RBm76Bn97FGKtQEurMx/7tr3VBAIIC0h5oAIDmCzIecIqZzzZung2QNZcstYrjU2vuefhi81KyBfkCvLvTsIxP09kfRq77VyZBmrCZqL+vulIkgTLYGIFh/CPdtvQry5q/El+2lQ3kv/ksTrJ8hDqxlCdtlvuSoRsJOcUXSQZENV0jQ1dozKX5p/qf7lQeBxjuOeKj1e+U1Z00ySzykKrLioyMWVnTkSekZ+1a9B5KyGufiw/f7riWyNu6Eg/TzGlUPVjVm1gpqdeP3483IO9NqVqmd5mnP3R1mi60gMBy0x5QJNkFxWlUFFJNsXk3SGtfwUlI/eorb+K7bkifMixuulHB58/WvCdPx8V2Ni1GWuDjrMYS5KmUJavBr/NWph9XxjRJQInHqjApZyOE8wK1QMvelQJ/TGndn6pG8tJtWtWGRasmyTZANmA/2H2xZQlRt0c9z7C/U0wpMYEGHlOsrwfIzupmQ15L6Cjx7gBd7/ltkK5rfglK9UJt1g3uYoUBcm06VG4HVDABz2GgJ8v6SoYXRs+mzOTvoPlFnHaiGkRUEIkmywZ5N0VNo4qXNnEciguhT8hI7L2rGiLMBS18+1hLl+rwHE9R/KaZG5b178oatw8IRapeCSneZOz9+msrVJgsVBxgOyvZiAkTbSEprI9FMTXjwmAIfy+qgQP8K5cnNNWBhBt9mTbe4wjBctBpBPRdMdqrElpMsXu8IYshUi8SSJheYctuTWMdVOEu0AlZwnlcJha3VMD+BD7pjQ+FdiOvlGhTSu5L1OEbXBu2ikpftPqrVukXB1RFSdGszJORq696E9FM6Ni5MZ6HsiNCev1pO72gGxWhIjUckWiGDzCMM9zKVmHa19uBBO1zFh6R88CMvbVWCu14yRk1fEEl/0tmUClJRPY0Iye+EslGy/hj0BnywcV4oZK9kT2QoFyFdnDEfzFc/zC/4ncpMsstO3+g7NKlkmwosocF8+6wfS/a/P8pcB9jB5Vzl4npDRSXgDf9OAlkRZKAmVSiYy81VOJA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7269e5c9-e233-40bd-ce10-08dc1039e86e X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:47.9513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5Hg3acHJr0DoczAsZG2NqSsmutA8k90L5Ou8Un1gmktmcUl5WqiiXsMAgZDJZME+iZL1+n1vqfzs1VrjPfyWYuRZeEDUooEZ+wpEIfJVK0o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030659_343921_4F5EDF39 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The INTx and MSI interrupt event num is different in Microchip and StarFive platform. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 6 ++++-- drivers/pci/controller/plda/pcie-plda.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index bf5ce33ee275..8a51d3aa7e88 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -817,6 +817,8 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, static const struct plda_event mc_event = { .request_event_irq = mc_request_event_irq, + .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, + .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, }; static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) @@ -960,7 +962,7 @@ static int plda_init_interrupts(struct platform_device *pdev, } intx_irq = irq_create_mapping(port->event_domain, - EVENT_LOCAL_PM_MSI_INT_INTX); + event->intx_event); if (!intx_irq) { dev_err(dev, "failed to map INTx interrupt\n"); return -ENXIO; @@ -970,7 +972,7 @@ static int plda_init_interrupts(struct platform_device *pdev, irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); msi_irq = irq_create_mapping(port->event_domain, - EVENT_LOCAL_PM_MSI_INT_MSI); + event->msi_event); if (!msi_irq) return -ENXIO; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 16b81b23c213..0efe64d5f688 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -130,6 +130,8 @@ struct plda_pcie_rp { struct plda_event { int (*request_event_irq)(struct plda_pcie_rp *pcie, int event_irq, int event); + int intx_event; + int msi_event; }; void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, From patchwork Mon Jan 8 11:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513291 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 1C39CC47079 for ; Mon, 8 Jan 2024 11:07:09 +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=0JZ7tncovWmz15N5ftA9hyEf2MJaySC81YizH7T1Jdw=; b=tGhJ9QW7O/xVf3 xVbo5GNf0MjA26I6YGH3HERWdus/1uBRfYbJyRcB/nYLMWP9qUTMO8ro26Xe2+5Sdv6js+2dD0CS5 duFHDqQKC5HOSGc7EikR1qlr+YIhXLo5fG6aPfE7xaOH2UXVrF/qvT4LgiKwwK8M16vW9baGskahC iMsvk2tpkTP2qIxZqojKsdVZAbgdUVJp2QOR95krBzYeV6IsVvv6gFVacJNm7GQ8cyRb0Yc5PyVci 18TEk53ED4Ro00wKTBo6D4QEygBjpPha0nFSLqI1UP04Z6L55mjWjqpBd81zSffvUByULlCtv7kRv BWLY+eEVevUetQ18VBWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTA-004h0a-1k; Mon, 08 Jan 2024 11:07:00 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT7-004gjK-01 for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:06:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DO3/KZJ0ej4TjUHBdZ0yRwqRkGMDn1FVm3cCd0RIuNVo2q4rQQ0URJGQIbK7GR368HAb8QnbRno+j/pDYvU8sczUJT6gpXxf10SZ8fdZBpGVTJ3u1wJlQPZSGQYESICERtOgcCYuIVrZNeN9q63sWQuOg402PpGoJD5MLZf+tMUhuPsTCfrOfIMuui1Aq1Odz6gJy3n5yQKVOkGGF334H+GpZ9Gi/qTMeMipS9vb8IIzamjhdi9ybR10C5q+hsQfV99di/swBezGUqLpIdHLMcwONgx8Ip0b64xHPcE5f4rx0Iwtk/td2NZ+m28xvAU+n16Wl8kVO4FHu+H+QFNoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7MZHud6DOJtHq48cZ3FRIwx5aCvi4W9JCy0s5IDEiPo=; b=avTgESNSHBSAEBV8EZ9D1poqZzsebloDpVzynWEyILmTRgLI9rFHuiyHojxQyupm/LkDLV9dAseSh9o/ohg6C0Wz4R8nX1ChNO7dHMGiPcD+rR//1eROiooSD6Ew30saXV/nmvwzPmAr/9Oui0QW75/+J8MNqg0mwXuZ2lbaC7+JMtA2CpRdCjpIakIyPWsTcVg79NZO34xYED7B3HAHiPZv4qWRjMZB/FoGR4ogAwE1voKj7kKutPsMu6xmifcbA/TMlX4lYUyrpQrwCK+yUkvwg8T4J+ZwcfN8dsRVnD1lQVXyJgjGZGDlWaL5mEVbPcflU0XaW1q1N1MwbEiwlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:50 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:49 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 14/22] PCI: microchip: Add get_events() callback and add PLDA get_event() Date: Mon, 8 Jan 2024 19:06:04 +0800 Message-Id: <20240108110612.19048-15-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e7bb5f3-f1e8-4b32-098b-08dc1039e994 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q2xb0/IrYH/URU2UW9oK4R9fCBNF7RVROCWAoy8Z4WqFtyRBEnWfzXyAmqZnuKM9ERT5I7osCJ9mwftxl2Z/fD43ZZL0mOJpn9EPz1TPgM/6QCrPYtvZj0AJkAytF6dn8DOcmsF+sQccHFVNROJ1b/3OP6/ZMuIgoOFIU3uCWf9SAstn0M2aRjgi0x03dnMQO0EDCP83tk4EPol6XC8ZnKWcKGdsaUbjXirBMrTng/v8YWHTfvNYqH0Mv1EOkBVTy9kqWTJrRQfMX1lX7O7nI1uDg1T1Lqd9GDOB7Teg5x/gGup+N0S5i2fdpb8FuSNCdrzqxeydQ9aK8YpXPN8fiTr9HujVs7/wUmBy7QtZcTzCPAOPUb7ann4cJMoMLz5V/awy1iUW+0oEJjbI3s6xVgbbhBAbKb7l0ql1cxFynuIOm+S94w9b55xahE3Mh/ngm7PcXgWPxC2zVMUEMihkWwAbNm51G9dvOoh+ztrPc7+2w9c94whmEjk+Af5HxZbeJWxTOox3cXDmT4QA3YRKla/Z01+20q49RykYTG7jbd51xmPwmMmKVbb6li1/9pKL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y8Q7fC0zRsLwGsIBCiTFPKOZQ7U2QMIn4LY/Mzi1oYq4t1iiOn3ZdhDNg7pBo5kdknWaj7bFckUp+xoIjc4iJB7weLzBWDu343npfyqbhxEp08w2JqD73voANVtxl/1CoYUc9SMVc77HlczJedXv5Koiv6C0KuxFAz55P1QxJjbj3bg40NV2iw5gwwB60lbAVM6YpAxiI7WBBiLfAmcW1JL9jJXB913moJJpC1JbOJxx40WXs0Gbs1RSxtqX1g7sc9R6MTH09t5/OZW8jfxDTbYLdvms6aTKS0FPiqcYFB2TurQBAMf/gB1M7VYWmh0uoQCcyIs5YJMu3haR9byEwLkMijIb8eQ9mXZQTa0VdGYctci9RZtBVEjIO4ua9GPiDdpuzWT/m0f+jMz9ce0C8jwnEbDW70Q15Y3+y4rkbTekpml+V0pL9sXekOR6XaieOICdt7ljoRyLTQkQEjoEo8C5Jt8yVGvQizBfL6Q9Prt/NDr5jB3bSY1idI5OX7Pp8m9crAB6FM7EKHOp3yX4O7jMH/9/o+L26yfPLop+6ndo/n/xWD5UBEu9YxURj0qW0+ltyJDheLontmZxvN4heeBvpyB1XyyqLB/28wsuRozXLfamjcjNMtM8tAo2c3MQ4+eza+m2YoqvCitBWDPkwd8Zsz0ILbWygJXpB+lFPfPOq9JRVJNaVubPiZ4svrvQCki9wb2Ohv9vRwA1/9JYHMIhp2p0JnpUv1dsPLNPue51yT3CHJPs/5ZYWxx2SdBYEmLB31P67nC0m/m08DgWQQhDTQ5zPmEhJWQLN0cKAKjtqBSjERCK6BPGNTwNP7trx9kbg7NRpqcC06wrqXUkmGbCzxwNCGJgk3sFBW0n8oAnKLHRHf0XVNFqDUy8wPFQ+bvamx5aOltxD44IN0g56PyHFYdn2TXgpuv3bQ6fhwni+z68uykEoQZ5atF6NZBLUR88HWLVG0ftksGHbbFOmPrMpYV0VmHCYWMUN55Hq4j5ylNrdf7tsyVZ9ZJWOjRXl9Q7cmzdOX8ufS99ayEd7A6Gn6nvKdDE0sJocMdCVko9vV/nlfjutYwK2vJjMN1KUozmlI95Ie02yBP7SrcbK+frfUrGnAY/z8gIDCfpXujI5m8WbLnaR6WeO9WiuRhdTDYXgLZiJzdGqRba/Ilwdod+x+usWAkfWbsCTplNfDp+IlEfw5MuRlFv2uW43Mq98HdtXiubLSnIfPif4A8Lk09ogMlptammGiXZdNOI3vDbcScT9aFamYy4lA4ythC4nPanUWN5Gz/oTJLp8ScPsPVHncXkqfm51h62V75wp2MCTnlkM0aq7aAFnIgmwmQEqYGI1W5YzOkcBhR2ZeEQasW47qekwNqCLSmO17jPMX7C/eKqpnNOAWDeTq4ct+Hmi3YA/VID6UQ/TqCHKzY8sd/2Iten4BAJnC1lsIbkyU201v6a/6bbG3Xcb68ti4NmdUJLzQPWR4AcyHYK3yb5QHG8vREPON/Pg/+Z5v7jWdXnjjP7y71cizcv2AnsBBf//ckF0TqPh2VL/XUwR2BuSDa2bQZZe2ZZujipE70iGP3hk8ocmsDyoTU6JnHwulcsoNMmiONt81/D5UDhPw+hiw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e7bb5f3-f1e8-4b32-098b-08dc1039e994 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:49.9173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 45qgO6nBlIqYv860XjADsVQ/RU1daaLyT0X0lyHxal4fyvXjcAzMckGBpGanKzIu2WKFnx9C3OAKwQBWonHCE/WGhNvjQp8hHhB22sIi4eg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030657_059724_85E1957F X-CRM114-Status: GOOD ( 17.46 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showes, PLDA PCIe contains an interrupt controller. PolarFire implements its own PCIe interrupts, additional to the regular PCIe interrupts, due to lack of an MSI controller, so the interrupt to event number mapping is different to the PLDA regular interrupts, necessitating a custom get_events() implementation. Microchip Polarfire PCIe additional intrerrupts: EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR .... plda_get_events() adds interrupt register to PLDA local event num mapping codes. All The PLDA interrupts can be seen in new added graph. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 35 ++++++++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 32 +++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 8a51d3aa7e88..b3df373a2141 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -626,6 +626,26 @@ static u32 mc_get_events(struct plda_pcie_rp *port) return events; } +static u32 plda_get_events(struct plda_pcie_rp *port) +{ + u32 events, val, origin; + + origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); + + /* MSI event and sys events */ + val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; + events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); + + /* INTx events */ + if (origin & PM_MSI_INT_INTX_MASK) + events |= BIT(PM_MSI_INT_INTX_SHIFT); + + /* remains are same with register */ + events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); + + return events; +} + static irqreturn_t mc_event_handler(int irq, void *dev_id) { struct plda_pcie_rp *port = dev_id; @@ -656,7 +676,7 @@ static void plda_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = mc_get_events(port); + events = port->event_ops->get_events(port); for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -750,6 +770,10 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; +static const struct plda_event_ops plda_event_ops = { + .get_events = plda_get_events, +}; + static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, irq_hw_number_t hwirq) { @@ -815,6 +839,10 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, 0, event_cause[event].sym, plda); } +static const struct plda_event_ops mc_event_ops = { + .get_events = mc_get_events, +}; + static const struct plda_event mc_event = { .request_event_irq = mc_request_event_irq, .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, @@ -931,6 +959,9 @@ static int plda_init_interrupts(struct platform_device *pdev, int i, intx_irq, msi_irq, event_irq; int ret; + if (!port->event_ops) + port->event_ops = &plda_event_ops; + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -1007,6 +1038,8 @@ static int mc_platform_init(struct pci_config_window *cfg) if (ret) return ret; + port->plda.event_ops = &mc_event_ops; + /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); if (ret) diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 0efe64d5f688..9db92ccf286c 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -58,6 +58,7 @@ #define PM_MSI_INT_EVENTS_SHIFT 30 #define PM_MSI_INT_SYS_ERR_MASK 0x80000000u #define PM_MSI_INT_SYS_ERR_SHIFT 31 +#define SYS_AND_MSI_MASK GENMASK(31, 28) #define NUM_LOCAL_EVENTS 15 #define ISTATUS_LOCAL 0x184 #define IMASK_HOST 0x188 @@ -108,6 +109,36 @@ enum plda_int_event { #define PLDA_MAX_INT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) +/* + * PLDA interrupt register + * + * 31 27 23 15 7 0 + * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ + * |12|11|10|9| intx |7|6|5|4|3|2|1|0| DMA error | DMA end | + * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ + * bit 0-7 DMA interrupt end : reserved for vendor implement + * bit 8-15 DMA error : reserved for vendor implement + * 0: AXI post error (PLDA_AXI_POST_ERR) + * 1: AXI fetch error (PLDA_AXI_FETCH_ERR) + * 2: AXI discard error (PLDA_AXI_DISCARD_ERR) + * 3: AXI doorbell (PLDA_PCIE_DOORBELL) + * 4: PCIe post error (PLDA_PCIE_POST_ERR) + * 5: PCIe fetch error (PLDA_PCIE_FETCH_ERR) + * 6: PCIe discard error (PLDA_PCIE_DISCARD_ERR) + * 7: PCIe doorbell (PLDA_PCIE_DOORBELL) + * 8: 4 INTx interruts (PLDA_INTX) + * 9: MSI interrupt (PLDA_MSI) + * 10: AER event (PLDA_AER_EVENT) + * 11: PM/LTR/Hotplug (PLDA_MISC_EVENTS) + * 12: System error (PLDA_SYS_ERR) + */ + +struct plda_pcie_rp; + +struct plda_event_ops { + u32 (*get_events)(struct plda_pcie_rp *pcie); +}; + struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; @@ -123,6 +154,7 @@ struct plda_pcie_rp { struct irq_domain *event_domain; raw_spinlock_t lock; struct plda_msi msi; + const struct plda_event_ops *event_ops; void __iomem *bridge_addr; int num_events; }; From patchwork Mon Jan 8 11:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513293 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 2B625C3DA6E for ; Mon, 8 Jan 2024 11:07:12 +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=UugVQBeKZMRLZt0JduSBmD2yfRvHx0kjzvq9QSQhmEI=; b=l6LoUx+YirqDlL lXDiixAiX6KZXX1XReu8kg61rBhQZEXF30ZZeDU5KK5tGNkAWlW3LYcbmXZVthasJpnv4TAF98cXa 2Vjxt0dDma7+QP9GOT3lgfgJzimPCeylR2JMx0cMnfnvEhITR3j+duGSWA7gmmqUeB+T942ysS8Il Oy7YBCbJX/Q7sv2B8/GMszTMKvI9nnMnamL0Y/1T7S2uQ8AFEoB9cntHUTQqrF+Y7JP1UuObjMpKa wSZkRxke9uZDKKtXndlk7iCBgk7VP5BAtixGy4cvxaK503Zd0JQ3HY/P5rL+XkMTVOWZxGeHcYSO8 FdZKbrR+t42rmYMHMOGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTC-004h3V-2Y; Mon, 08 Jan 2024 11:07:02 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnT8-004gjK-2y for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c28fN9/VdEPNREDUgMvu9KHI0nKjCTShAFsNunNLs8RhHqas4Ryjqo6cecw4s9ALv5snRl8ueiHHUJJywg1W4oM+ywhfmefRbPEHR3HTtcu/x1Ku+6A8GYzFViX+szi7m03BWy1HVlTWXTJj6+Zv6KQQB1043tjM/jN2q+fB7eQnyaPAiqGwRtlQkA2JifxsiW1kBwsojWPp8EyUOS74pCiZr7jrxLQa2otfx3a2BLIu9AXT2nfUGRlAsZv/15CjffXgScTxpYe91U3uM41kLw3fGlQ6JaxZYT6B/DLDwf5Jq9rJwQBEV15sqNQ5T2X0RUnGfpMUvNaJf0Ely3Yobg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FpqY99b926ol+SPs5WN+/WcTgyU1vh55svYRCowYusg=; b=hZWqvjJqARZvYFZ7wA7GovVp+pz+p0LYYBUz1tmBgm+mGakRPLayKtbYtWBZYvwsaf1cnnwwFC1zpGqp7nDZAexCKcqs+SCDI7LD6ol/b5LC5PPIQehnOEKEzb0WZd5q59vtDH3LaPC1jXYbn3EWrMy0jQGU32ItirojZZ/6jTgx0Fyo3AHI0JmXJLR9Zwnv0b/3cPG+WMRsO2+SS5gnyGaBK8HBCBF6pvykG2pXvkfj4zHiP5BKVkclX6v2zE98zooikVnnoycIQqM8dtiO54OeM4PpG5/1LijdB0BlXZ4GxEGzX4bFAKs0mczLu8I0eGgo3Fawzd1rgbGGMOeAjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:51 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:51 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 15/22] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip Date: Mon, 8 Jan 2024 19:06:05 +0800 Message-Id: <20240108110612.19048-16-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 778b46e7-0fc1-4a29-6bf3-08dc1039eac0 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g2x5tHIXoV3eaALHSxit4oColJzGiknXodpwtuxjpyh4vTzTLqbOJLqdBCt6dIRe4o77He48rhUku35EouEHQSrJPXeS+UWjlmcGYsXhWtrmHh9KZYWVkyq9t8RysrNaxWvzYvdUgltwiKX+q4lMzsAxmPpUV9a73hs/bznOFoCCXY5TZ3oXnC3N9FiU4U3AXdyzYyPwV3uDLPcJ3KvahVMdbZ91fJUogf5nfiKkptrq+1xTFR9bLLfYfTRXEuVcU6nWGMYkClYQeZzC8A5e81ecBtoMJwcBCguAQ7iSFcXaapZKsaTvLEVYXztkGwiBxjjUKP9hwkEY7Cr45pXCDDCaPfINWRRKAZDj4O/wNNXxtqI7x5tPZ1jDziM/rAggPhh7wKOoas23GlkWNif0Nsf7zAgnxmgV41aEfkf8FHSiZRb/ev7usDER2XZhJLdjCtbW7vCG67RFCHgOM2xdqJdOiuO/6UiZw+kLJ6yhbUMDiTmU+KV3FCEndI2rselPOqNjqv2waqld2xhHog2csIDDCcOily1/DUnbFbxBk3LqAJKMYqrlgwiwCd6yHw1t X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OEfiKfX71KEG1t00KpDQQM65o5tYWKvJmrNy+1E9FfVp+OLX68EMGWLpMz3/4DXXdKvFELEwpXqbfGSgDLAze4G6ze1R4IVqNI0/gAQLLGw3ba9Y/Je7cr7MSypTAkSfcc1MtB0izScOnlxux2iacAabsR0izXuak2zJaecgzgjzI19fLXddSeag2LsrHZ1ZdOfkK7vG7f+yXzWZumSTMtgwTWNMkitGfrq4DG8bgFa/uJF/SkVamP7x/AU+W310qDn0YOhY6TuCZqJRREz2ZFsUQ09+LKseQfqph4kUek5oDzgcfrL2jWuaS7qpISYGqNUVKpnAA0+7k13k4ccwAQEQvw2loNbinRh6pJlTVAVl1xqAlXTh5Jp3f8uMiVlSKI8KiRxhp5TTXVepVhCpEfIDbsqIBKyICFr6fLs18OtoSpOqiHKVFP/TPXnRveBeqVpN8IzGl+K86Kx0IlRHExurOxjW3yhbVOqN27dvpSRcgt3rz4KN+h1m9RZQf5LnXzHRoZwzyzroPKZfoyRaGT03Iy1UzTLzV7LzD3ebPxDsdnzWbz2EGVDwHuOR/hMXso6yZ6x2MeDBL9SFTkajIJTBizejrC0/BQHKXp15XGCdcwIplUuf7HkNsfIMDJO7n1icuFay1sVc9WLHzUdTRpuWh4NYj65V9H368mNMm4gIh6TqcJfjp5iUqegcmWC6IHOYOi7UfUA2oUTJW/w6oxdzhdx7R2vm6KDXaDGAGI9mwtxqo58AuRH8keZn4GaaIpasch/9ngA11yPdnBgrOfaqNsha+A9nVku3u+PMQQnl/cz3iK2fm26SM9G9LzGcm5/qO3SxkshgJUXbCJrdqjR1xe+vbj2NaEYsagnePBeBYhKRAg4fQAhSyMARIQyP2/XSELTBPhaGYnN/mEBLArfzYYYAflg1bzYGLRqWpznBautJs64rpF1Twi9IKdhr/zhMxdd+Xl37qL/NrNhvaC35DzMjorewOoVTrqYRTWhy2wDkCxGfYKmwBj99pi+Q66xenpSRvimivQld9XTE72vr/u25ehe8Ny1d0JJj4YsuKCTfMm1GJJcXrNsCXboYM6kZNq7SpkETgubR8rmR0SRDRicwlJeysX2Xp9e81PGJSrYfU/+6L24y+lSE4F0zosw7K+vVC80LofFbSxQ+kVl3mEGz2kCA6Kb7He5bEXN2e+fQqdPLLS3uXTDot8U3gGGoVeER4muaj+D6RvT64iWd639G0nBtA+y7re46A2DLw9Pa6FTlpsuM2z/gImRzyVfLIQe+0E3p8Q9jiHLFLzqAqY0vkwwVo/h4WoB1vWoRA2ylrSDmMp2BM4z2EMB6hwfn0wox0Duvw6DLnDaGfU9nVGSFAK8hI5scqxh5oaCIn4m7KmDy55zbtRIPHFU0TkKDqIJE85tBeTSQoEwMAlh5Hcecs9DjCho3o0bKX30iXmp6FcDIvOLsBfEhqjZl9F0h533bvHi3vj7lfu2LgwB+GS8c4BlwOsGWAcgpg0rk1QZuRsvZTda7gl6r8ug7lSEKW0Ct0XbYsmMFoNtikLWAct/mjF6TNPz+KboIHaOyZkJxcNA3k1mV0+OtELMn0wbnFFxxffUT9/oUNnuuJw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 778b46e7-0fc1-4a29-6bf3-08dc1039eac0 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:51.8588 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gswIXt/Ba1UJU6Mbo6AbKLB+ProWYSDyq8TuGZMZh0XiOtCKkNmyTkdDlt8ARziA5qVvw/q2VtbmyYy/HIcTd0KufQOf8vh/PRT2JSn8F7c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030658_964645_EB273A15 X-CRM114-Status: GOOD ( 16.04 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showes, PLDA PCIe contains an interrupt controller. Microchip PolarFire PCIE event IRQs includes PLDA interrupts and Polarfire their own interrupts. The interrupt irqchip ops includes ack/mask/unmask interrupt ops, which will write correct registers. Microchip Polarfire PCIe additional interrupts require to write Polarfire SoC self-defined registers. So Microchip PCIe event irqchip ops can not be re-used. To support PLDA its own event IRQ process, implements PLDA irqchip ops and add event irqchip field to struct pcie_plda_rp. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 66 ++++++++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 5 +- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index b3df373a2141..beaf5c27da84 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -770,6 +770,64 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; +static u32 plda_hwirq_to_mask(int hwirq) +{ + u32 mask; + + /* hwirq 23 - 0 are the same with register */ + if (hwirq < EVENT_PM_MSI_INT_INTX) + mask = BIT(hwirq); + else if (hwirq == EVENT_PM_MSI_INT_INTX) + mask = PM_MSI_INT_INTX_MASK; + else + mask = BIT(hwirq + PCI_NUM_INTX - 1); + + return mask; +} + +static void plda_ack_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + + writel_relaxed(plda_hwirq_to_mask(data->hwirq), + port->bridge_addr + ISTATUS_LOCAL); +} + +static void plda_mask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static void plda_unmask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static struct irq_chip plda_event_irq_chip = { + .name = "PLDA PCIe EVENT", + .irq_ack = plda_ack_event_irq, + .irq_mask = plda_mask_event_irq, + .irq_unmask = plda_unmask_event_irq, +}; + static const struct plda_event_ops plda_event_ops = { .get_events = plda_get_events, }; @@ -777,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); + struct plda_pcie_rp *port = (void *)domain->host_data; + + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; @@ -962,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, if (!port->event_ops) port->event_ops = &plda_event_ops; + if (!port->event_irq_chip) + port->event_irq_chip = &plda_event_irq_chip; + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -1039,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; port->plda.event_ops = &mc_event_ops; + port->plda.event_irq_chip = &mc_event_irq_chip; /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 9db92ccf286c..a3ce01735bea 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -107,7 +107,9 @@ enum plda_int_event { #define PLDA_NUM_DMA_EVENTS 16 -#define PLDA_MAX_INT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) +#define EVENT_PM_MSI_INT_INTX (PLDA_NUM_DMA_EVENTS + PLDA_INTX) +#define EVENT_PM_MSI_INT_MSI (PLDA_NUM_DMA_EVENTS + PLDA_MSI) +#define PLDA_MAX_EVENT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) /* * PLDA interrupt register @@ -155,6 +157,7 @@ struct plda_pcie_rp { raw_spinlock_t lock; struct plda_msi msi; const struct plda_event_ops *event_ops; + const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; int num_events; }; From patchwork Mon Jan 8 11:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513296 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 534D8C47079 for ; Mon, 8 Jan 2024 11:07:18 +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=StvbXXHCHxEsSifTKS7hIalKhrdyI4+65kivioqK4+c=; b=bzB5BSfXEn3jXV k2foEmz3VqcEu2OYTMLwZZTXdR6iUn0am4alnXa67luhu/Btxs+OzjH2LgoW8U+qtGvy4HI1pI506 XAa+gk7IbNsCtiXxFTO8HeYNlpYfekZO0Zr1AJ16eJjDvYOgH5rCuZAJkdjvhPhyHW/zROfY/50sr qhDynd7OsxjuRlSQ3/vPSKgq3BxOeKGchXCXr6j7awnrx33yg88kKjFtNHkAZKNO8VFrDR9Nnn+73 bFVLCWtiq6XBQdoRn6bGrPilgWNAgjHXNcSKCFlKmqew6M0x0UiCTRuLUeZCuHMwk/B31cATpFMfZ ynRXcUNKcjJ33YGOq1RA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTJ-004hBx-0Q; Mon, 08 Jan 2024 11:07:09 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTA-004gjK-2p for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY9yY9B+1of/zjhl6bhPgVKCwDcUACdDnrzv5SwkRYJgM7wBTwTQt7oL6MmvaqWgdfYQ+/VljuQIYNYPlz97wk9LU+ypW34/LsgPv428eDuX7fZDcxlBoeIQ+QONxYovPUczWNnuGSOcsP/MXaaY7lI4yRxP1F0tC9IXLNihZh8E8R2STx35NjLvyjAAme61KKgj8/6SodvJS6D1dHt2xXL9h/2g6ysu4X9Mlhzsioto8Maxe0hgDyOBrUN29bY/nqTnTkVScuNDRC36gP+pNvm9BCRNXnzee/UO9++7fKFkIv99CJv8PgAAdSNtdtAOZT6hPD93XOF31pGy8y98MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/ryPNdgWx646DZhCAUX6Zmi0rAUhEAjWZ0SJhEa4W0=; b=lZ3dI79/7wNxMHx7a/3CVPzBQQ9CrifH+FOm0mQ4Jq6+gpKkJnR9tgFmlP+Io46HZ1kArSHWqY754LH/vl9zq2T9ogIy20VFlNlAIaan5vqWLrDNh6G4LuJKJ7efarhbm8tm37uVzkxmLhKIVKHbCbHVQX6L+LUkqP4ih5ScyWkOg19A0HNbIcGmAbAMWxh7tMevVvQr1rUPvuAcsikP/5ZeG2LihhUmCMzb1nszBZq9XkehttGYoSNTbJVPadfE7fOJHlJbs02UVAG4gpiza/PSGVNyBixAh3zcpsL5B6Qbzzim/brCaF1vCAtB4SdN0tn/5cTDx79lSLoRNQ95Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:53 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:53 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 16/22] PCI: microchip: Move IRQ functions to pcie-plda-host.c Date: Mon, 8 Jan 2024 19:06:06 +0800 Message-Id: <20240108110612.19048-17-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 67122e59-4a15-49f1-09ae-08dc1039ebe8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UGIKaEps5ml5qkJQgR3EhaH0+8uROna/jvQoXmGpOF17AkIYCwFxr1rxBb9v7UftmMLokJ3Ot10LGU1iw+6mUNGmutHW0PG4drZHTUinZbiuVA89Q7N5hXy/T7W3guFBi+6ANY5kXgDbiOGGCw/uXzSw9ExkqvzwZeazQm7ThPv7NLABYqfMunTcYA6i+e95YH6R9a1WTb07ZoWDCSTmH/eZE2KKxVpwM3DI9mjkT9dNgtF+fkKIpDS1Oz2f3j+tAhiF0LF4lXxQPT3OeavZ/kAgiwqjRPTeKNuab7QOywcAu0STARNtv5LSb98V5Y0w/iYAlHvL/hn01XudM9/n9VomyJxdfPysCKaNqv9jXUKN90agZDuXiSKt7Khx81aJo7PS9CMhtgbU47rus8bADABf5kyFtizjYbmyXTK0dmezIDLr87GqlUMGO4mWSKHZ+BIEr/tHzDCudq+xh/EHQ9wXsdWd6J7mSMXl5j2QUWneDynOZk/1J168pyI7b2EZ9aUP26tyEHiJZXo6pdoK30W4pIhnuuNGn2MQl2No2QdRhRaENv08lSaDFaOxJCkE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hd86GMfxy3Oa0Bk+3+dTJAF/E0XKZaL84bKhKIKlvvQOFqaiWmFiQZ7g8IVvhnTUbygANUHTa7A3kR9hPanLNKx+iQZKyZ2m7YE6zgg/n4HVrnsHV92ZVYktN9JnRUByHm7Do0rmkjDLAazlQhKpUCEpynmGXrON+sCq3oqcBjGD8LaPd8mS/fREdssPwR1bgHgrbU8+RcAaiZRavAwK/KxUW6n1u18OB8h/bGl9am/UMVSkmglPyfti9ARkkCj9D+JoXNl1E+bHWIxTkzyToeVTquri7Jb2zP3pizxAR5V4R14SPbOP+yZ+z8N5O8bwjonJpatE4r7hSCvjwvNu5afM3ZbH5Iag1xf9SAS/tZRrjSUAnqTQRrWEZpZDE0FRmD+RDsOSNPqRyuq+S4G8nIElzaw7JBg9YEG6Abx/WplGXSR2WX+K6IjusogEe5eQk+HiZlvsdIgLvuQgQwvt8aKshq7lFY3kosFGTBYUmlPDolxgrwkMXNn5r1LrxmQt9HS6FD5SF9uFmulfiGStU28vNjFtn+pBVvdvtgnVn1OAP83v1tT6RYJ7QBoRNHVga3fhW0kindyZi/EmVmtb81sH5ThIOUk1LtV/NbxOZBrYGAT4d2gZWMfWFtq0XaR5ZMrHjfH5iNwaIDHwm2plUHeQChYTIr35VF7IBQgL2ujJMl4wN2PBhyRbPAmkFtOOlilSpdNrOHQCjQ4OFFlulWdmp0T1v8BfTxXOaYZUIUC582fbYKOp6bV8cQKUec/9dWmLGanfyIZ+EOoc54aZPamlXxa+0unYdmzC+jrL4OcJbEk+FINXwJOZFJ/YibVlCDgqfSjcNthPYfEdiUYES11XmyF/qmOYiNQBQxF2vDD4JExTVRVto/7lRWIoQDJkChJWMNmiJzAPXeywEFPZGE5y1Z5pO/ck14pVDfuyoqCQDEImJ8tHZytEmQV8ye5BGN3Jwz3hroyuJybME4SI+ZChbDRMZ0TmxZWBVg7JXc6h+/YrZcGvef9GUuKTI+E+cwzgKgJkCzKWTMNGSHPHgWRDHPZI48okdUqDsN8OQwb4WncyoFhR/FhoAiF/1e1qqOoYl2B5S23ZgpY6KiOrDb1XXio8yQJ5JsRsRz40ixNYM3zPCibfKgio4dWUu6XkGRHdHtvbXxjWa0UFPlSxGID0lViEg9UvFl/RiR1PkEX8QWrRsN3efB5yNe3OktybCkBn8PbunetL08S4RF4FUy7Cu8qBH9tqCTuwAPCkiyk/27+PXTkuJnXPHR/RECwlTjQrzAskBm+df16kAxzVPVjxw4nsPKkdzcpkq0oPqnTZAcLhzjhX9ir1km5Ec1ed2MZEVuWToeY6CJ9+UHmq4ycF2BaGUpkZOZp8yzZqHcDwfc4WfMzKatZnjAkuquojyvlaMNQcmN5GB96+PUhe0bblxFxEnjhOHx2lPWKmnayklwgebcxpQvr+rPvfaELnwv9YWWqcDKfKkmB+I6kVJLGV3hlw6B6mHnFYwR+UQ4Mbc+M1cboQdp9GbfrcF0u2SyLEnzmD8/rs3ADhF4JtjMJH8Pc/lmNnpigbbxgD7Wb0UCEWjPoPrYXezNLtaPhV0K1qNI+PJt5HQHXU29h+cg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67122e59-4a15-49f1-09ae-08dc1039ebe8 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:53.8461 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 27nQ6v8ZJ1uDc0bRvuxG5wrZ+HF8pnBVzdo7TQeU9pXeS3I5G48JwyU7gQyE1BX+CrXfsyEeO6lO5Wjwva4B+C3McJU5RPZRV1FqV/S6sMc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030700_934974_CC4B6564 X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move IRQ related functions to pcie-plda-host.c for re-use these codes. Now Refactoring codes complete. Including MSI, INTx, event interrupts and IRQ init functions. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 467 ----------------- drivers/pci/controller/plda/pcie-plda-host.c | 472 ++++++++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 3 + 3 files changed, 475 insertions(+), 467 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index beaf5c27da84..105964306b71 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -318,244 +318,6 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); } -static void plda_handle_msi(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - struct irq_chip *chip = irq_desc_get_chip(desc); - struct device *dev = port->dev; - struct plda_msi *msi = &port->msi; - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long status; - u32 bit; - int ret; - - chained_irq_enter(chip, desc); - - status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); - if (status & PM_MSI_INT_MSI_MASK) { - writel_relaxed(status & PM_MSI_INT_MSI_MASK, bridge_base_addr + ISTATUS_LOCAL); - status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); - for_each_set_bit(bit, &status, msi->num_vectors) { - ret = generic_handle_domain_irq(msi->dev_domain, bit); - if (ret) - dev_err_ratelimited(dev, "bad MSI IRQ %d\n", - bit); - } - } - - chained_irq_exit(chip, desc); -} - -static void plda_msi_bottom_irq_ack(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - u32 bitpos = data->hwirq; - - writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); -} - -static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - phys_addr_t addr = port->msi.vector_phy; - - msg->address_lo = lower_32_bits(addr); - msg->address_hi = upper_32_bits(addr); - msg->data = data->hwirq; - - dev_dbg(port->dev, "msi#%x address_hi %#x address_lo %#x\n", - (int)data->hwirq, msg->address_hi, msg->address_lo); -} - -static int plda_msi_set_affinity(struct irq_data *irq_data, - const struct cpumask *mask, bool force) -{ - return -EINVAL; -} - -static struct irq_chip plda_msi_bottom_irq_chip = { - .name = "PLDA MSI", - .irq_ack = plda_msi_bottom_irq_ack, - .irq_compose_msi_msg = plda_compose_msi_msg, - .irq_set_affinity = plda_msi_set_affinity, -}; - -static int plda_irq_msi_domain_alloc(struct irq_domain *domain, - unsigned int virq, - unsigned int nr_irqs, - void *args) -{ - struct plda_pcie_rp *port = domain->host_data; - struct plda_msi *msi = &port->msi; - unsigned long bit; - - mutex_lock(&msi->lock); - bit = find_first_zero_bit(msi->used, msi->num_vectors); - if (bit >= msi->num_vectors) { - mutex_unlock(&msi->lock); - return -ENOSPC; - } - - set_bit(bit, msi->used); - - irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, - domain->host_data, handle_edge_irq, NULL, NULL); - - mutex_unlock(&msi->lock); - - return 0; -} - -static void plda_irq_msi_domain_free(struct irq_domain *domain, - unsigned int virq, - unsigned int nr_irqs) -{ - struct irq_data *d = irq_domain_get_irq_data(domain, virq); - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); - struct plda_msi *msi = &port->msi; - - mutex_lock(&msi->lock); - - if (test_bit(d->hwirq, msi->used)) - __clear_bit(d->hwirq, msi->used); - else - dev_err(port->dev, "trying to free unused MSI%lu\n", d->hwirq); - - mutex_unlock(&msi->lock); -} - -static const struct irq_domain_ops msi_domain_ops = { - .alloc = plda_irq_msi_domain_alloc, - .free = plda_irq_msi_domain_free, -}; - -static struct irq_chip plda_msi_irq_chip = { - .name = "PLDA PCIe MSI", - .irq_ack = irq_chip_ack_parent, - .irq_mask = pci_msi_mask_irq, - .irq_unmask = pci_msi_unmask_irq, -}; - -static struct msi_domain_info plda_msi_domain_info = { - .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_PCI_MSIX), - .chip = &plda_msi_irq_chip, -}; - -static int plda_allocate_msi_domains(struct plda_pcie_rp *port) -{ - struct device *dev = port->dev; - struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); - struct plda_msi *msi = &port->msi; - - mutex_init(&port->msi.lock); - - msi->dev_domain = irq_domain_add_linear(NULL, msi->num_vectors, - &msi_domain_ops, port); - if (!msi->dev_domain) { - dev_err(dev, "failed to create IRQ domain\n"); - return -ENOMEM; - } - - msi->msi_domain = pci_msi_create_irq_domain(fwnode, - &plda_msi_domain_info, - msi->dev_domain); - if (!msi->msi_domain) { - dev_err(dev, "failed to create MSI domain\n"); - irq_domain_remove(msi->dev_domain); - return -ENOMEM; - } - - return 0; -} - -static void plda_handle_intx(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - struct irq_chip *chip = irq_desc_get_chip(desc); - struct device *dev = port->dev; - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long status; - u32 bit; - int ret; - - chained_irq_enter(chip, desc); - - status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); - if (status & PM_MSI_INT_INTX_MASK) { - status &= PM_MSI_INT_INTX_MASK; - status >>= PM_MSI_INT_INTX_SHIFT; - for_each_set_bit(bit, &status, PCI_NUM_INTX) { - ret = generic_handle_domain_irq(port->intx_domain, bit); - if (ret) - dev_err_ratelimited(dev, "bad INTx IRQ %d\n", - bit); - } - } - - chained_irq_exit(chip, desc); -} - -static void plda_ack_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - - writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); -} - -static void plda_mask_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long flags; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - u32 val; - - raw_spin_lock_irqsave(&port->lock, flags); - val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); - val &= ~mask; - writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); - raw_spin_unlock_irqrestore(&port->lock, flags); -} - -static void plda_unmask_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long flags; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - u32 val; - - raw_spin_lock_irqsave(&port->lock, flags); - val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); - val |= mask; - writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); - raw_spin_unlock_irqrestore(&port->lock, flags); -} - -static struct irq_chip plda_intx_irq_chip = { - .name = "PLDA PCIe INTx", - .irq_ack = plda_ack_intx_irq, - .irq_mask = plda_mask_intx_irq, - .irq_unmask = plda_unmask_intx_irq, -}; - -static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = plda_pcie_intx_map, -}; - static inline u32 reg_to_event(u32 reg, struct event_map field) { return (reg & field.reg_mask) ? BIT(field.event_bit) : 0; @@ -626,26 +388,6 @@ static u32 mc_get_events(struct plda_pcie_rp *port) return events; } -static u32 plda_get_events(struct plda_pcie_rp *port) -{ - u32 events, val, origin; - - origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); - - /* MSI event and sys events */ - val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; - events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); - - /* INTx events */ - if (origin & PM_MSI_INT_INTX_MASK) - events |= BIT(PM_MSI_INT_INTX_SHIFT); - - /* remains are same with register */ - events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); - - return events; -} - static irqreturn_t mc_event_handler(int irq, void *dev_id) { struct plda_pcie_rp *port = dev_id; @@ -662,28 +404,6 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static irqreturn_t plda_event_handler(int irq, void *dev_id) -{ - return IRQ_HANDLED; -} - -static void plda_handle_event(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - unsigned long events; - u32 bit; - struct irq_chip *chip = irq_desc_get_chip(desc); - - chained_irq_enter(chip, desc); - - events = port->event_ops->get_events(port); - - for_each_set_bit(bit, &events, port->num_events) - generic_handle_domain_irq(port->event_domain, bit); - - chained_irq_exit(chip, desc); -} - static void mc_ack_event_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); @@ -770,83 +490,6 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; -static u32 plda_hwirq_to_mask(int hwirq) -{ - u32 mask; - - /* hwirq 23 - 0 are the same with register */ - if (hwirq < EVENT_PM_MSI_INT_INTX) - mask = BIT(hwirq); - else if (hwirq == EVENT_PM_MSI_INT_INTX) - mask = PM_MSI_INT_INTX_MASK; - else - mask = BIT(hwirq + PCI_NUM_INTX - 1); - - return mask; -} - -static void plda_ack_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - - writel_relaxed(plda_hwirq_to_mask(data->hwirq), - port->bridge_addr + ISTATUS_LOCAL); -} - -static void plda_mask_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - u32 mask, val; - - mask = plda_hwirq_to_mask(data->hwirq); - - raw_spin_lock(&port->lock); - val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); - val &= ~mask; - writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); - raw_spin_unlock(&port->lock); -} - -static void plda_unmask_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - u32 mask, val; - - mask = plda_hwirq_to_mask(data->hwirq); - - raw_spin_lock(&port->lock); - val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); - val |= mask; - writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); - raw_spin_unlock(&port->lock); -} - -static struct irq_chip plda_event_irq_chip = { - .name = "PLDA PCIe EVENT", - .irq_ack = plda_ack_event_irq, - .irq_mask = plda_mask_event_irq, - .irq_unmask = plda_unmask_event_irq, -}; - -static const struct plda_event_ops plda_event_ops = { - .get_events = plda_get_events, -}; - -static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - struct plda_pcie_rp *port = (void *)domain->host_data; - - irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops plda_event_domain_ops = { - .map = plda_pcie_event_map, -}; - static inline void mc_pcie_deinit_clk(void *data) { struct clk *clk = data; @@ -909,47 +552,6 @@ static const struct plda_event mc_event = { .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, }; -static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) -{ - struct device *dev = port->dev; - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; - - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "failed to find PCIe Intc node\n"); - return -EINVAL; - } - - port->event_domain = irq_domain_add_linear(pcie_intc_node, - port->num_events, - &plda_event_domain_ops, - port); - if (!port->event_domain) { - dev_err(dev, "failed to get event domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } - - irq_domain_update_bus_token(port->event_domain, DOMAIN_BUS_NEXUS); - - port->intx_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, port); - if (!port->intx_domain) { - dev_err(dev, "failed to get an INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } - - irq_domain_update_bus_token(port->intx_domain, DOMAIN_BUS_WIRED); - - of_node_put(pcie_intc_node); - raw_spin_lock_init(&port->lock); - - return plda_allocate_msi_domains(port); -} - static inline void mc_clear_secs(struct mc_pcie *port) { void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR; @@ -1010,75 +612,6 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int plda_init_interrupts(struct platform_device *pdev, - struct plda_pcie_rp *port, - const struct plda_event *event) -{ - struct device *dev = &pdev->dev; - int irq; - int i, intx_irq, msi_irq, event_irq; - int ret; - - if (!port->event_ops) - port->event_ops = &plda_event_ops; - - if (!port->event_irq_chip) - port->event_irq_chip = &plda_event_irq_chip; - - ret = plda_pcie_init_irq_domains(port); - if (ret) { - dev_err(dev, "failed creating IRQ domains\n"); - return ret; - } - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return -ENODEV; - - for (i = 0; i < port->num_events; i++) { - event_irq = irq_create_mapping(port->event_domain, i); - if (!event_irq) { - dev_err(dev, "failed to map hwirq %d\n", i); - return -ENXIO; - } - - if (event->request_event_irq) - ret = event->request_event_irq(port, event_irq, i); - else - ret = devm_request_irq(dev, event_irq, - plda_event_handler, - 0, NULL, port); - - if (ret) { - dev_err(dev, "failed to request IRQ %d\n", event_irq); - return ret; - } - } - - intx_irq = irq_create_mapping(port->event_domain, - event->intx_event); - if (!intx_irq) { - dev_err(dev, "failed to map INTx interrupt\n"); - return -ENXIO; - } - - /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); - - msi_irq = irq_create_mapping(port->event_domain, - event->msi_event); - if (!msi_irq) - return -ENXIO; - - /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); - - /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, plda_handle_event, port); - - return 0; -} - static int mc_platform_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index 40139d998568..98c51e594efe 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -7,11 +7,483 @@ * Author: Daire McNamara */ +#include +#include +#include #include #include #include "pcie-plda.h" +static void plda_handle_msi(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct device *dev = port->dev; + struct plda_msi *msi = &port->msi; + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long status; + u32 bit; + int ret; + + chained_irq_enter(chip, desc); + + status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); + if (status & PM_MSI_INT_MSI_MASK) { + writel_relaxed(status & PM_MSI_INT_MSI_MASK, + bridge_base_addr + ISTATUS_LOCAL); + status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); + for_each_set_bit(bit, &status, msi->num_vectors) { + ret = generic_handle_domain_irq(msi->dev_domain, bit); + if (ret) + dev_err_ratelimited(dev, "bad MSI IRQ %d\n", + bit); + } + } + + chained_irq_exit(chip, desc); +} + +static void plda_msi_bottom_irq_ack(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + u32 bitpos = data->hwirq; + + writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); +} + +static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + phys_addr_t addr = port->msi.vector_phy; + + msg->address_lo = lower_32_bits(addr); + msg->address_hi = upper_32_bits(addr); + msg->data = data->hwirq; + + dev_dbg(port->dev, "msi#%x address_hi %#x address_lo %#x\n", + (int)data->hwirq, msg->address_hi, msg->address_lo); +} + +static int plda_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip plda_msi_bottom_irq_chip = { + .name = "PLDA MSI", + .irq_ack = plda_msi_bottom_irq_ack, + .irq_compose_msi_msg = plda_compose_msi_msg, + .irq_set_affinity = plda_msi_set_affinity, +}; + +static int plda_irq_msi_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct plda_pcie_rp *port = domain->host_data; + struct plda_msi *msi = &port->msi; + unsigned long bit; + + mutex_lock(&msi->lock); + bit = find_first_zero_bit(msi->used, msi->num_vectors); + if (bit >= msi->num_vectors) { + mutex_unlock(&msi->lock); + return -ENOSPC; + } + + set_bit(bit, msi->used); + + irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, + domain->host_data, handle_edge_irq, NULL, NULL); + + mutex_unlock(&msi->lock); + + return 0; +} + +static void plda_irq_msi_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); + struct plda_msi *msi = &port->msi; + + mutex_lock(&msi->lock); + + if (test_bit(d->hwirq, msi->used)) + __clear_bit(d->hwirq, msi->used); + else + dev_err(port->dev, "trying to free unused MSI%lu\n", d->hwirq); + + mutex_unlock(&msi->lock); +} + +static const struct irq_domain_ops msi_domain_ops = { + .alloc = plda_irq_msi_domain_alloc, + .free = plda_irq_msi_domain_free, +}; + +static struct irq_chip plda_msi_irq_chip = { + .name = "PLDA PCIe MSI", + .irq_ack = irq_chip_ack_parent, + .irq_mask = pci_msi_mask_irq, + .irq_unmask = pci_msi_unmask_irq, +}; + +static struct msi_domain_info plda_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX), + .chip = &plda_msi_irq_chip, +}; + +static int plda_allocate_msi_domains(struct plda_pcie_rp *port) +{ + struct device *dev = port->dev; + struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); + struct plda_msi *msi = &port->msi; + + mutex_init(&port->msi.lock); + + msi->dev_domain = irq_domain_add_linear(NULL, msi->num_vectors, + &msi_domain_ops, port); + if (!msi->dev_domain) { + dev_err(dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + msi->msi_domain = pci_msi_create_irq_domain(fwnode, + &plda_msi_domain_info, + msi->dev_domain); + if (!msi->msi_domain) { + dev_err(dev, "failed to create MSI domain\n"); + irq_domain_remove(msi->dev_domain); + return -ENOMEM; + } + + return 0; +} + +static void plda_handle_intx(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct device *dev = port->dev; + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long status; + u32 bit; + int ret; + + chained_irq_enter(chip, desc); + + status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); + if (status & PM_MSI_INT_INTX_MASK) { + status &= PM_MSI_INT_INTX_MASK; + status >>= PM_MSI_INT_INTX_SHIFT; + for_each_set_bit(bit, &status, PCI_NUM_INTX) { + ret = generic_handle_domain_irq(port->intx_domain, bit); + if (ret) + dev_err_ratelimited(dev, "bad INTx IRQ %d\n", + bit); + } + } + + chained_irq_exit(chip, desc); +} + +static void plda_ack_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + + writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); +} + +static void plda_mask_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long flags; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + u32 val; + + raw_spin_lock_irqsave(&port->lock, flags); + val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); + raw_spin_unlock_irqrestore(&port->lock, flags); +} + +static void plda_unmask_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long flags; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + u32 val; + + raw_spin_lock_irqsave(&port->lock, flags); + val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); + raw_spin_unlock_irqrestore(&port->lock, flags); +} + +static struct irq_chip plda_intx_irq_chip = { + .name = "PLDA PCIe INTx", + .irq_ack = plda_ack_intx_irq, + .irq_mask = plda_mask_intx_irq, + .irq_unmask = plda_unmask_intx_irq, +}; + +static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +static const struct irq_domain_ops intx_domain_ops = { + .map = plda_pcie_intx_map, +}; + +static u32 plda_get_events(struct plda_pcie_rp *port) +{ + u32 events, val, origin; + + origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); + + /* MSI event and sys events */ + val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; + events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); + + /* INTx events */ + if (origin & PM_MSI_INT_INTX_MASK) + events |= BIT(PM_MSI_INT_INTX_SHIFT); + + /* remains are same with register */ + events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); + + return events; +} + +static irqreturn_t plda_event_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + +static void plda_handle_event(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + unsigned long events; + u32 bit; + struct irq_chip *chip = irq_desc_get_chip(desc); + + chained_irq_enter(chip, desc); + + events = port->event_ops->get_events(port); + + for_each_set_bit(bit, &events, port->num_events) + generic_handle_domain_irq(port->event_domain, bit); + + chained_irq_exit(chip, desc); +} + +static u32 plda_hwirq_to_mask(int hwirq) +{ + u32 mask; + + /* hwirq 23 - 0 are the same with register */ + if (hwirq < EVENT_PM_MSI_INT_INTX) + mask = BIT(hwirq); + else if (hwirq == EVENT_PM_MSI_INT_INTX) + mask = PM_MSI_INT_INTX_MASK; + else + mask = BIT(hwirq + PCI_NUM_INTX - 1); + + return mask; +} + +static void plda_ack_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + + writel_relaxed(plda_hwirq_to_mask(data->hwirq), + port->bridge_addr + ISTATUS_LOCAL); +} + +static void plda_mask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static void plda_unmask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static struct irq_chip plda_event_irq_chip = { + .name = "PLDA PCIe EVENT", + .irq_ack = plda_ack_event_irq, + .irq_mask = plda_mask_event_irq, + .irq_unmask = plda_unmask_event_irq, +}; + +static const struct plda_event_ops plda_event_ops = { + .get_events = plda_get_events, +}; + +static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + struct plda_pcie_rp *port = (void *)domain->host_data; + + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +static const struct irq_domain_ops plda_event_domain_ops = { + .map = plda_pcie_event_map, +}; + +static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) +{ + struct device *dev = port->dev; + struct device_node *node = dev->of_node; + struct device_node *pcie_intc_node; + + /* Setup INTx */ + pcie_intc_node = of_get_next_child(node, NULL); + if (!pcie_intc_node) { + dev_err(dev, "failed to find PCIe Intc node\n"); + return -EINVAL; + } + + port->event_domain = irq_domain_add_linear(pcie_intc_node, + port->num_events, + &plda_event_domain_ops, + port); + if (!port->event_domain) { + dev_err(dev, "failed to get event domain\n"); + of_node_put(pcie_intc_node); + return -ENOMEM; + } + + irq_domain_update_bus_token(port->event_domain, DOMAIN_BUS_NEXUS); + + port->intx_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, + &intx_domain_ops, port); + if (!port->intx_domain) { + dev_err(dev, "failed to get an INTx IRQ domain\n"); + of_node_put(pcie_intc_node); + return -ENOMEM; + } + + irq_domain_update_bus_token(port->intx_domain, DOMAIN_BUS_WIRED); + + of_node_put(pcie_intc_node); + raw_spin_lock_init(&port->lock); + + return plda_allocate_msi_domains(port); +} + +int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event) +{ + struct device *dev = &pdev->dev; + int irq; + int i, intx_irq, msi_irq, event_irq; + int ret; + + if (!port->event_ops) + port->event_ops = &plda_event_ops; + + if (!port->event_irq_chip) + port->event_irq_chip = &plda_event_irq_chip; + + ret = plda_pcie_init_irq_domains(port); + if (ret) { + dev_err(dev, "failed creating IRQ domains\n"); + return ret; + } + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -ENODEV; + + for (i = 0; i < port->num_events; i++) { + event_irq = irq_create_mapping(port->event_domain, i); + if (!event_irq) { + dev_err(dev, "failed to map hwirq %d\n", i); + return -ENXIO; + } + + if (event->request_event_irq) + ret = event->request_event_irq(port, event_irq, i); + else + ret = devm_request_irq(dev, event_irq, + plda_event_handler, + 0, NULL, port); + + if (ret) { + dev_err(dev, "failed to request IRQ %d\n", event_irq); + return ret; + } + } + + intx_irq = irq_create_mapping(port->event_domain, + event->intx_event); + if (!intx_irq) { + dev_err(dev, "failed to map INTx interrupt\n"); + return -ENXIO; + } + + /* Plug the INTx chained handler */ + irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); + + msi_irq = irq_create_mapping(port->event_domain, + event->msi_event); + if (!msi_irq) + return -ENXIO; + + /* Plug the MSI chained handler */ + irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); + + /* Plug the main event chained handler */ + irq_set_chained_handler_and_data(irq, plda_handle_event, port); + + return 0; +} +EXPORT_SYMBOL_GPL(plda_init_interrupts); + void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size) diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index a3ce01735bea..6672a231a4bc 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -169,6 +169,9 @@ struct plda_event { int msi_event; }; +int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event); void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size); From patchwork Mon Jan 8 11:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513294 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 5573FC3DA6E for ; Mon, 8 Jan 2024 11:07:17 +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=bqIhbIw9JRH1hKU8N+H15JQRBLKpSDUQPjKiaKlFYQY=; b=eMUBgiA9wE5Q1Q ISUFuGRrx4/UfDhOxTR7EV02XOhfcJgm8DwWXN4cwAruOAF8XAPevISDwABbJWC1S15v27YZHyXfD Hd8C0roztzgpkk2vJSdaIP7woLTWvUiju0RD0dS8oAfpvfVepiPPUFXrQb2xIxhewInoAttcYZZMu 3PuPvhlEOAnLORgXsXVYY/RrWNEkftYBsh9Jh9Sb3A6KQA93UxfC0nSTGESggQx41RtVq4PnzkO96 IQ7trbool2AjWqmISqAUpxdYzi6pJQtlO4VZo6X983c9CTW4pKEcdrkHT9knJ+rlz7fehSGCoOXUB ZTNuyND3MWV9hIc6xYIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTH-004h9f-0v; Mon, 08 Jan 2024 11:07:07 +0000 Received: from mail-sh0chn02on2060d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::60d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTC-004gwv-0c for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WhRWu3ETNsVVYYFb+ne7/tHCmGKTZsc1Hhvkn1fLqNYPnyqZr+KrgmxRDCkIUNp1NIIMHGfgMt9lwl/5LS1w92HLiVZCUw+nT0uDv9JZE9rY2EU2k6M+0yxMejzTrdkl0TKnavwaqiXzxI5o7XO8HaFLpO+Qbf9eejbBBi70A7Pxb1/B7nXi4jCZujItLr3eQqeJUu6opGwWi6y8A13Y50lOxwO1Uea9CtszABeBi3WRul1GfMZ52greZs0xslX6sJeA9P4VdONj+EfdftrsdtcMw+UGmA7WDVPnG7CRwsPrbdOK5Uq2LI2AcnYAVi+hHDbv0eOaCjKX7qkJXgKfnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K4MD2usSBbRdsd/hhE4tw5xP1KyGga5Ecw5HSB56sQQ=; b=ZUhQWQlBkwKkVtiyD37bqg7+1jeAuSEjCC/PkIkNlvqoVkebET6k0wdLWxyi1Z69XtDNLUh10YO8S+yqSmr5qUmZ9yX4a8Qtuc1piRRCwE2+rzmw5XgJblhYYTyyQ5C2ozcMUuZeP7Xc5BaSDRHHcytcxs/daGThL8LnY46Knr0HiPVf3CO8gakMLO7I1gBtUKsyWHvIc758uun1otz29PkO2WIjTV3d65v0YtlgRl6werl+RMkQo+xlPp/l/kw99wSGCgXuKIdHrh9QrNsyWIKv8JRNWo5RI7a1Vm8oFR/1ATCWI5MK5/g6rDMlQb9Rref303NXmJCACJIQ9TaywQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:55 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:55 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 17/22] pci: plda: Add event bitmap field to struct plda_pcie_rp Date: Mon, 8 Jan 2024 19:06:07 +0800 Message-Id: <20240108110612.19048-18-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 820ef93e-0853-4224-ce5a-08dc1039ed16 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q5Ei0ykGaYbqehL/3sj55/l/M2yq15Q3WZRrjgC9Sq+tZcaMzBr93xdM/qkhlMBO+jvqioUQBQ2dL9TkDVWHCNdXDCpZw7qBX4apF6eUxskB1YIhDdRf6NYCM7GZSYGgz54yEoeDb9I2wCtjh5GgH0IcF7AY8f/1xLMK5gKN7L/haT9y2tz2pq0ZUBfkvPber5K1GMnWR46cyRa5jfJkIC8DyvgbH2/SpyjYu41ockiCVS/DfJnhMAEAB8X3qzSOVd3oZ2BrlfPzH6Uukg4gR3gR7d20jxi02NDONQPS7RCNSOyetmozfYh8Fafk5juN1rnjrpF1bTYkTCy6AOmHaXEgCVqC4qz5YAiKUgtMMj3DoEQrN7JhDx/y/5eWQvx8o3m6tMayfRVBHbN+bVrfsRGJcS/fbGn+BK4vaJGrxxFQE/hyyz/ErIkHfNcDnfULpH46GZ/8vjnjtw47+Q1UB2D17btAQBiLDZKt8NeXqq+ZWKKDeOJHJVhYV4yTlpX/Hm9dI5ezM86agEMR/P32440Yxws7S/TWb/CA6ui+ruJ9O82J86TnzkZjx3aprazd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PRvcDt+P4cCs5MBqAw6VZlBZhlKb/Sx9ZRtfELKd0/yuCwoGMSss8pE8NefoIxl/8j5uSgqJf0P+qtopbjQyj4lw832KBiIO/Hv2C/Ew8pB7PSVhbhI889n8Kf/+eEyfEtVAfCtGoUfyiNcZPQwHXtdzQEtddFD2mSnvhESX+7UVAjZ3byAZMB3Bzs9kAG4UeoA/E7q1MtXLUNrPhTSlehbck8OjhSioves7KtBR8Hl04qZ2Lzdpl4r3siIGysaHJLo0+5jC1pcuGVZ6zil05xAhGodHvy9ZDgcMEcIlGyC4FUtzdMRV0IuCgHjcqGwkR9hUlmC4oFCyX0wmhqqT3QUOaW3cvBjMbu1Ynz9UVGZySJAUsCB4nDkCW6Y2kcs3aDNpN2MzA/UVHkT+jbIlqFoMMEE34v/A4UBHCT+u30yzLet3ETNcpzvizxhAcMzXbdpoE61IR1sYNxz4wEfpGObRJ+NedCeHoH4WKDVDJAOG8nl3+M5/cCzH8LjsPlyuGp+HUK832hP513/YL/ZXeaedL0IxZ+zlJKgDQYaCK6gIf5rG5dU1/hanB9NkKRbggfxw4qGyFbmlTfqkkT71fWEqJkEjp0eV64IC/0dkxyttU4GEPo3xUxikLsQkTjlq0nnJsPrcxtzbOtbQNfjkrtnWWmNxEup4q+CpD1cUPSrhQVEvSE+T0gDACLMf4k1MkWBgZKg5ThoT4QiIJYZ64q+e91seXetm37VQOpNCeOWxuCv8sBUCyrLOr5AtVsj2Db4CMvY2MGvt6KSR8ixVB0QXdk0B5f7x1wx4qE8sk39Ql1HDjrUL8cxU9pSbk3PaXTduxzHiQ2tIx5Sar7DFo4ODJhi7GO+xrm4JZHpaWSHrcbC3jMfdI4yJqfSyL79YitSdDay2HjLCvfAtLrCMn9V1q+hp+imxeVyETACk0JtWJexgICz4iPhDR91LhlXAMs75fV1CFNYPCxUajHuXKtcxVXtsY/8SJ9EpbOISAfFy4/KAkI2R0zM3HUpzEIZGQszWB+8SfsyfQQx7D5Kqx/E4tCMm26QiazZcxI1Q22x3ft9kjIwBi4jEtl4fMQ4OyGm/7XKjwv8a08n5MImJtOa3IS/gGb+jHG5y9ORplsMy2t+J7LjBoQ/cRlnKv2lY/2tXYpB9DbQtcucim0fgOBfjRfHpV73SS01UGPeA8tEdI5nB+goUGCUEalnjxbC25v1ovQhW3yNxreKEqm+0zcnmQZRlFxbYwv1tN1NZljUFWTiVXUsDCJfqHH5/ljNlKqfqtdpZR2Z5MpcLPUhGt8frEL2FZvXIuaXuP1HT2zx3hOI7TvVxvKOqisJWyKv/AKXFIeRTs13L22gME4Y3w5tGRGXRNiyoQ2/lfT5d8DvEagi/jlLtu4tLS9gE4wEQdrCC36i5+/+VM0Psq8/bLwZovPu5WEi9XE6FoGmb46JyxfFjsonJgqFT7dIRZk+LcuSHVchXXD94fJhANfjyNQq9qRkxiohLrR6fCrFQll5PIgto/LJXXptkNzpha33GSK0VcFev6jKvPBEltkXAxjxFATmrFC1bc5LIEzUHaTeyoEDRGpG30YNwbWTzrOr5ibvLMjCRWvX08fjNi/BF3g== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 820ef93e-0853-4224-ce5a-08dc1039ed16 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:55.8195 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cPFmXoSY1P0ZMBj6/Zn6goBsx2474dtYrofyKDxB7rNSb/NtN3RPjhRN9XtrY9SVvpYWtsr8m8FGMpJHqUok5O6C+47HljMksYck1RnWUTs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030702_249941_1D5A9ABF X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org For PLDA DMA interrupts are not all implemented. The non-implemented interrupts should be masked. So add a bitmap field to mask the non- implemented interrupts. Signed-off-by: Minda Chen --- drivers/pci/controller/plda/pcie-microchip-host.c | 1 + drivers/pci/controller/plda/pcie-plda-host.c | 6 ++++-- drivers/pci/controller/plda/pcie-plda.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 105964306b71..48f60a04b740 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -636,6 +636,7 @@ static int mc_platform_init(struct pci_config_window *cfg) port->plda.event_ops = &mc_event_ops; port->plda.event_irq_chip = &mc_event_irq_chip; + port->plda.events_bitmap = GENMASK(NUM_EVENTS - 1, 0); /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index 98c51e594efe..a040e7e5492f 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -290,6 +290,7 @@ static void plda_handle_event(struct irq_desc *desc) events = port->event_ops->get_events(port); + events &= port->events_bitmap; for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -420,8 +421,9 @@ int plda_init_interrupts(struct platform_device *pdev, { struct device *dev = &pdev->dev; int irq; - int i, intx_irq, msi_irq, event_irq; + int intx_irq, msi_irq, event_irq; int ret; + u32 i; if (!port->event_ops) port->event_ops = &plda_event_ops; @@ -439,7 +441,7 @@ int plda_init_interrupts(struct platform_device *pdev, if (irq < 0) return -ENODEV; - for (i = 0; i < port->num_events; i++) { + for_each_set_bit(i, &port->events_bitmap, port->num_events) { event_irq = irq_create_mapping(port->event_domain, i); if (!event_irq) { dev_err(dev, "failed to map hwirq %d\n", i); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 6672a231a4bc..443109d04d59 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -159,6 +159,7 @@ struct plda_pcie_rp { const struct plda_event_ops *event_ops; const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; + unsigned long events_bitmap; int num_events; }; From patchwork Mon Jan 8 11:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513295 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 4A2A0C4707B for ; Mon, 8 Jan 2024 11:07:19 +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=RJCZJx/T+jYNHIjX46VsXYOm89BuWWY/ZaddKWXK1w8=; b=1IAxOjDGrW4Udb fiaCh4JPXg42N5KiL3zyoMthGIpT45B+srna/SVR1wn+vRbKZQdLd88jr8+EkPgfHZisUm21XTVNK mtxOpZRbrxIrwJ6RtKLevUYLoly/DqrT0l+JL+2SAhuYoouQ2h8BahAEwLWxD8eZKt33TVzllMPZI h7f+oFqmfXI2OHOy7wjWjn9rTkjYLXZKgk3PHy0bd41trbG4gs2QESC9lNmfri4TXu7Nu2QX+9DI7 WE0MYOOaaRU7iz6s/MnX+aH2ggi9ih7xknWsgbL8xPC/J5Ul9vSF3zgo2ppsq5eRMNz9gEAF+Pirm NYZ4SKLe4zoZP4yVI4zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTL-004hEb-1A; Mon, 08 Jan 2024 11:07:11 +0000 Received: from mail-sh0chn02on2060d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::60d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTF-004gwv-1B for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dUpjKSJ5IYMiaVgQPn95FCJdHvWUwSAi1QvIk+KEpGiKY/38tUYLyGZjGbUC9yS851VZw4X6YeiaFJHS8OO2QgE/ouOS+foPTq4sGnv0uq/VRMz/z6FJcY/SnCl3IMaZ7T1He59Y3Si01UeiU2g8UzC2hnVA1+c/H/q8sCeHYdRN5o8PyRPF4wVpfi18h2IzGBTHq5OJtQ2lncFIBRUJGhhODg+9ovT5Iwu4izheje4bzTzXRKEvfRwPGG51Nfou64iMWxYMHUrTvtWYvHMItOMK8YiOSgBq7DvjqAoHXTLDgIfAShjc2uvSeq65GhRBdmA4hzlU+tsFfVivwDBwYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6mdPM9tc7+aMwCmMjqDwieu4Un85dfZDn1ub7cOMzuk=; b=GwXmNlJt8AfQekgn4KSBi14VHJzIL9PtS12yq4BDdVKqhYc/4wf2kCCAuLIoRCzGv39oBxUN+pvYPa/ariBNI8gSytT5hxnSN5A07j68PsR0L6lV2wza1FPI3TtrHHshpG0b9pDqF6lckUrWfrFV8PaJvWTezrXVAcaJ92zny4iygX+AVz0qkRqfUn/V+N3+NmIGwakWdaktng488WMn8nElRQIuMF3He0XPO0gD/iBHEoYA/657+WicbwM1QmhgA7DMkxHHVdBOou6gyOBcHKUB5EWWLaQ04gAOhDbsalS8shWkOHJYdAaVXxOGxnUpPMHbFQNPBdJZ7bgjp7irdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:57 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:57 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 18/22] PCI: plda: Add host init/deinit and map bus functions Date: Mon, 8 Jan 2024 19:06:08 +0800 Message-Id: <20240108110612.19048-19-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: eb1cc44f-580f-49ba-f55a-08dc1039ee47 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hw9IiHkHlQqUYx7KzEOqyyqmRS+oGcf9wM/xlphRm5OAFwU8fazAyyHmgnOX+0OuinXQ7mqosT3WovPDuQTqFBJkapjfxrXGg1K6w1dC2yIdJfJaGdU92WkmX1zUh+di5/Jh0A1AQlF3oKBlWZTOlWrcrFz1/3yfu8FQeTTuetDi2CYBmJ8cMSWk1xU29O72LP8BfY4wca1E30BW63d8lzBQjbnqh4DlPUYO0v1bS8qeGCzriXA6bt4c7IyPNjO6hhUsoshQIJwnQRcb1Wd/w6vn9PByto1H7gwdgSTj897a+H7i6xFOZLMXh/qJOdqUInNZYtfB1Hrvl1/2+tUNEyaRfal5kFdefDUysi/rH4ob76YS1PmEZFo6Ns+FCZANzXk6s//y8JPX40n4g1+LiWXtEF0OyTFCPQTaDaMKUgF9927O5phMoHzokp3OpM8IcGJ3//cqbCiU0wzb+XOlzJ9VHarClzkXMskWIsWXKJa4od3maUeYZ4HWonVYyI9Rcn3RQEr/gWHiuwAKPvqBSbDWKE1YgCmoGEeODLlc73uXf/EdM3GJcCjZxNAKhM7i X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r2kxNW57X/cvEPiU/ixQW9239FgfpWjQ12abueNT4E3riX43NWmCy7wWjpNc7csgSC2xpQb0uuSEPxaNRb0wxSwiB+xN7b4tPamiyQzz42vOh1rd4VDaA8hTxOvngdiZvFzVBUmHnBT8JNSOCmiEhwZiV431NXlPJGk4lbwTyRGvgpVN+qMBkha3dYvlgkoVOfV9kVI9ea9FFSS+6qJG+29NW8WSFX3ITL/d3I8/uiY6DIGklSRv+ZB2S51YqVNAia0kWWdCs/fZchRu/sOra96dqNlXM2UGzqo2zhk+E3He3oDGF/Wy8lOnCMh5BeOAx+FV0YROVPUccwvvflaWhqcNIKdroFU+fb4XB3IpxG3T+69pMFWWfd8dUM2mKwriIiFlmFXJ2KjKJwI1jl9CFKeuSbZPq1v63b5YUxc+K68cmZdSCLjRJHG7Br7iC3W8KCIwLTfF+PA/DSmzqVtYqznGQlgFGgogbkeCqMbDhzvksm3Y1dlsVQULV+PWIyqdoi0llgpo8LZvihcnN2g/tUihkMw/HDfm33dA46kVoIoFmbhXRZIBWoHDQYHnCeCs51ZsMnj/7qTKXGRidCf+XDTL/VFKZpq+jHUMFoVldNErGs1ko3X09uTK14p7NNrhaZQkRZ+5IAAKjROmw6A1np+pG7hRzNsQJZto54epBMehQ6IfQla+F4rw3CCQEJ8+ds3C4jQcmJ5qfLgngE7B+K7B7cvAr6ib8r/88qUNhJ/OT955T1AHilL6g3H0ZENvs4do3yvtoeSGWwzO1hfXrkq3HRbc0zIISk+zxcfobOt31L1s8Wm7lN9A1uF3M2f6na2cOPTzycgFepro/W/9AV2P9t/HKfg0/IUqz7tmgzmGP46X86VM4YW5923PDzDWT8P7R/Xs1f3yG2H+Y5UOLgdN8+Jm6GGCnrqOa2UpmggJ8BPGS3bfk2xTyfAQsuq1Yk8FCvEXqhN0yoDbP7EoHpPSkNrP66TIZy3jts6uapPcapBMbTLuTY3/rCBdwdVq3mkElJyZnwStCfJi8NyOQPSz9DINPYDmYsqkU+W2QuYGdUXrNPH8CT6oQAl7kFOfaL3EyugKAw+2ZoqC8seU1mrGNzxwgS0lpYskRNeJLG+9k6N47HIyNWoLhMUMwGAmLtcdxp2rgM1tj487vARgQSn+rIFU+2pxJ4yjZB7kjvbe/yl2WPTZbx2Kz73kxwmaYNSmgt0epL3MPxjQecn9WfFaSZMDRqsqrMC7nlHIixW8+989zQL8wOw42NLaidDLlPJMAtkwkQHHEQMFQyswQLIdXHRf+N3eEbXdaxm1xOvKY69Y+F6NUgGN3s7b8nZYphAEi315OIXGFnC5PlYusnO1MMaF7YoPVVMfkoqDoNgSKDYCVpCAWxBrZ3Hbz9DkRAD8tGmpl9jd6OZKwzwWsClFTgf25ETMaAQ+pidiuyEI5IjNEhxWyJW8C2cQn7LecwcICW86MFDN8o13YLTXYmybcx71NKv7OfXRdAr2AHomQBbQc07Z5UOHuvLoFCBlcZP78lB1Fm7xQ34MdOmLYfXAi1La/Y3rlHVQtX5J7T84dVlRy7+Sx6DzL+yti7TnhrXAHqGK4JTzS/b5KYefTw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb1cc44f-580f-49ba-f55a-08dc1039ee47 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:57.8313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: n6Z0EAit9cLTxlbuTR4gdzDjBZmRgy0CV2xt7qA00jGae45hrjh0RU2zESqsOIN65as5uuOBoTPyhytdmN30YHKB5CY3D+umYYNd8WyWhWA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030705_418885_9082C7AB X-CRM114-Status: GOOD ( 18.05 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PLDA host plda_pcie_host_init()/plda_pcie_host_deinit() and map bus function. So vendor can use it to init PLDA PCIe host core. Signed-off-by: Minda Chen Reviewed-by: Mason Huo --- drivers/pci/controller/plda/pcie-plda-host.c | 131 +++++++++++++++++-- drivers/pci/controller/plda/pcie-plda.h | 22 ++++ 2 files changed, 139 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index a040e7e5492f..a18923d7cea6 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -3,6 +3,7 @@ * PLDA PCIe XpressRich host controller driver * * Copyright (C) 2023 Microchip Co. Ltd + * StarFive Co. Ltd * * Author: Daire McNamara */ @@ -15,6 +16,15 @@ #include "pcie-plda.h" +void __iomem *plda_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, + int where) +{ + struct plda_pcie_rp *pcie = bus->sysdata; + + return pcie->config_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); +} +EXPORT_SYMBOL_GPL(plda_pcie_map_bus); + static void plda_handle_msi(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); @@ -420,9 +430,7 @@ int plda_init_interrupts(struct platform_device *pdev, const struct plda_event *event) { struct device *dev = &pdev->dev; - int irq; - int intx_irq, msi_irq, event_irq; - int ret; + int event_irq, ret; u32 i; if (!port->event_ops) @@ -437,8 +445,8 @@ int plda_init_interrupts(struct platform_device *pdev, return ret; } - irq = platform_get_irq(pdev, 0); - if (irq < 0) + port->irq = platform_get_irq(pdev, 0); + if (port->irq < 0) return -ENODEV; for_each_set_bit(i, &port->events_bitmap, port->num_events) { @@ -461,26 +469,26 @@ int plda_init_interrupts(struct platform_device *pdev, } } - intx_irq = irq_create_mapping(port->event_domain, - event->intx_event); - if (!intx_irq) { + port->intx_irq = irq_create_mapping(port->event_domain, + event->intx_event); + if (!port->intx_irq) { dev_err(dev, "failed to map INTx interrupt\n"); return -ENXIO; } /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); + irq_set_chained_handler_and_data(port->intx_irq, plda_handle_intx, port); - msi_irq = irq_create_mapping(port->event_domain, - event->msi_event); - if (!msi_irq) + port->msi_irq = irq_create_mapping(port->event_domain, + event->msi_event); + if (!port->msi_irq) return -ENXIO; /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); + irq_set_chained_handler_and_data(port->msi_irq, plda_handle_msi, port); /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, plda_handle_event, port); + irq_set_chained_handler_and_data(port->irq, plda_handle_event, port); return 0; } @@ -546,3 +554,98 @@ int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, return 0; } EXPORT_SYMBOL_GPL(plda_pcie_setup_iomems); + +static void plda_pcie_irq_domain_deinit(struct plda_pcie_rp *pcie) +{ + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); + irq_set_chained_handler_and_data(pcie->msi_irq, NULL, NULL); + irq_set_chained_handler_and_data(pcie->intx_irq, NULL, NULL); + + irq_domain_remove(pcie->msi.msi_domain); + irq_domain_remove(pcie->msi.dev_domain); + + irq_domain_remove(pcie->intx_domain); + irq_domain_remove(pcie->event_domain); +} + +int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops, + const struct plda_event *plda_event) +{ + struct device *dev = port->dev; + struct pci_host_bridge *bridge; + struct platform_device *pdev = to_platform_device(dev); + struct resource *cfg_res; + int ret; + + pdev = to_platform_device(dev); + + port->bridge_addr = + devm_platform_ioremap_resource_byname(pdev, "apb"); + + if (IS_ERR(port->bridge_addr)) + return dev_err_probe(dev, PTR_ERR(port->bridge_addr), + "failed to map reg memory\n"); + + cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + if (!cfg_res) + return dev_err_probe(dev, -ENODEV, + "failed to get config memory\n"); + + port->config_base = devm_ioremap_resource(dev, cfg_res); + if (IS_ERR(port->config_base)) + return dev_err_probe(dev, PTR_ERR(port->config_base), + "failed to map config memory\n"); + + bridge = devm_pci_alloc_host_bridge(dev, 0); + if (!bridge) + return dev_err_probe(dev, -ENOMEM, + "failed to alloc bridge\n"); + + if (port->host_ops && port->host_ops->host_init) { + ret = port->host_ops->host_init(port); + if (ret) + return ret; + } + + port->bridge = bridge; + plda_pcie_setup_window(port->bridge_addr, 0, cfg_res->start, 0, + resource_size(cfg_res)); + plda_pcie_setup_iomems(bridge, port); + plda_set_default_msi(&port->msi); + ret = plda_init_interrupts(pdev, port, plda_event); + if (ret) + goto err_host; + + /* Set default bus ops */ + bridge->ops = ops; + bridge->sysdata = port; + + ret = pci_host_probe(bridge); + if (ret < 0) { + dev_err_probe(dev, ret, "failed to probe pci host\n"); + goto err_probe; + } + + return ret; + +err_probe: + plda_pcie_irq_domain_deinit(port); +err_host: + if (port->host_ops && port->host_ops->host_deinit) + port->host_ops->host_deinit(port); + + return ret; +} +EXPORT_SYMBOL_GPL(plda_pcie_host_init); + +void plda_pcie_host_deinit(struct plda_pcie_rp *port) +{ + pci_stop_root_bus(port->bridge->bus); + pci_remove_root_bus(port->bridge->bus); + + plda_pcie_irq_domain_deinit(port); + + if (port->host_ops && port->host_ops->host_deinit) + port->host_ops->host_deinit(port); +} +EXPORT_SYMBOL_GPL(plda_pcie_host_deinit); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 443109d04d59..7b69891700a4 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -141,6 +141,11 @@ struct plda_event_ops { u32 (*get_events)(struct plda_pcie_rp *pcie); }; +struct plda_pcie_host_ops { + int (*host_init)(struct plda_pcie_rp *pcie); + void (*host_deinit)(struct plda_pcie_rp *pcie); +}; + struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; @@ -152,14 +157,20 @@ struct plda_msi { struct plda_pcie_rp { struct device *dev; + struct pci_host_bridge *bridge; struct irq_domain *intx_domain; struct irq_domain *event_domain; raw_spinlock_t lock; struct plda_msi msi; const struct plda_event_ops *event_ops; const struct irq_chip *event_irq_chip; + const struct plda_pcie_host_ops *host_ops; void __iomem *bridge_addr; + void __iomem *config_base; unsigned long events_bitmap; + int irq; + int msi_irq; + int intx_irq; int num_events; }; @@ -170,6 +181,8 @@ struct plda_event { int msi_event; }; +void __iomem *plda_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, + int where); int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port, const struct plda_event *event); @@ -178,4 +191,13 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, size_t size); int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, struct plda_pcie_rp *port); +int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops, + const struct plda_event *plda_event); +void plda_pcie_host_deinit(struct plda_pcie_rp *pcie); + +static inline void plda_set_default_msi(struct plda_msi *msi) +{ + msi->vector_phy = IMSI_ADDR; + msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS; +} #endif From patchwork Mon Jan 8 11:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513297 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 A1998C3DA6E for ; Mon, 8 Jan 2024 11:07:20 +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=e9tYAIsIYkkF6XEsT6G3zRybMUFw9+K2mSo98pp3CxI=; b=jEzc5DP8a+XGq4 he0uqg+okHw0gqUFOAnbKM9Mwf0uPDOc0vEwd27dkP/k0Be6JkhPxDwrUzLmctu7BK2hpE7gdZeXM ON4fFWKvlVXBWnz0y+h2k4O62HLUqmoPV3Iry1DIc/mzAGnJeJiiUepln7cEOou23tvejjOrHQjzt pWPKw9iFZrGTmSqaQZAKlSHvPQ+uCvWSC6iWzbYG5T+tkkkUaA+f/K3FkKWMy4pygtDZbYHX6b3zD nSoLnL9AR8tlMXqO9Q8sTEF8ClkT1w0Mg38Fw4EmMO+Kcbxbl/eVlNFCE/QC0ADYB+gNQYbB++yca Rfo/E4evFFQyHzuG+Yzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTM-004hGl-2e; Mon, 08 Jan 2024 11:07:12 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTF-004gjK-2X for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJK/3IReauIRjNz6iNidDSYr4W7vENhrhIG+SvqBJLV9U41tH4x9hexcXl4QrbxAPexV3Gbr1IFMbH09ouxRvNl0C9deNrhp9YfMN18mynVm8yf4XgKpsDyPUT6b4RdXZHqN6AhCIpt/aPX9ax4PoUQ1qW0lfpCa/MLx+IEqHQf9afmNdpP3bxmG8JVpSaDUhwhaI107G8/Rk6cslyH1oGa7QBqF9IWOjea8EC4PfBnjIY6kE7JVnJk9QsRuf3w6yqaBcK+0tNMliPEWzGS75H6TNl/wYl2wSnfkySMUenBXlDqm7TYQrqocwGJofZQFdIpM87E03RQUtXxgTypAJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dKh7nmkaSdzB3ghyDF6RJecUyhtYIfwA0UmbLzDOakc=; b=ZDGBjQqXOJDR0oCmdUSWdKZQuH/QTHI4D+lvQLeKWVLHXhOGTyt9NaC2hNNOBRgpvhfozImz971Re3jem6RImD+OHrT/NJzJBSzsrZ/oCwlRS4ThR/6bGk2zGUfvgoTqViRZXwIqpDDKfu1ho2yelV+xYvTryMCh3xW6sJTszykYoY2ruFzY5uRuH2iTq2NAELg1nW8AKWK2LRKkqhAnlpReUPDrQejReAbgffVYxcZUOvK/ZSwzBktFVelhHZp1wkfy2AHXceKnZ7ibecXjpEFNCVLjNkpTRfp6/O3UGsD8n+FFh6mz+VD1QSFnEftBsarNc6RuV369LSCLHV0kGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:59 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:59 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 19/22] dt-bindings: PCI: Add StarFive JH7110 PCIe controller Date: Mon, 8 Jan 2024 19:06:09 +0800 Message-Id: <20240108110612.19048-20-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1f906b-b202-44a1-1c5b-08dc1039ef79 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzLqtqdbDCoyX1rNcIXxwXkXY7yROHBD+99QsywOcn/SX0bz9wUkVrLgcgoHoAwFeR0bmvyo74EIcj+8sNICs/ywxvj0Kr3MRUr8Kzyvf7qXvMz2kDbnD/wQYXT6g1cWXyym3hjG2Mi+cfe1CcDr7LCSeEDOcfUn/v2ANgqb6UXOeAFi7YKCx70RKtNDnbaKdgHsVr5WqU8W+sqjbocqdezV3fzFeWKXOGOoXW2vHhBl0EI7FoLEnKyzwSSztfkuYlDxDeMoqQogotk4nWEWAr990MbCvVExDjHj2W/TX6075Oes6WgLA1JIByh/piugfbTKxcNswDj1NIPAQf1wIKkuE/lkEHFjsWowPrb3dbItwEkrnlIVZ0EnpRP56IBa4NdfvLI/AuHHF1BrnvkFB2iBw356NjnO5Ck91qRH3iJP9t3cdis+K79IpM7ldO+1BbMbuKzYK+MaFc2MJKMLnbEj+KVU6HFd883yE0dUtbQ3UZkRTUcF590JKhedlybbqul9XH7a5h7lrhUa+wntu/AWh8M3kV1UjqgjgQijarRlWIZ8bnpNc2MZ7fqUO9mr7Q9vsswecSFsqCwCLhmMAA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(966005)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003)(449214003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ki1hL+J7yNZaf01k3sWXdWif66mlS7K8V7Bd+yDQ7SdCfJq2KK4i34r9Xc4PbyjpUYK4eVH10P+7iaHnUBU/5WS4E8XXUBe5ZsGjSeHqX8EEPO4i+oOPc/dCJPVMvVL7ic8yqQIqRif3Z8CdBTFu/WaAzipAQbGRUW7DOxl5rM83BN6jAk5Jm2QW13s0j8INDcCSWkBwbLntWyygpV35EsuZh8x3PA1bN1U1AtLTNRXqzQZE9vihTDUqaH7fHlK5haL4JjXcHsoIECvx5waf2ari34d0v/KnXUYVCiuEDvQoJtj/PpAwZjnY7PfucY2iZa1L/90oqsEUM5qRYvo5twQALtVUd/iC0eazUUyAzJ8o16o3w5v9Ch1fFPUtRysA0m7SeFEXUj0kr3fypj7GtitXbq2TfLqQm4n+SfTCvs50dJg/ie5IY1PaayrsrKHkH3gXf0dCyF9Wdj5GO1pnCX/8esEZpckZZqI9kc8Jbeh+TDvAu3I7sQqMtzONb8N5gl4m89eeFwiqMEncBXkn4N9cSETLMw7pnBTbJuGdSzAvjFJeamupBMkEyeeF6OInzr43N9ENhJtP6mM7HrLT0raZmcV5Wczdhi5l2UNlK3wn4ZYUNZDkWiyR6AuTEflF8U2kkcTn7xgXME8qH/PAMVHXnIpdEYe3XrOwxdT2ky8vbJI1lICch5uJim4NXMD0Q6GzrCbG8S/WGPt4FDKtITPKf6SMNK+SMtrjHf+DrLflEE8L5r2UpaR8jtAoXwkGAZC7yvnsghlhtZjs7Z/7oxQWi4xszvIFRvkcZS9JLFJM0U+Ea0QbjNwrr+umrfBbWJdoSZANxA7FcY/DBYq8NeWHrH/xl7bIPYKd54bzN01mbsbjRoW/Gmcc3XbDVzmDGmlIHiFKMqa+CFBA/Sl2nk6d7EEx8bXGCl9VKqvsAEJ4cgANvZ+rBxzGpZfrvb8wjoJZubmCpylOSwom2kZfThmSzpDm9BEJ69zo5Xmg6qhoJU7BwkfNn7TtCOlXiKFpg9LF7qzc0PyUGIXT3UxOxYV0zlyootHhk9nqWSFMAeA+/VYFj0nMAoDIx1ijvL+4hpXGmmNGTz8/ohVoLKv1AM6R4AjzvnC5X+OnwrZEm4FYQDvs7yCizDsMmpmSTWkt9ST7DkPHWq+dXQ4Z1gxeeVuQIz9giwcAev9aPSEOAbS7h9YJiLdyB2GyBJ3okKLV78kuwy/z7lu9NGn1XXal8JRcMn0w+vFSyw71JHgU0vu766z6QektlJgWXYPuXIxY35zABCbchbTLj7QyVGMn1JWmyRK3T408oYDF+xxApZdoNn1dH1j5lodrP8DlOc/VcEddSafCN8qauotwUdssuTP6r/pFgc5iVcqFgCkS78ia/pJ5jmkBtj5t5CoLEZDgNvcrQHz4ZPl2yxk2zo3qFYzTy0TqAVgRqQJtUhKpb6GchI9ygxMrF08labGR+zBf1Y5d82wia/EPYxvyqxJ85yfIW7/VOF/dgicKq1jt9ogls0CtC6/pi16q/p1wMs8Hm4yE4rqSSqfUYSY5GsaptoSXsNs2CIkdX3V9rqpc8UjArBeZTdaMWB4ICkcij8Zi86xQd14xTKd9GPY6u3g0qQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1f906b-b202-44a1-1c5b-08dc1039ef79 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:59.8229 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EIE5b+2zyMPKhigZmY5k4hrWDjDnWGkjBFSm+FPr8q7U2YQgU+q2RYEEK0zp9SmVOwQ/2Jb+XImJzooqjVgPhwJprUkjfpX5en0vFnjT2AM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030705_843846_E5E65425 X-CRM114-Status: GOOD ( 10.30 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add StarFive JH7110 SoC PCIe controller dt-bindings. JH7110 using PLDA XpressRICH PCIe host controller IP. Signed-off-by: Minda Chen Reviewed-by: Hal Feng Reviewed-by: Conor Dooley Reviewed-by: Rob Herring --- .../bindings/pci/starfive,jh7110-pcie.yaml | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml diff --git a/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml new file mode 100644 index 000000000000..67151aaa3948 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/starfive,jh7110-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PCIe host controller + +maintainers: + - Kevin Xie + +allOf: + - $ref: plda,xpressrich3-axi-common.yaml# + +properties: + compatible: + const: starfive,jh7110-pcie + + clocks: + items: + - description: NOC bus clock + - description: Transport layer clock + - description: AXI MST0 clock + - description: APB clock + + clock-names: + items: + - const: noc + - const: tl + - const: axi_mst0 + - const: apb + + resets: + items: + - description: AXI MST0 reset + - description: AXI SLAVE0 reset + - description: AXI SLAVE reset + - description: PCIE BRIDGE reset + - description: PCIE CORE reset + - description: PCIE APB reset + + reset-names: + items: + - const: mst0 + - const: slv0 + - const: slv + - const: brg + - const: core + - const: apb + + starfive,stg-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + The phandle to System Register Controller syscon node. + + perst-gpios: + description: GPIO controlled connection to PERST# signal + maxItems: 1 + + phys: + description: + Specified PHY is attached to PCIe controller. + maxItems: 1 + +required: + - clocks + - resets + - starfive,stg-syscon + +unevaluatedProperties: false + +examples: + - | + #include + soc { + #address-cells = <2>; + #size-cells = <2>; + + pcie@940000000 { + compatible = "starfive,jh7110-pcie"; + reg = <0x9 0x40000000 0x0 0x10000000>, + <0x0 0x2b000000 0x0 0x1000000>; + reg-names = "cfg", "apb"; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x30000000 0x0 0x30000000 0x0 0x08000000>, + <0xc3000000 0x9 0x00000000 0x9 0x00000000 0x0 0x40000000>; + starfive,stg-syscon = <&stg_syscon>; + bus-range = <0x0 0xff>; + interrupt-parent = <&plic>; + interrupts = <56>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc0 0x1>, + <0x0 0x0 0x0 0x2 &pcie_intc0 0x2>, + <0x0 0x0 0x0 0x3 &pcie_intc0 0x3>, + <0x0 0x0 0x0 0x4 &pcie_intc0 0x4>; + msi-controller; + clocks = <&syscrg 86>, + <&stgcrg 10>, + <&stgcrg 8>, + <&stgcrg 9>; + clock-names = "noc", "tl", "axi_mst0", "apb"; + resets = <&stgcrg 11>, + <&stgcrg 12>, + <&stgcrg 13>, + <&stgcrg 14>, + <&stgcrg 15>, + <&stgcrg 16>; + perst-gpios = <&gpios 26 GPIO_ACTIVE_LOW>; + phys = <&pciephy0>; + + pcie_intc0: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; + }; From patchwork Mon Jan 8 11:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513298 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 D795AC47079 for ; Mon, 8 Jan 2024 11:07: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: 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=oH5i50BcYDKBua5GnsN5MjL+hQMqe6SqbztpOec1sCs=; b=XO/4w1trYkAKOo TI2LxUzIJdpEBZPOnI8oN/lM79p8Ab/iXZ0naQ2rZ23Are+RwTNavkucyprx8En4h5LrbhplmfxRk iPmtnIs0Sfj+5tgeV9koniLN75Kx+wTxzu+tD4tHdMS6FXpGo/c9ya9eSRN+G14a1xQ6rgulQwz7H KG+pnAWrh0m+9jADarCYIOlhVmzkz7Q71S1NHmv1cWVKgP86WS1hHSImWuTWtCtLgodZlmPdaSDoo ntVVkozIa/w3rqLvGyGxGWFbqsW7o656aJF1YkcTyB4wL/RtczaFtnafbwJ0BhG1j++a2eBquqZ+s v85lCUjVtUyCCXKCBYUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTO-004hIe-0m; Mon, 08 Jan 2024 11:07:14 +0000 Received: from mail-sh0chn02on2060d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::60d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTI-004gwv-1C for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WYQBUgEQ0VRnJUy+VUYvbz/90fFMBMNyWkHRvWtcYMpAcDNeGQFLtUsKb2+A+gNCMYvw2OHzakhLwNYxIrAnZoLZHovQZEjlBGd/zqr1KIKzIOfbOAZJJfSCSk/eJh9sKe6G++TSr9MQSPeVR8VYprdL9eSpd0y2cw5xiR2tWXOnNnETX6v11Baql+QyGGJ6mtCRNR1SvAlRxSvJgyS4baRGVg8LqILcZpmlM2eQjqrhzvoV+bU3Jfn2aI973McbHbkmOZqJ7JDHIjEocmAbN/tUSuPjB53+ZN39z3vtcGblospRA5ryMSsseMGMEdOzJw8EIKo1V4ZmYIDcviG8iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rk7I7qrzmKI1l/EnFZ3e3e32keUVuOOU9pJsxnUoF98=; b=IfLLApPUaHJzEHxEhUji8xXP8icyHYIFPBvpkRo4c0bSzWvXYplczuyI5m/ElY94qcbztulVaDDwp5ySQgCkRdrELRYCfU7++9/hIT59nMPeRmOIoPPL6rkYaIOfSZQ0VhkNkERzA2L2u9f5glchWtdDLz2ryG09rMZfjWjWTAJGbmfEgoQjf9YSachdc2bnhDfZyaOQPDZ/t4fsSW8EhJBEYw7+d5Y5l8NcXmyaGXXVICM6iYNJYIkZhuTrnPd8AW1SltDoxBXKUPU1dr1Mvx3hUd87BBSmtdVXo8MzfV5MnEgyPfQE/mtRBaDhI2SMg+QvBh5MCG9qS1RMWfFWIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:07:01 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:07:01 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 20/22] PCI: Add PCIE_RESET_CONFIG_DEVICE_WAIT_MS waiting time value Date: Mon, 8 Jan 2024 19:06:10 +0800 Message-Id: <20240108110612.19048-21-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: c41f4676-138d-417d-e107-08dc1039f0a7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yEpwQKZcTzsksPNn2w9h01LlRRzpEQd6tKMBfojLcLvrkCAYijI1gUENONjYtf5cFY1q4ptr6Lw+uAAThokUXkNCoqwxgjZsOx6e1L7Pdkp0CEODZxtUi0T6MHyxBbZcn9ZnXgYsnGxUx/M14ZANq3mXiC+Jmrkqb/6RfG4eR8ZNBRMd8/sxIaj+NcqLbU43hCLR5L/WQw4cM7MidGsuPIHKNWcFsjrl6AhMQnnBPoUcuqlDTL/y+Kj2Zr5dQWVb2KZjqsLvHSzaxqi0rBOHJLJMr8yvKIvDTurimrAUWOH7YYuSgb03Nu1Ij6W3q29SsjYk95F33SVS/yJathFBRbN0/fnFjwAB1763lo7XSX8Q4aatywxC6qTUgJxnNPbatf0WIG8HwuQoeA/PtyksRioVzAohiGltNwINKUdJ0pmlgAaPcoQq92r0jRu+HvuXFQVN8mQTjoyN8ywGt9mJXrbHQUjIrvye4tsDlnvJPH2O+RaxzmAaYVQA7CHOq7s6NZeRbY4JSBygXBvMznvBHIFvbtOe/6kAs6vM/dmxzoAstnvmFPxSrbVWs7UhiXNi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: je5Z9Y5AyTlaN25nO+PfGa1ZdN51/92SBR/EWZXp+CSLzsQ+xZTKYLQQmjXbjjq/NSKQEEJMQonb707SRUwS8xabFwVwfkd0/y1Ngps50Mt6X+SdyMKzxjThYnzPuNnXmIETCvjpAjkvnpja86GjSwbwnFruSxe+UdZy5HBNpQ+IF1Ewulk4u7WAsm+FXJXk9ovKtnFkIAZae6nesuQCwi/z+GEtBP/UYeZhlqoq6Mqf6huFwMTI6j7ur0ubGzGvo31wLxmfUMls8sZjpo59/JZAEiT4NH21zSMMvZBMXOkEHaLiooW3KJC2HDazE6iemfOt0g4SOOI6mEt4aqV2Ndh4x5gngwyj1RRnf5MNxXgcaaJ3kAei1jR/qevSXYko5+BvChWCMq3T6Wu0mFOrzrwbduEY06IoLvcRgzH4ih6IMg//yZQZ8A0RgCeCkxaOZuxYYZcWUtRJhxrCrwWBybYxIM/W8C6AB1CCAIECPmqiGPNiJlTb6Nk+vd0LYUXCj2EfVUXYy38mClKPjq87JP0W8CmZvjGSat23R7RIxNv2SyVWwC3bjnTqmhKODEcerfWdbPvkpOE/QhDPB5GYdMMpJs5kNAMQKI4sYpStwbR5eHfRVg6zIB2ihZGfPBeuTpB7bnXRJ6ZhH2qGVKNoaGH7OkY2fPrq0cYCQUjcSct+aQCL3XFjGUXzO6lB/ba1MdPA8jbf9LO8fzF5hLLGNCmoDTjhWogujNoKqgjL0uRAHAiL8txUcwJTjuXT+jD9z5jWP3EiysKQ7O+sBoDr3IOTaR8kcN48Yc5ny8BUkJ3uE95Mnh5RLh3vEPmNvgPJh8oiD62wBtS3Mt481mjTK+uBTl496UfjqAvGwUFMy/kno90SgAFDf135J9u7L/nU9UjILZaYINGXQemIRY6Rh7gvvF4AohCw33+y8NYCllaCjS0R8SsyGDlHuV9wWK9q/eVJsZ89B/yD8kJvd00pArPqrKz923zH20z/96c2aKEUqBWn7c4rP5O2cNTSmNhJGaa0RGRxb2jp/rmm0e5uT1WufBKwpCzgXP85dS07P6dfbUpjtpHSnJZkL7/1uNQ2ZfwQRfNQGWzul+Q7RTgI1V9nG3mNt1LDi7tgAiLZRZqRfFMvbbwgi5nuDFoKtfugVqDMBeCh592FiF5yeJ9V+BQxdvC1hWJ9CDhDIQJwzbaoRcpXdNiv04FHmuoIzCC40Gphgtm7fHZdKY4zoLDB5jPoqSRwScMQMPdy5cHXTEM4DqfWdMnOD99w9D/YFshrfj4kckv2ztPMhc+BxeM7ojGgkMEm+BdUpfSOYt/TrIU6deRiWTC1kDz2oI1l6RvbwjSDsk/Dc25WhdCeti4/EVE+Z4MUoM82swpCm5o1tJYjAUk6OuQKtSZCSamL+RNBZi/CfWCE84xmy9ItZ+LHvNoNQvchc6Unyth9b8zI6QtU2LZxXjSAOWf/CK51a8CP2gmpkf7UfwtDVii7A4nFHcIccuA8TYIhqCh6s8uouaasr9xDCwzSB0hACAD06oPAZqq9vWa9qPMcEg+q0UsTiBgdVw0nEfwEHjVJdDb9xYTvX20WOKdVWOxzoXeNH8BquYWZgC59iihulk+BqeFSrQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: c41f4676-138d-417d-e107-08dc1039f0a7 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:07:01.7931 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 49OUmuFZt+eC2Q2JgObT9k4JA1LdP1QMbBs41tyIQH9bGqW9//cNJ2GvdOx9ZRW4m7JosuRVQzWgQOUxtg+59Ejce/91M7im7OiPNYhXx+s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030708_448677_201FCA58 X-CRM114-Status: GOOD ( 10.29 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Kevin Xie Add the PCIE_RESET_CONFIG_DEVICE_WAIT_MS macro to define the minimum waiting time between exit from a conventional reset and sending the first configuration request to the device. As described in PCI base specification r6.0, section 6.6.1 , there are two different use cases of the value: - "With a Downstream Port that does not support Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms following exit from a Conventional Reset before sending a Configuration Request to the device immediately below that Port." - "With a Downstream Port that supports Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms after Link training completes before sending a Configuration Request to the device immediately below that Port." Signed-off-by: Kevin Xie Reviewed-by: Mason Huo Acked-by: Bjorn Helgaas --- drivers/pci/pci.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f43873049d52..6990146e14e3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -22,6 +22,22 @@ */ #define PCIE_PME_TO_L2_TIMEOUT_US 10000 +/* + * As described in PCI base specification r6.0, section 6.6.1 , there are two different use cases of the value: + * + * - "With a Downstream Port that does not support Link speeds greater + * than 5.0 GT/s, software must wait a minimum of 100 ms following exit + * from a Conventional Reset before sending a Configuration Request to + * the device immediately below that Port." + * + * - "With a Downstream Port that supports Link speeds greater than + * 5.0 GT/s, software must wait a minimum of 100 ms after Link training + * completes before sending a Configuration Request to the device + * immediately below that Port." + */ +#define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Mon Jan 8 11:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513300 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 0D347C47258 for ; Mon, 8 Jan 2024 11:07:25 +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=2v3kfBnyT8zfD4Fj3pMZondeg/9uJn7SovmQvHTXaJ4=; b=0fHVaOU0966W3h fOogq89Si/oUHEVyD7ICa/tnftwii4TQqmpBg9u6e9Cp4p2+zufbP9oBkzF0DkVznAXCJ+b8MgWft u41X97SsD4XFQp4DVlfcLfmuQFcsZRAZazEcMacZNQKzI22VHKyOcFcD2VVB3YFVd+asUwmFA+l8C oz9HqcTSPUnmFE+aUP3JFnBB3w+sRKLj8FXAxxN+16v2O54uFaiT5tknRagedZZA1gWSwwXSJPTNC wlXy8vv8g0jAmxmJerYhWAI7pq5D/0xo5xC7bMsAR2Ls57W/g+87OjlxRDFpbWEoKLsHUQbi2h27Z xPPu4FAp6uuin4b/ctjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTP-004hKA-0r; Mon, 08 Jan 2024 11:07:15 +0000 Received: from mail-sh0chn02on2061d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::61d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTI-004gjK-2e for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRAhfbcpNECD3bUEbKwaPktbW2YiCJMM9K8d/8VIZhYmDox/WOmpNk6vMtIMPGBxSPBizjQ92I3FNuI280dRWZDb+3VvWv8c+95cxrehy9dRbdV+RkCZxgJnoFJn/LoBCcJPrw/UTXH2EwQ0cVSsKNjqZTauLvhMxmf9KFcZRsidnoVbDGZBW5e45jO+ICxoZUBeix5pPswQCjfDKab9I5RTfYSb0dBqCPYgMP1B8k4DUl+SR9gd6qBCYWsfWvOqxF19itJOZQdyEwZHlVhXUIvzerOhagT3S93O510qMNICZoO8OrGxf/dWs6iBGYeGcnY/Wbpaug4K1ORQLYWBvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Au2/G4EBK5VuF6ZN6z3pGw3XNqUfkLw2F7N4CI+h8AQ=; b=eleojd4SQAm6nQrYI9fj2EOWoEQVH68riTf7caSnHDwVmlqtq6X3R4qGTcpEUZRIsvDTU7UknERDh5BPuM5BqL2sEfCcFseEtk8AJZ7fkWWZSV5Wbxp51v2+mAsJoFjz2pgdXP8KkgNMoLjjKRtkEpfq89P1uSl0xmAjJfRudBQLqy8AwmR+i+5ojzJZTNgJD/BSCdx2tTx1aAcJf0fwfkpipD/Y01Osj4PkE3+nRP/CnIGRBwB6DBG0tAOb7QxeA8ukI3zMUUsgtfz8ad3syizT9OXXOhHlDkMXy4GnQTgM3H7SuKrw16qd8Y0aiqqbLfbS22z1jxPjMm5h27Xg9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:07:03 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:07:03 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 21/22] PCI: starfive: Add JH7110 PCIe controller Date: Mon, 8 Jan 2024 19:06:11 +0800 Message-Id: <20240108110612.19048-22-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f4f205f-f0db-41a6-a5d0-08dc1039f1d6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c858YkTLYaFP8+ZpSzVtlcVfVOEWH4+v4Y4kDiaBsAq+1Q+jVojg3+9PjiIYAk+EzByU5TV/ZVwLDZx2Z3ZfCl3pU8doQCxLi4bT1QTd606ZC6q4nkHyli7yLzXRV+SVntr1XQeK8ghdZ3wZ4o8xKcGwrNNBJnIXVtu8ga1NQoghqnyw4jkUkWpqG4/hlCfn0cHKL4cZuZ5iHwX4RBov/LwSlOt4Jxf8gwLMU8y05vcq8zeMfSw3CkrCC95bu6JLnDmXmk/H08YKCT+R4IeI9Fcr9YhmedOynDsaAOJOeDjf/jLTynd3j7YT00ci2gf55xfVG8c89dnDAr8cBgoHwuRiitYGLRrXr4EnGIl+lwpeat0XyUKBL6aaPuCR4+/RSJAVbW7h0zQTZp2YpbhxIf04ZVN1ojWxVt54oBgfAhbXSciXSrCfPOdXaHQ6tn0FapOnq8tJxuWyD0Wpqe0vSgFxPZe9g5+Arn7qu1qiBzfNLh+52xoRBHi7MLaD85KC3rU3ekU7HjBS37F6KHxrJltXOmsUIVAeM62rvB731pENfqTfQ8MI09O+u5vehMA3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f9d/PqNr6u1GS5i5i9v1i1YluIhql9foIksNjLaef4ox6THGUel2NibtTWWtqJRM41f1/M/ve5brc7HAFlKjhmU/GoKpbv961T7PULCaMYXWkmFnuuMgd4nKF2i0Bv31bP6e+N+0cUDDunm27Bo6h0utY3SdS4N0eeeNKsQHw8642unk780GzTVuvRLRlBsf830++Y+EMylmx0q78BoMAThHOmYHdMhkj6NxP8Q/6MYacTI7VjELv5JZBZzDidyjILdAJENkBJkkFQEBApVBuU1txF+/kZPi2CYYidj7R1Rl1AijzYw0dSVFjcZchYqFF2hq7zCsOYdJwatgcLxF3e1aR0cJ/R+CUNK/o5b3hBM1yIc2c6rl/Xwb4IauOeRW0DUtXNxoZ0i11awrwm5ZY9ng5clvytOnbKkHsM/38jfokkPS062BzXpCHRVmqCHoLgyzc90Yvcz9UbiUjUt6aFmc4k548r8xyI3GpJ4TpSimZfmCGua0CfS/h5zDmHij0VM2k+DtIa9deVtUirInx66LJjJIysZ9rB/5wiuLX2pzpGuDRiaXqTBClJtGGkx7C1O5mSzbYr7crLi4sPgOy+pHirLrHpcWMqgVGeCgC9wrQX1BUH/FdQDf98EfD1JdWxEyBQoOqaFJmiB2V5IArWvzxOtFkI3gpjd8NHqLPDYLoNhZ0s+7scRu6t4xMJ8DoKjhoGEhW9Voeq9Yzv17vh4lOB3Ho3ahxw2XA2//J1vfDURyL/1dUejVJ2AaHDoAJ2DhEGTB8DA/fyoADHsDFNRsqnd4MP/6KTKfLOt4Zewt5iuBrd5AY8tbSa+ooGQSoh/OTZZLao2pXNoSDHck4m7hUstVgIqz8eWvD4z2npKwupNjgL5dlsGjvw+qmpVymJewIDTLnNHizgKiUP00wm2jYWI6pQJr6ImmWuvDqIK1IG297RwT3o2V14ESdSeMM9zJqIclmtiVnR7/zdo0SX7Hc5QFrbTaggff6IMHauG37HTckGDEHojGEZq+Z1IFf2QIhM6j9L5CFMGtN8sGhjqYarKKCdiyTRijDpzcXbTia4dNcP0kws0IXDFA8Pb0PulxkBpnYhMQ7Fz3oQqLdTegyfWCJ8X69Lb0jx9Dz8b1mQbJu/BCVKn31n6GR2dbOu7gKpT1Accvz312mnyW40giI7EhQrkv0J1y2ygxgfsPPksPLUh5qg62Js8SyrqmhUPC6laQrlGFaEP16SzTqs2mT8gHLlJOUfb+N9kXEIX5Ce5zjDU3m62bvStui9ulLQdaQ/2YavHbIMcFHvWFX2RO9w/6eSa1lwUCEfpo3unoe60+Vjse0OEsE2Ve0ZBa7ZwY+wrP51X65KjlHTkVl+AMlOjRitE/umy6q8qCMSxxhhWS/2CT9B+a/uz6PS6+H27NTdgQdT1SdZCPCvD1jjYnAPpyyXJNYqyU+BbWq2vIYhI+qPQtRc5PMIQr0wPjtnOjxGpVOLZza4kv/sIhFhNwE5PuhvqZkFNMXLjzAZyxlgOUb0jyQ4REBKRSdd9CIx+6ShhSH+bkWk0cLaLghMwvhSq84+jOUaQ4WcGfCxspAv6/oReTcuZPaUVi17UEG3Y7u4AfJwNJfeiUsdjuVw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f4f205f-f0db-41a6-a5d0-08dc1039f1d6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:07:03.7864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: n3nS4MQwsH2PxpzNMKN0LmKlipVI97Y7Jhi8CQknj10K20sgqQ+xu7qf4n2jk5d26hgHS/pykXLk1xnxg6a/3aE99KYBZSS9kcM+4FJhTCE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030708_877710_C789178A X-CRM114-Status: GOOD ( 17.69 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add StarFive JH7110 SoC PCIe controller platform driver codes, JH7110 with PLDA host PCIe core. Signed-off-by: Minda Chen Co-developed-by: Kevin Xie Reviewed-by: Mason Huo --- MAINTAINERS | 7 + drivers/pci/controller/plda/Kconfig | 12 + drivers/pci/controller/plda/Makefile | 1 + drivers/pci/controller/plda/pcie-plda.h | 71 ++- drivers/pci/controller/plda/pcie-starfive.c | 473 ++++++++++++++++++++ 5 files changed, 563 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/controller/plda/pcie-starfive.c diff --git a/MAINTAINERS b/MAINTAINERS index 730fe2d640a1..7fa339e6c25d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16821,6 +16821,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/socionext,uniphier-pcie* F: drivers/pci/controller/dwc/pcie-uniphier* +PCIE DRIVER FOR STARFIVE JH71x0 +M: Kevin Xie +L: linux-pci@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/starfive* +F: drivers/pci/controller/plda/pcie-starfive.c + PCIE DRIVER FOR ST SPEAR13XX M: Pratyush Anand L: linux-pci@vger.kernel.org diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig index e54a82ee94f5..c0e14146d7e4 100644 --- a/drivers/pci/controller/plda/Kconfig +++ b/drivers/pci/controller/plda/Kconfig @@ -15,4 +15,16 @@ config PCIE_MICROCHIP_HOST Say Y here if you want kernel to support the Microchip AXI PCIe Host Bridge driver. +config PCIE_STARFIVE_HOST + tristate "StarFive PCIe host controller" + depends on PCI_MSI && OF + depends on ARCH_STARFIVE || COMPILE_TEST + select PCIE_PLDA_HOST + help + Say Y here if you want to support the StarFive PCIe controller in + host mode. StarFive PCIe controller uses PLDA PCIe core. + + If you choose to build this driver as module it will be dynamically + linked and module will be called pcie-starfive.ko. + endmenu diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile index 4340ab007f44..0ac6851bed48 100644 --- a/drivers/pci/controller/plda/Makefile +++ b/drivers/pci/controller/plda/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PCIE_PLDA_HOST) += pcie-plda-host.o obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o +obj-$(CONFIG_PCIE_STARFIVE_HOST) += pcie-starfive.o diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 7b69891700a4..04e385758a2f 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -10,10 +10,20 @@ #define PLDA_MAX_NUM_MSI_IRQS 32 /* PCIe Bridge Phy Regs */ +#define GEN_SETTINGS 0x80 +#define RP_ENABLE 1 +#define PCIE_PCI_IDS_DW1 0x9c +#define IDS_CLASS_CODE_SHIFT 16 +#define REVISION_ID_MASK GENMASK(7, 0) +#define CLASS_CODE_ID_MASK GENMASK(31, 8) #define PCIE_PCI_IRQ_DW0 0xa8 #define MSIX_CAP_MASK BIT(31) #define NUM_MSI_MSGS_MASK GENMASK(6, 4) #define NUM_MSI_MSGS_SHIFT 4 +#define PCI_MISC 0xb4 +#define PHY_FUNCTION_DIS BIT(15) +#define PCIE_WINROM 0xfc +#define PREF_MEM_WIN_64_SUPPORT BIT(3) #define IMASK_LOCAL 0x180 #define DMA_END_ENGINE_0_MASK 0x00000000u @@ -65,6 +75,8 @@ #define ISTATUS_HOST 0x18c #define IMSI_ADDR 0x190 #define ISTATUS_MSI 0x194 +#define PMSG_SUPPORT_RX 0x3f0 +#define PMSG_LTR_SUPPORT BIT(2) /* PCIe Master table init defines */ #define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u @@ -86,6 +98,8 @@ #define PCIE_TX_RX_INTERFACE 0x00000000u #define PCIE_CONFIG_INTERFACE 0x00000001u +#define CONFIG_SPACE_ADDR_OFFSET 0x1000u + #define ATR_ENTRY_SIZE 32 enum plda_int_event { @@ -200,4 +214,59 @@ static inline void plda_set_default_msi(struct plda_msi *msi) msi->vector_phy = IMSI_ADDR; msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS; } -#endif + +static inline void plda_pcie_enable_root_port(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + GEN_SETTINGS); + value |= RP_ENABLE; + writel_relaxed(value, plda->bridge_addr + GEN_SETTINGS); +} + +static inline void plda_pcie_set_standard_class(struct plda_pcie_rp *plda) +{ + u32 value; + + /* set class code and reserve revision id */ + value = readl_relaxed(plda->bridge_addr + PCIE_PCI_IDS_DW1); + value &= REVISION_ID_MASK; + value |= (PCI_CLASS_BRIDGE_PCI << IDS_CLASS_CODE_SHIFT); + writel_relaxed(value, plda->bridge_addr + PCIE_PCI_IDS_DW1); +} + +static inline void plda_pcie_set_pref_win_64bit(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCIE_WINROM); + value |= PREF_MEM_WIN_64_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PCIE_WINROM); +} + +static inline void plda_pcie_disable_ltr(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PMSG_SUPPORT_RX); + value &= ~PMSG_LTR_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PMSG_SUPPORT_RX); +} + +static inline void plda_pcie_disable_func(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCI_MISC); + value |= PHY_FUNCTION_DIS; + writel_relaxed(value, plda->bridge_addr + PCI_MISC); +} + +static inline void plda_pcie_write_rc_bar(struct plda_pcie_rp *plda, u64 val) +{ + void __iomem *addr = plda->bridge_addr + CONFIG_SPACE_ADDR_OFFSET; + + writel_relaxed(lower_32_bits(val), addr + PCI_BASE_ADDRESS_0); + writel_relaxed(upper_32_bits(val), addr + PCI_BASE_ADDRESS_1); +} +#endif /* _PCIE_PLDA_H */ diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c new file mode 100644 index 000000000000..9bb9f0e29565 --- /dev/null +++ b/drivers/pci/controller/plda/pcie-starfive.c @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * PCIe host controller driver for StarFive JH7110 Soc. + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../pci.h" + +#include "pcie-plda.h" + +#define PCIE_FUNC_NUM 4 + +/* system control */ +#define STG_SYSCON_PCIE0_BASE 0x48 +#define STG_SYSCON_PCIE1_BASE 0x1f8 + +#define STG_SYSCON_AR_OFFSET 0x78 +#define STG_SYSCON_AXI4_SLVL_AR_MASK GENMASK(22, 8) +#define STG_SYSCON_AXI4_SLVL_PHY_AR(x) FIELD_PREP(GENMASK(20, 17), x) +#define STG_SYSCON_AW_OFFSET 0x7c +#define STG_SYSCON_AXI4_SLVL_AW_MASK GENMASK(14, 0) +#define STG_SYSCON_AXI4_SLVL_PHY_AW(x) FIELD_PREP(GENMASK(12, 9), x) +#define STG_SYSCON_CLKREQ BIT(22) +#define STG_SYSCON_CKREF_SRC_MASK GENMASK(19, 18) +#define STG_SYSCON_RP_NEP_OFFSET 0xe8 +#define STG_SYSCON_K_RP_NEP BIT(8) +#define STG_SYSCON_LNKSTA_OFFSET 0x170 +#define DATA_LINK_ACTIVE BIT(5) + +/* Parameters for the waiting for link up routine */ +#define LINK_WAIT_MAX_RETRIES 10 +#define LINK_WAIT_USLEEP_MIN 90000 +#define LINK_WAIT_USLEEP_MAX 100000 + +struct starfive_jh7110_pcie { + struct plda_pcie_rp plda; + struct reset_control *resets; + struct clk_bulk_data *clks; + struct regmap *reg_syscon; + struct gpio_desc *power_gpio; + struct gpio_desc *reset_gpio; + struct phy *phy; + + unsigned int stg_pcie_base; + int num_clks; +}; + +/* + * The BAR0/1 of bridge should be hidden during enumeration to + * avoid the sizing and resource allocation by PCIe core. + */ +static bool starfive_pcie_hide_rc_bar(struct pci_bus *bus, unsigned int devfn, + int offset) +{ + if (pci_is_root_bus(bus) && !devfn && + (offset == PCI_BASE_ADDRESS_0 || offset == PCI_BASE_ADDRESS_1)) + return true; + + return false; +} + +static int starfive_pcie_config_write(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) + return PCIBIOS_SUCCESSFUL; + + return pci_generic_config_write(bus, devfn, where, size, value); +} + +static int starfive_pcie_config_read(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 *value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) { + *value = 0; + return PCIBIOS_SUCCESSFUL; + } + + return pci_generic_config_read(bus, devfn, where, size, value); +} + +static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie, + struct device *dev) +{ + int domain_nr; + + pcie->num_clks = devm_clk_bulk_get_all(dev, &pcie->clks); + if (pcie->num_clks < 0) + return dev_err_probe(dev, pcie->num_clks, + "failed to get pcie clocks\n"); + + pcie->resets = devm_reset_control_array_get_exclusive(dev); + if (IS_ERR(pcie->resets)) + return dev_err_probe(dev, PTR_ERR(pcie->resets), + "failed to get pcie resets"); + + pcie->reg_syscon = + syscon_regmap_lookup_by_phandle(dev->of_node, + "starfive,stg-syscon"); + + if (IS_ERR(pcie->reg_syscon)) + return dev_err_probe(dev, PTR_ERR(pcie->reg_syscon), + "failed to parse starfive,stg-syscon\n"); + + pcie->phy = devm_phy_optional_get(dev, NULL); + if (IS_ERR(pcie->phy)) + return dev_err_probe(dev, PTR_ERR(pcie->phy), + "failed to get pcie phy\n"); + + domain_nr = of_get_pci_domain_nr(dev->of_node); + + if (domain_nr < 0 || domain_nr > 1) + return dev_err_probe(dev, -ENODEV, + "failed to get valid pcie domain\n"); + + if (domain_nr == 0) + pcie->stg_pcie_base = STG_SYSCON_PCIE0_BASE; + else + pcie->stg_pcie_base = STG_SYSCON_PCIE1_BASE; + + pcie->reset_gpio = devm_gpiod_get_optional(dev, "perst", + GPIOD_OUT_HIGH); + if (IS_ERR(pcie->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio), + "failed to get perst-gpio\n"); + + pcie->power_gpio = devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(pcie->power_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->power_gpio), + "failed to get power-gpio\n"); + + return 0; +} + +static struct pci_ops starfive_pcie_ops = { + .map_bus = plda_pcie_map_bus, + .read = starfive_pcie_config_read, + .write = starfive_pcie_config_write, +}; + +static int starfive_pcie_clk_rst_init(struct starfive_jh7110_pcie *pcie) +{ + struct device *dev = pcie->plda.dev; + int ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) + return dev_err_probe(dev, ret, "failed to enable clocks\n"); + + ret = reset_control_deassert(pcie->resets); + if (ret) { + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + dev_err_probe(dev, ret, "failed to deassert resets\n"); + } + + return ret; +} + +static void starfive_pcie_clk_rst_deinit(struct starfive_jh7110_pcie *pcie) +{ + reset_control_assert(pcie->resets); + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); +} + +static bool starfive_pcie_link_up(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + int ret; + u32 stg_reg_val; + + ret = regmap_read(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_LNKSTA_OFFSET, + &stg_reg_val); + if (ret) { + dev_err(pcie->plda.dev, "failed to read link status\n"); + return false; + } + + return !!(stg_reg_val & DATA_LINK_ACTIVE); +} + +static int starfive_pcie_host_wait_for_link(struct starfive_jh7110_pcie *pcie) +{ + int retries; + + /* Check if the link is up or not */ + for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + if (starfive_pcie_link_up(&pcie->plda)) { + dev_info(pcie->plda.dev, "port link up\n"); + return 0; + } + usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); + } + + return -ETIMEDOUT; +} + +static int starfive_pcie_enable_phy(struct device *dev, + struct starfive_jh7110_pcie *pcie) +{ + int ret; + + if (!pcie->phy) + return 0; + + ret = phy_init(pcie->phy); + if (ret) + return dev_err_probe(dev, ret, + "failed to initialize pcie phy\n"); + + ret = phy_set_mode(pcie->phy, PHY_MODE_PCIE); + if (ret) { + dev_err_probe(dev, ret, "failed to set pcie mode\n"); + goto err_phy_on; + } + + ret = phy_power_on(pcie->phy); + if (ret) { + dev_err_probe(dev, ret, "failed to power on pcie phy\n"); + goto err_phy_on; + } + + return 0; + +err_phy_on: + phy_exit(pcie->phy); + return ret; +} + +static void starfive_pcie_disable_phy(struct starfive_jh7110_pcie *pcie) +{ + phy_power_off(pcie->phy); + phy_exit(pcie->phy); +} + +static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + + starfive_pcie_clk_rst_deinit(pcie); + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 0); + starfive_pcie_disable_phy(pcie); +} + +static int starfive_pcie_host_init(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + struct device *dev = plda->dev; + int ret; + int i; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_RP_NEP_OFFSET, + STG_SYSCON_K_RP_NEP, STG_SYSCON_K_RP_NEP); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CKREF_SRC_MASK, + FIELD_PREP(STG_SYSCON_CKREF_SRC_MASK, 2)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CLKREQ, STG_SYSCON_CLKREQ); + + ret = starfive_pcie_clk_rst_init(pcie); + if (ret) + return ret; + + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 1); + + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + + /* Disable physical functions except #0 */ + for (i = 1; i < PCIE_FUNC_NUM; i++) { + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AR(i)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AW(i)); + + plda_pcie_disable_func(plda); + } + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, 0); + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, 0); + + plda_pcie_enable_root_port(plda); + plda_pcie_write_rc_bar(plda, 0); + + /* PCIe PCI Standard Configuration Identification Settings. */ + plda_pcie_set_standard_class(plda); + + /* + * The LTR message forwarding of PCIe Message Reception was set by core + * as default, but the forward id & addr are also need to be reset. + * If we do not disable LTR message forwarding here, or set a legal + * forwarding address, the kernel will get stuck after the driver probe. + * To workaround, disable the LTR message forwarding support on + * PCIe Message Reception. + */ + plda_pcie_disable_ltr(plda); + + /* Prefetchable memory window 64-bit addressing support */ + plda_pcie_set_pref_win_64bit(plda); + + /* + * Ensure that PERST has been asserted for at least 100 ms, + * the sleep value is T_PVPERL from PCIe CEM spec r2.0 (Table 2-4) + */ + msleep(100); + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 0); + + /* + * With a Downstream Port (<=5GT/s), software must wait a minimum + * of 100ms following exit from a conventional reset before + * sending a configuration request to the device. + */ + msleep(PCIE_RESET_CONFIG_DEVICE_WAIT_MS); + + if (starfive_pcie_host_wait_for_link(pcie)) + dev_info(dev, "port link down\n"); + + return 0; +} + +static const struct plda_pcie_host_ops sf_host_ops = { + .host_init = starfive_pcie_host_init, + .host_deinit = starfive_pcie_host_deinit, +}; + +static const struct plda_event stf_pcie_event = { + .intx_event = EVENT_PM_MSI_INT_INTX, + .msi_event = EVENT_PM_MSI_INT_MSI +}; + +static int starfive_pcie_probe(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie; + struct device *dev = &pdev->dev; + struct plda_pcie_rp *plda; + int ret; + + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) + return -ENOMEM; + + plda = &pcie->plda; + plda->dev = dev; + + ret = starfive_pcie_parse_dt(pcie, dev); + if (ret) + return ret; + + plda->host_ops = &sf_host_ops; + plda->num_events = PLDA_MAX_EVENT_NUM; + /* mask doorbell event */ + plda->events_bitmap = GENMASK(PLDA_INT_EVENT_NUM - 1, 0) + & ~BIT(PLDA_AXI_DOORBELL) + & ~BIT(PLDA_PCIE_DOORBELL); + plda->events_bitmap <<= PLDA_NUM_DMA_EVENTS; + ret = plda_pcie_host_init(&pcie->plda, &starfive_pcie_ops, + &stf_pcie_event); + if (ret) + return ret; + + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + platform_set_drvdata(pdev, pcie); + + return 0; +} + +static void starfive_pcie_remove(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie = platform_get_drvdata(pdev); + + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); + plda_pcie_host_deinit(&pcie->plda); + platform_set_drvdata(pdev, NULL); +} + +static int starfive_pcie_suspend_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + starfive_pcie_disable_phy(pcie); + + return 0; +} + +static int starfive_pcie_resume_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) { + dev_err(dev, "failed to enable clocks\n"); + starfive_pcie_disable_phy(pcie); + return ret; + } + + return 0; +} + +static const struct dev_pm_ops starfive_pcie_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(starfive_pcie_suspend_noirq, + starfive_pcie_resume_noirq) +}; + +static const struct of_device_id starfive_pcie_of_match[] = { + { .compatible = "starfive,jh7110-pcie", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, starfive_pcie_of_match); + +static struct platform_driver starfive_pcie_driver = { + .driver = { + .name = "pcie-starfive", + .of_match_table = of_match_ptr(starfive_pcie_of_match), + .pm = pm_sleep_ptr(&starfive_pcie_pm_ops), + }, + .probe = starfive_pcie_probe, + .remove_new = starfive_pcie_remove, +}; +module_platform_driver(starfive_pcie_driver); + +MODULE_DESCRIPTION("StarFive JH7110 PCIe host driver"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Jan 8 11:06:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13513299 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 79DA9C3DA6E for ; Mon, 8 Jan 2024 11:07:23 +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=3RjDNtNdnHFONxk9IaApAiihv5I7VJ+yYl5crP0hy1I=; b=YvtOX8slc9qBUf yF5d2Iu+a4uzHvp90r0RCTMDxhIugKK1Ep+NM366K8xyQcgsjnlneIX/HslGaAccfrzEqcXSS/f4h 4uh5GvPWPXYGTaX04krcnvNuWSdTke6YIP5Pl+I+1bxsChHN8AqoIN4YcxdQ53GsNLBTu/80F/l5I XBSXq0MX7CuxlSg05FiFTrtbg9MsoF4h3+lCt4yRtiwypQQ6CgWJMkRhJf0EGZNAE/FAOdYd0J1md o8LzkgOR4fA4OvnsobP6Oc0tIHi1cE7Z1DCFO1crRS+HxX18DrFbY8BlUYEy8j3rX73EN4Bfq3/B4 9bXifB4dSLRQUPOF7NyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTQ-004hLT-11; Mon, 08 Jan 2024 11:07:16 +0000 Received: from mail-sh0chn02on2060d.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::60d] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMnTL-004gwv-1r for linux-riscv@lists.infradead.org; Mon, 08 Jan 2024 11:07:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcmS4Xo/vfDZ03V9e6QIYsRrgEOj6ihfmIr7axinSCEj9yGL3ndytWcOiTmkJUYvg1CXJpC8Y5xEyu7l8QvVhSXXPP14HM1iSidgij/3kL37xK5TG0/GLem7mPuBchjTN6VXDQGT0/QFurNtWnOMfIxOlUwL+eHN5bXiunceOFxLCSNNKuY9vOBk3jBKr6Kb7do4WA53EkJv0MY74go2rtZkek8DpgEANCArWJznk9Mr+QecSBDq4CXMtzBqxMkcKyKqkE1z9dOX/JMn0DcLRGV76f0edJiM6y/ZVEqLpZC13bWr5+6iL/HwyA2C29Xqf/aOZwG6G5vDQQd/m1WYNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nIXi8JBQnxVNAlvrZCPiLc7iuf6UII3Un7BOHkCInrQ=; b=cf8FmjqClcwNqJhrDg/xlOKY3dpJ0Y/g5REAQdXLnrmlu/znev7407nHalyG/mp4HzdyZIrDSLyDTbrd6pv/JKdjfuAeRJZ4A/fFSvlFvfEYrB7l5t1hKtnzAd+0Xj/CI6q2CWqFV49+pDXKmcUiQYE/07CyARxuCmG7HVlNAscMwPaqmFWL+CZrKp2QFH3KRCke7fH2r1erHt6wcb6A72wAmoFGIL1XXyxzq0PZ76tdraI/PlwL8lPi7Y2ARkbRmQntIV2ybzW2GkfxfyopJjA6eXNI6RJFjKOwRtulzQnmc/XCsg/p8IpAYIHiUFAdoKN1SUup31bSZ9BPM21Odw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:07:06 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:07:06 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 22/22] riscv: dts: starfive: add PCIe dts configuration for JH7110 Date: Mon, 8 Jan 2024 19:06:12 +0800 Message-Id: <20240108110612.19048-23-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: de845b7b-d4b4-42f9-f18d-08dc1039f32d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Au/8Vz0+INYcsoJuhF4WP5xN6C5UqtSNGgbhPwxRWBnURCef0OLthtRM1vX0J5hRWmEIn4/T5C4gLFdsVqgrTyH+rc/mTq5cWIDM1pgIDyCMBur5BYV2MGrfNKKULSKJwmYYdZH1fz2kPQdeqZa1peP1OFXW4wxMa8cbEiVgCzTtsdmGfNE+2WJH0J4yIVws9VqYTDBk0g5h35kqz03pWQCUdQjSkfNa/esl3VGTdIqGQd3vOfQNoMfIO/rGS2RNeVVWheB+SiKtyiCUuse2ISv6Bo/EA7TuMmiATPgshRmGi7QFSbo1Pjs2tXveRPx7i8+Q7YSmjCEmIHyG59ttKTZxdmk63s63m0+cKrC6N6m9ozfomZ6qaPobG/XnE077ia24Aw14UBhLVwKds1RdIMQ+ODVksKkZDboGNjqO7v2+Xuu7p/DblWQok06V+2TILvnMFCbD6231PaS4IhhMQvZqAnTynEnh/wvs2Tvc9WPuWU719I/PiPEMs+dGEAJ57a9Ai1A7WSOifZRjqyqoCJD3GPh2qd5YPG79gp96Thl9E6MjlxoGT9DHbZk4j0g0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjjHs1FY8r5RTSAc1V1pOA7pkaAFV+TrtEVv0KzF6wkbV1tMq1Lg0OXyykjtW60DP7rQusT67dXF1B3OwqmXH2MsY4tv46KKauTDks+aNw5y44aSwe6jLsPN4N5yYb6cYXr9+Ik/jzG5Ioga3Dlz/HmRrIsdAMwb496M6hxETKqj+2sCnbFAGlMEgxFeSgAjWv+BPY9mXavXjXCPb9iH1H3q0tfvk/U3Sxk/25Cf+rstykFdByb2mAtJO2iqOLj7VfGFaSzwcPrlY/36xYTPLDuobMxdyVrten0zqSqVgi6X0PKeZ22AjbXS2MQk4zicHUoFSVYib5F+76jld3uq3Xj1CnMPHdfzziVWH91vQ0TRNhPqyfC5COVyaheL+vnK1LmUoB9CDvWpVoZevt/8BB7prRj8cvdv+hPf3Wd2Tp5MNROOnEezFxHiV/28vcCLjxDgY6qaj+0l36/CShjFv02+gYF5ie0Ae8CJZdSaACBRqWCFoZnTohSQ5qr0Wwh+dsHU672xMffi3CmEqdeFjDhyw5If5jK7SOL56bdOlxA80jHQcvD/7bYNLkJFppHnpDUsi1N1FysqykERL3ipT49KKr088/mtaHhR0Fr0e2qf5RQP+I/oN+ufnov3dXqmTHThUbeULgetJmd7xQ7ObT4TSLN2WO37gwimqPbP+Iqv29swzctXs704xoyDnm4jAhwWJLhUgO60QfIJraTg4S6sBJ6xZY1NxgAa31i97xQBcWTIcDLvwRYuY5T+flddmkdfT5cj3KDQMZqvC8boKrMvOMvJReV6VgbH7+GpPdNi6oHEraSmEHKpnEkn101QzaiS9QPKfAfJ++JLrnKrzI6y/qaZKIMoNn9Y0bmxfscgBL/tSY3p1kLBPFk7xR+jb1zMSkDf6/oT+IH4T0CEeAeJcSBND7LAU2jH/1yiS24Ybnij828Du/yDmmif1HLR3h6zZrFJPtqu2246sc1/sZpas2oKco4bm4fonxXWBeIxCXhRo3ePVUmMB5P6YfoGDZcSdKvaemVa1vNsZLTIinHIIt5pA7AQ74Hz4UtbqzCOxtpyXMh/9ArL/HUiPGsL5v1T9cOUBU+4vDqk2z0yMxKWF57ReaTzEfSBZMXWnLGaeWJ0lFpLsHL71etoj0h/YX/fdIdDHVbC7mxJp1wqnjsu/tC6sdF7a4hLTbSFWScGPixYspWPv+URgq45sFs8OA9m1Y7KsFAnCi/rTlLVNXooNABeeNA/ePiQIgjPvWzfF9ODdPirWCTxZqzucpSQjbBn03cEpfe9h20VrJOrieqLT4oobW+I4yDSZNcxDiCFzP7Bb2KhFdRjhnwka/X1iDPcfgE1pUm50gvRABrVRQdptdeFcwWzO1c0nbCJnwO7pzYE9R5StU4UcYjI67m+oPe4Y7iBmQat1udrKT45CkzuchB2wYdRdwzPw7yz9PEuXntI4U0VWwWBXcA8InXy03NT9TXJxZkrixzdcqI1nTgNXGhtEs79lXtbT7dDRSMXphhwWQKR5pnyz4CzkGP5iGwlzpm2B4Is+guEjraGWxf+E9/Yd8E0PB364pw/xECS1Nik1pdiejVDQ6sT3yTjR3qiKT3e9ULQJXCZ+olc6A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: de845b7b-d4b4-42f9-f18d-08dc1039f32d X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:07:06.0221 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2CeAkd7su+36H9bEo1LJ28pvECYhwOwPfDOknYCI16hpLPfH77nx79b14S30urmZG2P4lSKBtBwCYe+AVZXP9MgmDZZyQcpikxvikMmLnGQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_030711_704202_E4B18B30 X-CRM114-Status: UNSURE ( 7.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PCIe dts configuraion for JH7110 SoC platform. Signed-off-by: Minda Chen Reviewed-by: Hal Feng --- .../jh7110-starfive-visionfive-2.dtsi | 64 ++++++++++++++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 86 +++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi index b89e9791efa7..2f8056d6f817 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi @@ -287,6 +287,22 @@ status = "okay"; }; +&pcie0 { + perst-gpios = <&sysgpio 26 GPIO_ACTIVE_LOW>; + phys = <&pciephy0>; + pinctrl-names = "default"; + pinctrl-0 = <&pcie0_pins>; + status = "okay"; +}; + +&pcie1 { + perst-gpios = <&sysgpio 28 GPIO_ACTIVE_LOW>; + phys = <&pciephy1>; + pinctrl-names = "default"; + pinctrl-0 = <&pcie1_pins>; + status = "okay"; +}; + &qspi { #address-cells = <1>; #size-cells = <0>; @@ -513,6 +529,54 @@ }; }; + pcie0_pins: pcie0-0 { + clkreq-pins { + pinmux = ; + bias-pull-down; + drive-strength = <2>; + input-enable; + input-schmitt-disable; + slew-rate = <0>; + }; + + wake-pins { + pinmux = ; + bias-pull-up; + drive-strength = <2>; + input-enable; + input-schmitt-disable; + slew-rate = <0>; + }; + }; + + pcie1_pins: pcie1-0 { + clkreq-pins { + pinmux = ; + bias-pull-down; + drive-strength = <2>; + input-enable; + input-schmitt-disable; + slew-rate = <0>; + }; + + wake-pins { + pinmux = ; + bias-pull-up; + drive-strength = <2>; + input-enable; + input-schmitt-disable; + slew-rate = <0>; + }; + }; + spi0_pins: spi0-0 { mosi-pins { pinmux = ; power-domains = <&pwrc JH7110_PD_VOUT>; }; + + pcie0: pcie@940000000 { + compatible = "starfive,jh7110-pcie"; + reg = <0x9 0x40000000 0x0 0x1000000>, + <0x0 0x2b000000 0x0 0x100000>; + reg-names = "cfg", "apb"; + linux,pci-domain = <0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x82000000 0x0 0x30000000 0x0 0x30000000 0x0 0x08000000>, + <0xc3000000 0x9 0x00000000 0x9 0x00000000 0x0 0x40000000>; + interrupts = <56>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc0 0x1>, + <0x0 0x0 0x0 0x2 &pcie_intc0 0x2>, + <0x0 0x0 0x0 0x3 &pcie_intc0 0x3>, + <0x0 0x0 0x0 0x4 &pcie_intc0 0x4>; + msi-controller; + device_type = "pci"; + starfive,stg-syscon = <&stg_syscon>; + bus-range = <0x0 0xff>; + clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_STG_AXI>, + <&stgcrg JH7110_STGCLK_PCIE0_TL>, + <&stgcrg JH7110_STGCLK_PCIE0_AXI_MST0>, + <&stgcrg JH7110_STGCLK_PCIE0_APB>; + clock-names = "noc", "tl", "axi_mst0", "apb"; + resets = <&stgcrg JH7110_STGRST_PCIE0_AXI_MST0>, + <&stgcrg JH7110_STGRST_PCIE0_AXI_SLV0>, + <&stgcrg JH7110_STGRST_PCIE0_AXI_SLV>, + <&stgcrg JH7110_STGRST_PCIE0_BRG>, + <&stgcrg JH7110_STGRST_PCIE0_CORE>, + <&stgcrg JH7110_STGRST_PCIE0_APB>; + reset-names = "mst0", "slv0", "slv", "brg", + "core", "apb"; + status = "disabled"; + + pcie_intc0: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; + + pcie1: pcie@9c0000000 { + compatible = "starfive,jh7110-pcie"; + reg = <0x9 0xc0000000 0x0 0x1000000>, + <0x0 0x2c000000 0x0 0x100000>; + reg-names = "cfg", "apb"; + linux,pci-domain = <1>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x82000000 0x0 0x38000000 0x0 0x38000000 0x0 0x08000000>, + <0xc3000000 0x9 0x80000000 0x9 0x80000000 0x0 0x40000000>; + interrupts = <57>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc1 0x1>, + <0x0 0x0 0x0 0x2 &pcie_intc1 0x2>, + <0x0 0x0 0x0 0x3 &pcie_intc1 0x3>, + <0x0 0x0 0x0 0x4 &pcie_intc1 0x4>; + msi-controller; + device_type = "pci"; + starfive,stg-syscon = <&stg_syscon>; + bus-range = <0x0 0xff>; + clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_STG_AXI>, + <&stgcrg JH7110_STGCLK_PCIE1_TL>, + <&stgcrg JH7110_STGCLK_PCIE1_AXI_MST0>, + <&stgcrg JH7110_STGCLK_PCIE1_APB>; + clock-names = "noc", "tl", "axi_mst0", "apb"; + resets = <&stgcrg JH7110_STGRST_PCIE1_AXI_MST0>, + <&stgcrg JH7110_STGRST_PCIE1_AXI_SLV0>, + <&stgcrg JH7110_STGRST_PCIE1_AXI_SLV>, + <&stgcrg JH7110_STGRST_PCIE1_BRG>, + <&stgcrg JH7110_STGRST_PCIE1_CORE>, + <&stgcrg JH7110_STGRST_PCIE1_APB>; + reset-names = "mst0", "slv0", "slv", "brg", + "core", "apb"; + status = "disabled"; + + pcie_intc1: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; }; };