From patchwork Sun Feb 18 10:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp722107dyc; Sun, 18 Feb 2024 02:40:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWefsNZrBPCA6q4EBvXGFlwV9Pu9fty1Qu43QYVpLBXjt+GfA8f9eyBNrb5y3gJqHvN5nVzWj8ykhC3Gi0NSghr5lYImQ== X-Google-Smtp-Source: AGHT+IGgSdmkU5JJQDhWu/MgWjDscqYcn0hNinzqYOzUzLKi1BCStnoqUsJ+2/VJlX9FJQpWgxEF X-Received: by 2002:a05:6358:7618:b0:176:3e0d:9910 with SMTP id r24-20020a056358761800b001763e0d9910mr11338376rwg.0.1708252843975; Sun, 18 Feb 2024 02:40:43 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f13-20020a17090aec8d00b00299458cffcbsi2871857pjy.22.2024.02.18.02.40.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:40:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70339-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70339-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70339-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EBC89284694 for ; Sun, 18 Feb 2024 10:30:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03EF239FD9; Sun, 18 Feb 2024 10:30:13 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2129.outbound.protection.partner.outlook.cn [139.219.17.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53910374DD; Sun, 18 Feb 2024 10:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.129 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252210; cv=fail; b=aLceJrSzR0iCHVDO/RjZjvj6aZhyJ+fYiZsZCaU3YqDGfC0iOvOtPB31kWlyWZVyWZdWaMatf2ZUqKAxyIZue8zH6HoQMI1ggZuHCHhSUADnqWVXjEX0mougltFTVdWoDvOyOeloCzyArT0WbgdzULYQYk4NQaGBq6DFM10+1+o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252210; c=relaxed/simple; bh=153z9nphCTtjtmLY0yRQaHO9ivj+TovGeZp8rlL4AZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nT+5uyl0h2xNbhO/QWn4hgaVqfxYweoozhdxSHgDHFjqJvUKG82VGJ482cRw/aytdhsn2tFN7SGp2nUxfmqnl10qmc9k7MovxOnG5vCfH7clzzAlHLbxpuKc0zFQyAqEMeNWf58Unsb/6csONVCN2jxwpF8KIgjO5lzvjdWRLz8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.129 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ej7pjPbsqzuqTwj8XbekSN3ETlX4O/GNFg54N+JL+pgbCGHXxYLRT5dj8zFmB1f6ooQASwzNKgnG0oaqRD94Ba64EAzst4WHYHUrZVfAKDz+n+Qv5w1D2naDX/dMg/J9EeCcHRzbb6C6mXG8axIIEK1+HSzDrYcm4VQBTkxZlnXW9Q6Q01PMRuA/8adhqZ3Xio8GqHHh23izbkq/YxyA4NdeC+cSa/nBQnh1Gi3iy4Q2/6Lp9L3057ieepmkTbcN5mw3ph3UriVZ/FOjhltS1NhSha2jKxUmibxzCu85GcjsmQgKfuXnV7QBqFMY0+sx4x+8/Ft9aAWnIIOpq2Cc0Q== 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=Ctyf8IdVWlTz4QXO21WPLuub6f1TJbAJm7ECo9RHHR2HCCFnwCvq7ZrUsvPDfrtZtWeZbiNQ7wn/uK8J8PCZe24OpQRvaACMX6fpm6pYopYB3Yj3nIrp+EmRDkgCTQrkO4PayuS+L9LSsU8z4vlOeeAhUVambw143vQ+DVPal/0tXkAg/jGxARjmv7BdFFbB7ZUj4DbnIbQl7bTjmzxX1sF0s2oEGANYIwDP5bXRRjOosrcnJVWtv5716hHP86leVDJ/g2bocWMAmM1VdQdiblYOjcotvkHHjQ2aMZJ72nX3/pnN/ckuZO86YXDNjq1S+YWZVOT2qcIN/ImNBUyZ7A== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:15:39 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:15:39 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Thomas Gleixner , 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 v15 01/23] dt-bindings: PCI: Add PLDA XpressRICH PCIe host common properties Date: Sun, 18 Feb 2024 18:15:30 +0800 Message-Id: <20240218101530.113306-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101530.113306-1-minda.chen@starfivetech.com> References: <20240218101530.113306-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0019.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::28) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 256dc340-5454-488e-9396-08dc306a8e3c X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m07vXg0GA6d+0RHOn43g1WrmmDmvUoSVwCPsw3J/rbCLu5gpSpbBiiOBLihaN3sJJxct8aPEeaDaUHLsny0km4kMQqkCgGbrA2ve7XnElB+yagCq1fnN+PJqpQDtLl4hcdExRdNi5gTC/iJ8kvzwu09iMyOxkrFsdxWXEzCP6tFOS/4KceUa0nM4hbkUCrCm9QvrJq7Y/xvbCOQyz3f0sB317zMV9kvaQshw7d6PgLKsQZLC6ssUOpQZb6PX/C3pmCNtk7uYevSMIlhxfOuyXl75m3Ns3pjtXCIgsRMMLVn6LDJxRnCr0simk/jpec8saXnwngPxjXi0MO0Qd1WZLiwc7dak/y2KLL7B7feTGQlcSTcL0I0nWg5o9CK6ull0gqH4G7D5j3LlkNKcf0aKA7Ixap9vED92AOlBG7rcs07iwRZebCxorL3YDsluu7ViYMibEqhOTdbtSr1aLLwBhzA3eVxgxW2F7oV+urroI+7HpKKQ4pc1LRScBtthJh0bJfnGd4pLifZsersaAny64vPV1O4pyKpmncKAEWO8zL2m+H2cf8MP+rvbDMj5EiKO 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(966005)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qy25mHapg9j+crG0IE7fOG/0wFKiqF5ePEfK6saGu+Gz7dA5eTQT9pk+MFIfA5AwGWs74XQI9EGjrgcWksF6Xjt5BgT+Ht7CTCLdxtSkyhgIPzs7B3CJEg2txRCMe7vbNdAUfsF8nsGRqam4IIWkwPC95vA9FzlYOc77tHl7V9PAWJou1d7fCHErHqqCYj/znCrxONOwAkQye1JO0z6NiCi91zonDr+EsjM+i6gq4JbNl16OH7ZZoPYZOCCf5bm8wCyR2+/kr15jSxYGiOPDzVz2bHh20u1zdoFvINYzt/InI7RDLax4LV7G30/EH1EHryLE+VU+VBJLED/mZu7hvjs9P+JRpRcCPDKiGdI+UKwgwTYw3Oun3xKggxFVEhC2amEFG1liGOgOAzkcT3Q5lXTNmNQgZce85tkryYEYIU/16VgsdTZ9Idbb5oto+awemyapU/cFGhStmQ8HunhppoakpucVpHd11NzozLAScN6qxZr0dyRviKwTqzcx2ZHkpKczG8OXfkpbvWQxrMR7izPYeb2MTXi4lGcdXmQnY45KN9Phv5BG+WfuD4Z1Qx3J//Fg9/23hQuNz3eoLo/Dy1rhfoA7DqEPYJ3/rBvbh9+AURoQZziMzsgR0kOa5UltZPhNP/ZDu34/KcIcwiW7fSsMnxrPv3QJ8yL/FBMujg+/KZXsfCmFlJ0GFrgK4AtIz85T52EpG7zt6bcUFNxIgKQU5NYHOXNTV48mVsPrHFDtuXYqr/KETyF75cohXoKo7KtqJS22t/3wST9qQrMLEC/mouocS2dVE1WTVhMxGW/LHm5zwKSdpCXWtDCU7FTGkGVrn89XQYpHDYqGE+cl6KbogGAEsyCWBwRHABazbpltqlLDfgqX1VPdfdakwkM+NBpEN0V9lp2vi4zMfYQAFyIwu8r5zyVCxFlkkzZWz4k81fNqDXru/CNeJm2D2dLqhfQN9pbWOi6rwWFBIu45oxMYX+CQvOCHj145GKLT2uTd6XYseSFPfDy15WGYgSrEU8uREH8rFGJ2rNRTotJ3CoTY0nCZLzX9SpFsuCD6drwKNkwtAWKJv3pIohDvV+OYFvOYfXGVV5WIIPkoq19FnhZwuI0veinLB0kmQHWRuZ6VhQZJklGFNr+Fg+el13daDWDDmP4Ql0g2nxEL7QdutufKHgII6nfgtl1Q5DamZ+fq0b01/V7lurM4NkNy5upP0/dQGGuG93l0uGWDv3yQ6TgqB2rzmReEvJys7E97EcRlCgsBkY705l80ESkkH/1rXqi20qRPFjco8cYLi/TxCEz05gwcIftVAJWlSl8c6A0F7IG5edEoJbyMsLJh3uy6vr+xwVjfBTLlsTgvBVIlResmc4kwm8xXnTEpaPNb0+oyv15WO1G6+fd448CjISH/HuSyW0K3oAmsU3XdTvp8Bosz6VKkdsRDTDHjqO6Ii0XeWQ6p1C4blEbaof0bE1EMF1HuhvS6neAApRwEcmnYlznuTVsBM/q/efWxVVGY+e4ftzXq9qlilu+13BcOlgNLraA0tZKvKOy0GYuQtn1Zsnp6EYv9iH1B1kZsiYqUJbI6j8w1xuQ4Smsprqts5P+6QtXtguz5TQThkr2mFpz84A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 256dc340-5454-488e-9396-08dc306a8e3c X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:15:39.2193 (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: LqeNtsqDqa5RzEhc9JWwKVhFGq23WfFGrEIqqUYK5ZrntCzPusWfiqdHpc/rO7zeBJhdmgQsKTaWlKbtRKUggWSU/bezLZJRwJb7y8WKMKI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232933749423423 X-GMAIL-MSGID: 1791232933749423423 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 Sun Feb 18 10:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp742495dyc; Sun, 18 Feb 2024 03:49:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxLTQyrvZHQbaZrg1PHVzDUJVKN28PK8SrUVHz777b98YVQXqTbdGCWoqC38aZcptDmVcLHpZCDqfz97LQ3MM6//7Tvg== X-Google-Smtp-Source: AGHT+IExsOIp0WkvCQPoxkzIxsCD4ZMp/k5LsOq6CkJVs8zNr+FDd7VBjy7FLv/7f4CIOVYIT71s X-Received: by 2002:aa7:df14:0:b0:564:6b09:92f6 with SMTP id c20-20020aa7df14000000b005646b0992f6mr390318edy.18.1708256997825; Sun, 18 Feb 2024 03:49:57 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s21-20020a50ab15000000b005646c29cabdsi189908edc.283.2024.02.18.03.49.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 03:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70371-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70371-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70371-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4BC111F21A2B for ; Sun, 18 Feb 2024 11:49:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F1D763510; Sun, 18 Feb 2024 11:49:44 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2121.outbound.protection.partner.outlook.cn [139.219.17.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F7264EB41; Sun, 18 Feb 2024 11:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.121 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708256981; cv=fail; b=kff1gpSxFAY9+XCW2R8fMfr6bckK0pgitKyRlOpgjQeH+CLp1QWbSD8RsZzRAqTixAGXQmjWKvXlCUlo9GJ31jdk9xoTEx3CtrsTXmYoPRw7a98kt0zH0pEOSu8TZJLCSP5xCD5IPjbkSWhp2tcFRikGVUU1kpUdhE4KLL4mDRY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708256981; c=relaxed/simple; bh=0zKdFaBEvvTpoknHfFCIpkeI8FGLQQLyd6lI7L5NVyQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=g6pGhIaxbwZwnv6L0N69f6k3H2x9FTQcBFa/5nG0j3V57FKaYfP0RLRBr84dFTqkpjN+EdAmZlAOkdqW5iy7ncNh4u5qtftRjK76fUXrKPVom4DBQWUh1SHxFH+X2BpNFKjnLBumxzS4pcJGeA51kAfnhZBPa2MsnngAiqr8dPs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.121 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cs9DVCcSJdjD3KqxtPCK7DOBmYEAqSy8wlTbMZdSFNURwCqE2qeDzsstmBfcl+TP6F0QExQ35WPQVdvO5tnL5FHjJgqIWq872zWewK+skbfG9419pxrirySks5v9NNdMiL+keQPQTTmCfILq4KAd0HoahcKlKy5MmdpW35c5Y+bvZSqWP7WtQHTfah/vwjH0j8d4nv4EinopFayLn5f9JwAAG3PFPOqPWLh8k9wI0kUKChF13JfejM9F7i1tBcEBcRqRsPm8GUvogSAZp0QF8M+s9E9LoD6ggXX+4stUQOgFXMScrIW3g4QeTm9YZncEJCAVVwBQ1x/g6JQ/dYCn0w== 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=vVCQG8bILR383viubFKulvnCCQ0XA9npwE7/M6Li5FY=; b=Crtf5gZa84VjhATQzpzATRBB99q+PJ+kHHBtnim0Gb8gSkyA+fEymTbiuWzIaxAuI7aPC0sE/emTZWCo5Y8RM1obophlFQchdk3Naf+kvBHK4GUmDe3ZLYimuMbFkIZkKJCQ6m5dxrsYXF3iw3LrDqXa1uyp+C4el4QYr7gF8oJGng03KfxmO9CuvoCUen6jhEaLeWNpv37tqYK/upF5sATBiHbktJI1bHphCyQ3t/TyzFGlOi8iYNmpn7L8iJE/gfz3LFAqXfTCdoapEmwKhJDWZM7AmYFrIQhPEg6YusJWXl61hkHk1/g+muVbY/c27+Rob+oXR2gNqe6ftF9P3Q== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:39 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:39 +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 v15 02/23] PCI: microchip: Move pcie-microchip-host.c to plda directory Date: Sun, 18 Feb 2024 18:17:21 +0800 Message-Id: <20240218101732.113397-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 92ebcdaa-84cb-48e4-913f-08dc306ad5ba X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MVE2nMsuFb41oXhHPD5JkrdI4ndwRUNry7NrcS+nQBZChHujxIyFTpeuFzxzfZVynrZ4W2TF8pWC8IFCOCCXpSi/+LAYqI8rx404JtIhTAoASUoYxOUR8B5ZQo4jJzVQj+G3u7NWE2xPf1COF+lnq9D2jfi1rt2YvcXEz7zU2MkpYpP4a6nqNNJKwl2jPkutJPLW7mK/8C0b05gBalIBILd6lgkjpJbnKNbCjnZzaN+x2d6Elrm5XOZ0xkxx40gbPySLaLFFq7mlbE+cj7QYe0DCPI6wVIr+prbL6/CSXikAlZ2Gd0G7b+fugWnQOMj/JV+6W0HvrsJnkokhpEySeU29q+RpIQeZbZyWIKObMCeyrSxMiBqY43ITM1BVeZYKRKUvwGaVXMAuLzfLQBFo5zRHRRBWUVEBZhyGMrmH8jUWhJrBuPeWK9ntHhdZRl0IjTkGDoSs3yWZMl/BFGQ5y/mkKcFy6sfNMQbqWVEyQ1/GAhQe1OYg+tcAx50seZvh1oZGlgBWzCyxDaEVWFrPslHEMj5g8wBv6aNdZp+U67M= 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(45080400002)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DwQtnWRKdPpB7wobOBIz1fyFDL0bprTeylA3eyS3QlpWuw3gC6hOVP5R2XZh0jMUPoZ217JU2QEa80/WBfz5pdJgihjV+A50M9APvwri6cCkEy2YIhYz5k0FkNmBF5iIGACZmA/fazZSfntQSZgu+Q7/4od1Pm5sn+hgvlG3sjXBpYe2QyH4y7Jdnofm1A/Fn1cdynnr9XB5Q9EIkDAPqbxaEpK8AUEIMOFngvX5n9qdknbxL1uK9eNJplnWF/JpOqt7UGyosdLe3tSPogUXdak5uB3BxM0z9XbfZTM6LIsK6SpRAwgjyEjIU9EtYojnAiNwxP2Xx/NBypMmzJ+zfXxohwq+KBxc1PWTgJOLIMhUXpThfr4wWpzinodJyIthRGTsfhj7s9RODvr5bfQOEqHxF1ZzI0Nwww5JqagGzNNBnAk0dAB1WxN10aTahmt2/bCBl1WJ5YC1q8Rxw+P5ctSiJM5ec/2V/D6EQdpR1xVMwq63bZP5vDAW4V465XR7cusTOJF1s4aVPya7mH9SB6ddmw3WuK6t6sJbjTxFs7GAlipfq6MI5fjXAV5cX2dyoNtC/2NCT0z3BCE+xkQ82atO+rmkXo7GIMeOJ+kp+l7uRRxv+u455nbbXfh7R1Tsdi/dTnqk8d7/6vTcdSSS1O4lVulSKGiscYtSxAXMbeV1uzV/l3H8rOrq2bWyJf588aNW0DzLLJJcH+rF6GxQRvrA7qkDosc3HcsE11S09/Mh+jK+aai9FVH3rg1MkqVealhnn4S400zoI01HF1rQXMum3pq0ivlfEbUrMSEtpdBwcYecPfsGZldTpYPfBePhCmat47aQnNqRLDHeoeOqXdbYnfXFaOqN0NJu0H2Vx6ZbQC5Df6dH2QYhiomaz13ViQpY1+SPVZeB8BBNWlAWnjg8xFk33NfylWBeuojjhqOvCRmTadA7Hc7eeKiyJ+Mk0TONoqK6Xt4OVdbkdY619xuYRFbAsyGexCvI8nApHJCETp+RBiES9Nzp+JXOq1gdEo2mkTi5XFBpXbPKFCPvqck2KKTVEXgwO8W1BfDp5I2DzLdiwImwBpcwSNKpHFytZJG0s8Zk2yb0EYmynV2DAcDiWHQEA5QgrxHN5ZSByzk+Rtn6xYXgGA4OT8W+cKZocf8wBcqBOJslh3CxXfGmEd/oBHnF/Yq07evu/q19xY4keIHMU87q8B3qJSO600ZOEsCKoqN6Qg1817RbjZrmkr76icm9QuLC0rXDupXYhoX6BF5jAjuGHAIf5vIQ1mgkel6f6JLj3w9Z4V2pm3hNMLCBquDid36lg+WFxnU+AzGodXoRu+aa9W8PKawRYGcsLn/MQkVC6xQL9G56m2PiAgrghSZJCoIBXKRtWMUsBsPUgd9ldbR4QYnhCRDUrNuR04Hfh+/H5w0bGj+l49R76slT+PVPHrbwI2EAEJgaYnyatFDUi33yxVWq9AG6P4fGE7pP79yD4S9mbxw8QSUaAcXmRCuK8yNzU1bFld6WULbKkOsG+xRx+G3kQHq+4Nt3EA8VdxbbhKAWGzmrHBBS1LEfotO14hUT0BnEjwoXJ4YgpzPF7M04fVfN5QWxYA3lGFL3Io/09VIIBFdca7qoAg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92ebcdaa-84cb-48e4-913f-08dc306ad5ba X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:39.1247 (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: OFXubbSX7vk/QnjDbi7onGpJog+nGjXl6n6EoT8JW6y02VEA6bNGOxi2SZ4IM8F1ElBb38QCX/H/4AZAWoisPmyJCRlTwDfKkSBA60wino8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791237289705073823 X-GMAIL-MSGID: 1791237289705073823 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 960512bec428..2c28fb28270e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17039,7 +17039,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 @@ -18831,7 +18831,7 @@ F: drivers/clk/microchip/clk-mpfs*.c F: drivers/firmware/microchip/mpfs-auto-update.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 Sun Feb 18 10:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp814011dyc; Sun, 18 Feb 2024 06:53:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUPQCcxFZakrna+hHlU0eBH/jhIYhvMdXfcu9Njx4Bpvf25C1yCpgm7ZOSHZZ0FFCO1r3uN6h9gWRWfTFlzFwhzP/54hA== X-Google-Smtp-Source: AGHT+IHOmm5btpHmOJ+ZeVT+jiLzP2cjG5dp4TZ0+BA/F7csQiRPAdCp1QSczMPlmTMfZwH6vt51 X-Received: by 2002:a05:620a:20d8:b0:787:34f6:a706 with SMTP id f24-20020a05620a20d800b0078734f6a706mr10539782qka.28.1708267996511; Sun, 18 Feb 2024 06:53:16 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ou10-20020a05620a620a00b00785d69d211fsi4252077qkn.444.2024.02.18.06.53.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 06:53:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70417-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70417-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70417-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 42F4F1C20A3F for ; Sun, 18 Feb 2024 14:53:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76F0B6D1A6; Sun, 18 Feb 2024 14:53:04 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2137.outbound.protection.partner.outlook.cn [139.219.17.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86975FBEA; Sun, 18 Feb 2024 14:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.137 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708267980; cv=fail; b=QmtcHE0A5/ljRB1EokmsX+LQd1jyUFAPAJeHISLYXb0KOAHIGmHJGO3Bgu7fgh6dmS+xC1bcVCbnq7hpa2FMoGmwEnY6tGcFeZFmkI1kbsdV+bsdkLGj0SC89ok7e0H2N7K6dcsrMdYJZmXdeKicq/dwk0q52nTGdAIB8FSvcYM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708267980; c=relaxed/simple; bh=qtdCexKf0RhV7NeUlusIXpJoviFDA09h0n1X+I3d4VI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UC4DBr6kzz+YC9YbPjAVhy8RJjf+f0W92wb7gSL/4IsDkpXJeQepGqX+ENDv0OASaiNVomzkoF1VFViHrJRKNJY2Prl8TDJ+t0nXH9J4g5womk6ukxh3Rq8vJSBxEYxRyuOuiKOX4PxrHs5lRfhN5PeFvELFkyOIFv7os3ZF0mE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGsqknNe/lFwsvynnTk3fJ8ArNaDHizPFdKnFMhRGgQ48uO9iLxNZzH8uyiP60Mi1HS+J9KgMknZJ8kmfsE0Ky2MuG6Zjx2WksD2KzqPHXyT8koh8itAcjyQzUxQrOpaZUMUuivNfCxl/QiVdxHzNAllJlrqBjgR8IwB4cRJYN5aZYFkW58aBYQzxN/w5OkqZ95IVuz0DiV+4jPB6WcGdd69q4AWIQF45VHBRMUBVrzr42/NpRsNwP4tqtgCDAL2CPEC3c5gydpiSTADnNRtNSIhUpOJ958GTsrhHfy2Q/7tvqdYMjubL728wHD7jkOLy5C2R5mUfpAJ8Ux3LVVXhw== 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=QNCECHR5VWLxr1Xb5YCK7OceXtaF+jtsMysQb83OPyk=; b=GFM957w38sJe7BMqIwdFhv9xcLz9L7GeiROPQjnv24aTD22OTp/vdokjcue9HJE+E3xbaQibVsWPCzMWY8k09lYA9vrgZ68+UYF3ZFlr5/P5RqVMO1WWLa3xTrzdOe997mW8mfB8THWVlzqFRZwveFCkTNW5eixlPtJsOtxECuaplIcHsCpUj3WXJt0kx/h9z4Lv8wgCHCTcG4IkXtpV7K3BBNzBMmRHWir748dGt1lpRYu6zP7swIHm1gM8VcaTWkVjdQ129hFHmkzrD9E+KJ+w1h4idyucYY2CafWdhFeLiLMSEHd+IrXBuMnyb3PW4Mi04sLNf0erpK/aPHTv5g== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:40 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17: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 v15 03/23] PCI: microchip: Move PLDA IP register macros to pcie-plda.h Date: Sun, 18 Feb 2024 18:17:22 +0800 Message-Id: <20240218101732.113397-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 7273949d-a2a2-4e26-c48d-08dc306ad631 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hyWTBFsxVNPvG61y9wAgWZXjVEN+0VsjU3AqpF/9Y+rZG1KqbkRJojXpAE/sf/a+fXb7x8juwYA4B4TN0qZAgHWGRJmDo10An3ceCBWoewnTcSA26sgZR5VhSGgXRonHLqGh2jasIXtnudOvYxFzFky1BG8reTfiwIum6fRbVPr74IL8Qoi4JdR4giDK9VwMoC+FBoN/9QO5FA5MOLePxQ3puuM28qAMP3i4J6R5IeGwgTwhGIAori7OJelidH90iyzFIM+xlBUyEWUTZSpkcTRdTZzedtCJUr3Vx04b04wnScG/NGAsBYag/o+s1hLGdfRlJX8kTlGeM03TsW9s6EBXJASz5cCNTPekVI/d9U2LONq7nVI7mImKRdSc5MUkBXsU/MJkhbLrvfmgbBsvNhO4XiSHp3ZnvJu1t00/nakOy1ov/Q7qjRt8I6pLh4TXfK+Lp1iLDiKqYvYS79JZFpspS1naYOP5u9G4gLnTzs9Qnop6Ozw+Tx2mdDb2g5Je3q5cF9zqFMVraia3KrFLAOAHD7/k+Rn+zT2iXpFRXUQjh4O7fEbYNiwBFmdyCHpn 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(30864003)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gV/V06eNLE19v5o8CPOzmSzMO9e2fPH84stcfn0sArUXyFiu6vs5DeU7kV7nz2SKYc1Q7KbTjgA3Bwfd9Tm5CLlfzfv/FV1VIQzO1yNk3N3+kxK59p60POdhVqaKtDzwtmeN4cU+rvjHaJWfcx+jcqZ7Uyz4D9YciCPKphxZq2WMOLWOA1TfghHJpVmnSSUG+6Ht8MMzpDUBJhG2nynxCjskpuIY48mUYtaFjfn9QNjRGWcWrJG7egdSaQe8Q3+cwRB8ChwDsjcDyB25L/3KVc9C9sQQza1PIPKgXIibE98K9K3cpGJSyD15MWF+5ilApz6ZT29jUjYA9epY5EkfhhvjEfQ13glKH5ZFarlqwwk0n0ZthLj3CraPaDspdDAvfJwgES9JbXek7U1SiPbl16/aKv/Curzb2b3AH/JrL224a+ZdYNwmKJsHB4d80SigrD3YziUEDFdqg9WUfLd5TMl13G8H+LQVuC6ybR0Qusjb+drouA8qxlBdEd+HybPFj54xAKI8fdlVzZ+y/2XeUzmBAZ0P6okKhVIASRNXnddOlv7weMU6IY8JpIaAmTSlhR92mn22NG2qNlG0DTdEMnM7z8KzllH2Ll9g3Y+2Hw9zxKd+sx6NeBhIdEKUIsFr1BkCmgibDNHRvkFSObpmLvGI5FiaPaE68dF28nstBmA7stuSUSOB7zoDr8zlFE2fHCXEuZiVs5XXgeNZ0DFGJtrgjv6UPFUflHvgoM1HW28DBAg8Yh6o5fUfcJuN9jhCDIItCLeTiDUQV6+ZFFD0InS1B7MgX3fnbcuZYJVO0gV/5AtwlHoc6ILLZUaA3uvy6i1h3DJGX1lqQ3H/Y9rd+ote47Bas0hla62KhK6tVULWN08Ecj6wmjp6bmRehjHmzxVeaeO0FQq8GdGNWjichPndsXZqYXco4E0hvV1tfsT8XANmL+gJ5VURS7IZNkY1/DP8Z4djCxW2LQt+yuzAUhuPoVjfO0jfXFzXxN0WCX0JvjbOzmaPbVHsCBl40KdiU4lH8mEtetNdcO04H3oFzynBYGQ++0lAzPDKauhaXI/iXIkE3P83ajwyl8M3mXPIQVaSypjp6DmfrMh+ARv/REY5AmnygaX2eUVugkI1W4ewQScuSp6/6w9Jh6p6f83DNFUoESv7BbevzD730afqtQ9iazACzDDadmRFXpkjJ5O/+BvTQFqRNVZOEvEe/0I7Awbm8JUkyAa/06ERJz3Upp1s0GiG5aBZIJK48E+BskRM8CIhwJGIGtuLuqK3iLeFXJgKcpPgV49AV+nH95Efen9h7//4clnmX7pfQVghFOt6sItlNERSOsbac/rMPIZBJDtS5mB/cbo29d7y86HI9G4Jn4IjkdXx0F25c7kyruihBY7WnIPJ6p942aD9Nb/OaMDP6BN5MmfQwdERIFwK+GpKATPy0v8SPZn0QcBN+2Ood+iF0i60buFQGGZmo7hwgA6O1LGJsLX2Iswxqfoov8rvUewi1jRQqnfEglMh8JHIDhUGGizNWIk490bez3uXi8r7u70Ib2lJuNKWlttdgT0tCQNUMBL33AGDcdIVaPyRJ1ZjIqAFxi3UA7O4p34xxC7atROxbmZpNzy3oXKRGQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7273949d-a2a2-4e26-c48d-08dc306ad631 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:39.9297 (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: 0IDbG/LtN8XvbmgFIOW0Dp64BYU3x69tU1GbSi/lLlmnQZedj5h1Yu8X70mEHSJINCZeG3OJC0XqGJosaXUIHwkaMyzQMJsU8a7pn2X2/4M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791248822514676580 X-GMAIL-MSGID: 1791248822514676580 Move PLDA PCIe host controller IP registers macros to pcie-plda.h, including bridge registers and PLDA 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 2c28fb28270e..9c2132fa6f26 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16808,6 +16808,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..65e0f3b72184 --- /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_EVENT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) + +#endif From patchwork Sun Feb 18 10:17:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp720394dyc; Sun, 18 Feb 2024 02:33:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWdSZWMIlA2DtHMSAGlWqmVWQciovYyrGxXFFS6rrCqQrjqX6CnXP7eEIjf21qKM8nI1rddFJKwhZWwvQjTj/fFkHZfDQ== X-Google-Smtp-Source: AGHT+IFZ+Ds0KVDQpEph4OzU/2DdTUnTko3MyXjwM072in3/n9AZIcHu7k6HhalYBFFt5VAu2M5j X-Received: by 2002:a05:6214:29e7:b0:68d:1272:2629 with SMTP id jv7-20020a05621429e700b0068d12722629mr13988352qvb.51.1708252434709; Sun, 18 Feb 2024 02:33:54 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gw7-20020a0562140f0700b0068c67a0fc45si3671922qvb.572.2024.02.18.02.33.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:33:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70342-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70342-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70342-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 722A41C20DD0 for ; Sun, 18 Feb 2024 10:33:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 976DC4F1EA; Sun, 18 Feb 2024 10:33:37 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2100.outbound.protection.partner.outlook.cn [139.219.17.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E19DEEAF1; Sun, 18 Feb 2024 10:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.100 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252415; cv=fail; b=ANsq0KqJxE3cAZvpiz7pKNo03joZr9ZywZli5PT31PdCFYRr12HrzbtcpR58CWnqe5JpR415R2NDSr1cXg03OFZ0NS/rrP3hqswFomI3cEVikU7WOL/Xi+0Bofw4iMy+9SA08/+Mz4CkcYi2+rBwT3Mwt0zuO/iU+5pHwCTTfRo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252415; c=relaxed/simple; bh=Jr9GqF0VedirT+pLXfWGwtgNFSVamL87RXSJnlSv/Rw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Po5La9V7LnH/AQatonR7cCrECav3N9e8twn9ged74E3sEreO/emrHX7kB7pzYQoEUquox8VkhQ+bvyRvEcvGEUYBqMkSboKJ3p/1Cl14lYVQt9+kyrwDKiOGeX38g1CkZP+wJKcG9PRt/Zw7uo18KZVOh8UChw29Aet20TAur/k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WcADFrQZ+WcRHciEN3UZh/QjaBbp/FsKhzrVFR3QCz0lBszJMxkdLbCkI2YAEayCIv+gM4eTrosRAWGoYfcNZJDQPVOzD3/Wu2oGvdWFlPNu2ByKSn36dzcgVJeS5uTds+a2R4n3RW07tQzG2eC/0KP5uranYwD9V02RoPyS0I1AWityfiw61QGkJ97MvMLWrictRquCIsKU90x4dn5b04TrOMFMgKiqbg1QN2cf4Zjo0qcGHT3IS3xKYa5mEvHPopmAsQSL0tpoYpbYOE03spnwWxoRra7w0EScKwjIFr82JbnkZR1oYY1QIhw/PaV6BQ5lcn2YVl6tvwDdRIZ6bw== 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=nCVJZswY1SVyvVcESOef9Z1i6L2oO+jqPVuLDDNOYe4U/k+f0QIPP9w1u1Y2lMtXu9YyEpTRn4AifAlxI6fGrPwJ/uG7Q1NyIij8MQc8kqWYTRSbz3m7ExQHfZ78TIQvoZHZjNb8xu/4834YhpcHsL7NM7Ka78INK9TXZnn8mQtyqq1JyOXLs5Q4elSr38Q87PVeJI8UMeHTn1pSEWq6F646gRvO6lS3j57zk0qyfmzSL2ZIiS94PeEvcx0UnAYt6DlyPR/wlRcXE5jqz1v2n5eACo+mmYZgCr2U6262mfbEMmw8A0wurEdBDBHrt4I0qx9PHhzSAuWwrdMeU522/w== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:40 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17: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 v15 04/23] PCI: microchip: Add bridge_addr field to struct mc_pcie Date: Sun, 18 Feb 2024 18:17:23 +0800 Message-Id: <20240218101732.113397-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: a964eec0-b5f8-45f3-5a08-08dc306ad6ab X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tNa8Z291KrHrTJJzq7fxQ8Cd4fisuO9gZI7jaqqpMzm/Qns1Do1UzXEYyxGTLwlhMhcNqxnYkZEZmKgyZ3EX6lnJBb+aPK3mNLn0+8uWOKa54UKpsOn8PSlu4Vw76iM0hp5+DHp/2bPUlnDa8RdLgSiGu6yszc3G45yWiElcyP+vJXvE8mE/7Vrwx1uBf65vBwncBuymg0ej5V6LOXmWbRK1f29V3lCcocstJZ41CH5oot6PyztHq5dbmvX2PqY4KAdm/3K3FOnXsqOjFrJ9G3cDNCBhZEYzKSeqrQBnwEUXhn6aqSM1yp1VpsDelw6JXvY0BYnjQA8MAkO0jx2R38VlZ34m/0UD+xxgpdA/GsA/y3ODRTe5CmKAvB7OOvIOyfb2wuLWL8m85G30ES77E9fD5OWRXmkOt6er/THpg5AyD/cDBT3Yo2yEuFNzptdylh1ZTPr+AxiAzwlzvURvJ6MzArFLb01H5IQMnqw0jReWGVDRQEGluE9RX2HqzdIzxYOb9K3QXXaO849FSkqKUDDEN/2RNyjcmI4RvHAfIvtmRUiDEhQ2YWdJOOBSWLEo 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qEM4QqnOgt1MwuNUc2/pdYRff4pnK8J6oJh6+nDAexRwTg2gzvdTZkc38tQyxXFRzuEzjhlLKm9Gq44xOzVqXKka3pls2J8/Zp8Go017a4GzOM/r26gzTwqz9QnRih9QzpRrGbKFALr5lM+lTmyBDVwEPaO0/H08RTrCBq6apdMZmY35d4Z7GvyFIlP5GKhHrYIc077t/Tr1n0pJ1+j/fQ5CQBNUohd9+qyiiTriixTm6qMPWG4ibOxRWzIBvwIusWni0JLkjPd9gxD3kexzVXxxUA18SnYbCMn7ehpY+tALW3vvdn2iuJwGh/Ymd7O/0fxP9UjdHwQW9/fu8ADC9WPuNn5izAm1I9a9PXlRZARSAQJNlbU9QKvOzm62LaS40bvOk0851bQVN2ItJIcKPsq8RpQTmnRiIP3KNsWDa+OyGH5AyYi/wioXF5ro/Rkz2C6WXf83WheYYvxyIwbhWFwKD0yigYj1kZrsbCv3qSZDKKzYxHEUuDHCf4ECFtwxoVL2L0EfenUenBmrud9HuONYJsWouCR4cAvHY6fV2GrRS5UvK+ZpNGyJ4qZC8QuuvWyJZ52m304+uBoUQZB+qrQLYFyeZiGcW1blheF+1jVSACnpK+NtJJXBk80XbkG3fVCxqVAXnUph4BYmZ69X2ZxOTkHoCY1SjmyU1QbltkBVoT5wXWnotOXfPc6UMSZ7oBGkFl6T6+/dNqPIscqzKjX5FPJ7RjoQqAnw4jAsMOWYIdgpLkSPKt1+PDaP559wxlDHMHLnpHfeZpedWwnZp0snSi3FieaO9+Y9whdzBvmQfzr/YA8Ade8Oxitk5CtfP6OWAklnW1Iw5p4XQQV467Wp8ChGQrEf+65ppxqJ32J39F1KyO6EdrZk0dB8M3Isx9scBwr7BpNiu/4+6bxRLAh50BogKyjsbASL4wbVhSzwE68L2yIJAR6qbVXlIOhuFMt1TNVJOld8EpU/M8eN+jfScyRJ/WV2oyqRXlmJaSa5PvN6hMNrXoKfSmJWK6rJn1TvW7LYuyHAPfly3hozFCyxgxGieJWJM34l/+ZWyObtTp88Tyu2HPfybiD/Uw/ish1Ofg/2J4Y381yXB7TYBeSJhGE62mmlQ+Jzwe95ThOcgdp8jzfdMtct8TbH0ctTyHmB3/MNLRWjsl8+IBFMDLJOnumoXj/5Hxr06J7I+lyiiLe/eospUhiOgqgFjqQWMZlb9ndff/u1J/ZEjTMHEyA02+A7CnC+sreloS/JFibT17eLBddcVBdjUJDSgdLiiDwdzlrgg8GqNyAttzoNpujQWN46ObopVgFp6tfKq09e+0RYnGCOp3tczRYahVwGRmpqW80VHabfdXWLb6tTzva5YGDEV29Sm3uPTdcsRhLZdzKwhllQ5upaDTBOGb1BpmGvRHDLLqpVE94l559d5KttUonkPaR9st9R2IyVFCfir/dfFT06+8JIAxhdZHh4D7J4VJzTSTt8Qepg9v5e3R6CcB9JXfifsqT4CCBXwwwhQdafpiiawphrywg73huPuj29+L9LokEImD8X3CcnlrNqvZGL7EDR0RIBleJ62yPl63cMZ4iTsMtEE+cXbJAB8IblNSFfUuCIYxbutS5fYg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: a964eec0-b5f8-45f3-5a08-08dc306ad6ab X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:40.6944 (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: 45LIfPssovXV6GHQGSnKFn5Eulqcu4seNU8HfHQGO8lfA6xxS0Do9btkoKUeau/8ly2gnZoSvE5riwT4EuH/FVvncjiB22C4rr/myyO1hCE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232505060888145 X-GMAIL-MSGID: 1791232505060888145 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 Sun Feb 18 10:17:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp724638dyc; Sun, 18 Feb 2024 02:50:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWL3DuVZvwWDYjx/V+5dq6ox9FdTxKLZ28juTyQ0JfzCGDmlTlYUW3Buh4+TVE55ZDZNbxvrIMaaSFbS/hkBXsGOHMv7A== X-Google-Smtp-Source: AGHT+IEFVR8ICMhW6aWaguTp1ThdHOSYhqoYg5ZrBsrIQie/KqN1vPB8WHIlf87NAUihaImPl5vR X-Received: by 2002:a92:b706:0:b0:365:2390:9321 with SMTP id k6-20020a92b706000000b0036523909321mr2373391ili.4.1708253444822; Sun, 18 Feb 2024 02:50:44 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u11-20020a170902e5cb00b001d9cc9f85a7si2760899plf.566.2024.02.18.02.50.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:50:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70353-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 95261281C67 for ; Sun, 18 Feb 2024 10:50:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F6614F1F5; Sun, 18 Feb 2024 10:50:33 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2135.outbound.protection.partner.outlook.cn [139.219.17.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B404EB2B; Sun, 18 Feb 2024 10:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.135 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253429; cv=fail; b=cknohY/vSGAdxBLSYh9p8jPtk5MWONXGrXZxktOG4xsi3N3TTo7jZdZMXIl9YUosJFpEH0Nkh2nSV2eD4KYiqBWXtHbyAqsp1s6LAr8rZOQg01p5vS/c14khbxBHsIMjAxCnNfBXdm9/t+5mMjB++wQrlrdG1NNlYVWiHCOIKgY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253429; c=relaxed/simple; bh=a7am6v2xZ49CNXVganzyoymQoDUkzff74c7Tk7OWT8s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rzJl9mu71XIBJ0dwqouYhEHx1oLZbC/3VOvEDGsk+OYZJ2HFYE6dFcfNxEHi4loDODV4y95k+neUOLsLE01bYRc/rLBoNV6n1fgGBUKMxKHgjdr2EiDuFM0OY0cyrMTAcA0EsfSNxxoLcluL5CUGDdLg9KfzQfhrMOqbW9S9qCI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ogzm4VKVSASBeB+U7yYxVjAvIcCYCb0Jpy1ijAwFJhAo2HfzUW175nH3E05DHTAeQJKSHn+Sdr6xGaNxiC0Hi9JE8Ijd2BxY8PGroGaVBLELgLW8ZuZNf4qec5Azc/3PxZFsHLTZ3h4tPLkfTZELcQqD+vc+dU7oh4ZuT0422nfpt55hoO42HDVWKH+xxJCv+phcXkB06SkoZlFz7p/FGUIB0PtDOz2E6/f8SYP6ECHojd+uDfKHANPJV0ATcOjNS689kJ87Nz15vPNIeWJMOEPErHlk3fzxWKSjhsibTivdC32nfkcWp9d+C+och3ue1dVodzry2OC7XdOCDNy5Mg== 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=OFhyCPf2QViJNsMVWUCmDP0SSsfWrOo24lbniBnUQaphT3I8erAFuAetAWg06a7RvuQDTpnnnuO29TYpNy1w3VcuREGfzuZinmqKIQhCgYHnEHk5RvZ+mYtyhqjF0fTkAR8wU1N6gaFaMHpYgjCZT3fDXr5zzGng2+qAq6h5N1JGpPbpNYbAhnxxlwLrVgtnykDvEW8+v4ge5hMCi5BOLZY7yn/4S6zajulW6BZl6B23F/Iwrc+DR7RqX5WSwR0mitUvkE0fq8aH9A/2HOheGAAr0NyCc41WgXw/GeYZaq2PQx6gHQEOWZtdi7+c5SuX44AyEAV80UUypevxp4y/oA== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:41 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:41 +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 v15 05/23] PCI: microchip: Rename two PCIe data structures Date: Sun, 18 Feb 2024 18:17:24 +0800 Message-Id: <20240218101732.113397-4-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: dea9a3ed-4a21-43c1-8d45-08dc306ad722 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Aa3M7J+WSBsm7sXVyG6eSrMIZ8bJeI03GqmZzo7Ttsu3c2o4ViMveTJdlS6m7lWUga+ooPrkChO953My1rgX+3b0pUgpb67mmPxbluZjYezPIntPE/BO1VUsE5T8BUmxxuY/QeDzeaPwqah2y/rBv7szTI9GWgFY6ebzartZyO7e6MjALn/IAgGbHJ+cwGQFqVomMzIurp2u1VOACX6nC4d1ltFdsxncqlVkuGneeRUZFsLzRcYPyaU4hZxG+O13VFgbepkrpOIzD0q8e+9CYMhxUYX0GLYMpAWv4vKkvxZL9NV3fAGf7cncZuwGZZQnIS9PYf9BU5wd8SmAxEHJ+feik4wbiw9Paf5ZCEiuLT0DgC0TwxFLMDhLeFqtDTxYkTGNOnrrIunlWUjMXhiXO8Nd2rraqQJaOe4jPXdCUCfBWlbqh+Cf7eVcEuu6XE9ht+TFLXpYZEed0OVrzdzazNCopZHSLnYNnXFgrZKk8jWwpHcpZa0QQbPHUTyP4yUAH4BZMzDKsTkUMpmFFTRrF/L8SXRwgT80iJgSaFboYjowVVOQytatfQhfuzcRd6Gn 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(30864003)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f7M48ELCblRghXErEi3OJNJtwlafJ6ZbxrONzn2HR7bQp+AEbySN8SsvT0g1tafyKX0/nVYFdAs9wG5/p+34+di90wHQcqv4Qu4lnxtkgf2DJJITrEiXVWWtb/BMnypLLhzVhic2Pn7LtJDD8BiHkIkKtlE0F0INXq6nXK6pugrHy9Rkfdxx8UWqh+yh6r6YOAKFzomuTZd8X7hNgDXQmlMwED/K3sAvg9UZ4tmDzFhABoYRX8E5M7MAL1phHPN9aloSai2sjpxoNqTRzHFCuwmAXojhS0aGBhybjV1VZNsb0VvvWsYTZBVxWXWEWuhq2WEONK2cJFZU8CNC07hp+j4f/6lK/Tr4TCqnWEcbBJGKJ99Ec6zdQtxm6/tJVi5jyl4Nd+YrVznm67F7lesBDi6i2W9L4BscTO23bZ1Tu7w36q1BYmsSusTCiVZA4RxVOGh2sa9u3WOi08s48Lmz/nxFi2sa8BOSagayM4S9shzgKAWsEW6fO64MCpbbsPCpk1936auF5SVaocMd5QmLryUHuQQ1OmUQSWwlc3PeTn05cJRSTpknq0wDc7gH5lA/Rd9hYi+IV5swDqB7e+35YpEBXXxKrufi4QiMxDjXhLxhzvd1IkguUmlwAKt+fcXw/CSCyX8mX+2LF1rPY9RCZ36Ky9Cvv5iOjx03SEmd+VPfdwdFj+05EplW9zlXLDm3kqklNOBaJ8cvyU2NRHhYWv41QZ8/OjM0U+bakXXEeAOtNOzz7WF8iIEXRctqV4r8VUxAU4W3gjVsO60rQSyt7y/LlpDY0SS5edKZKtThxXL1pZTheum3LP/5RY6Ajn/oZBiJ1RSDI74ma5GjJPzcp+iuFXr1Syg3H1uSmY2n9ElagvySNvfPE0FCt05XzRRLbLMkayIzebG0FrXH41QqKkzu0CNs62Yst1SNmkT4nEy+s9/ZT8EMUvVP63477W4iRrjVXcbAQDSPRau7AAR086uTu5+lHfpXAUGsaA8tDMBczEdpLBsQRRGUTMltfAhzr16J9OJzc1eau3cPj/MCevbQY1tDn/dKGWakqXpJFYnxqMFwgGsS0vIBA+aEEw/K6mNp2q5Gi2nvKsrUuhwT0aUgoTsaw9bgiQ5cNN4gryYpch3VOHYv5oyFXok9Kfhl0/qfHIeS8Xrgz27d79E6h20XLdpxenk/Tw6XpFMzZFijKUaqIMb0sWW7y1qPfKsexCoep01ZSTps9DqUiw6xd2Df8zh2yZ/vx+E2iFavGlMaNa5bAvkqgfap6feFA+FqrhQXDOy3+E5X072aOkEUmYd1vGDBsa2V8z3zx8fbailYoiw7SHxF1zWfCc2bRa+hRcG3S/fMfWtVjfMvPRDgN7Bg97HWfWj5hRBBdHOFQsRUtEU6pU/rjQY5BODlR2T89FMPN295WG8DG7sqbANaUuLhxwRd0kr6U/oKwsWXT3emNznHdhAuMdvnuuZL6rIcyY7d41AuHvqbLU6+qLdSQlnGutUr6j1CD966GWxNiPfBi+ev2ifIMkdRWzQqd7+duPrMAGH9MlObYBEHc7hwevU4cCakdzL0GOBMFroSE50m9qNJHKVXzt0ejUD195kFhLV5AHCdROMVHgLDzNMw0Q== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: dea9a3ed-4a21-43c1-8d45-08dc306ad722 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:41.4887 (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: 0uIC0HGlw/NLCjLS2PIGKswajeS5k8rZoNdirAvFw5EQpXzblhLD0I3VjqIA6wToXMFw0Ruz6zp9Pg7KA+g6EW9MSiA8ge1H1oTdHWz4JvM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233564170978148 X-GMAIL-MSGID: 1791233564170978148 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 Sun Feb 18 10:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp724967dyc; Sun, 18 Feb 2024 02:52:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUe5CoNkrKeJ4XE5spbwVN8YQLQovQU2XmOuHDm9zJ5VocZAOjC9my2SyLMQDq2UfB9xGhhURrfBYzC4sL5BX46J4NNyg== X-Google-Smtp-Source: AGHT+IHA4dt9uGcnxDxfk9WdQ/plMmDG33evjpWCQOs1qTHdWrjdSKNy1nmsRDK9r3877DljNp3+ X-Received: by 2002:a05:6a21:1789:b0:19e:4e58:4f04 with SMTP id nx9-20020a056a21178900b0019e4e584f04mr14671168pzb.61.1708253534277; Sun, 18 Feb 2024 02:52:14 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e19-20020a63ee13000000b005d8c5595ddbsi2685297pgi.271.2024.02.18.02.52.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70354-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70354-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70354-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B3756B2137D for ; Sun, 18 Feb 2024 10:52:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E52634F1F2; Sun, 18 Feb 2024 10:51:49 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2097.outbound.protection.partner.outlook.cn [139.219.17.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9BF28DBD; Sun, 18 Feb 2024 10:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.97 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253507; cv=fail; b=glC2h3T7k4ZHeL4J7cb6YxmPDJd/IGRBl6JNjDe87jvm7o4EIGfwykVJTzysVuj2WWSyA4lKJNV1bDPwU/ns0xqy+Jtb0iwd+TZbfOXe2tQdQ0PMldXa3hDAM2DQ4Ieuzq8UBIfKtBjjqoCLdUnyyC9ocHrQiDuekiVJFnSDUek= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253507; c=relaxed/simple; bh=Zr4mWUFXYvtyxcrmFpVmK+dYKLWMemI9hE1iMc5NAH8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hU1MVrKZin31bdSGOAJUzqlKrqUB7j0KtmjpByyKSCEMxdLPyX4PujQT2hDZusFNnC4EPfOsxRlHmLIQPG2kv6mERVGFDAVZ3+4FDsogB1eT2RQPqk3t032/K2+ioNt0adY8n+GnSu7mzIq5/0fhcYCYhIl6/0bJASUu8NnJ6e8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=We/Y+QJQTDh9CbO5ncvAtjn0IIAH2n8YdaNiy42rVl4ybBHrQ0noBVxCCdQfgpoyQuKuVBJ+RS/gNbKedqZQcfkxMjDUC0uur/EljoGjBj/9QhiCo1ql3OrwFv2V3VnAqVboqsRiN95hm/vm8nPnFSscRXBvjHDjSovsilOX5276OR+WYtrM2Pz1QWmugPCuSAc5A1C1YiHPEvmUe/D/Tm77AM7bzkHVzguO2vMCbZGQfx5tq1c9ViMCTaRD5GrnzF9a3cwLVDC3FhZQP2CzpD+Gs8Dj7ivlrpawo5UKcS7kRl1mw1MOwUXe0zbpU4XmNEd1NhhRWw3/rCgaeeblDg== 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=vTje0ALVDFVTLXaFJ/d5aQDDyaSpWhyjgAzo6CfB/Hs=; b=Q6aDJQauFIDmFmADYsMV/BgaV9absCiUWx9R/b0PgMBpjVnk3cRH5r0ZGHtmvRhKSZUA5WqdO9Y2+9avT7sOdgfUMfZRVbcI9Elfeqz8GZQB8rnIATFdDduWeWjovGgvL3ZNUg0I3WBatRmKy/e1i2f+GYRg+Idm5TTDsLXA7jNFL0vmF7Nn0bF0+7Zve7uzuarHXQ1Ttr1uGH8FZP2x2wm2MARyZk8uH1DbLZa+h6k5cf/5fNvIy3H9sHrV5Zi1Ei0ZY25Wp+0PTR4hhMO5AkSCAuzq4d6aBYdBxQFzzpzh9zmIFFqG29Bk1NeYh25niDO3QrRTKnaiY2/uRvNi7A== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:42 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17: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 v15 06/23] PCI: microchip: Move PCIe host data structures to plda-pcie.h Date: Sun, 18 Feb 2024 18:17:25 +0800 Message-Id: <20240218101732.113397-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a4c0f1d-1b26-441b-c084-08dc306ad799 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OoEyl+j4j6o96xYgljpcozLdrzCCDdbBXClAlyUeVlGdhUreJkRsu620Ja8KhcSVFCgl5Xsu53m+SV5xXpGydj/o5hmu50uzLS6ixLR0Z+fwqRsUC+9auroa7W/cJs/8/dTOKgHA9o07WcNGg5V2kpyFvtH1n6BvMXb72NsqyB1cfZ2rlPgKW2ffVQnJQT9w8U63QCe4dLNI8BvRkCZoGrEGeGQFsOEoomkJ2X/tS74exAMOCMCQLSYwBmgWxnFoQBqfSRIHvA7r39pRM3aHk7Uor2xkTGGK6mqdgjLYgbuCUHbzcFQ4DQCV6gs4JmxHbyYbJdwDbO6J7Oh7NCUxXVC4+5ewkoUIV78+dRTVtY3AE8A0xN5fPd9Ib3X4jZCfYFh2ikzE6eEDHWAaTAR1F59vr0+d8Jq9u0CrXPpZEnuaR2ydq40ZjU/eIf/ZWZpr4ax3XnRcleRd2uGRYUxqbWdc/q3EzP+LyPk2CJnQnCAlUdo8hiVbZveOF9ip9MG4ojEKvFfpo7N6p541yEXtG0prG5mpHbLZi8BrpuUJYXBdl3UcDqsyFnoc/UwGqM60 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xR9liw3jYkrolLGsqe8tumHKN4adOLKqQhM/ERSl+QbR4deU6rBf001eMayGO8aH1A3S3joakOv+88bzawos4NFbamI5+iA+HPIvlwkwGlcX7HJRZW6s3C/SzL6mBsnYh7Yp4X9/TBtdkWs97Nb3zpR4otDdITvCz8uObqRdRknUViF8AMD0Wd+rK3sQdRP+6SO9jh9e8ftGke3oKK3cg3ig4LlJXrNwq+9JYzjmNDceiPBFUJpWtHnPdBa6B2ly6JhRXs53K4WLzsIMnSxCg8JYVMxYB0xKXJJrw/4JAVEYsaj9sBW2fUCktW4UPgyTO5jxQ9dEmJx/9QE1gatIboDl3h1NFeG/5gng0SYFMfIKgCCX6vZNJoJQdMhRvQyNZVyE87P933+lSDxUuSehnRhwi9QuIM9BvGjL5KmEJfOH2bFn6feR2ok9eU7rIHDbeVs+yu4070NXsOWlVhSyf/iwbB2JuagL97RhsvqfdfFbewT8tcYUDr6CH3PydClUi4BfpWZkL5ds9QjgBjA1YsFpHyVpqT4QfbJMcqkvaosrAy+oLCcD79KqxrzzJ4JPLfSxFvR8l6lqJreHBMqDlm9b/fmTKK4wQ6MyKbwaE5+7tAy1KEn65OpAau+GFtOFIAlJbTL533Jw2fp5DHFLvJiFKt8CWzaDVDXN1CS1Hyhd68S9izMP6IGsAYSW6Qe0kcu6Zoe5vNvEGeBAVaU4guoEzN5btHgYHHrmYlOXi/KPmk955qOr3rn4fnO4ZIvdwsZRZ0XMIjHcQfrjLItaK/Llf88Liof3odf28+v2ECLxrl9rfTL96TYol6A9D5ArHBedhhUI944CG6V8WUlMYYAej79JGGFM83rTaGW2LUTfmQ8lZezTzPiT9bIxRI990i4OkN4cQJieIcJCg0uVwhkqGrIbciO+jjVKX4oclpLs8Pjk9UgMhAeEwUaY6V39sPCK46VBPfUnL/nxFNR04vaizba9bWOlrOKn1F0zqNy0M2oTEGgs4/yp0zAku7oW1MabCaK/bH1Yb2DTyxU7oXlTD3C5hjikzt6yALrpouk33wv17amNmyfsJ8FrG7JTGfD6VZ0r9wIhAK8P+JLdB6lCKC2/zs9yxbGX8vSiXj1lInKgTaNfgELLlMUgF6ha2tTuCT1jV+dSwbLxxaNpGoY+LJC3hMEEyK39G9uxzZ9Qym2mAY9pxuMx5GzXlg65kpCMBYo4ZYNpqexgxLTObXhC9vEL++Uwzdmo9OJPp1f92PTYctGgLOJPWbGcBoLEzINnVakVZ5jDKMYjpYpIHPeZxXhsC2Sn6O/Bz4oA6ljfMznlE5kSADdPBBreI3fGqlrRzYQ01c4TCY0WHi24wqsKEEH8Ck5rKy+gYXOjk8yoYUhLJQfxZ3t1I8oFrEVtSlhPzPiOwj85a65up2cTEy2I/KcTeCLlBKuPYSPZR5ZYaoEMbWNRBG9h7wCsB/IbcATqpIiAQx6jtqnf+FRcCWUh6xjPSKrJyVPfSFVZikIBCrEJDamBiZjYGsUW8J3CJ8dznLj+RXj+4uDGbLmgH0jLkZP5h+6VeKGh8n5Gq41/CU16fwqr9UNdxHryeCzCZxAfv3m6YTUtq5rdo+b2oQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a4c0f1d-1b26-441b-c084-08dc306ad799 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:42.2842 (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: iM8awgOHD2kzXN36DiYT8H68wUT5exmGAEP1Z2pdVjWaOYc3InMXeWwPK2tD2meiLdGc6QIOHT2U4046Nkc6mIg9wqBIinmN+SRWmFxKM74= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233658267217287 X-GMAIL-MSGID: 1791233658267217287 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 65e0f3b72184..9ca66916c609 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_EVENT_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 Sun Feb 18 10:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp722177dyc; Sun, 18 Feb 2024 02:41:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4uaAgR9oghLjFc/B95QnrZhm9+TbJTj958zLfXUWP0wUJOjjz33Uh8HbWKe39ftbhkDHTRUUPwQvKMy9uDr5CEdZJ9Q== X-Google-Smtp-Source: AGHT+IEm819AAIdR+T2bdaqLsTRVIteC40ki6rYVJgcAZfKXz+oVejnSvLS94vEA8ddCjiESrTIq X-Received: by 2002:a05:6a00:a29:b0:6e0:9a9b:b620 with SMTP id p41-20020a056a000a2900b006e09a9bb620mr13787548pfh.27.1708252863561; Sun, 18 Feb 2024 02:41:03 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y12-20020a056a001c8c00b006e405764390si1119442pfw.70.2024.02.18.02.41.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:41:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70344-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70344-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70344-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4C6202869FE for ; Sun, 18 Feb 2024 10:34:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 557B34EB5A; Sun, 18 Feb 2024 10:34:20 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2096.outbound.protection.partner.outlook.cn [139.219.17.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 457BE4F5E3; Sun, 18 Feb 2024 10:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.96 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252457; cv=fail; b=Bti+xifiA1NyxZmfYXiyFSfA7/2JC2HOdJVMiqHLqNH2xuCs5SaS+WZDQdnqxNa69dMz64s5Ha8iXQNOLxZgW5tql+oesLrdy4/zlPFBy1PtMXIC766un3yQiGoNx4Atc42lMe9o83VuZ031IQ5YydD7sB53iT5wclmVxQUumW4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252457; c=relaxed/simple; bh=Wq4Z/mmbsWDKhaXfuZB64deZXyVlxQgOmWnGhLzld0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=WUvTAoPZumGZidROsPOy0AOieohEzOfAlTUmw5cOZEgQ78KxgQvwDzviqYl6LGoGdX/7gDBmpiPy4T4Sf+FBMwy86IeBLuZwlCQJEzNH8Lh+jvOrKPo0ceD500uZEn2sZV0LMqlvZJDv0IThoFu8RiDMDQSvToDYW2teIhkfSJc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.96 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hHE2LucH27t+P4uepGoJMCt6sIdG6ItScu42UGx9QnxZs+1jwLq25M1SG+NRrcoPbGtbULBpKObxcjrTXPf435CxqX1n2ThusnaM+BSGm54D9rMC4K37GDln29Q+eTIC87jdHUNXJ/hFwVYs/JwOpxtCSyJLMIUUQKZ3BNWxoT783HdNlxF8vPW6yXZaWYMBtJz1U8mpDH0/JtH7Apu5w10q/+H2/FSSRKziErATzd9SHYfagjwkCEhKnlLbsbGiMKsGHjIf6e08PtN0C9bn7Nf9rU8bqHW0dp6ZrFEMqzwXhpu+Dq2IPLidKZLp1jk19LaZiPIQ01T7aGW+hcop8Q== 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=kXbx5ZJ3rUPIuf7ApoFWVrY+h2Whso9BxUS8CCjQaNaDfFpe+9hZc4JOyzHU4SbdFn2zs9t0+KWu3ZWu9cGR5SLgmIC9BCXzaGBDC+uGcBcEpNpcc2h9P9boZ2IcIGnqzyKGzzd/nkV5V89tIWq3B7MK+tdzXe2+mx8Tc5fc4vrMOGqCi17Klu/A+eI3l7HePT981oftYTAGIy6Tc0W/vrGaHvQaDF/Yg5zVh9ktnZFCQE6n81tTp2JSwATGDfAH0Tp1JH0u1GtjIjhEefNa3Eydu6nHfzpINtzI99nlZlGAR/mIzvZwvxbnHDQfa4J26UOBTOJSGvlgyb/UnqelXw== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:43 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:43 +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 v15 07/23] PCI: microchip: Rename two setup functions Date: Sun, 18 Feb 2024 18:17:26 +0800 Message-Id: <20240218101732.113397-6-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 913ce892-71a2-4fc8-5608-08dc306ad813 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mHD69TylTeet4U0vWB7q0MTJ2G9aFflpdRXzcrX/VHSi8eXXAzQ1bsseUSFucKT+t/7wDkyM9PjZYiu+DYAr8qA8FVFVXBLqQd3KaggfqiUeCp4q5Ota5sNbSW+/936EUt4FFIEj3HAgbL0h/v7oX0S05+cP5MUxNWPmcdbYtEsNcBz8Fm7pXmFrUPnk8PHPGGxE87YLiXNAq67NG8jX2SCrfDo38RZ0QF7x0CDP0LcIBesaU/PJvJXwW4OAbjgZTDZWD1jbCAB+b4A0yaSZf0aLlayq4EPEUIpN7foBjVCzxSrGqxXs2jbYaZw7Kj4rSY/+cbEvJJjngNxb+XiSmOZvk8j6shuoPHslzzi2QSeoT+kYL7kFqFYn7d56Bm/jAUpX5phfoC8rzeB0uAfCeKYddYGLWr8Ca1fqlgZQh1zgvF6xxvCY9xoX6T+2kI4F+VDyT3PKl7GSjNnVC/oCyLR2n4bHat2ryjPtXKAGBEamKt5iTSqHdO2AicMwWtYj7GcvRNzgCdU3snuevNJ4eaRNYAfNJomqVd8yFdfe2rCJsnqtdQKu41pIN6S/B6Wf 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VNsT9joutmQkHa4G0kcEjHdERblRlq2304MzA4+gt6+LQhVWAlHFWSe4h5ZvUKn9TmQZ9PtpIBgkT1OKlI8Mmx0qaUjcikQis5GGuh3Cs0H+kyIrOHbN++/pQVMllwrS1mfFza7btAyXCjUGS/nMrJCr+KGMJx6jQtn1DGPVKy3E9ddJ10Tb7aruqeqKi0UNvN6fegYyEM3mlcY0iz+RVsayiTT54rU9ygc5eizHkY5BqYVKU/Q1hHtP4PWvU0owRSccAGpUW1J+WUvjv9UB1smOVwmgq+ytKAxMi/ZSP9F6SuIRrIGw3UM+WAlu9Oaxq0zrcHdtdRT57tqXwcbzCZQXZnHuzkGr2xEpjYc5H+fSPhkiJ1jI0o7oHnsyubIUHL7xfc4H3AMHJZnM5Ue5939EsF5KOtmvd2tXMvUwnIK6xN2dnog6Cky8NmI7wRAdOGeduB7XkMx9UtwQtKooMScJl5ySCxc3tufWNQ0xKDySyFkBkmy3K2tytTO6oggn3SUYWeUQlVPtI+DLI72xcQG/wZpEsWJbPn44JRwoNV8GhSi76+By7io6eGi6GoOPjcm2WPRa0CI59BxcaL7SzC34jSsjv9SkFJ2FQEDA2mUqI9vDgHjeftWL3f9rBfvw5tc6be29ntBbze2zLHBzFHTSvKfoCWooQz+SeJK68X5vMIJGYf7lI3TSJx+VSShaBW4+HQijpvxgsSNQp5HIxahlOpAr79MQbHNLRfOf0ub/AO/LqridrLNwoCD8VnPHS8wSJkMc8QxkhT/FnYKVbOEDV+JOo4cEFGo9uQrLbpSRhgcxqo21wsHu3iNzD+3BvTxKyrfDwG/VxGOTBQ6aXf4K7NkRPbbIGM82x6mfmzQQf7XDuHnoAF7nbA8rtVnb4kDxB1AZORi2Ucj2OjBXKTetct/jU5LAGXnF5LpUooTyg2CgZL0bdRkQoVCRYsJDZSxOTcUNIXi7MMhofe15+X+pVm4NvzyleIQgAXd7vk3m+OduuzccKYJeopYVPM3tKCo+bOjqzjv/FsqwAvJln4ttN9DVzJSMFRroB2V1fSD5Uglx4aMqz2QqsD8PDnpzr+NWOGEjrTlOozh18bqU8Gg5pN/qJ3kxepRK82lBOt4rg6by16Bdw84Hb8ow8hAE1pjXHcsLxEYxLRVj8bSj8rF/v8Py4ltfBIaFhp/GgKEQQHbE4ETSHNljCyKTk5qE52mYzXx8vNjwF03LQ2bsVEN2sIBjBO/cgMosqz4Kg89eh/Vg3OQwRtbNmYceCLs2apiFFye4bA7WkmYErt0WEOWr2gFg/Q/MqeGV91mxfAAKznQxBpQkqwOMUv/bzOJ27ml448q9YqDxj5cxMNuCLvSS/fRNdzC6Jl9PVczKcIY+qN9+2UTLEhfJUMxw8Zq3LlsZslmXuTpcgvbDF4kXngnnGVdbNnEhDdDX5DuUFmUKJA1gjRSEv9VdscokVF3uxf7TIsp3RNBWT08NusOLDUoupeFtOJukIzQcvvt5LGdFMWL44O93/xBbYh9ZvhWc6MXyMzIHg5Pl6x5yPwYhXkB1u/Pxy8rVKNWIT+vp77uzQmfk0CGJyS9Dtfm9qtTGKpAmhgyVLonSs/iGYeXxTQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 913ce892-71a2-4fc8-5608-08dc306ad813 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:43.0641 (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: FsgJafBHxZzyZYrR8U69Ge4vYj+LtZim7M4zh6Yh+2jRlBlHuRUrk70kSeIoTVjH/ewk0vVNaFCDBe1XSCCvn7KVHJbNBhxmN5KcUS1obMU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232955095398624 X-GMAIL-MSGID: 1791232955095398624 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 Sun Feb 18 10:17:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp725132dyc; Sun, 18 Feb 2024 02:52:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0aIlfkS5ZmPChXDdzPHYJA8rK+57oRjG5q6/igie9sln+k7ew+m6Z6wAZ56lcJ/uu6YeQ2Zl3n9C3BJBZXmcuuSyNYQ== X-Google-Smtp-Source: AGHT+IHtyuCzjzQowjnmjxHBFF4VU+k0jMPUcuGH7k7o9WfysaGsaqpsrncLUip8WQSWfF0RVPEe X-Received: by 2002:a17:907:9873:b0:a3e:6bc4:7754 with SMTP id ko19-20020a170907987300b00a3e6bc47754mr628891ejc.20.1708253565405; Sun, 18 Feb 2024 02:52:45 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s27-20020a170906355b00b00a3d94bffa38si1578167eja.157.2024.02.18.02.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:52:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70355-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70355-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70355-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D7F981F2142F for ; Sun, 18 Feb 2024 10:52:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A347F4F1F4; Sun, 18 Feb 2024 10:52:29 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2121.outbound.protection.partner.outlook.cn [139.219.17.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 933804EB21; Sun, 18 Feb 2024 10:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.121 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253547; cv=fail; b=TrdUK28bsCYT6CTMGZqjSMp4Vfv7eiHDdekGLMKJSO34KIdKXTHsuu3GQbvfSlpNousepzX9IC1b7pmtW48WFrsvDwL3yUQ98kwvablhQowliv3w5jz0XiXYjeheMmS76BC759IMhSeqe8T0C9PcVJNxXivOdfDpPFcEumhtzWo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253547; c=relaxed/simple; bh=6IWs/9L5/U7olRhCkLt+mH+c3E5Xoo0SyzW6LQLbL8c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XCyVTT+MdlcmiavGcyjeUlhnxwkWTyifc9fsS1O81CD5sGlgOYaH6BH7NReXMg69Bk6JHjtc2AaiX7nMPkvCPtBEdjBGL0WXymBy/729iJ7jOsEIzsEv+d4ceAQqAgU6XGPBNTzEvNsXC/1gGY938ARYBru/o1Q+OGbQjB8372E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.121 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lef6Y5A8qhzuIDEy5oD0azuDI7yoHDt4ZTtdKaW7ORp4BWkKLAAJZHXglII2ZuGctLTRU1rLeQxZPA0HVjQG5YWi17naJUm4BSBKewz+6CIizE3N4Zb7lHAraWv7bvy5Y+eJfaIOaWCkBBcIZNlDItXWNwsUb29J3D0mZYUhMQ3glycdpSozybPKVCOl/qSERLkuV+nNKJlP0T05bSBKVoYVG6SUIPjRF94J5WN6orBKNh7kY2szCK9UWOp6/ygXCfK2M+6y1MhZ1nH7+k8obamux4yUpbW5O0r+YExwbv2Bpf+Ai3yxgJ2fOQ05WR/HrTUoq5+uIjLTk64tgzFeFg== 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=b74mEowkO76tc8nCPTObdhx23tQyPOKPS15iaGEMKchDFYeLERUOELgcERgl0Ygyv8L50SqeW8iusn6iPZt9hAUaxRAxJKwDTT4DLTT8kEoEoLPIj+rOFoB78Pt9xvBbkJBHBDmh7OpkH58efFLarK1kWKOsHPQQKOBQjUZlGwcJzp7WPZjmBa7tXLokHn/4kk+QFnhMwjunSGrzy2E3DvewCO4oM2InalqKQTscGUUMXXD+lk6pPIpRPLWBsfaIn9Jay0Xn0s5nFJaiwsf8w8mud6wPJWrLKseBGosnV6ifwtVSc4lHct4Vh0zbDZ5CIhgQFFxPLq4zb2vbzEYbQQ== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:43 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:43 +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 v15 08/23] PCI: microchip: Change the argument of plda_pcie_setup_iomems() Date: Sun, 18 Feb 2024 18:17:27 +0800 Message-Id: <20240218101732.113397-7-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 769b00fe-aecc-4c22-8946-08dc306ad88a X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 83w/HIPo14ADlXVI+osf47iYMxotXMzk260C7IqG1EwQ2cx7hKx4Bg+OpzGfHOzywmqFSSSpOR0tcIMNrZpMl4Jukfgqgb8iYh2UXrjhvynTC9JDb9Jv29MvjFQcpQW8XI/+SQfcnY4Lu+yOzTfeH/hKxrqTxzfvw8lf33eqN/x+GpThyIRIA0T4tC10iIvMk2TWXo4Z1YVzFYUoRIa+Xw6STNhPQMnnG7HHSEaXsIcitkvbRwq2NaO++4bMEzXnyz+mQp8I732i1+n4ZtciOtl+KOIck+jKq6ppoWFhYpOvnquNMhOBsDFbfSd6WpR0xaGC443dCgGuEdQQyh4dFT/vvu80uQtmw+X5rXt+Po5k0tL2GQS7l1G/AtaeT2u/STbYacNCcCBTAanejkXQZYxspcoOb5uR6rTR5NOF1WLl/fSrDxBf9/Qks+lZ2g79370h5m/mC5UHcDMIdVtIW8VBRW9+D2taqapd70IAtw9FzaN1I8D26142k3nJbJ54S9rtVL/6qkfIlg86XdzFcSZO1Z3HXasJRgC6SRIG8r2fBoEM5xouxkfZJFHs7Q6y 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EZ5QsstCIdvt3KqpF/4aK67XvwI/xDQTVggNQieJDza42rm2ONjP6e3KCU+WehYAUAfrZ7mMPim4wMuYrLHN7f1jxlKUm4H3fZXzOU09GyZzBy6jRY6FP3sC8C7NxhU6YoGAHQMr2ifU2MQhQba+q3o4EECm2A1m+Ibe4Mc58cwhZffJfyCp5UqvZDOnSLvGSl1UuSkAZ09NpqvuICOHhHomyJWRekKKT7i6ic+r51tNe1/c2UY5Vjh3yCuf/wgnxbbV8/yRswkPWJXg6o9qgfJ8mplkIJY/3yYJNUmW7f23pFeIVgZaD8p4nYBN3eYRc8OL1xCmpwin4YEbuyuAPPqvedjYMs17i7MYSz7wIwLPkj2kM1LEU+Z3UP0WMVGpnkjLrcPh7oraj5Hf7/QoH8ni0fBYK/fzGNNrrgibANqA4ocoKp/O45LxxMrt/FUgkSJ6a8ehfEq1Gi4X/ayJEJhB16K5utcR2zcffWciEAxbhXPewARqmGQcEPdqTWPhz74HpNTiejjiU7Ymvo7oawzGvcFCirzbc1rstsxcqa2YmNr/44z4mVV1b1DDDMrctgw0rluGEtqROpb6gBhEG5EfUpFXiVkam8klXAi2ywZy/BXh/t7hJ+WpAWP7EbcrKPedEEUugRPG0z8BBgIeo5xNDuRUkdcNIvPAuch03rxPMsOLW7rCiicIScC0MQ+52vPPGsXggZILZu/tQiMZ+Vwmil7UfRuod855jOe52LNlEnOejUVIc783dpZUjH9yyWXUed0ER/+ulFWfpSKpQPwgaBQyD6DJvPj7mRIBXuVB94/6o4rQHKIWzaFVpEydclbSjcOhYzyCJu1FAmpupXxJYeRYTd8lIJGuWCcgry1ss/mL7/54O9vnpR13vTHui/Xtj/bp8ODh++eHXxy1gsmLyyXZSncRrG7kXx+pEy95R4TWWnQNd4XVuKtrxtxfpNmgYytBi+1uQ5h7fivqpRguAk9Sssk+0gv6Gyvly/36EHo/F0Fe+MgThKZQHggxU6YRG+Dq/b+vfxpf/FbYJHSR1dYpJ9RgjU27RHo/e+VO2JRgdc08CD/IlHqCKhc8uFncs6G8vBy2ZeSuUlTq/HWF15SRsy8Vn1OyCFlXRexYuupczsUOepCKK1iRZKnpQOnsU0YdaRtQwnZEH7Q1BrLBsD9MsWVIYpNBixIQqxMjCKt2SrWyC6m+sHK0a1KjENrA9s8d9Z4lMifb5d89mAo4v5SpOaNzQSsj/cg0QdbuPJ6jNOqx3RKHE3HEnyRx9RUM2wFr7k7dV7LitrFXevmm3Fk32tnAYAIfkW9nEctSl1XramOF9KzoWu6VhLPtugdkJGkXsXr1ZdXe/TDvaz1xinBwa3SqOzzjrzeC0df4JuhMuKZhdVCEUpjXkjTYfkcjwE1ttORwsVey4lqq7lfD8S6T/ZyHaJZY+KLyULt2vGIG4e+pmt3zshNYQBpiOy5ypHZ9xAPgKR3T5GyswGnJtyEtcppsmoNxQXK99u1DaR8nLaog6bDr5uenOJu99OwtGgfeyMMUkczN4BjbrtQMvE1JHRhYyPuhMCtxP6KrTQNvuGdSjy2HHuGdUBFFMwATE8eVVqLoH7HRmDMu9A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 769b00fe-aecc-4c22-8946-08dc306ad88a X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:43.8234 (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: eocS6y9iW/cmXfIQGZBZHjNMxUw7o7Mn5UqeKw+uAtfFpoMVzTjatoF0p84VR+vQr9lo5YIJAkZK9vgxCsRYXPuGwEKU5AJJXIj2Kj/enFQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233690512404664 X-GMAIL-MSGID: 1791233690512404664 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 Sun Feb 18 10:17:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp743357dyc; Sun, 18 Feb 2024 03:53:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWm4lh7s/S9q6BplO/kf20lWyWckPiMmlLXadMCb2jQJeCnNJrAaZVHsjAEE/1mfz+oSAd5P1modMxD5cypeTlniBCp0w== X-Google-Smtp-Source: AGHT+IGv27flfE6JTUKrLduxYGxbN/iFoiFFC1KgpZJLzn/T8SniaowmdTfryEm7859JHkmn0lwU X-Received: by 2002:a0c:ca0f:0:b0:68c:a83b:b1ba with SMTP id c15-20020a0cca0f000000b0068ca83bb1bamr9438837qvk.38.1708257214982; Sun, 18 Feb 2024 03:53:34 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iv1-20020ad45ce1000000b0068f17b92618si4180669qvb.602.2024.02.18.03.53.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 03:53:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70373-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70373-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70373-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B577A1C20B12 for ; Sun, 18 Feb 2024 11:53:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BA6764CD5; Sun, 18 Feb 2024 11:53:10 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2090.outbound.protection.partner.outlook.cn [139.219.17.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 831BA633E8; Sun, 18 Feb 2024 11:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.90 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257187; cv=fail; b=SkExeDawNbOp09PGrBvluUyDuXd7nHILXYq6nqpIe3EFjQz1GKAI2crqZk2fZ+Brcs4Nd0ObMAqCLNV9jCpUQSuCRgDBfQv6Gwe8nWLds3AbYimzpdNUQqVuq1Ibd+d8kjKO4qRpif+AYkOYCbzY7Pnef9csxxkqFgYxQtGfiXc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257187; c=relaxed/simple; bh=6XCwz752cqas94FR5RuhUpZl6UqCr7+eaQv1gJiOKZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QhM5b9vQE44/ReB/XgS/uaUOLKbg1SbzrMNRQ7wJJyK84C0pIewJwBWpiVV1XX4QDS2nh17m2yw0cO8lDIRKQCaXhceNjNV9330KIHDcIalg8DUyxLvXqi4w0dyC99sea0P1Rsc4/6SGZgoYIT/7t4TuqYJV6lmRRPkNWEh11o0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4BVq09jU/iFVJVNh2NJk9WMIdT3nzdXM1Yom3tlG1VTGwXBvC6B3hDkISZqJyISHo4Wxa8pnIburTgS0zy1xRJRQzZB/AzVY/p523hl1jgRuPSPfp1DREWJb9meV7FiT3Wv3bn9E67ysVp3aV/xEae4vns6eew+Tz4sBOSs0A5Ur2luMt7T6U4X9KYPredTPLqcmV21v3Eyy5p3YwpqQRUD6je+Hr3674NNmTlq+jodm4KCXXR6pMPYhXpPyrRy4oMMVBVRqrMH0bp98nUowlUbeuIz9jAQ4O9O/CkMA1oETwzZfMxvNzN33sNwOvIEzv/Gp3hj2RKY3fBWLdjY2w== 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=DQxZhsQtPCBTQ2Z4oxeeYTZYEbkQfql9Jw52WhQ5GP8=; b=iwGpThkEnXRNn7Rz9sB2rZFmTWKDDneCfdUAywPku+wIH0GIPIF6vgRTc+Y/lw1ut+hpoEFEzs11XB1VyLTKGsKzrab1NPNI935txOE931pB+A0YYn8gCp/c29iaq7oUHM40B1aZUBHy5AxwLGEEiEzQ5XeVIy5Af+ooMvZzKGiBoo5QcAbJSpKrPHqcBS/W1/aw+5lwU3hoDYoQYOyB6v26UGI5p3dq5yOHX2wELnyF+a8jp0irNVUDpCwYKgT9HhSzzBqcbbtZM9+KvYTYrxG5pYIW8VJXB5sEIg9dhhbi/s4UjGpVAIwzt4m0lmSH5voM4+9fSV8vF+2j/jSPgg== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:44 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17: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 v15 09/23] PCI: microchip: Move setup functions to pcie-plda-host.c Date: Sun, 18 Feb 2024 18:17:28 +0800 Message-Id: <20240218101732.113397-8-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 495fb8aa-6333-48ec-f7e7-08dc306ad8fc X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vU7+cZmEtfWJcvmfF0vwK1CDy+WKWa4DoNqfzAp7O0N6f9TTILzGkiBS3/odwRVhokDLOsQURqHDYwewFqipleHjVN0oUr+ql7xMlAAgooZuniF6qi2PUfZFsltCOrbOJp0sxi+ARllyS+QiCMKKaEL7JGb7hpVnXhbZh5twyVreNq6DEc/FJmcvFZ9CkvPJlNtojqCEeRfCrOVKnnB2bLkqWlFxjXZjXTRQwL+6CD6Xef/Doce+QC+NFru89IiNawxo30+Z6EGkkwzYLPpiElctkdwGjvX90iOJyne73TYn7hHo7pTkfi9b+4233UBPPAdgceJWAAmhuH8Nmm8yOQMXHN0X8kau4QB/HWwDRHEQGaXsaIQVg6Bkj76mvkik4R7NhmFvA1IRs0rS77z3r7oAOdiS411t4CNm1TrMBlmKBBWNw9aYPilf/KVXHRVCPBFPsrmWQAR8QUhcGP0DQ1SBdIlK8ttXLMb5cpbpx2O7qDwkctnRKBNRdwCQTbY0Rq4cJ6VsHHI0XpYQ3c1PF1KvfUgvCuO++ueRizr8y2c3DeKu8rqAQ572gAwkOgp9 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZADZzMn2IVfGot4Zh/vR29+YIJtY3ZTHL0WZjANOG0mBpdRFsq6PZ2oUQNOGclREweEMuH1bXu/mHXKkqIH1TbIUMH+piz+q1mQVAjSXi/Bj5QcijirSNArQmk9DaLmnT/BxgcWZS9wgruLNWXRWoOIQ16dzdgG9jetySlRtJHaJrefnwo+G+VhLp+pORBdU0DFb6N3VryJb9HCi71yFPfSg91IBOCWmz5W2/Aa8Qd/qhFYCTwEcrYm+/+cFbMSStJOHuoQ45RRqGubtnZ6J7xmCSfCPTdJywHHHrvxQODBLmJdGbBp7XjZbxLD/mrtzfMVrE2wquXIrYC88zjP2DypjM3aHX1bhlSJ68LPa49csG1h9HQO8MrLYALw63WQBPx5UgIj1pSIvYd9Yt8T4S1L1iqhe32Hv+T4ihwJWutPsAZUmDth1EZtjWYPkF90XywGteQqzKeqIbiZ+VW4FwzZSiNY8hoVdJk5iRk5M0m6t/m4hfiFEUj+BkhQPSSwPyBJqOAlnSYC5YxL7Pkg6SnKbFBq2hW/bMVZaShAV5Dg1/fDpWmfZWtfCK2uqxDkewU4ge+Pen1GmIWOPf0Jye0Nl0bTPEECPVhXjcYq3+cADNRqot4wQM9vM+JztMdf3uCuCiSjK4M5/enLGNnG5G+L0+QE7rbD4383CrFASzUk/VMDUJjanDBWiUwGYdqwfliGPKn5TUI1iVYkVujdztawg+9YHa9s8bDTgo65i/OpfnrI/YmokTzRrgScqfHx9/gBVyCiWpDp1K0Dm0qlZOTKfqhxXhPMXQE9IWBIUeAKFJg6/+ZMm2y87ji/kpxUd1Zq7mR5Nh4SJoL7xM1pHXlPIIVHOB4dd+xnjlAK+KmrUb4s6Wvt3oLmJoyZo9uojHfHrAN9BAeC8SwJKgtBW8jALZyHsG/OFQjuzo5caBU6Z+P1RWqC7EY6mgtwk7h74zw+buhMfYdFF+uVtKueUKnecNuD6UhWwmuH6o5WBTy4dAcS7unzLnmPfvO02Kf6A9KUxPD6IiaqXdxWLmH5NJYi7D+rrFyzXGuhC+Wt8Nx6Oia9pC1d3216SnYjoKql8tv++1UWoG4Pp7BTNEDtbUAf4JoZ2UUa0atmwDwbC6Y+CcMpO2/Qh9wqDylHudwOKKlI7hPb6l266YytINGub9UGFWAeF1wfYuiTHXsEZn8kX89kj1m/ixeKFDZx0r+r80UkYYok797yBdlEPltCNXMt2VNKs0VS0mgGv9oS4+KKRWrZYcArLw+UTgu/T/PoU+S9RWzxcoM4tb19/d5MqFDngGQGpuRtSmI8bjUvuql4QRcu3jwkGfHxTBtU+iFUC9q6TT8cTkzXx0U+j0Eeh2tGQ9gmnb5c5SNv2nMD6dhhpjaqBEfsRBBQecgAq66eVZsXMcyJdoylGQIxzXYKItYtjxoDTkQQHqtJvPNRqQdSsC5rGpxS0DxiQCyNKZgmIvNhtJBbRv4gB8PVCb7p1eiamQBXuaiNuwl9O6qMTyff+L4L+zMXeKzl0JpK3J9ywgliaTSHYpkGptT/cFQPN4HpRsw7PsoSLMyiJjflEv4CSs2Lp/p/kMAm7nGKcjdDYjDAPqw1MTKYRMYgiXDZ3XQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 495fb8aa-6333-48ec-f7e7-08dc306ad8fc X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:44.5917 (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: eepIrag9pJKJYUesSYer4JXgXdUTa7sME/8CnxxdIcsUZpvNqPYVkighKyt/ZeT4FpoN635BQZksT+kIJwzRKD6/aw8DNEfr8mRRGEpqFP8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791237517086406013 X-GMAIL-MSGID: 1791237517086406013 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 | 73 +++++++++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 5 ++ 5 files changed, 83 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..05ea68baebfb --- /dev/null +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLDA PCIe XpressRich host controller driver + * + * Copyright (C) 2023 Microchip Co. Ltd + * + * Author: Daire McNamara + */ + +#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 9ca66916c609..e277a5452b5d 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 Sun Feb 18 10:17:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp720632dyc; Sun, 18 Feb 2024 02:34:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUcF6RsoWjxN300s82iAPCq5wtCF7+T6RAWKQJskgq7DgjernbiASGqpxIEVyi3Z4ED4ci0vnAq6bGopTybWKtLeVrORA== X-Google-Smtp-Source: AGHT+IH32HtOvyroM33Vfyd0pNzOi/OiUj20Z4RmquX8NRwL/G1wgPXuRYLVsNK9hEtItmb0h1gh X-Received: by 2002:a05:6214:2466:b0:68f:65a4:f22 with SMTP id im6-20020a056214246600b0068f65a40f22mr664806qvb.20.1708252488845; Sun, 18 Feb 2024 02:34:48 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 9-20020a056214202900b0068f33327fbesi3939496qvf.22.2024.02.18.02.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70345-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70345-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70345-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 947311C21747 for ; Sun, 18 Feb 2024 10:34:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F64B4F212; Sun, 18 Feb 2024 10:34:24 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2096.outbound.protection.partner.outlook.cn [139.219.17.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C52E4D580; Sun, 18 Feb 2024 10:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.96 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252460; cv=fail; b=fT2k8fqo8ybv+RU9ts6+x8j71FzPHOJwzkvShk6Syr/BW+6lmjrS0fHFU1JTtZfhmYDmNHOhwNXMOoSF142P6BVXYQyxrdZw6ZXYr9ojOZnhRcr5HQK3V9vaale1PHcnJeJuvTX10ziEXVoav3oVQUoCa7Ri16gJF5F60mbZCyo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252460; c=relaxed/simple; bh=22WfnNEhA24fGIAnSj8FnGthhV9+MdctziwxO7auJ7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nQes1GYo1oBf15vBQQs1wnXm42crUoj6nZj74+4wS/lAr6ZzWxdCYMs5iGBtvRNvMkv3x4zgFZilYbVBnhwFXcHyUlB1LxyOnSuT9Z+KK9DxvjrmymAjwlmDwo91NYjioKTcQUfNO7SWtyhViia1ojhloZ2NkLLLGyscaj5SSQY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.96 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WaWKoMkTVFq8gDcWjjyhCLqbbKZBFAKFTAcfqHrk8mlPnqbP22+9MfW1pFnYsbxxbCNBio9BVvn7uvLlg7gO6XJGJI8Hj+FZR0x8DNOfI7iEN38KXHXX380+ypPr1nisXx3SWOd3w2PZv51m45w/hqIu2JApDs2bH6dGe6kZ5k91iIdP+szsU+acBtubfxg1kx6SqyN9XqGxSVE2CzFzPzF/65hMRlZuTxJv26TVtzmmge3yQjclM7/WugSDRF9cEu6XvGIN8JVdaYGOY8eLBdlXPQpJNCS9OlcC7ySALR1Eky6dcdkIDvCAF6A+m/tVxjffc6TG2pNpx3u/KjllSA== 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=mYEQ2l/ZFT7HZ4sc8aQ06+Kp2Z04wbnY7VcgNq5kQDi0bDhXzBb4H3SXNkaOvdUfylFkFQWaA1hJiWsZDSj4F6w1OEsb2ppM69asbGYFOBLLfMJAMjtqHlaO3J4cGX42BfdqXgbRS1iNfayJWZs4w1EU317dIPL7OI7OGNc0B/IGnU5RhM+brQjuiXBSiBUXHl71JYyprqJwIyXJI9URQ73Jtxea8w7s7C2oqvupytnBQk6C6DnOIlGJAULWU2NedTWAuy/zMYse32mT60JT2b5n7Jg/8f3hbU3+U7+pa8DbFWmjSQP87ffJDNcimo0jv/Rz4FJeN+0nGPwZ3Af4NA== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:45 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:45 +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 v15 10/23] PCI: microchip: Rename interrupt related functions Date: Sun, 18 Feb 2024 18:17:29 +0800 Message-Id: <20240218101732.113397-9-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: a5dfb301-0d0a-41a1-2b26-08dc306ad974 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZI3IDs8XAA+uWInhCgw0SNN9XONV1kzFrWl6+yBXReR5K5ANsyycBrWuQR19tO8/54yJhMt71RDVfbm5Wy7odSfns69qrhwp+dhm+t/iW7IWZrpXxCFPkR0IzCbkNYzFbg0I8yGpNPhJt5lAr44TksOcB4+SIVIntPKln8OngDcJGGk8ApjG0VXVItsIEmc95TGC332avQZ8pVCOMQeCNF3EjSOfYuFAMDBLbf2KiDDMFxtl52RY+Afy/1L+Dl4x3d0syovDwgfo3MbdVfDG08MOoFpRkZD0wsRHLvv2fbSrUfDX/2mFENXyqGDv4HwOQGldCzzuJ2vS0bfu0w4yjfoUm8y4oTVMVdfNODJU42Nd8/9bWeXxH95WR6Bk7y2v3G6ImVt8t5+e+WclAFWMnSKUTSRn70qmf8opUwvRj6vnG4fPoFKw419K7ktNiPgGekkuq3RgoKsD6QwevcHBe6W+Y6bTTIQD+I/7gDrDh/T+ibXjZm05AdfsNj/2HkN0to279LSYvmnPdBdInmSiMMXwjMh66pPAC3nwW1ce753MGw54dP3jrTEeByKfNmbp 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(30864003)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: joiRhsdCbvv6PwkOERH6uuKYtwhmt7KIbaIW9owg5TWBzNohN9bu2K4vG99h8a/0I1xadentbFhiF9+AOIc4jCBdlljfnwZTix+ul/PVPgkNIjLJE5mSsdK549CRLzsAPtzEZTsdkxeP/g0zUCh06aTTePR5Jid3JJpKdp/C0BZpoexeDpYtN/INZa+e2j0MJ8TksDBEr4qC/Wef3za2BXdIOWd5ByPwuzMwnXV1lLqHCDcwHXjUtbKAaImUP4Gm8IR1j0y2zDV8a62cIEEWNKmvxQvM8jv7ytDStb4BfNQ3YWCKi95HArbcHjNlZSD8mc2GeFlwPVaHI5rJ+OEq1MFiF/z6PRUc/hYa4t2bDt2XeEBCWXX8YZwnTmosiDcIo4S7Y+uUQGDcUKlSQ7nBqGsQuTK+TQFRLx1IuDoRMwHzQJUn/1ObyAhnA755YyDKffhJFnrBa+jiYNHeRnTyePDxctZkLClp7Zl+tqoek0KTf11ULQb9epWqr4l+/R+gyq1Kv7M0Pl0zKRFh7CnH1vkja5cGHuxM4yn4O+QNh6PhyKgp1WobWkExtH9pGcI4kllZIkXxfaHAcPMcpfc4rbBGMlWo8KtAcbGGxJMfvoKw/CqLHAmT9jopSdViKJXsx998sh+kPgS4rD6L8nX0xN9GoaQnM0YGHLL1mgFNB/vEisl778G1LlDeNaVDPpSg9E7shzHUJyED9pCTd1x7ujla9tHJgQYlvUwGgAblY4JX3eEe9F3pwB9VtfKFaGPUa779KpbSCWo9496kewKeuq7lBTzdWZtRQBUhBtNb/RdqGnkh86oD4/0VPecgTEdzdCeO2cGWiYIjoTR0e/XSssKhsFSt/z4qSGywmBVpBPA54eIkB449BRo+UYBuSBH29TeKD99iC+uwsMOmI3Z9ijSDpUiCkOPhKJgfzJ4pjqQ7YecNLN81xsvHhpbZvfOJ9HZ8lwVTmkhIlklOirsaSVtkkDvfYv5dAsOPURZ0fZF/EZmX/0Ry7vP6TQrg6D1M33jhC0c6RRDsCJCOKrtO4Q+6t89/Og60+zD9N8BegffrVTcUCpAsWF6Y7CGgsHwgYSMb60VuwbF27xeofWdodzF/c27RMTpbEV7ZxZNvJ7h9W5qo7lq6ZwzdgRU8rsC1KggIkCedu0OQ9bK/YZizHvgueM3nsqqaApbaS14a5MhyyqvbgDmbuksMXaNXCPNtUjSstUBYlnkXkyqkQfKbhKttHE28YTi5rXMCpaAFSI3i2fabvgRSuvvr/Rb8jdm1XfMwRVEAdeDUwc40rVQjAQMmjbjvzEr1zBkWtVbVkYnlhgAXXI/lBmTu1cClk67leJUQMfiXd2oB5Q3s05PEvz/5+O9d2xt1K3l8diGEVZ7mVK9uqueT5CTTH1P9I9J9Qn5BipQc3VobIUs5vJfew29n4o8Gl8wwJIvdHwO5cHfkX3uBF7gLRXvl3zPAyPEq4dldGUC9HfDCCKhqHMbjU2o4uKhGMkpo9S8J4itpDIe6myJuVkE3BaWkC70DQmZ14yWcOpaXbqICNKGePc51Ncou5Hb3GuaXWg8P7lZD+RI/A47j4rC67mbN2NC8oxKY+aDTTEqEJlT1uTa4OqpXZw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5dfb301-0d0a-41a1-2b26-08dc306ad974 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:45.3598 (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: CqXO918PbT6Mj0Jqm3i8ktwRGhd7TFxdPhIsAWbDg7A262Zb1BbiPP0G48LgXxxF0eI4GtntlaygZPXkpRktkmesnbsH3t+1Ar3SP7RW5TM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232561907263441 X-GMAIL-MSGID: 1791232561907263441 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 Sun Feb 18 10:17:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp789061dyc; Sun, 18 Feb 2024 05:55:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwdUwAVumfxtUt83FV3kFUbLGB6/cqNdpxz//RfxadDEZk/ri3a4yoXWn+Pkg3B9TlFgaqPn2RgibESQGLUplZZbqrFg== X-Google-Smtp-Source: AGHT+IF8R1aZoxjGojIuPQnFmg1INHEWvl+rtXUj/H6ATkn4zrm2Yb2eCtXRuW/0URNxJbiUG4uV X-Received: by 2002:a17:906:d93:b0:a3d:9515:f196 with SMTP id m19-20020a1709060d9300b00a3d9515f196mr6090588eji.5.1708264507793; Sun, 18 Feb 2024 05:55:07 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d13-20020a170906040d00b00a3d5b436455si1674417eja.153.2024.02.18.05.55.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 05:55:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70402-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70402-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70402-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4109E1F217EA for ; Sun, 18 Feb 2024 13:55:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D4BB6BFC1; Sun, 18 Feb 2024 13:54:52 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2139.outbound.protection.partner.outlook.cn [139.219.17.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEDE36350A; Sun, 18 Feb 2024 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.139 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708264489; cv=fail; b=ErjFDhESuyM8j/SWFel1d1r/t50icpqzy6lO6/CnCVpAWtXxKkpobYsI1m0JzOvkppObnmkdadsz2jPxl+rnrBvZIEGfWuN2OjH+USaDm5bOWiwog0UKQT6dDK8grqthBLNySqLk9O3Ao38wEIMWZ6YyhcYNiJiH5T5bivJ/myk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708264489; c=relaxed/simple; bh=/4PccNbWjjS+4Uc+iPMog5YcbODT2POYLU9j4TmmDl8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=m4FVSGU7pvI04pr586WxKrs4bng+em4rSWyKnTf/8bfGckPOOimg+yyaclYia8fbACjgwshMxnZEFsu7QpCJlb7vodmPx9BCQubDAIFg2Jw56w6f0kbRECN5nySjP/uNLwS+edhzx4XEQ+VfJhijilzhTUrmHNgF7w2+F44/WlI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O/AXF0Sh5UMBpORY79hRgdA7qgky+XB9ZD7UhB9VESE1LqGvoGhv7tsQQcutV9OV+64XjvX8VqBc5wFOB+oLQgmrUhG9x36YfSASFS3GEuPYDD8fOAYDz7B294Q+E8qAut5PC/qw5AtN1ovUElD/4odl78aCiKM7rNam/oX/6RkduujLc3bmY00CxgCjCRSghLRTi2chrnAM+K5Yu1OmRMu4q1c0FQjdxlkI8DOGYQqDvTurGfm3Vg3aIAqhjrf4PqDOX2WPAJdynjJIIP8XOJ33xkYAVN4o9fW+jDJ2aKDvXWrHCdC8kJ5vUJCJ7Wo9n3LdASv6ZTG1n4a/obTvgw== 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=qiqHj4APLQ+5sb97w44ol5KWqweOs8B8Tg2C7Uqvdm0=; b=YZtmA3Pltg/wkzVtetNM0dDJizxKQSBwwt3TaP9QF83gvxNyuripwsCgcBe/E8DaOHMJtMfvguBiTOUasVaEPsGwIGoEeVXONlPWWjcyFSVOsuCOBfHxMGM9auQPDdamY4iR5/el8Sezm+aelOWWWJHUWrcODQ9NKwwrCk4FL52outnsfTOKNTdrDXBpSPEerCdxPaPyE61liTBcF4b3AVR7Pd0R8Fd0A5Y3jF6Yc7J5wyJlAy0NwHto1/lwbQ6F+uVvByMhQtKP9uT9rKhmpHNDnWce//Igo2YP+KwjU1y+72jUaD5j5MV9cQXOn8eIpKopgkTwKUJ3eVqobjrJTQ== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:46 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17: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 v15 11/23] PCI: microchip: Add num_events field to struct plda_pcie_rp Date: Sun, 18 Feb 2024 18:17:30 +0800 Message-Id: <20240218101732.113397-10-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 65bfaaad-ad15-459e-99c5-08dc306ad9e6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: co6V7q6hZ0RZCqIypLTafcAzhAnVEtOuUXXp3fpav0iIH9ducynUUd930CxPqEjabY7NZwCDAVUDPZbfpQQf+Gbs4CYVumMAJc7kt8s/x6Ib6lCfIqxKXzQeOYiz13/S4O1RthTGfkr5EH18keRwyYDKZqbrQ1nQRw/veZLV2TqiDJTTkPriWOpalOFrLq6Zfgsq08azvEFUhbZ4sGUfIS9lronFgLlYqvDrxKGftTvVk/1UhsJHRsknEo29D2aGYSaDpMerUXHt8iRAiCRc6yoH110sFrl6fkFbCxGFYJvgLWl8aoX/UguH+ldkRUGBsW9eXSprzZeWnnzkuJWwCW86wFtYiPtmLpipAIOl+jRejQ7qAl5AG0J18la58sLFowcfqL8fVXKhDilfcn5iSKGxHQSclDD3Wc0dhwyZQPveJjsiYwVceKYIoHhqGDrLoISJiEBdnrPctOE3QfiKGN22CXC25/9gbNxKFntY37ikzqYafC8uQJYZdzo8IMG/I63Opt8cM3kbTNZf28A9QPd2aE6CfThKKCyfS1dsaB4EMfFvXuEPOp4Lz+evFjsJ 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +B/akDW3uBJRNeHBHZ4bPTIRvcXvqFCLIQrVe2wWNUaK6i4rICLfkRSQct+u5d7urybcBlkiRqHYbxzA7/lX510rziwsUQagnphYQznvQkflaUbjVUJmxGRVnaIVE/YCuJwGSWnR28X8pWeJfmRP9I/A7s+k0J7qRgpuYbGiwHh5xs4c7nxLBeILrY29r1Cv0KDTz/ujCh8mtBl9GBdbL/IqXCyoBmgGpZx4KYdLYlPf7FDDO74LdXzgAsGFN9ERo61eilXcok0U+XpTJW14hx3yS4AWMS3XZV3Z8CmtF3Rn7P8uOhn9Lb2pqtJQuTYaao7G8ZcsVxOHhcDiaJ8E5HSV8ODzQBkFhkPLigimOcGzQRvEIpJbsaHvITgc40dvi9X3MWQix+UO3ftGecECUrQIf2gL6lTySGsaDAV/gG8qttXftbyG/Ib5x9aOx8UyzCKlW14wwjQpva5zOFnOCcBOthp+gUi8kP9zZtQOC70KKIpoMyQrkjQs+TI11R0/epz5/+Asj9sQQPQxA9ZIHFlRIgFMZZBkmNn1Uq/GM52vPwxOG2IPiUcLWzZwXTtQrCOViMYylWYmSxfMjKu1+Cae5PKCIsiuy7+WFE0N6PlZ7HIAja422PFD+7inkGlfdjRA224KcpALFiBwutiuKw+ECWTNnSYQVG7HPq7nphqJuL+fu13iz7yJ54BhCMF1VFfDuMEI28Exp2xWwlv7WocRVvPREkhI9ZWY4gNfLqWaof/aPLokQRGIYLEpYmQSkndtkeVytGmDZL0PMt8yL7mioUkoXfGYIJZTJHdw+pL36WDga1ipMYapHvn6OZHzLCGtrLlSavbnjgPGDaPjYBjUZSaM3juxjL3N/qkCGupdtt4M5UDgMqBCvfhEddHlOdF5W+MbgGoqrbxEqwsPflp1l6gw0lUM2vhjYAXP31a4ULL92o1GLPhyqjBKw8WTGB1KOq7i4R7w8kO9pWmKk1n3ikY0vlmlKe9pG0/7leIK339aSZ8Q6uBXCj6ZXMDAnnyuUIgpdrpj6WPuVoo9+MsskT7LmXy52GQcc9ypULAm/2sZIlRS1UaJNYBlgrrxP9iKMucX4xXw35Q4Se+RxGhejfVVnd4aqWrXUwgRll+lp45xANgfxre2VqYp4mCN6pNphM0KP876shiXJqIgXRTW0io1V5lvA9OmxzxvBKmkx9wElHiJL7nHcV1jxmvE+DsGy8YVO8FO8FqDornRlMZmyNqn17QAahQoBh3MDDw1wG0ZVHvy0f1AvFhcATTKBWPsakGZYYoXw/GjtkeAW0V+HKtedN1ESJJ5T48IHKe79u6jVvIXSTU0JMeFxMGcZHfF0nnqosev5Q/Jw5COAWiONbqYD/VNgw8oYYtjYT9DXja5VmwTW8FML7Lxs4EUNZAyJi9gbnuC8dB2FuJ2ghU/K5T7oIIYD6Id3WTU7mfwzQFD8FFTz0oSwdQAr+Artmed/7IjKgSObp53WGBdghzlslHRBja8UtTCAt/d5Ma/c4CIwsISjyAOrtAEZtyz+wQghNIEO0gQrTb4nR7ifB+bSAmBoULWNkVErS9EQougi5ARJ3B0iVHu8iXnR03jAy/caxBhtdwP7vXUWASMNw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65bfaaad-ad15-459e-99c5-08dc306ad9e6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:46.1389 (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: VyZ7S/xcA6o9tESdyTN3eT2BayA6xOTVwzqOCf7yaaneKMArszdvGnnNqKFFXMMLZphILrrirGgvmyqWBmp+/BcpY9wMLi1KJ+9EkqqZkv4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791245164491899922 X-GMAIL-MSGID: 1791245164491899922 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 e277a5452b5d..f7e900b395f8 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 Sun Feb 18 10:17:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp726180dyc; Sun, 18 Feb 2024 02:56:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNPZL+dTnslC3HqGG4vkuWbqhKkPc5cvV7cGRFevGcm6dH+PiO0utDji+R1Ip2u8Z30wrEMRLJih9NPiug2qLDDZnAxA== X-Google-Smtp-Source: AGHT+IGVo+qul2Ea97wqyXWw0+SMJNe41FQrBeOO5e3DkbM9mMrW1ZKiDFmnpKYzc4rqkEKi6kwP X-Received: by 2002:a05:622a:1344:b0:42c:6af0:860b with SMTP id w4-20020a05622a134400b0042c6af0860bmr11884482qtk.12.1708253787044; Sun, 18 Feb 2024 02:56:27 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e17-20020ac845d1000000b0042c36fb227csi3447857qto.421.2024.02.18.02.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70362-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70362-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70362-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C55EE1C20B5B for ; Sun, 18 Feb 2024 10:56:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FEBB50250; Sun, 18 Feb 2024 10:55:49 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2115.outbound.protection.partner.outlook.cn [139.219.17.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471984F210; Sun, 18 Feb 2024 10:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.115 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253747; cv=fail; b=gsc8fnqsaeGoAE+uSAirmPUpgfQCwnwHQBrtvkFa1m63rN8UvnKWB6Vdro3MMP6va3AuQLstDpv/YjfQUpNWITvJs5Se+Vcbyx1TuuhPb9yYLvd2x/oAjGY7RVJmdZu2CTRJKi73iFKKvyx48UWTOfE6sLH1Psc32B3vVD15EYQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253747; c=relaxed/simple; bh=BBYnptWQIjFtcUllo2fZRW0ZqwaT8YAxJA0EoTd48OI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VMaZwvzZeHe39yX0a6FCpS6hDBiyzxn7du4uhi/+n2cjtniKjD4xEIpgeEHj1+h1nddLyMcmi307sOetdHDt8reEfF92OFR1lQ9xFuHJ3tm25NZeY+1EygRvXyZIwiX3nJPCR9AmlCWH4mOVP0tjhS1gInr91xup59CdD0ZaPGs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ooi8HT1DC0XrO8v0HoAF6V+Si6YjyKMZrOIh3UVFfu5UTJA2Z3kcM3eApyqPyDpk0gLxzWde13JdvmgYYCgtcg5BHpA/AVTKbxzQKqL0n13LMFvb9OeHeDXd3RzDUFypjvXX6i9An3imRwTZYXrDYJnaiRT3iwdkSQVhfvprGhddmWehweyQOHTnCfOhyAl0x18pYN5cHeNe52Xqk+7s+uBYoiFj546vEwEqguSKSaEaVGspBkuBKH0LASzulTtfrkhwOMo7/BUPRpILpE6G8vj7znEARsxT20qxLwBt7fbmzLDl1KtyWT7uUc3RhOF8jX0gKj8oiHN0Wg0GxSTrMA== 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=loSF85QfSFsTWg1Z4YTdJt2rwA9n7SE/EKB3f4Wn2eA=; b=Ah4+AiASrc8j4dQDgoE76SD6UkqRgRajJYL1J4Lu+IMsR9rjHDs+tDLxwd4Lom02z3DxDC8xRAtO7Rig5DQcsYmN6xJuOX4/8vGTEouAkzu7igMXWwsvwnyGmWjbWCqELhqPEx3J3OpIxX0sO3KT30OApUTEf0MvtQg0cKBCSUiDMr6yCI54jOkuUA5ECklPDFyRqed+vEr87HyjxCpxskj8WghQ1Jy/jmA/Totfm5SEjicx8L3QvyWWkl9lHzh/VhUDybeTdcgWEdaOG+u9dEQU4fIRRv32FwlNUUtoNejjwC/WipPch/zAslzzdJADTNKWLtB7Bcxc0I2cq1KZ7w== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:17:47 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:17:47 +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 v15 13/23] PCI: microchip: Add INTx and MSI event num to struct plda_event Date: Sun, 18 Feb 2024 18:17:32 +0800 Message-Id: <20240218101732.113397-12-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101732.113397-1-minda.chen@starfivetech.com> References: <20240218101732.113397-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0022.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::31) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 167f5ee1-297f-44c8-8978-08dc306adade X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VEQRJ56M2ulyu/tIthpjsVSlpTDpYLnThb2gz8lWAvuI+YFagjjhw8iZxDEFl2tww/6z7jMHHDWVK8sB18qulkML0xYy3VZIATiXZ9bi8zLdBYL39XzKxHT+IwnUhR77oOem49INcftzGxUwo42jRW98wMrZjzPbnMHNh4QUfzKex+f47DlQt9CBj4KgYIrurqLdwawGSjzyX7GgYns9gobV6srKTo4bIvQybdzaFs5XDa649W7Brg1cECJRtDaHzrbcHo+BTfebu2Ar8MpDKNeuIEA/TfwqSMeZ2nqxeo2E15NZOspLPDaZ7anB38CX1uey4JJnmF7p5k17MH7510TTGPZP599Bv2W1sMjmLrhBU8hsF9CZhoxHZYx5a74EGtAhrT08ifFmizlERXTt0ZOh2HEFoPuBJUr+OajZO3ibLMaRsaWuGa2i6bzGl3ysotaKxuiCkCP8dZdbxlRhqQVRf2RSsHQOUo21l5cwYM98cl3QckmCBpGgNOVHXhmItAA32o7K+rGM4JQqKYihsTEZdEKhTAQM6FrF8/ZwjjNLIoX24bvBGYhL3eDcezRt 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FmwKvm/zcNzg66q5lR43oIABZpZzRo0o7rbq1vZtHlR3bkmXtvFMillV5Wo0YjYOhEgucWMiSkTDVpqXLLIPlebAiK9WRcVfZ4kZGZzIwDVhaL4ByxUo7u0KCNoIcZ12QH3edcmvoWaFvkEpijIbbHYM8JF19TbHGPuW4oFJsTvQi0eY1yDP08scMtUCkvtJtXlY2NVXK7A+qfkmXetcMOop4wi20ZvnPI3gnZIvA6eRENB+pJRUJyciyXkJb8CHPjWbGmm822MrIIs6NkKKqeu8TzZ3jcnBYwiBTo5+Q6eHMab0cy+rmXozw/yVxlMaqpsXdVPI5IlDvamcyarnraf9KPBD0KYcbzqRxZy/ZE3dsPi0P6qn37E5HdiNkPiBJQxwi0AC4lA/lU3XJONwRwnLzP0SK6PPOE0TrW/uV1SHn/OaqrOJrbYZ1p+FHN1++gaefJOZhvF5LlkTqjvS4GwhtH4u6bYgq6IUehpdF52Rz3JsxibKcnJ/xYr5EX03yZmHoSjqVX5SOPgCiQ/NUOtQK4lxFtuN0MtKsDHjBUx468MsWZGKwB/dk327V2RSJzdgYqUJ/wWJifA8p4IgVyqWq1HSctzEQUmBNP3o7u/Xfrg+mbwiTocet+5Ra8E3w5/4SmNIR0u4JQfPPWq8ySW8Jf23LsoqON9py7DfMEwnEdjl1dHIgbXAeMjQHGKIAoHK1U+WGeuvdAVNedWDVYqz66P7XZgRfwjbuhPJxHomPExtqpjPfs7uXtkWNGm0bhi3lJEtwxGY8fPez0sRxehnCna6KIDFsUnqy7C6z+V/uVeSk4IFa3CNjDqz6vxaOooNwgg60ENRN+SZ/RX4eEHLx+4BYxclKxtEOKOse2IN+tg3jl3vQzelBk/ldsXcDDb/vN5j5BR2xtKIAAomCIViMiXO2NuLIoi/iMGtfL6mt/nVxBwPPv82lgE8OdT9MK5Yd9ACmH76beZf82g5wcFFqsuDGCzz74jD+laXF5BcjGTQcTZhFr5+WPPx8l/J6j7z2AD3FshvyOcJXI5/DWZAgs8hpyXQxbx24/4QOzQHulYUShl7HhHcIhcmOOJrOigDeQgVacrWTJZ3F1hdi5+Q8oMTt87w053Vi0Oc3YL89Dlt098KkQfXAmjD21UonLebh1NBZ27i6B31/M8FwNtQFOP4N709D1h/UxHO71JlcbS9Ev9jCnz87D02NIgNeuQBL1PG07rYvzcPuu5N+LY2ZZ54oDVFXcBaGl4F9r5kzm0JpqWO0R5NLrwFAh78PIW7+i4GDQYLJf9XbMT+slLuy+n7gWSojZiZAHwlhCUuU0o+IC1jbJJikokCDlE2HAwKqkXop4ceF3DmGk4wEQ4/ElFLWzfOVyKdaHRFfrsEAJx4j8LlO/ncuEDi4L1FCb5zXNttRCRvaKeP7+oqlFGTV4Ewbscm83ajcc1v7G+MX2pbAtLlFRnVcGRO9lrkEZvi2XBARGFM45pGdnhDn15c/7UPRcBQSfwb2wjqa7DKDiK3ReD+TzqciK1y3KTkpqOeUjuD1bywOS5c8XHs7LT+gZJF7z8kxRxUwtDh/4LWRtMq37Wms9Tg3E6dj+tNsVzBjxzz2gSOpMxQ6mj0pw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 167f5ee1-297f-44c8-8978-08dc306adade X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:17:47.7640 (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: WMOH0Mjuif8ftVQ7hPbQZyLEwdnfU7J0HyOboyGHY8HosDVvrEvKXYFE+H9lgBzw3CvAt5ODiYyCvTOeC8ltMuoIf4wCKxF6u4fhk7TDAqQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233923054254200 X-GMAIL-MSGID: 1791233923054254200 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 935686bba837..89172ce18237 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 Sun Feb 18 10:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp720457dyc; Sun, 18 Feb 2024 02:34:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqmF3h1SQwI0nddSMm+As6HPbItprbjRMceqTTz8PR1snEJKTsoWjPoLDLtEw1CxGgFV3dk8vFLaxfqQ8X1Ti7fKZkEg== X-Google-Smtp-Source: AGHT+IGx00NmevjUBCfIyc4vl2Yz5j0ZiABxhnWkIgXM0E7K/yFWDKriUYt/ULfIJOCskxCVVUty X-Received: by 2002:a05:6870:2308:b0:21e:a8dd:622e with SMTP id w8-20020a056870230800b0021ea8dd622emr2444535oao.5.1708252449409; Sun, 18 Feb 2024 02:34:09 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t29-20020a63b25d000000b005dc8914839bsi2758350pgo.5.2024.02.18.02.34.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:34:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70343-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-70343-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70343-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B6DB1B216F6 for ; Sun, 18 Feb 2024 10:34:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D5B34F216; Sun, 18 Feb 2024 10:33:40 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2100.outbound.protection.partner.outlook.cn [139.219.17.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5509C4D58F; Sun, 18 Feb 2024 10:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.100 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252417; cv=fail; b=tWWdRZBj6v1fTz9vYRpqq9GcsQKZFZ/BjQve2zJdcNF1TjsU9Ey53BWWbBj68sI8Y8h72ivf71+ZKnNCV7gRgEdtcZxjKh2SIyH7QgRHDf9u8G4G42Nl7YH9StZgxgqlCo4pWoeOvao5Gl62GXWUaaVjKMdFvLORifnt9jP85RY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252417; c=relaxed/simple; bh=SDRluIKdtwPtKDRBugcC+G+YH4p+OtMs3ZNtesAlOAQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=oESZWYp9GibLqIXpHH9WSomxtlWNVW9m0kl/QHd1WkwYoltN4GHeULfdYUOOSVH0VEaLKPc+LKgJYjxQ3AE3HMABCw3i0MuWhUkAyEsVzrPIZiJ+zVZGCny0m0ZspNMy8gdNBJfvvRdsEOybUFEeFeJzoPbnNlcdjPXV28xYf58= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XguiKPLkvthW6VH0kQwjo1wtBwuh8HAnwhdHZpkZpTuDuMB80zB68Dp5kSIHpfq4mjH20Red4NHy6MYC+OF7y8JzOxWEJBLNazZ/RrET5xeWHKWzxp2UcFIaL64Nrmm02qswcTlI5SQcnZAvbQQQBHUcnu8wgDbU+lku67Au9x77vXTLjOWPaBJsRpYezFoXjsg6L4w0jeYJ62Q9YVOFgq33MGVeUegNPu+ABmkgJyTgntR0wNLhUYovonYvtnsbRqVfkpAXXua2360ytZBZtWXWBC5TVf9rrA7AIlb1KZQ6o0GkoALJXO/b02Co11DGiQckEhqhUNGQMfCIJiH6uA== 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=SmTs1eknZteQDcx68ARGiu+5RvkDg9S67OJ6YG+dVN4=; b=YvrhnoHcRbRPS2kdi2mdVJoPUTl0qDFdo1MQTTwkbN1ebDat+BEw4b6gsdM8P83qFDzfohPRwIk05hCHWKbLObcMdY05+Z6hlHGYAewXnoO6WOJL1JNGXGw2WmnfyBqDmETgrx5FoxYvlIcZx6cukEz1vkAb2BW9ldlCf+HP1GxgY7mtt9gxUo52u1qp/GLwMBfl2Fghb4MjIcfDGQW/WAqZAAI6BOX6SLr1ClnRc/tMXvZwRIGtXjXD0dyK1Th8iB1wNgOw9JBfTA3nX3NeuyNYOQPrPirU+u6dgVUQ9mzrWh2LEy5WzvQe+rh0QDI18KswTWYQSr2nv2unK8OALQ== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:18:40 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:18:40 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Thomas Gleixner , 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 v15 14/23] PCI: microchip: Add get_events() callback and add PLDA get_event() Date: Sun, 18 Feb 2024 18:18:30 +0800 Message-Id: <20240218101831.113469-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: ZQ0PR01CA0018.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::15) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: f1e88696-6286-4cc3-4218-08dc306afa00 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fG77tOYjZ4P2hWB+06HUJ1mp1AcpAE0Csb/ai/js8BriShIpuSrFVnJA94exwtvhFXf4wC1B9gnZl36UVboF/OfNpxSxTJHu4hf27B/gYJvBcvXldhVopotMF6d+/wWVnnDakZkUOFQbRRE2LpZPfo3/heImRlna6SSX32VHXhY0H/2pI9znOGcFqHSVDycnQI9cl0GmURwQ/xTPu/ilHtX+uFS+qcImUP0HGTqHXXwJfcGj0UQTufZkBCJ8TIu5AZJ+ONx3FmMhkcxe6yX1sKYr2xKLGpsxbv9r2vJx4csDcRqt1cL41KZvpTHGKwfQXZnhbOhKejfSzIAMZZ0t1pLsDbJm1OSJFq9wB0FNMekx4b6IIzCt47QyK5L0Zdi13ame5RmqiTP9YeAdO4KHlKBIsZogfEGwk64cjlZuIby2avDSI/5oMke9QDBDXfHllGHtlbEFeWx15sK2JIqo99ylHHdKQjWfV3MV81VWI6a/x2cx9QF6qP+tj/p6dr02NWzJpJayXJOmA3UE4AzLuGtuD0sHo3Qn/lgdyNwZ3a3eYEZ8w/gA/R2aQrrxOEea 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V7HOLSjhdEebLdeQzhIxpCek4Q+uRhWOEv6jow9mSYnqFXD6TAgeH9Hox0dxt/Psm2hLwUfARGiO1Nv/U2a1VF0ZKocaLDwPk1+28PHYHRbp1Lo08Hu6Ejpa0CNoabECgN3FAbzlrfe0QtDBf2dwjF9iSGXLnKCk+qO/WVgKqMvxLrcWoW+foia2hIxy4nG+1XZ51/NV+yJv+ilMXuo4kuovpOBFHjOzj4A2CYsXEh42D1JByQ/0fTBuE+1tZwKdqe2bzsE4YGaKXOVGp0LuIPoiN1s8FsOzJZpZ9V6Q7seT6+6hCjNYKDEi3466zlu196Q+qSnabOOKSCMas4M+cG9jqMAihO9WXgoR7t0mPKmBCUkjfQJM0KLpjEaTA+qTg9PO5R5jD12UvN7oaj/gzLtKWttn6IkOMly3HrNKR+Q/aM/wMsL8qWwPPTxH+t5bMR5mduwrO5yf2R0IybpbGnHKd84au/pE4Z7789T93ooxnt30WlzkWJ7Wbr6fl4pVdaQRZkQxQ8tZwA83zGh2/kM8KJy3v5mtDWtbd4fD1xev81p00M+wWMjUnbjn7vXjXtK7qX/rV5hKSUshjWSc7r+57qj6k/xnc+r3jfmYnoD3pl9HYIscAkPb3cGjbRCACof4EwhjesBUr+9UD0BCDxgFSjptsr5sg+LLbBJ5Sz984wkb6O+S0rolJcB/fX+LYsqf2hU+eYvxgJk1xqEO0FjFVctPPwatlxozYqxa++heqiIKo/Q0KvYx6pcc3SL5CjijQC6uM18jY3GGF29VPy8EtA9f1gFBpWMRAa27vpcvzv/52Lzvr8bTB4YC5enkGQCQ4ipr0Jw+kr3nFSj05EOwkNfBtyS7RrKW5cPo6nZdJ6RUaSaxzBaF04sii8v7jXKKXqq55CxYBC89fId68/ZYsrAKcC0xZKHPB3DDkjh68weQx6HY8S+f+U9VXsBektf9JkMESd5RN/rYmCbcsdeTV0/pXPLf1Ps9xoM7nGFy2crifjIRZf8b7vkgkd76ymubm8N3gYAvpQxpaozbc+RBAtpwIRt+6xeKnq+cxAKaopn1cf7QHFfGWKofOsa+kiY1XQ5Rfqb/V/+lpi4dCuoBD/mb2B6UV6uhIqQaKS09ZaU1k5XviDN+z4swwi7Bn22aI9X0eeyorNVxgsXn6zgu5HIndncXm3bfg2VLvPyQauXV2moIdPmL4wpmKm6sv3x9VA9QU2ZhItO0/Dv0LZAgSc5tBOC9iz+Zie3bJiBDZvBKxZSmCZKlaLwtJ4VK+YzsBO1py9wcb+EJc8+RhpzCVNIMii1bOiputJUy4UVlQoHsu2yC+DGCZvP0RnZahbpkWWAdODRDYuVBUzCCK0IUrepPZw6qqAHCR5KakrqYKCOdQeDJ7+VxpUSz5lfPY1OAePZFhdrVfSGDLdU7qSj0heIIb7iZAPHg5XhU7/qTtsDWnIf3+YzKNqEzdvpWDlssJUmU3TPxq2Cbfx8SikEuPFPne7XkBLut1KPOsJHGV28nwdnhVFbY1oKzC8J0Kb/1VCg0mkXi+X7ZO7SQJ8gMN5MnrhVwML1kRPDybZiDesYdXkOnr+91vwiiPXyi0Bnwr1Yz8YGzcoduyr0mBQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1e88696-6286-4cc3-4218-08dc306afa00 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:18:39.9877 (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: 6w2e52Yz4B5wIsTnfByk6aJTCGiwM37yFmNVNKSvSqp57BhUfg4HpfD6fkDN029wuML3/7A308W5c92Z/VgzmNRuyi6Y/uzI+Obk2Ab3A/k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232520441835247 X-GMAIL-MSGID: 1791232520441835247 As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showed, 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 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 89172ce18237..e0e5e7cc8434 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_EVENT_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 Sun Feb 18 10:18:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp721043dyc; Sun, 18 Feb 2024 02:36:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUiIEyNsQSvn4wzRQ70FkgkIm30kRTQYhfHU2UEwZSpRldgfgpBL0QFuSyapCFLr4dEdDSoIZmoquw83hgRxiciRO4iIw== X-Google-Smtp-Source: AGHT+IEXA3tQXMQAxVhcM5RACyA+BaTAt11pAUCIbxPxVnsr5pV/Nzzlm6aNaYZb2U/1UoZItJx2 X-Received: by 2002:a05:620a:1650:b0:787:35b4:6bdf with SMTP id c16-20020a05620a165000b0078735b46bdfmr10253488qko.52.1708252586390; Sun, 18 Feb 2024 02:36:26 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c10-20020a05620a268a00b007874665353fsi4324586qkp.308.2024.02.18.02.36.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:36:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70348-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 23D941C209D4 for ; Sun, 18 Feb 2024 10:36:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 751084EB5A; Sun, 18 Feb 2024 10:36:13 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2112.outbound.protection.partner.outlook.cn [139.219.17.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90A903527A; Sun, 18 Feb 2024 10:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252570; cv=fail; b=LAMMAWiBCgr3RnXjsn4rsJVQNeqvkUF61+n5Xu4Vj+pS19LmT+4PpyK5WDoahTOL+5hI0Wn29uwXKJ4PpsECLKzdPrsmrPml14NeoDvRZfjcSIZSulfnO06yrfp1m4/HuBzk5GgN6LxGoqm0hxk7Kj7zrij9puQS2VGed/rdF3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252570; c=relaxed/simple; bh=6SnxoGHctv+weLX/56bmnX8+FM2s7IXcfCAn0xJUvD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TpSbekT3J8My6/yDIfvUDgV4H5dALLvELDuie5aYVYuZJSdJihGC3mH0IWZ6hHAzHrZIkdLYe+NwM7RcJJ6P2myYBAmOXegOM3Z5ZrLLQo8s5GVyTmlOj2NMGIOAHGT0ON4sJNLWomYySBzIKcf0hMvrNCm93SGFrZEX+x2IQB4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQKWX1Go0G+vpdJhmkQcsKc1BS7KjvTvBYp7RHmFXejP3gKIxkQz9PG0Tz03egPG04POk6fsndeqI6V18OsQDJz7XOa6ZDzH+a7ILQZhPvPloXrmW/JAAk8jJpfi+jtzGgqHvDfcdNU+U38ULnRyW2unBTb1CaYz4hnnU/Dv5OiJEtTxvqtYQcFMHtwwUrgPkhZT8Os6w4orwtJi8nJ0nw290rAb4BFAzNvMMwoVb+stpncUMkhZc5v+VgqnfogRiLKqY0rlRLz779sBNxRKu6pXrir8Vz2u4tcwIVyaUzYuTmmlPLN/vSSh5yJbJ+HfB2AB+y4fq9K3rHqpVYyieQ== 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=nFAi/9ANhMNoN8P+bySA8VVky1s7VfWBI39iKhS+vok=; b=d1k8UoX1GqqUXd+yVsOoei0M+QTwBihbe1fppvMAsb4L1FUc2zA0nkRuuXNm/Cpqjx48VGBBTFpHG3H8iB+qgKyWrn4U6OcGT3CZuYAHfYaLuV4nPEQmp3OS0F0HHgIGFML62f0gB69gfUCiMWzCF0LqPILoPgQFyiBGyD1rHnKwOdYySAnQj+p0Nb0f08DXJlXZU4boH8WvZ4boJ1k/dpNMB7xydtAlC9stfMGyHixLvEPCB5b0F8ZbyLB+KdCZ56rPtKGFSFlWU1TiBz4YShoqSznz4AO5Vg9d5eynIihVBDLAanctDRsNJdK4UY3Jh0Di6C+HkSm+yWAHAOL04g== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:18:42 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:18:42 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Thomas Gleixner , 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 v15 15/23] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip Date: Sun, 18 Feb 2024 18:18:31 +0800 Message-Id: <20240218101831.113469-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101831.113469-1-minda.chen@starfivetech.com> References: <20240218101831.113469-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0018.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::15) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: ecf2983c-89c9-49e4-54ba-08dc306afb3d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nNLym30S3K6eBi5q39Pyd6Gvxg6GwXIuvGmh0bGZkm7yP7P03tKVj0SPmhMmktWX2tcJPypKmIwLne7GhxbSm4HIRwdMwWIVQhUe3+9/UV3p9BHNVS0xN91ByB4c58+974rlkJDosjhUOUMW3CRqE9+mO+iI2b33V0zoRBNuSVN2TvJc4j33t4nmSOB211y2fpfB9ET85p0+LxzfJtp9RQTPxLcoCQ1bxvbesAGB2/FfbwUE62/gnCa9dG2g12FxCAf87D7A3otrZHKo5he/Lo/3GJqMd1n4Oon3oNdoVdU/yDH4b9AFW7trFYhtaYUsapgfp/osWmHE/LS91tVO5QzHPc/P5Pfjq8kp0kkqHl/qsF649cS7DnE8h3/cNlgT3Mn0IdlMuLNErUP23/u3LPLK9EOG950KP9d8mDw2jbmMEYpaxJeOE1NCPReEdfExlJdQEyyng7t1EabpmXRVK2pGruoPqAYahK6eUBLR9Kv9opbXaH32Ubw5Wxw4T8JD+GuaCFIRLS6030qe5RSbYiUrEgpIkC6aJHP3Ds5Hi0RS1EG+esKxXc5S4CcHt9hq 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M6MzmM/cLJHg6ccv0uKExLpOUFVuzBkArhQ6s9YbXsXVqepminBUlIaJJEGWpHveBMOxUeHSUyfre+1xhPys8BU35HmeXFfNAKp1gxuPZGubGIPcdeTow006Lsqi8MAiRSPSm7QDtW8auoc+QK7Aq7p4/FH0isLjpcsnLqGJjkEE4sas+A+cILiCyrG6hakjRu6s1rCnt1/oWsqW0fU6b2amb8QunZbdJq/bmVZdx45wCHHfFWIw1FYyU+CtAalEGjGIGis3UAnfnEiULZfFR1aCEQbcQCkazPIppEYlEY8/qDoRNr9zWl03LcZCZk2/X81Xk5cBVrx82+NcbWCCIJiNTjB26k3Mp09KrqYk4iyJeMxhoHbanHAK6Mfhl0iNYfKMULhFsJiDZvlmoUnVDyHT2hYuBxWFTWfE2w3NdxYe36TgK13Llo46uOsVtXTIaytFnN8TM7VLfRdLWljzf9BfGR7KQWeQ2V9kDqRebNrg3DQ04A0D0B9XERrOdeBAkvgMqEVF8BkHOj0uBmgWj0GqUc7yLe7FzQX+czJ+ZK1OWBVGNnjoYoiRmgN6X9kyxxLEL9uSPN0ttmH3mlC7vOgO3JL6vOEY3Vrg5t2ECTRty7Rpu9kqGhB4ItZt/DiOAXq8xHn42Co47M2raKLIemeTKuvXB+EDbvvhH+crdLkyn2YziDpFGGSk6Yng6TT2iP+xfLiLHjn7g5oCPytDNu7ovqJCVbTOWZMug/OvzBAcU/lIyslmmCqFFoWv2L2KzyI8mkaO1qE+OW0Mwox0Wq2XEfPhB0L27XMCQ9xg7q2LaiWw9OpPtQ1gChuPrhRK0G9JivO0Ro13aDG/CZpRu4/LxRcoHk71FNgN4bK9QuvWhcv7eZO/4GMR5/53aeRNSS0Gy9GdEo7+OiPluq22YNqXQSgQaSShIdXaB2BhKn1DcZwM1AedJVpmuh+WvkWFlIqYhgdZGhQWyBwq0W79xLoR9U1Gbs1aBF1GaFpqZcydJS2ejDDswQaspY5gWPY2HfRksHnz/2lED8pTHxNA9u5G80dTkfdICMptsJfSzpPhncOyofONJEs0y8fHsAQmEr3tdhquoxvr9d2Rs2+DR20gsSqJ5BcqWXYGqpFjhvZGkUIlBRey/D8fYi9L09vxPp2YwHPOtFUJVDN3tSQ+GYEHLukex2CFiUHNYMz6G7N7LnfrXhFMp6N0OlPrpxlT3zUWZUx+xfLWyMl90yED+6O+5VBfCfnyxlmSUr2uIGOQds+HCBqWMXp/gMox7LR4Q25za7auwqVewSi4qVIy66wKFAe+BCDA45MzlTJ6shL4A4UALbOd/1L1GjgHaVUsqu66o5A6s/4ndoiFePxnF2B3Ev2sK4Mv948HGMzqO6+XUDn3Zhm0oIywdQ2FpOx8/vVpMDBTFcfmEvYmdG2MJugeXFxfYEL75Iv8QRG6fKZ+wi1jHIgKi0m2inGKPZw6SJlmFT/vklneGSVaYFQAAW7d/kwWEY2CUk3sdSuz2ykpP9L8NqLZP9oEXnPZWdyaOs7PXt8ka6Q7SGtEEcmv49TGRvyWBx9mA+ckxNAH+a6j1Oa/zE3ZnXkNSW87H5jp0yisAvOk4K/V9IhQR1M5vA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecf2983c-89c9-49e4-54ba-08dc306afb3d X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:18:42.0768 (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: Oe6cxYFUlwIp8Tq/L4PKBXPMPTAsw4+y11nrtPEoeqYlvS4o6XNi3cvHIlaa4ta3hhm1ZO9KuiCSbFBDbY1fDrTY9vfhCDNcY5OZwtRFvZQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232663871672778 X-GMAIL-MSGID: 1791232663871672778 As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showed, 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 | 3 + 2 files changed, 68 insertions(+), 1 deletion(-) 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 e0e5e7cc8434..a3ce01735bea 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -107,6 +107,8 @@ enum plda_int_event { #define PLDA_NUM_DMA_EVENTS 16 +#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) /* @@ -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 Sun Feb 18 10:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp743511dyc; Sun, 18 Feb 2024 03:54:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUSJ/OjV9/imjX7nyqaISVMOILo/U2AYghbsrSGiGFzNAR4ZqxVii3x0yd2giKmguVy4hHwza39hSkzV1z08Tq3APYqKg== X-Google-Smtp-Source: AGHT+IG9Bq+dsBnVtkg5wp/+QJWlyyhHa5dK34U2CyhV4oNDkpXjxtqiCFMvX8soZhvL7Ya4dqSn X-Received: by 2002:ac2:4209:0:b0:511:a95e:422 with SMTP id y9-20020ac24209000000b00511a95e0422mr6164261lfh.63.1708257264651; Sun, 18 Feb 2024 03:54:24 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y5-20020a50e605000000b0056417546b18si1452831edm.323.2024.02.18.03.54.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 03:54:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70375-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70375-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70375-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E5C161F21A90 for ; Sun, 18 Feb 2024 11:54:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 797A764A94; Sun, 18 Feb 2024 11:54:07 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2096.outbound.protection.partner.outlook.cn [139.219.17.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3C836351D; Sun, 18 Feb 2024 11:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.96 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257240; cv=fail; b=PQI8RubBjS9BB7xo0Z2OyVT2hPE7035EEkrHQ4c8RJP/ca9mZNanAeNy9caxywo70Gr/flV1x8+47DoQiT5XXOuslO5HVsrC6Sc2Zhd8LFWS/23sPmnmm3nyKZ1q2y6byWhduQ5YbL4n+yeM2aLfrvSzUR5gTfGHiraGMXdmO+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257240; c=relaxed/simple; bh=ggawvIbzZ+PVOvsxbzkoIgKBxmy45+7ZS0uM5XtO8PE=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=r1Om7CF5iBFG2qi2G+R9oPFfkEyrw+PPGh/6xnpcUy78eMkLNUhoJiOqAFYJROsK3kE4ED2a500LxYJXAtg9M4t5NDVxfnLBH49gqo8FR0UPMVFPVG6N2ZL3f5dIsTvCeoMJn3UxvpEMTwYAuJ5QJ0X6xIMtqZawP3WW9Afpu+I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.96 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AiLuWZ2mVmBDQaDcXfZbpy5r0C0AQbxX/wB9Y5YoaZh/JF7UpyxUxxIimG+TrUTqDwcUIIWzebmD/9BHDoIIAKxE93wPPyTJiJou2eVS+qaeYDYSzYuG9mXPTPAmxn0dLsw7KklntnohftXQ150OUBDS/Rl7HUD5Gz0XIhgQpCr/PkDzUPIzsQY1EVWQi+dCurVC6f4GbYOWbT8u+mo0IfY+SvrjtM84lllbLU0x9O8rlv4DdPCi9AXf3kjC3/KAkgj1UCid3WrW32EJc2z7ZLnhRvlYAPz4EV6Pkimyn0NuarYNBF+tsMbFRTdcC5RcjsyL3FU5iNPv8ubQ6/JiyA== 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=SUkOg1G/JyezYceJLyKECcz3PCvNZXhK6wSQeUoGtK0=; b=CCuW12PpYTcfNmK9kuKItsNY5s1qBveBCDKySiOF7294RWPK9Iw7Yc48ze3qsBUoUBOTsDrg55LQfUExnKGD/lWDqLtWL6jTUYb2P6iYjCsQxfO634I+1tJPQEAj7lU9UoOO7ekJBNPLeMn6p9dlqxLE7sHKFnMlMWo1Obnkmd8gw4hwHckf7Vq4LdnTy4hRnNJ9Itp0Y0MOSafY9RyaFAy4Y1Qiaaa8qTkjKhERga31qeNoaJ6qRbiUJSZwNUrjZDrfrdCJmsvJNVHYGetAt7cLKV3BWXB2GjcQt8ApY05msPEwLwpFNmdTYyhK+mjVtvWaCEnlqlAQQ3cg/ob+Pw== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:19:30 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19: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 v15 16/23] PCI: microchip: Move IRQ functions to pcie-plda-host.c Date: Sun, 18 Feb 2024 18:19:14 +0800 Message-Id: <20240218101921.113528-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 88beb8bd-b895-4b3c-613e-08dc306b17bc X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /0ondVA55ejsG4TIIu/YExx7IaY//k5FiBUE7ZfhdZqdcxAk7J4+qS9f79IKgqLx+vQUmEq8ytd74BRBwakt0ea5/JPGtF19G1tH4y5sg+JcTYxTvVSdn1RgxCpIiNuadS561zr7QLY6RfSYZhhXV2mDJN7EKTyJlAPhFDgKULgp3in6ILg4OdpbfUKUU/M0N1I/QMtkDN9OaHtCdpXh9jUzP7nKdVmJw9vHtcvo9T80CgLtG+vlJ4viaAa88KVCZ/EuKhNT0LUeAkBUo2uqn06YemNQbCopdWz1m4H++M5K6upb5tptvBxBTLOoYQsdymXhL/1gslA6nBfroRAVgCRIdwKksf2QkPOuvYh7hYCMuaNbUobSUdSNIPIRD7kw+CMY0QrxCt7WM4eP6KAWupw81hcazeBMBkTqyQXcCgEVDVhpz8PhMtMSYxXdGqPRzy+ejwvgqPln/D3wkH0XEkeLODMCZ+eN5Hh1VeKWViomZEoW8XifVptZNUbFHNfhAzyPZn/3h6HDUJhLPyQk5/7w25U66x7shuqln0fbkcyuRKKA+1mgGgK7lcDMBiXK 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(30864003)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CRaKn24DyKhfY9Fr+DGUJ0HXix3kRMjePzL/XtOpzs7xz/CFE1qrWqi125hqKFBi3TJbPiq846+BICMnm/E/WQneL5D9j9+CWTLGreHy1kECfUoE+yCd5630LnuCd2QIauJY6A7m42eE3UC7e3vWxYfulv1/lsm0q4kJL7fiQ/qVJOosOjCe6XneWNOl5gLyTX+AqDZumGxjJOLcdmmNYIM+II2d4d8WN87F8YpI9Yucva0MYiZPNNXYKBHOXmj2kcE0mGhc5CiMA/E/DhWIOWkwV3mCLSEd3sEWiTYNZf0FpDMLynJ//2wD9sUSHspqPale6VuqQR0HXmx5Y9MgLqenE6FGUd++R058s90dYzxg99qkQEMgQFIyNHedDR/Qo/glb+mTuuVRSSBKPjcnWwKOpzWICnlmDYk2wu7Pi9pQLsF8L6Z0dktslyaQ2yM0QXupcX6Wgtnt5qc2iQX/GwQug2w0P01a6n0i/mP0IbAa3vkYZVopwphldchS6mJqNW92sBsj7GoyLp857s6+0Xgqhp5w6BZfjsioTYKjq0Rs8CFhQM4OkWKLCJMfiOrQdHsdaInEegzRZETRqo9wrFsMRKIUY7w1pdHQHetkqDfq63Sz6cpUcb/ZDhlyCbYK+ySuB3PMtLg7MPWtB/qbNKWJyCzMVszeaQIo+eTh7A6+An/RRwhtiuz3eKkxOb2rLHZDqSm8o9p1YdjifgtBFKozTiKE5Osp/SmdH/zhr3P+PVirMTFqv3IHycEXPetLQ0BtLfRpHAGk8xB+6Y1hzG7XXVXpaVGvIx834Z/y7/6q3sPlHsI4Gs9OXHSliRtwZ7U6QAB77dLqmHI2DZDAU3l+hQzChrCcI9L5BCkchDheI4bef9V/kKIboPImKQGmgwJXvEYpQT0AHjaul6X6Q/Amxq6QR+gtHe/vNBCISrX0RtxDt8fW+yWCZatMOkxdbFlLQ1N1p9eGqYAuk4TIorcQe5nL1FaHHcN7dymabjn3da/O7KIPVXpgpeyqFBbjddXTbSGMGl7qLNj9nBlNp/VMg26mHUNmYhwA4QGFzfSOFW07gFl9yiDkX+6T58/ynneZRhKpJF4yN1BzfXMTrQx0RqxO3+Zy9/JFvFjeDLEWu05zHJRm1f878Nsj7JAUkZoGVuilnv8vrfuCfixOoFaNJD80ekBdQUia0GyxzoX1YkJc3ONdHHabdlbrk42c/K4Ybz9J26t+qfBLvKhakP3PqqIlqKzZraHYBASHNEagimjGfIFGEiL2aRRn5tmkSoqcko1oh2Vwz/oOy66hqQH96z8J40vgwz4smZAhMWE0+AeX2r2O7z0wIB0uz/lJtpi/NRTXUSX9CwqqBsZPIHxWjvbB/MJMi5d1Pb7+JXx27vTvTkWWZ4DHrm4j/l+Wg7tS1wHW3J8nN/5vFGBZOwS7bV4srVZwW3T1Gq0L2yMjv+wXlX2x+zUzmCJGddcKXKYtoCT7XeMjpCc96nzb6mbXZAEZzJ0ENrmVGG+u7tjsVbVYLZi2zPnw+80dzzhzScAC7pA7m0Ve6DzChRvdJB83YOEZrZ6heA/Qd5wFypprhcgAMP+CiF3aK1MRonpS5O87cA6USvfo5Ed79ePJlw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88beb8bd-b895-4b3c-613e-08dc306b17bc X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:29.9697 (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: ATtZwKq3HAggbrqRAAd8eupc8nt675o0H/wbkmElYwKpMBiaohRK738ZcuzIvBuYBH9wF3MuhDN6n4645M8SzmArFBTI7mgBuS0btMXgSqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791237569175794957 X-GMAIL-MSGID: 1791237569175794957 Move IRQ related functions to pcie-plda-host.c for re-use these codes. The re-use code 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 | 473 ++++++++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 3 + 3 files changed, 476 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 05ea68baebfb..98c51e594efe 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -7,10 +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 Sun Feb 18 10:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp725388dyc; Sun, 18 Feb 2024 02:53:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU62RyS/YkF9ArtcSUKwq07L9RqIuemxIEZc+eLGlVkIddaoqinK9du/eNWEEceILw+uSU22Lyc/G9GaqniwQr4E1yD5A== X-Google-Smtp-Source: AGHT+IE0ohN0O+c95WuQ9uYxvcB79Msh9fvnzZgQzOEazgY3BfvpEZgq5SX55uwcPAoA4fjwpH0m X-Received: by 2002:a17:902:a3ce:b0:1db:a94f:903d with SMTP id q14-20020a170902a3ce00b001dba94f903dmr5128691plb.36.1708253619755; Sun, 18 Feb 2024 02:53:39 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l13-20020a170903120d00b001da1fe7cacasi2763920plh.370.2024.02.18.02.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70357-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8F27A28276F for ; Sun, 18 Feb 2024 10:53:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22E5A4F1F4; Sun, 18 Feb 2024 10:53:26 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2101.outbound.protection.partner.outlook.cn [139.219.17.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD5A2184F; Sun, 18 Feb 2024 10:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.101 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253603; cv=fail; b=E8tg2xVddbOLv4HMzqJuTsPpe4RgBgb8iyMwLcI+KbTv4pw72ym/CSpm5j+TyJdDvJTO5JWPPm+f0g7W6KUYyDy5ztg5ZkF9RH+MvPXbd78qh/7L4CyGAj+nFeyafZtmbxaaa61/0lumSAcc9sX93lVUvN6xLsMZOHrs5xBmpdQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253603; c=relaxed/simple; bh=9HFoWB89oSWytU6cFushowRyme5a5vBdtDh7hRmVzsU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=CwiGtmrf9mkXdpY3vBL+Db8jNXsfN4H4FHFGcTkxoIhiv4lSi2cvieBzje4kB/y6tEfvAsVoVgd6l3/HJbuZYFQVFsmPygN4GC61gq4yETFdN/BOvb54FfUz5rih243DEKSqTglwXmGActSzb7PQiMIA7Kvlvq6EfCYrPTVhjRg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dDOhIvZ5mnD5elmE4SGYm/AfwzXMevLGClZ/1bowXqwztT6NHhcRtU5jErUudyAneIy8QWk9ixofIZhBDqc4M5d8JxUAqjuVnfCvAPH+Xk7UVbeNC5Zbrz+8wlsomRKWzQEE69pW1VVkz60rT8fF7k9T9qrcAllrp6W/B2jWwqKg4ofqHOtKDjCvShRYec6sumDCberQi6dd2WT/iUDRDuVGB8NlUse8GJTIc+FHkiJQ0lXJGLSkWoNYOG5929m4B7ZPD3LhzXlNTAAiQPU2Q3anTIQWDhjXtAYWkCz1O2EnK4dORPHJD6K9cko8VAOI9uPqekiEHdj2FHJhMkQ6ww== 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=az25ZjnnQPWeAN1um1AQZySc7IxymulZ/4nqgfZel0bW4izVx8j3pMp0sNuHjq1KXPTPE5S0dAVK4qCpzdd6DZl5IqIU4KyBvmYkGWtAVFg3H37n6wx0iJX5jc6LEtWKffwjzb5MFbdDnjEwOWoTh6rrLE+ydlpKLURy524kr/BtT30r7ZPE4O+2xHemIyVL8YMnkB+RY5RK572FQbT1eb6edt44hGvwoVizLm+HXPpOQPGwfUVfk64ZhMM5o1umH6VfWUqhq1sWIrUYjnOlL3anFl5uKTS0/lsHMJPjHGGyBycczuRgDOAcolI8PL5Sziis1OUdoviUTSHduAS1lQ== 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 SHXPR01MB0765.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.46; Sun, 18 Feb 2024 10:19:30 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19: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 v15 17/23] PCI: plda: Add event bitmap field to struct plda_pcie_rp Date: Sun, 18 Feb 2024 18:19:15 +0800 Message-Id: <20240218101921.113528-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0765:EE_ X-MS-Office365-Filtering-Correlation-Id: 864ff645-3dee-47a9-f499-08dc306b1854 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z0zdOSrEdQrWAMwtsP7xDMigKcf2jXSKSWpnG3TVKOTSdfjX5xFrbgx/H5m3iWvfqpTyeGdykydC7LUrbVC0GabnQC7uaHqVx3tfzwwDckYqmnizlnPtJhPpe7U92kdZf2FRdeezvD1aMhWromwPKH0d+3v0XkorFS/NZP8aXQoVxFsVF0FY3sNkYoO/+GIT5xvxAYVmbAISlJYBc0GxxfbYoPHPu2UVWCsmh4ZGec1j9dzi9nhI5YVq8lS93A6+QHvlcCsKX4m/86us4w7ZwghGcytFdTBnfn/U403t9M9KURymewJOFg/eAUJjaRxRXOvJFL0mslMwwWh5KUNT/hdXbsfJOyK2fqU5NDQfU8KPcR5QcY8Zrmr6LrCU3mTHvMm9CqV/rymHprog59e6Ndj71f34o0oAJfKLXno2KX5oBBBJxiZR5RgyRaytKK4OftQeFzOBAJQ7B+gS17mTG+3C4ZP5fszZZ/QsomNQXzbU5NtRdN1Wq/9aLj45o4JBD35D3PPoxFtjOxA5rnKDTFvxQCF9WkTfjc61y96KTJwdKjyKsq4Fr56BZQFWMEvp 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)(136003)(396003)(346002)(39830400003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(5660300002)(7416002)(44832011)(41320700001)(26005)(1076003)(6666004)(8936002)(66556008)(66476007)(4326008)(66946007)(107886003)(41300700001)(2616005)(83380400001)(8676002)(40180700001)(38350700005)(52116002)(508600001)(110136005)(54906003)(38100700002)(86362001)(36756003)(40160700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XOEJd14lEyl9HkE8VF+JAd8UtitRLa45GDVycR2yMRDBkr6yOHi8MaMq+208idoUMjFfMk0y7xUfN8LiWZs3Rf+SjvZRg2IN3jsUCu3YLlhOoeDfSY03CNhDxgdQXOTiBynCu23kASlmGIC9U1joUxLmEk2JHrtpnamKos6phha0b+e5I5V7FrrTJ51yIQSOWgkeP3D1HdrLQXtZ897Bcm7ShuxVYjh1oZIoW5kmKTHLhfBHIZD/YNRn1Baf2z8sM4U/5khZ+O7Xth0mYbIqJ6USW5d70wkaFOxV2hAdZ0Zncx3pPVm0aRDZJOR9HRtpWqxP/AB4rfCzGnCySsK5/jw24iyBpBerK6OYsmWScrtapYD0lpmx5J3cxG1ScI3hZyxvmrReYf9O5NljhQucRIToAiu4UmnFw3OKAidIxq4jOaTe+beZwBNTsA7iJEvvCH/37CNxShuUGSwSbBmmx5BE5XWKNpHge+q7T4daGxwsPkjUC9yjGdwKVyYRUoXwtjWxjXdXGQKj05tIVItCWGlMzF0S9K3u6Ld601WCrzwYcdiQf0BEAIZwosTtn9k4VQA9SUXTn/gli15F3ZB8pEfnAO0Zf/vyTbQFnnnv/fkkE7oBuKkgjsFdsvg3rSH2gErZgDDMPtrLoD+tNF+6EXPaJdogmgUWXUqucax8+rz0/emVzxneL096n2HUGtf/ohH9kFfoEc2SFzym7xxD7zWbevyjRxub4so7yhX+D/e1yx7Ieo64qJqFRtEjEHkIWZVlp+TYjD0hr1WG03Swyw7jII2/ibW0EI1eqxClGYo0PCthDNFojzkdsXr4V3ivD6z0sSMBotli9kIgfeHmV0+ayQWlwlK4JZsHEBrH6nhnM9fBczLqm7mDKGpbnSh7hx9p5AEBIuGSi1TnGUi3YrjUrw1rquuRRy4Mu6ZCkrnd1q145SPEsdbgx0pxzAfzsuDRkvYMgNZWcV8cscnGj7T4HbZsbiBmjd1bZR0AnhWfSKiGgtRKzNMmoe82j0vJdJnAUSg88kqL2H2xd2KPWQ6Qb1FtFsLBsGVJ5rg9iXVIENSc+HcTWP9baUpsD6fPDqUae7KzOysRFbqlHMsE34REF9qcu3gQZnfOJmc+LOYnFKJskjBwPvULUK4FMpZjbKUumkEoIUln+TtCIgOnGyIEONOitxSi5xW2Ix31D7n/NgYT/ZSiMx8oMyVGM6UTnO/Bdao+cBARaQw7mJJiydtDO6x73aOgOzrATs8tFj0GlVe+Fwj0EUPH67hsx+zAnKh3g31SYXumihEB1qKek+OtNYanNmtnqNn3RV1I4PLY+imb1m371ZG6ZwWmvapx6+d9Cd144xG6+9TQbvkwwersEz3yLDFLeoADHGvaOIII3gKGj6H9hYPyUpF8BuMhrDUi9vXONYDyzaInp9N9ySQfbxYwdvaDCAcp/eqfc+a3YLRFQkb2OpxIy3aNfYQGe89NgDTsOngy+Lqw9SGnH+uIkcAvcmgyhuRY08B8ei6sGUOnfNt9rJoBRKfrNQ7M3Zti2/PAAsgpJQ+pSoh1fMKOk9kNrOKUBbI6AxTHvLLizZDvfz7lXEWySH3RHa5yatS0cVBk3DOsHUjSwHHXIQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 864ff645-3dee-47a9-f499-08dc306b1854 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:30.8802 (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: K+prY6aUblIjYQeUtX80NzWE1T3LB4w1rBF49HHHIptjtWfc/FrQuR5mvB1Z0y7xedQbsm1aFpRSHJPrHsytuSkQ5l3hwLFmifEUnKDsx+8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0765 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233747884507507 X-GMAIL-MSGID: 1791233747884507507 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 Sun Feb 18 10:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp743471dyc; Sun, 18 Feb 2024 03:54:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVbKWrgwdNAYnbS+mA+jxjJewN57ljfOTefA+XDM8mAefm4sGerEM4Dk42dw+vSe/lP6md7ySf/XBNIByNdQhYLBduKVw== X-Google-Smtp-Source: AGHT+IHEHkYKk1ss0NcUiq31wYRM5iClCkWDBqAiZWROwhOg+aBLRIpOaIxopw4ZWuFsmCnQEJru X-Received: by 2002:a37:e104:0:b0:785:d752:de03 with SMTP id c4-20020a37e104000000b00785d752de03mr9359165qkm.63.1708257247494; Sun, 18 Feb 2024 03:54:07 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bs10-20020a05620a470a00b007873d5d59f0si4366122qkb.230.2024.02.18.03.54.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 03:54:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70374-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B29F1C20B33 for ; Sun, 18 Feb 2024 11:54:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4625F63513; Sun, 18 Feb 2024 11:53:55 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2097.outbound.protection.partner.outlook.cn [139.219.17.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C34F633E8; Sun, 18 Feb 2024 11:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.97 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257232; cv=fail; b=Pz4Nytz5duSCqGl1PskSwcoVS3s3pGlnLdN+njryw/5xI0yclSyXIWgOU64Lc5dTJqQ1oJpa23dx55SWvbUA70pqaBxvnQsDBz4v9fqAvdG7EBhFZ5fMRLuw1d+JCqbbZl9n42+Q73RTDsNMM3IOVhbsGs7jGOueR+UO2xTOxys= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708257232; c=relaxed/simple; bh=aetGwQfCj81DGzrZQokscKBANT6NK6uQQaYIaEMk9io=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Z79TktSTSDznENchNZzhRpjn6nTSgKOR0r3VyZUaV/SArVzmcPJgjHPSAz5KSW/7NEO1TspCgz+Oeyfkr/i+3Q6PZ0f/vAi1wP7LkabnG8ev/ProdgJuwVLqtdDV2wBz+6HvbsMiM2AjqqGIPQifgQAipXaGo0ckWUCrPLst008= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SCMy5E1q4e9LgOaSbr/zgosPcYStkhgPwpxJZ6KqULIavSs0Nh/xdEyEQs7DQaNk2k/kgae5m/3XZsKAP5SrzikWpwGgHlTf3pzUcFZb8L+RnYLbMzOxlTJMKm0ZOBDEdaeRRVcrtXCsy4jn251hrxNAviPhusOkpSeGhc3eStuQhz6Vuyl+rBdcOMgKCUz/ja/bLtrTFRfZZ7eoCFOzM/1t/x91IkZcG3FWi3ehk00HpoyNv9I6cvKX6a0lq8iizby8yVn/jYksrLbz4XrUQyzTau1O1VCowgv6F5c+TBHLSg0j7uYPUuMVELNA0mrPG5o0ga1R5zV2qD7QqkclUg== 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=lAVyN8rKo5jkBwCvcGdMa17V6s1kv5WFrlcgQneNLXKMzBZW/YFOtZug+JErcjl+8BFo9lh0e0mpSNbyNbCNFxE/ytr10BsZ7lfi8utT6ZuhJOAfyf4uu/c908sVeQ1aplwBSFnJx2EUroB5dw2FHWPBVG1NcmFry+B6fRUMXO7UA7DsLQ+cNgAKq5ux3QUrG3O+qa0inaY8zJN0BgSKEoPrYkudGx3MR65ahIYtmjiZ70wnXAAutgm/grWHyP3Ci8kXAS0PgSaKJzeUl17SMcKRSNL0s7JnJpaRKJMnzEzlKZE0TqLiaukcV1nuCmNwOoPEPF4q7JGmKrq4fFSZoQ== 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 SHXPR01MB0464.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.50; Sun, 18 Feb 2024 10:19:31 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19:31 +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 v15 18/23] PCI: plda: Add host init/deinit and map bus functions Date: Sun, 18 Feb 2024 18:19:16 +0800 Message-Id: <20240218101921.113528-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0464:EE_ X-MS-Office365-Filtering-Correlation-Id: 7447f9cf-e240-49d4-fee4-08dc306b18e3 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A1V8bAgzxu9MNWU3T9VrkaHj3kbutmbacuAlOtzQR4UKggWtBs/SK/HJU3J5xyTcbfJGjfdya4LuV1HxDEOUK/e61RFDGQRh2gEmgRhi+G7t90Jp4UpTcFPGnkjxlhtIArnWodi/RXPxqHpzxOm8tDQjR7gpLCprfsAkR2zdPbYRn/5bIDIQFysW23dHMKo6jfcg6ry2czzMwiIn0Ahp/F/B61OBGV8qQkROadeHNxD98pHfEmSN5fWC6qh62ELyZRnkjz+K/MfgS5DxvI8wh5IUcFRNs0KKVVqd7uDWBeG+ShlwhYZirgYWbyKxcfOT3AcGW2i80kCiyp5IcUjrT1tTRovza73rACZIcSwKpBd7PburkRgAc7WoaF/n5Cpau/cXZXGHL2iwABo8vp/pdVAz7YgNRY2+y+ZtOUHbJUtLnMsWeTa/WFvmKyhRBuOoiJ7Rskh3wAmQCF9IjHpg9CE8XSe2IsVSf/5ARse9WDQfHtuDWxDjMIT4OnIhWrBcSiLMQSNpyB9oEq2nBksfMxX3ZiU24uNpNWpUy7YomPa/eT6kR2xDnKacn1VD63qT 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)(366004)(346002)(136003)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(86362001)(83380400001)(40180700001)(40160700002)(38100700002)(36756003)(5660300002)(41320700001)(38350700005)(7416002)(2906002)(66946007)(4326008)(44832011)(54906003)(66476007)(41300700001)(8936002)(66556008)(8676002)(6666004)(52116002)(26005)(508600001)(110136005)(1076003)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T9vE2hvmpppMi4Vpekx+vyTcjFHl96aIOkg37/R8uTbLPgw1cO7pcNBVblhWDdU8ZwaEruQGF9FVGoguWM1AbPl2fDX53mqmie7+NA2aEUcfF6y29InNw08/B5poazzqFcucB6dCun061CXOXcisA86izkRpr1osdRFcXww452i1equIPZ8rJVy4tPxSX8ksfPa5plUccjdNhxyDLsq+Tf+bNXk0l+U3h050AGLNT+gUfLvmXAuJ8k8i35ggxb+BF4Enz1wb/cd+j7TH0m2R5BkV1JUFn1d63lMRdt9IwuAgZpE8r9d/EdMd1znhhpOWRWkNhh0hpPy+vJhk8+A1Tlfai3W+ajvqnWHry8AV9HgsekVnsBKDjmUMDmMQ3yMyTIog/wZ0cWxOooLmrOIhFBp4voVQm85YgU8ptyJFyCrZbKbd6j+DfLELp/fRmZTbAPuEyJvGVaw/bh7davDW27sbkBezQU5jH2idpUS+BrDtxbEHLRXyecEeNhks0nAtiM4kZCxnxx/hEH4hWu6u6+vFo3yS1fzsH330YSyE1LN8CdwLRDgStUTFTZh1ZEvaQ9QWdEX0S45j1NkYE7gKaywoz0+Uh31nFXZ3PjwMkpiSbUvIA7wPWurZdPnSoAFOaYAKoAvE2pzQA6rUpdAnBADVRPvfoam0baKVSysiaWMtmi4+0Hd0I64C8vziqUuJkG8LhnZovwXSsYalSpNNjHAKc/QQLpS38bCUULEFknbYYny0TuKsPxtqOHxXHqyirv581ckSvFaAxxI4sZIPpADEcB/09eW29vLkYN6yKiNlpuh/zpG43D7qgv6fmIzhXczbq0Wnxpo0MwsU2srfMLzVv8wNmD41eydHNkoAodRuYpyH8z7BDL/i/UJ0fpKdR99kV4cj8T9Opie1wgJG3tLbSXrw/vH1wBthZtzpjwc+jKU0vv4UuaLWsn9eThn6PCQ6e/hbicbRcBQ1ltQdPZcXXxNjNUw5hXyW47CHtBkJgprhcZvReHj3DNopmEsBZxOUeY3E02Yzt80KPRQYaXfbfDsCnYaYcNtbZBykLLHr3W4rqnOQGTLSRIIS5+5cMlIDZx6YVispwRUNOlkappgBKM03jDo0tR4NPI7mpebcSkJf45yq8zUmWqxSQeYAxX6OZxSZisO7Z04Kvg6pEsGppM2VVsER3OQe7DjEf8uq0yFFgMEgwWfVjDE68EVN4TaqARpTiP1ee+vhNXcej7PSIZYuxEO3Hg4JnswoX5z9PyeIpW7DB4tDrJn3pOokLzpNs6iubyZi1+JfxGU3j0p4xrzS9H0EH5rdk1Rty1PfhCGAdSYSDwq+wzBPhek7aimxvaEb4sVYro1uZLkKZxUZ8UWbll5NuZgRCoWGmt5bPwt2lenxbMIdGvZKa4xfqGYpiJKI+LSHsSYE+dqaxQV1QqQU5fP1r2ME/z0InK63p9jnKbRaRu7LWHSAFe3VT5our6LW2umErIhpFytb7pZZaCHHJmXbiGQjVxc9YCCjjtA4uv3y6h72nLwUr6eKGmRjCc2F9c5kCd/eQDZBkAcGBuj9+BuFpkXNBm0YnEPfgT8dU+Jdryqk9aMkAbdrdsdxL9QWAulNTULD2X/JgA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7447f9cf-e240-49d4-fee4-08dc306b18e3 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:31.7983 (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: a3XFTzdAwvS1DCguoHxpdJF4AWTG8Z/6S9a3m3M+lQH2AZCCys0ps2VCk4On4C/aoHODdK4t2Gtj4yrsTPVuIxsfg5I2Jsot0rTmPpd4mJk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0464 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791237551766773121 X-GMAIL-MSGID: 1791237551766773121 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 Sun Feb 18 10:19:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp720705dyc; Sun, 18 Feb 2024 02:35:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLXR6S5hmQbpJdXYX0pwHzbeJoMmRZhBG+RRyBoCWZ5fXIzD85hmdWWWcTvwAUDp+3whphsyGejyhXfoFgjk29kyRdtQ== X-Google-Smtp-Source: AGHT+IE2uhRmhDk3Mn+9XMfhKbaJpbiqKXwiGVZH7Pu+qPWnGP9nM6qtJuuk+Nny5Emc6VKgr1Np X-Received: by 2002:ac8:4792:0:b0:42d:cff8:4409 with SMTP id k18-20020ac84792000000b0042dcff84409mr9032840qtq.4.1708252503864; Sun, 18 Feb 2024 02:35:03 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e12-20020ac8598c000000b0042dad235b9bsi3942757qte.226.2024.02.18.02.35.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:35:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70346-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70346-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70346-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9240E1C2181C for ; Sun, 18 Feb 2024 10:35:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92FD94F1E7; Sun, 18 Feb 2024 10:34:51 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2124.outbound.protection.partner.outlook.cn [139.219.17.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CA694D11D; Sun, 18 Feb 2024 10:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252489; cv=fail; b=e1bN+aJZ8tyvwCO2ut4q3a44YdF7U1vvNT8ZEN2DycArAlfIcng69Komw0UgC/sDlkhR18AgS9jhp8RAsTUO4Iowh6CCYbiVlCV2cWYyH13Z6dskZEBER2ioRsN6eKFpKrD6n6pdDKiXws0WMUxIagp8m1m1aOxIzeTm0IEf0s0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252489; c=relaxed/simple; bh=UXP6vo6wR/t0yuoMWcbzF3jkVu0gSycU4XIJfhOI2oI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JmtEplZzRuJjjGWdelDAknIRqtYchNUNeoYcvdxs3B30TkJr9drP3NUPwyXBHX7Bga+ViTSi6fvA5hwzWydWfzjKYA+cd6jbXd+9BiSce6zG9tH1ciggQ9OKyNJ2RNUi+NKygWlxuXjpBDU/vwVlm8WRvaMhkf1flJDPQNU7+MU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g+qYnbcpw3Hcrq2wl1V+ZiY+F4gLF8pUt1FS0rktEfaJdXWvgclqPmqJL+kUIY4u6iVHMkwDbYQZojf1yhUgF3WZNosDx5h72xuA2XRw75MUrPE7PAdlArJYHnm2Trwpjv6UJYkulv0aGtngP74dc5CUewrD5P677kxeI5OpRFQsXFN+8zYPKEaXUDZFpfVwYohzHTEMJcFy2lmVYrssEGVmzTHV60nbvPqTSiNN9Qh7KiCiPdDnhcPWX2Q2XuC2dpCg0nlMvlr+tRDYIXDEnZD+l8M9MKiGrhuhxIYlVCD1Mo8i0KCNzqkL8JbGgzOpo4uV0V27IA5njvNwZj7X0A== 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=3wPv+43oNHBW6nH51yVeP5rZGEMEmUbqVl4PTOt6gVc=; b=Q8FvgReBS+hsdnkJ4x9oxCWT+aEEpgZ6PkBR6AZ+S0TiG6cPw5AgdJgSF0bnU1tSh/4fVbQK3g0Y5eyr+6J+bELWqOusqjynLKswtg09lnevMzkwLsclZx+o4uR6/CaYwkgX7aZNLy5jNwEGj98BdlsBLeIavENmOOF2gxiEwPXW6kBr2+kwOXCDyUhp4qC5K/BH/k+7v6/wXXsk0R3DdUZH8NH1XqOiSXbMtQXmvDmq/s/VQCzAUhMwh8T2MyAAa/ozCjtq4I5DEALPqRcB3nGjEeVaFI1g2XTz09e5B1+6EX4uS2gkSfWGQ/+L/OB1Rr4B+0xItip/TV5kazrMXw== 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 SHXPR01MB0464.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.50; Sun, 18 Feb 2024 10:19:33 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19:33 +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 v15 20/23] PCI: Add PCIE_RESET_CONFIG_DEVICE_WAIT_MS waiting time value Date: Sun, 18 Feb 2024 18:19:18 +0800 Message-Id: <20240218101921.113528-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0464:EE_ X-MS-Office365-Filtering-Correlation-Id: b10fc9eb-a397-4543-27da-08dc306b19f6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUdKA9AzBLNQkjbgL9DM+vmBYsZbpl8lQvMWgiChTfOpDagTk1NogdInkKew9hSuBbyseNzlpHPq8JaQpYjuet5iV8mjdW1Zmlk+CMcB9xhKuOsoka5WE64HSARIur8NRFMSD9j1Ruzko2m4jCfbEHA1Cb56/WGpsSI/cFE6+1+ONejr8Ziydk09mZz7G9d3r6Aii2si1xipijApM/s3EgVjRrv5YBwGAerQ/YegrqtP01T9L8qwqcjb2bQdMCWVfGwlWeGEQgh4ybLSAeEyIwamnt1BeZlGRgef8WZaD5ATBWlX3FUb4RJalXOk35p2n3TKLrrffjcpyxpavYhTJjpLphoh5FGFx/OBN/EWJQHIidvhyhYmfwEWreuGtS4laLZVRPkE3kJl4pD++9i6bsVt9xj0wOfsGNhn2Ytg6T+qVuJkTVnX9c8ysGb4LfUKAAGXtzS5XjLgpLvlNrm9mKjBOuoWmS4srFwtWuFzhtmBP+lvy80zi48xB0bYPQJoQdjHYhcf787VdfuAkAqUyKbjj5Wl9EDzK5n+0d2jNgmldExyb75iAqmASIpmGfNO 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)(366004)(346002)(136003)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(86362001)(83380400001)(40180700001)(40160700002)(38100700002)(36756003)(5660300002)(41320700001)(38350700005)(7416002)(2906002)(66946007)(4326008)(44832011)(54906003)(66476007)(41300700001)(8936002)(66556008)(8676002)(6666004)(52116002)(26005)(508600001)(110136005)(1076003)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p4+s72JPOTrLhuJ2NJPaYQXRvLiHBoCCRoH2fO2zJACzD8j/ROJcmZ1oskbVKxY09Crl8J2DdphQmt37qAFCr4OB3LQLIvXsLfQjYQYvvITAgPyHvRD1nWbyjnAdDTZ2HcTFIy+/ljsnLw/4ar1yXZF3SOG2JiGy3u68nM/YZ2wJDr+bveEvIhko3xPmlmjO2o9D25gukNcnkmDvbAuQm4uQjsR9LB3P7bjlRrIfYke72PXoOcoO3pWCO+MBcNpU8hddHbCE4HLiYPnehCSCDmbAl7ogoDrCWg2/2+32xG8pjWA7odmmuWlQl2WzUqg4lBr0cJHOTBIchgc+EtlY8RkPn7r/ZE1nD2/Q1ulS6hZgq//RYDL6tAm4CZsJyu/Dmn5IPnEU44IdL2PdGtU1yXc8GMRInkvgFstNdbsmhmSy+WZweXslQO757wt+4IvOcZpXFCtoC2G38RZkLeCQX+tQIPMXeD0Uw/E3Wr+b9AYw3KE2wRD94BJh7xYBd124OTjQ3TsdmU9d8CsLPGjJlUxgtzvvGr2jfy5xhyOVz5j4YnKPQof7gj6jRW4QRi8PzhDWoKykwJDf92fWHzxtOefVAfHJe86YsZgPghQIH8X/xEIyr+YjVUZYfH+O2RHmgbOHtcXghvWJZJHx4Q5yoWYtolZwUBWbDyTJ1yhH4s5eb4i4fLhg9nrQawWG/bDn+9o3dzlWvooloxH1nGbU8HvVogJZny7+ibi9Zrq2r+v4vfrVU/IMi/yCOWs0eX3oaydrB/eqJyDLlp+sJHSfypLnmOK6nGpPlyy8aasuQqANNA7ZOJi03ArlkQWSl5k3K2m0JFljabCgq2jyJbmdhromwomaCD+HkrfT7yAjNbBQlzhhJn4ww4OC1pBXQM4Ew3JYEMtn+SsNzjA7852o/RYrDWsyc18IAGAaRGdFG96U6g3fBjTCca/iBOVVC+iSobwRBE+fYP3B4HS+D9EeFVUfMQIDlziv2DN9HZy+R2boCiIeWzndQttR+zOk+TyQ51mtdt/77Odk5+LyiQBc6dd2rpapTzs6AXAA44BI8AWYRQrdP1LjOOPoA3JcZ9/QF5yReAI3aSCzuUIly4+aXgPLK6K2oyxmIAfqOYx26bb7omiGpG6JsKZzxRQ9a46LalyNzDD3//FuFJjXTwrRy7s3rs6v0dTUITvocb6K/q1/hy1moTYRz/KBCzifFwnTwBOlyP1p+X+x5NklQK/DBLW2oVaCh67MMGzoIW88UbbUHr61IfWOKxh4DXcHCNl0KQSi41egPYGqyu/4qF+gq28njU55Dp6nSnhMfuYfUeLjNm1NjDTzFoDQTBE0uBGRIpkCvb1WCb1TYRn61gBLozpvskLKK2idwAyIeSJfPGRAk6iT84P0Gj3wt+GvOHODLxGXmK/RoOnDHO37DRQer6D4ahJ522fZJQgaFXTv59ZURR4YfMBOny18qaNR8m/auiUdVYa5B9DCVeX6GwbNIsHUhXrU9vyJNFUjId13SLx9mwMYP8yVK7PfrFrIN8Cb6EC4oRsMqCVbVtP7dXgOAOnmXCR4jKF57B5fHSuq0cx7iJ7vC5l649HsT3wJGYaBaiX0De9jptFrogbowon5Bw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: b10fc9eb-a397-4543-27da-08dc306b19f6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:33.5962 (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: 5bTzUOZxKGdAeZTUPWb0P7RgSHd+cic4bpwwwzDzFUQdmHmN0MBZs89x89x9HMoQNTg8z/uYkj+0NTmlOxpLMWYEIowvPYIHZvzvos8Yhfs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0464 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232577647660843 X-GMAIL-MSGID: 1791232577647660843 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 e9750b1b19ba..06d76439bcac 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 Sun Feb 18 10:19:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp788260dyc; Sun, 18 Feb 2024 05:52:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWr7+xZqXeKDJ05UIzFkp+QWSrO4k7FNdgK+IVV9+M/c4ND9rmVNr+b1Hs2eCCnglaarL4V6ERIgIlUxALKZ0Jy1Z2MJA== X-Google-Smtp-Source: AGHT+IGpDx3sPNmcXRbI4EQIHo3hQTujAeX/UxWg4Sd3zzPcZmqtQWJp6siNTU9q0YJXYqEXA1ub X-Received: by 2002:a05:6a21:1690:b0:1a0:6856:d128 with SMTP id np16-20020a056a21169000b001a06856d128mr9095604pzb.9.1708264371220; Sun, 18 Feb 2024 05:52:51 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q5-20020a170902eb8500b001db63a7c8c4si2958021plg.283.2024.02.18.05.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 05:52:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70401-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70401-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70401-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 74B92B213E8 for ; Sun, 18 Feb 2024 13:52:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98A066BFC0; Sun, 18 Feb 2024 13:52:29 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2096.outbound.protection.partner.outlook.cn [139.219.17.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0174E1E898; Sun, 18 Feb 2024 13:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.96 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708264344; cv=fail; b=a7+vkFdCsvnOlBpfv865Zl1GZguBnhOyZvbCe2SEyjFh3K5zPt+hfS8NJ1fAa6pwhMHS1DA7HXvHEcWLRz7ZtFR2EY7GSy2/j+mBoRSh060Slu9ALjaJHRKquCPAWjMvF8QrHmTfmsaCPXxM+26TvnDraVe723NEbLXLeLt4qjo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708264344; c=relaxed/simple; bh=KWTrow09BeUCQ65EEkwdS01SXHJKn+AWMitNvvYVCfQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=D6lgtdtv1WQrbMT9nkZZd6VSTJ5j45J83FLYg4sY5OGvHlXRi1dvQ/DBinHzs1/N3P0QvAB/dy2OfgIeOjpv69oft9RgZIrGRvGQvjS9EQPyU7CsELbDet45fiBPKe6TU/qTG/qABwdlMVY6fNpT+zTI4VRbfplDR8nZ4rObcgE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.96 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U3anFGtMUmtJnjYFEDSK8ONMR8nRFyCvcBcjXNbHAA0czum4+wuH2XqZJ3svXSF9p11QWHojuvAp7KQlmcJqTif6tZWgM9dfvBpsChFuV7uhISjgBAGThrDl1ipQKaHiSO5oJ/Yfx0cIRSPQ63bQObtHuiZexU0Ad5kW7x6VnInrYKpHE9V1I9qYpaADJMWav7qJxRlPoekbMWZoEGNCLTQjzBzF/9Rj3Yu6Creq98zW+WMEOIV2pIfO+34GG+L8wLSM6VE3cS1Wl1X9wstd2ZsFAcPmagHmoVYtTMK2NjyIhJr8HXDYRhtCIRdS5ymV5DF0etmH3OW87/8COoEQxQ== 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=b/fXbvTTCyFmFBlw6bBWsxH+bf8iVcapLJnuZ6lHgf4=; b=DjeOMOmARA4qo8xn2NNtl854RFESv5/PBj/QHCrDzmT/VR8FJ5NbpMaAtMzAb0sIX4zX+C6KlFeKjUohHIML01PX1fsZbN0F1BNpcWx1De62NwKuDgqR5SI0kYn2wvEZ9XUnxcDNKdmg1+Msbokub2wnYB9Ne2DcHD7Kme0GhvkP4kXBhYPiuccGR8wVD3sLsmsBnmHSE+bWA3kW9eDpy96AeiemT8YtxgOb1afRgKg83zZaPdTPt4p99TpJvTM3xWkYjFKknHjvWrEKLjifDEu2VwGKuAsKPA1rCyf3o/vgmgEc0IUbqZUBekilP2hqCL77oU0kCKVdGqfXz09R7w== 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 SHXPR01MB0464.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.50; Sun, 18 Feb 2024 10:19:34 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19: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 v15 21/23] PCI: starfive: Add JH7110 PCIe controller Date: Sun, 18 Feb 2024 18:19:19 +0800 Message-Id: <20240218101921.113528-6-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0464:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d32aeaa-c447-4502-6d94-08dc306b1a80 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XmKZUCsKO8twafHL/BudzdqYQ9grFOMEe75648qoBrPpuikwu1X5oOEBVH2Emw5P0X05kYMoTv72HY7pWwL5l+RsBNCEq8r+MMj2rJhlnX9JUTAhGWKbhMB6xrXLWjMGXCV680FzPsYFHmgXQyrAXnez66Ze5iyebU3u1yKxfHmB9UtbrE5DYQ316YoEAcfXtPf5xK1yuis3GLv/0c6KmOqku1tfwWowpD99kDogCvmSRn8stoGLg/YuQ5bNo6Cit9dnvUX+/lRS9H1OWGDrISGdT74WfIPBfSXJl7Pc+kHByWhYr2fXhddR1pyBHdbMgQiLoE5WoQbIoIpSAacDr8QKmDYZDjkXotvpJplBpoD50RW2ijX5EtFMrmcqFSVphLyhHILNtlEJknctyNUauHiy3NI+MuYrh2vnINyzQTYsN308MmYWcAGLcB9ZBjwHJ+sT70QklQs/41kXH9xRmRGO4Rkt6vG0GXLjCOaNi1jzAAWQ1Y2svEmQzygOUKGN2xFgrSeYWDyRMOZmeKVVsJEGNwxdF/djWisOuRhK74MuUEx3orROmxr0VJaFLkT2 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)(366004)(346002)(136003)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(86362001)(83380400001)(40180700001)(40160700002)(38100700002)(36756003)(5660300002)(41320700001)(38350700005)(7416002)(30864003)(2906002)(66946007)(4326008)(44832011)(54906003)(66476007)(41300700001)(8936002)(66556008)(8676002)(6666004)(52116002)(26005)(508600001)(110136005)(1076003)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jsn0YZ0kJDx1HaAj4fVO2FMVEcF4hc28UtVy6DZHxfg1oxcwLBTTIF7WQwudtY8zoPEi7lS4QDlOqXB0ddiZnOMtWcMIktttd4ynPSGL1roaPJswQFwob6yerY6th0JtP0o1l3QDBcVorx8rK3dF45VIfsKyls2oirpoYpYVhP9fFIUi1IuEu3K/UoRuTyaQs6yTrEXLN84dVXgyqmzHpo5kAu8SkvZQyLERWucY+EBtY0irziQdiYdbrSFdiGlc9IYncOAddB64dKCQNdD20meSgr65hDQim0G2Wu+N8JB4K7VxPNvj5rCcjgL1P5rP6K62FR8J5Q2FQl4nDRebNHAoZjVbaDbuLA049zwD4TLdz6yzUSJrewbi6EkmvR+JIQ62a17PtTpNxoESKDaD4R0x58f4N9c5luK9K2xfft71q4cakttrIAwfDA2uWnJwHnVUEUsXalo5wnXwaKDda7IDaEXoX8jMiCCZMffiJO7Nra4kgAsrvYf+jo7Z1l34gOfyeZs/LdMQeTXj14Iv7w3CRUOsuQp5oNITWvEu96O3r5fpVKfBp6IdSJ+vqx04JExMIPp+i0OHOVrXTvYxKEns/ECxO4Ccr+6FuqNiVchLcyyHi3uym4WCa4Y76iYtkKcz5rcpI8Vj8mqWZ/4kuwrX7u3roetuL5/U+1Eoozf1I/VN/n4QsEC19GWun5BgBLeNtsGI/pIeDjVyolEXPEwWqbQ5t6sz49Hbf95EXE4S0yzoXRorxh+oq/NmWCMnt8VfXGo27qm6RQgMtLtbjpfZnT1xqxbWWVwqyoNcpKfmgK2+u8z8L9fUCwHDQWxyLev+3evJeXv7seYN8+2UoeNM+/vN7lBlpympjBjnLcoBmh0smJF6mWzZp1mKojrzd6YU1uuJJfEop+VK/PzgPrAMJ1P7MaMCp2mRYreLP7+HH4EfkjmnH6obY/IkHehx2vhpoZBi4Emcp3Mvh6sF3+XW3AUHjUTOKukzEDpt1OVS5+7MpnhaYi8sOyTjWZgxZ64vcE4m43K0LhKoyLiaXlz9IObuoAO8GhPD7NmAuJnz/3mtyza/qY5hSmaNnHoqrjJ4qODFacVxX8GAYo6UV1nwhuK9AelpozdSLPNQnnBeuUeRAm+eWAfy0wHeuu3xYki0JRsMrt/Z6HSeDhxZVnyqldFBy13yYv/I0EpvaND00hoa/RNktkHIZN657PrdA0KmqZEAxXyaqeJulz/LMDJvYv76wbcB7NXFjO84Y/yZk6/jVYpJLjoPapc2THuwtIQuDtexte82NN2sE03bWMnHWIIUanGxn+uACgy+CuDZvAMp6WfXQ/sAU+DtNDX6So4oazd//s5xVBmSlv5dKh4UPi2oX/QsLQri0RMu2QG3Ila8hUcj8RXq42I6kZFye41aNPCDwqIa5asV1XMcxVakt5Cn04/CTZYYCpukQSP2yu7Tqa+GbcYnjovVwJXaPmwK4/5Tns6/hbm99wMyIIYgOoA/aApSKKEeeRYhi8jYob+011Hkv8K3siDu/O/EHYb7Gq86mbXsbE+6Zw5f0HPMQU+5ecgcwzJTtObMIo+ZrkMO8pXI3aL6YDgMx3mDGI3kJ6dW3HPAGdDUpQbOSA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d32aeaa-c447-4502-6d94-08dc306b1a80 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:34.5538 (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: DCvDGmCAjuvML9XyqnE499HZ9vw8kNCSKyY2INFUhTJNCg4ZRYtKx2sQPImSEA59Sa5at/3Fzwz77s4eBK4GlHWGLkuBb2ACQ/qicdbc5L8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0464 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791245021742687677 X-GMAIL-MSGID: 1791245021742687677 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 9c2132fa6f26..bbc6c5cd0c3f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17071,6 +17071,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 Sun Feb 18 10:19:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp721154dyc; Sun, 18 Feb 2024 02:36:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkcUZuz0BpNSB+26CtqrunqwRoUHxeYguSOlG+qRrQB6+L4o13Pl07/jF/kcmAnlRpip6kmeaZPS2u3AVGzNm2kbdb6Q== X-Google-Smtp-Source: AGHT+IGRmr+KYRNcbMHdd96BrBjSsTk3uQ4k0wnzNLiwenGjRY2MzFNCqinlO1ZRMS0YFM6J5pJL X-Received: by 2002:a05:620a:4405:b0:787:4bcf:e31d with SMTP id v5-20020a05620a440500b007874bcfe31dmr7230904qkp.6.1708252614519; Sun, 18 Feb 2024 02:36:54 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v18-20020a05622a145200b0042dfd040b7bsi2326170qtx.648.2024.02.18.02.36.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:36:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70349-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70349-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70349-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 438961C20A26 for ; Sun, 18 Feb 2024 10:36:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E24E64F1EC; Sun, 18 Feb 2024 10:36:40 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2135.outbound.protection.partner.outlook.cn [139.219.17.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2220C210E7; Sun, 18 Feb 2024 10:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.135 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252598; cv=fail; b=hzPMr2FPcpFaapo6vSX7wmZ9n3jxyhzPpKrPTDvisiMjVWPf8nM5vxub3bS9AjVvsZdIFz8saYnw9/NL+J5IaiW3hWvbT/Fg7OMUxnm7KVLOJziLs2B1vjtzSJ0LAYC5LisfNKzwTfkq2SkOhIM5BXGiEbeJrzw6uFYbLS2m/vU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708252598; c=relaxed/simple; bh=eMXulEIdcFeZNVPJXZ9a+bqdjedikrB3PLgnFZguxSQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mTv6+og3+vsuVM0XMozAnWkbMflyY/EBPVeQyNDMr4R9g4jUjbcDOiediLPKulve7tLVhp01QoHo+ErSO9Gw5y4vkvxAm5ntT05Nx8MgVIGkAcH3ATkQ92bwTmB2aQ50IIuJfqJ09LgHvs0sr4PHFACrYVWZFV3jdTQKks3xzMQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D6du/Nw94005xpKcvc370t+YikyKSoj/1Ut6DnSztz4TAszZjzujSlCM1xXbToA0Hd25XRkvz4EjoGamLw2kqBQjXS+XXKadcAPmxdXDCrTULaTqA/I9OC02JM1Dd6dmvBT99cExmvhoWKOBMLk+72Zl/rZQUUEWuvc7OBJDOeGPnXD1jjZs6wmleMVah9cdoRxcnPx5hsVupmT9RIyVh02Ur6YboW1Z3wO5fb5UPEy04nFn+Pz4y+crVpzHABdC23qtRR3zRpaWJYSdt8o4wOQ2mpVOudmcS0lBxrFPwkeTOVwZOBFn/fy9kQzRIiMSXRvroV7fzL900NWYcK7T8g== 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=JRrm21BRcALG/c3V+O6g+r9icHsk85hPZnWqZkhA7Z8=; b=aTqnpUtTLdHU8zmG8QD3GkHA3JiLgN77gFbULAEoeyCF12Z+O+wWseTLIfipuzd4dPt/BWCDtL7vdolVEnxD7Lo1dzc/akiSug4VB/tUykxqykRFTzSjwG7Ey377GlfKUVfD7mBRAjlfjHPPxc2KPxLMVNYmLn5X/mT4g8cSHBXwaayu97I3/MApwzjzozdXXlNrp+t6J21IfyvuGVk3Jz07qHHdCh2jWZoiEKNjEOT87rY+T/XKFjT1SSvxWPFfXxgMudhiDHH4nHkwQ0ZWo1ZMHHEfTErIuctBhPZEU7Yk1r8qDHihajGr70012LoCXq0e0Dg51Jak5Bspun6k4w== 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 SHXPR01MB0464.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.50; Sun, 18 Feb 2024 10:19:35 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19:35 +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 v15 22/23] PCI: starfive: Offload the NVMe timeout workaround to host drivers. Date: Sun, 18 Feb 2024 18:19:20 +0800 Message-Id: <20240218101921.113528-7-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0464:EE_ X-MS-Office365-Filtering-Correlation-Id: 229af3de-c65b-41b8-da21-08dc306b1b11 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v8ckrRPtX0j2XF7tx1lI2RQrqqWrNHT3i70bEguRg1HOYKuoQyjTO27EwKElXlZcvXgoGvzmYUPWpXNy2fICRdvGNjzVYyLD04QEfMRLIAegnCAQhUDOxGbsKHhxkFWXLRrF2t+0o05f+P5LBOdW1JE05uUhn4AlxgBA1vArEhjUwUrAf+w3NHEF6gIJeR/fknGRdeKURzsM5G9Ftz1dxDWs37RjpLUB+bYN4TdLW/9Bo/eTjIeztWCM9Ej6ngXYeItwn8qiN5pLxKeTfRJWEVIRPXmd+vqY2PLZE5zDifx8KrBzA4Ke0CoGt31Sb7bZEVfuwwnipbJI51H4Bt3mkQ3J6ofXDOehK8q1A5YZLK3EUhkcYYBILwjg8wD2NdjxTIFH1t0qsk6vTdmIk9+iZt2eHaOnXgeJUsTV7zTZTDyQMv+qgdwtIx2n8kGJ4rYNCBgIXMM2TFk0Yu5klOua//Cp7UAIM/DAphMisEC31iijT2BSHDABuyx6QItE5NmiAZlEhhGjn+Wfqh/fiYKS8+3oVzNPgO5DyJvYWiOy6dPeNFe0JxLZ9zAOqJoIWrdz 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)(366004)(346002)(136003)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(86362001)(83380400001)(40180700001)(40160700002)(38100700002)(36756003)(5660300002)(41320700001)(38350700005)(7416002)(2906002)(66946007)(4326008)(44832011)(54906003)(66476007)(41300700001)(8936002)(66556008)(8676002)(6666004)(52116002)(26005)(508600001)(110136005)(1076003)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l4Pfh5CYzOcdzvU/kbIlWK2VZ497ITSpBQH7wV0T1CUtRUbIdE6qKEGCLyfMH4jiB+5pdFSJEO5KjTCqGRKLooxDZTBBCtxtXcbkJLyoZ00NVzQ0DYvmkuaKKWx9Ky/nb3PfNCZgD56nwfT3jTEbQYMtJWlFBPfq18xcehqfs33MAFqCEcFZWDJNZQTXhFSTZIGSB0+/6Wf3+aw35cyJk6tO0W5f7TXtmOpWzX1dVdn+GwSUJvn3YAk2GgROPZdLt+kTIK1ilD2Hz3E9oBZ8su7vzynXo6MLCG1K/1unYKFQ1Fc5U81MoWRekzBtCFvYIYXDr44tAPlJTK67FN4Yz61avAABL5evBLsNcnHIEIuXPLgjETD6ctxM6QM+NAGspNzYrko0t+welvo4CQzUBDH8x4Z3ps1hhtPIg7Bb495bzGiHVBFVSXXYdE222X1/lH+XBtsVH9Rnf+NI/QwpLa1K4efWJwjC5nNqJb5dI57wIMsxeo3dNrlr8s4v/1w1oASbEdZQvyhr+GQ/2YHWbDJ44fqB49Q1Yz//Ap8OI2D4pDfZKf5/Pj0BqH2q/psuGl7kEG1lBwrizvlNIpsPlDBPmd9SFvTXJilvPjUmyZ7h7liv1xqqGso2ce5KCEv0tFjKwk+FbjXfzUNHTD7zplykmLIlRUZTzp+hvymMsTW8kRTHwmp+FKnSHlexku3DPNsLU/Qji6/2n+kysjZzxZ49+HmMh2kNoFEhFbX8eWe01atiNnbXdGqcGmQGm7WEDkraIl2EDI4cVTunZXzHiMXB2QFFyJ9+eQalrclPgQE/e7KAk91Z4Iz0voM+5whTCLet56lfvmHB9DOezUlkn5S0YCqezzzfKU+bNDirMtoYCZd9gHhJLq5lwZq2PZ7kJZN4gInxsA8HvIIpVoHBgDS8iuEiYXmSMcwu5fWrg6Z/YZF7tbV88AkV3BP9h9loW/vOcwYtZtxpQDpUb52gqsIkNPZUdckFMDMgZU5zs7COEgP9LuHCDC4RwGoAEvJlJe1JAZ9aZOULyfRotbC/AciV76zWKNiMYd5blsj7XnWcCTgKrZgS3O7SUe5AJJ2ZWpsmC5zf1zssnvH59Xyusufo4RUkXDa1oi0WaFtwklOC64GKUg787J2u1rZ9sLYI9PTTzsCF1T6PGYavUkO/qnnNJ9ZITHwrrv7NckwN1X/pUrJPXtHjLq010ZFv5hvEm6BWgSznlPTjgfouH77+YdUW/Y2G0wad02pyMpag/BUrdnXZIY15LJqJMB1n7yovLRdSWhUVlmnJHFyrL/9GTyk2Y32C35WHBHp51vu/GAucP2kSa3N1KRA2UD9huTFhddQ+/ZVytTDl8nz8PMWfkFkGIRY+W2/9D1amw62gnOxPvIzt81mvaEGw4Pa91I6S+24aRWkK3Up4egX3Dsie8Z/T5CA/6bV75vPktfAvMfbga4pU+hpXkFLCWkr17UfxCE1/exylpYaqeVzFh4uCId/sGvL/HyO7V9Zmgosukrrj0elD+C0fEi4WbvBaE20MYL/7iOY8IXgggL9LW9PWGxNZQDlnPcDx7RtewuVmeDL0QqAkI1+4kl9rntwucgGvyScPa9Ppe7xshzgGoQoveQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 229af3de-c65b-41b8-da21-08dc306b1b11 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:35.4870 (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: tdYZqh+6A87vzTOJOUzH45BN/7aqqEd/E0S2tBpqIrmIPzdmahOTGdBSWeyf3ZWXPYcxp8arXX+C+TxmubeqhD0tHqgscQOBdXApSDHSXDw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0464 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791232693129591274 X-GMAIL-MSGID: 1791232693129591274 From: Kevin Xie As the Starfive JH7110 hardware can't keep two inbound post write in order all the time, such as MSI messages and NVMe completions. If the NVMe completion update later than the MSI, an NVMe IRQ handle will miss. As a workaround, we will wait a while before going to the generic handle here. Verified with NVMe SSD, USB SSD, R8169 NIC. The performance are stable and even higher after this patch. Signed-off-by: Kevin Xie Signed-off-by: Minda Chen --- drivers/pci/controller/plda/pcie-plda-host.c | 12 ++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 1 + drivers/pci/controller/plda/pcie-starfive.c | 1 + 3 files changed, 14 insertions(+) diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index a18923d7cea6..9e077ddf45c0 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "pcie-plda.h" @@ -44,6 +45,17 @@ static void plda_handle_msi(struct irq_desc *desc) bridge_base_addr + ISTATUS_LOCAL); status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); for_each_set_bit(bit, &status, msi->num_vectors) { + /* + * As the Starfive JH7110 hardware can't keep two + * inbound post write in order all the time, such as + * MSI messages and NVMe completions. + * If the NVMe completion update later than the MSI, + * an NVMe IRQ handle will miss. + * As a workaround, we will wait a while before + * going to the generic handle here. + */ + if (port->msi_quirk_delay_us) + udelay(port->msi_quirk_delay_us); ret = generic_handle_domain_irq(msi->dev_domain, bit); if (ret) dev_err_ratelimited(dev, "bad MSI IRQ %d\n", diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 04e385758a2f..feccf285dfe8 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -186,6 +186,7 @@ struct plda_pcie_rp { int msi_irq; int intx_irq; int num_events; + u16 msi_quirk_delay_us; }; struct plda_event { diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c index 9bb9f0e29565..5cfc30572b7f 100644 --- a/drivers/pci/controller/plda/pcie-starfive.c +++ b/drivers/pci/controller/plda/pcie-starfive.c @@ -391,6 +391,7 @@ static int starfive_pcie_probe(struct platform_device *pdev) plda->host_ops = &sf_host_ops; plda->num_events = PLDA_MAX_EVENT_NUM; + plda->msi_quirk_delay_us = 1; /* mask doorbell event */ plda->events_bitmap = GENMASK(PLDA_INT_EVENT_NUM - 1, 0) & ~BIT(PLDA_AXI_DOORBELL) From patchwork Sun Feb 18 10:19:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 202779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp725641dyc; Sun, 18 Feb 2024 02:54:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0p8rnuqv0NzVTxPc+m8t/qltY6gEJ/ZNnWmGlB/AAsRC8450VKk1ECUoIVF2TX7YrPEQXxDXfTudwVdlPLro/8bWSQg== X-Google-Smtp-Source: AGHT+IHPK96mPErIN9Y5Nh8id3JvHzJT4nlO54FwWSXk4ld2kJxFBVhAK/rjKCqD1tYRHLza9u1b X-Received: by 2002:ac8:7f81:0:b0:42c:56cd:14a2 with SMTP id z1-20020ac87f81000000b0042c56cd14a2mr14585199qtj.6.1708253669074; Sun, 18 Feb 2024 02:54:29 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l23-20020ac848d7000000b0042c73051388si3735281qtr.211.2024.02.18.02.54.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 02:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70359-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-70359-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70359-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CD6431C2082A for ; Sun, 18 Feb 2024 10:54:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B85124EB41; Sun, 18 Feb 2024 10:54:03 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2106.outbound.protection.partner.outlook.cn [139.219.17.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 139B14F1F9; Sun, 18 Feb 2024 10:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.106 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253640; cv=fail; b=iJYPermGlrEu+/yGYV6ElSBJvZS2+/ACObPU1KVa+xIjC/BN+aWiDWjazwACes1nUUrg+8wNXwg64aCUDBdJNpA1XU1XVAoIDaroRf2zE0+TM1PpwCKQU8DSqy5sXGD6aRf/VR5vPod/T77b4q3eTRTEwEu2dVUqKhJY+/yYArY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708253640; c=relaxed/simple; bh=S2lDL0gD7pPak+dReXlI6JFdBr+tBRJUw89XXRjBFG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ODm/JKt0CUmv3XiBcdJcP+yBxGW86fHUuB0XuC160kmIjTrlMoUGjEXgQ8oxogeJ0rdr6+MEFarMeUbqHQKWdxyEaXsz/5B3MVQFhdycRjY7Bvu9abyKw4+rxHaRBNA8zh/mHtNNHyLaaIa60qKcgefTVFfecFmmNKTxeT1A+w0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lznK5zPla0ZKQ12N58BbgApBsMrrW0MCAHyKgJ0wn0sQ75v2/FTLN28Rz8x1iX3wbTADJQTM9aYdhcwe5vK0lEHG+hfpZn12Ew32GClc+hKzWXHAYaVPRxsrx6oyPPgkhHesUEK3FxaqAYRkh4xf2OLVR2zQO6h7J7OAdBx8xpsZWuEHK7Ji/gb3JRWybk5VKasq2/ytcrB8Z2EGB+VC4DbLeLVHRgmZDA56IjXStc3N4qw5Ef4Fy6e+63orDjOLzD8nd1FTSFKlfho7Lvjk81xVvrikSAo8BeW9LZ+upcku77MrFTR8eqFfHXlLtKhUqXlIKb87RkpxK9UMTmO27g== 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=GYNYAZrLB+dBrXkhLWB1l3/THGdK2+KMIfI30niLbJ8yz35+g/F6RS8xj68C/5d2JPsXwqRSf2ZKbergKCUQ4/J/IgKtpOFkFTvUai36m1rdEop27JSIqIk/obb+bcKnqHRhpeFxZYAG8WDW1exQHYiCQ3H7YGM7h43MfPELKEPOQGk8I7HJzm+8xB7mebDN6gDaZeRY0/Pf6GsI1wCGvrU5sSCO4zp36u6DXNxo9Y7ZlMOF9rdcbjxtUGutfgGdAUkp9Yk5X515dqLPZjOy7EsMlo7XqrqC4JEzWQ33I9/Q6TjAF8aBbwOkJ2YNejV07lYXScPR39NOj3mSR1Gp7A== 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 SHXPR01MB0464.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.50; Sun, 18 Feb 2024 10:19:36 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::5a5a:fa59:15fd:63dc%3]) with mapi id 15.20.7249.051; Sun, 18 Feb 2024 10:19: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 v15 23/23] riscv: dts: starfive: add PCIe dts configuration for JH7110 Date: Sun, 18 Feb 2024 18:19:21 +0800 Message-Id: <20240218101921.113528-8-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240218101921.113528-1-minda.chen@starfivetech.com> References: <20240218101921.113528-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c510::21) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0464:EE_ X-MS-Office365-Filtering-Correlation-Id: 0558dd7e-d6ab-4cc9-6da0-08dc306b1baa X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MOAQkIELSbAMHGT0owiz/gK9IKtDDZAPN7J8/H73JaAg3ijSubEWdlg6lV9pgSc7iPt4Dl1dwdfz43fY8WSVIlDhRyAJWmoMJEdTzX2tMHmTZczlJ/NifvG6QBxTmD9LiAFSO41L1WAgfj1e2cmhOaRK/XXSG6nSi6cRE6omX3/+PPgwkZoZOzzmCCyKOtQuRK6WNwVfTKR1rNnR2CU3EAIx4eBuEvU2GLZN0UKyrvKwO1/93eJ3M2rkniHwg5rJAtWOHplvs18rOBvMYhZ1GyJG1hMqOITLvQt0m/2LIkbAOjPE3Vvr1FMfyymk9vtdx+dwGTAeg/oMcTbzbKdKZDcmNTWrDVZLmgFnkVNR4GEyTSnKETzazGMF+bLN+NRuPKT+IPCe+LPCwnWeHs2bKh3sUZJSyV4NhA6gOl6mpfbdVO5AbJPReTMwQr9C5YbNdqSpfH5uYJamvYhU+7yfOiNy88POzzwEMxj4YwemuffrL2tX+jcwJaXT483xiFBmZSN6jFb3EGH7baafndmLJwLLdKwIGxmeSkrHw84NQmbYYYFxsicpuTKFogeSBVdR 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)(366004)(346002)(136003)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(86362001)(83380400001)(40180700001)(40160700002)(38100700002)(36756003)(5660300002)(41320700001)(38350700005)(7416002)(2906002)(66946007)(4326008)(44832011)(54906003)(66476007)(41300700001)(8936002)(66556008)(8676002)(6666004)(52116002)(26005)(508600001)(110136005)(1076003)(107886003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HR2TBmIz3ksq6Xpzb3etWIVfnIrrAEDrRnG67+w4E7MuO3QkEHFcaUOh6WiwZW1SJCLmYkX/nJRRrodKagI6UnebcFtGuFIqP0vDmoQuVOQK/lRb9F2YtJV6CY9FGorSlcKNE3i60dIDhoU+jMs4gaAyTrbKA/s7KnuMgJW3W5i3HK/cxQoQyPRiU8Ymg6MZgE+GFCXUauXKexf6thWOlrgHmf/zjPMqAiE6C+aEy8sJbkbEPuPponsoZLW+fscHRZbosqf/H7bWXlFLbYFlL7bb4Z8YQEKbj5RExTHwZRtxmSMo8ydQPElmX1UeChG2l6hc+RybLtuwjLvXEMJpG+MSY9JaadBuF76TVkQ0Rd5UJ6VFxPBDKOe79N24kWJ8NzhoeMpcat+zZzabajhg+6t1MMUShoXcS70d49a16tSVA4Udg+21bm7g86Z8LT7xrIUJftPvBkr72A6SRO5iKVabTOgzXlnf9Vw9RXiZkJ38/JQ9xLZpdkxW44tL+G/EEGjwDFSWdMakmOcMFpOY0ze7Fsa4VuxIS/izgDyXyiIgF0X2eIqQR59hFCI0+Tce+p+eyJtBBT94rwUwuvPqaSYw3GAPrd86eY7YFDVyqFvaOG9BUeUWaAIcaOyQI7itA6luDrWrYDr46INbFPhJ0PVxqZjy2hWR205cUcHPZsYgKhROohG1ZnFts0CwpUWachtJzhQ/DXbBeGC2HkvLY5igWPubgR4kb0hAWtLxrugZ47UvHS/VM+K4fjjf8VgqvaSDCsBNlCOp6PeFW10hh55KrQ2oqeU7nkyX0YoP2d6Dd6wo/Md9JRmiIHPAt2Tmt4OQUAS11LtfnFNkxXJRTTKZ1y5kVC3n82CUoAjXnUlhly3e5oHAmwBJy2iQk3KI/ikeMl0LPUkWooSGWe7G2F6CtsKlMQBsMpGrm7kGIC2680Ot6anwXqgpym80HDBs2MFEOKAc7WMDpll4yPOZcbKbMRt1UzoESuAKw2gckWRl8YOLfxRr6nlNoD8pnwoHSxBqFQsIqW0BlCxoA8oZxq5judbNcM4hGfkFLPVYHhYSvcrttzHrxrMR+sDQmqY/qv+vo2V3EzANnnmtdvp/CivRyLYw9i1QZuM9IlOgU65JO6UiJ4eptAsWx0cp6rZZljBxJh16ZoMZR32J588/GbbFxLMdKkMLO6BN8hx3IWHWdCDdg3q2Jf+AdQyrbk5FrIXIKeIXUHvwpOkZ6AaxYEIltG71pMhaUDUo8L8nTwiz3Q9lVxvloNgcp8VE/Giykq96zp0Y4FV3EqBGBjxKVjt2KdalcCqInShZUveihVvGJtX0bHhwwNdjHPY3bvDTfLEEE5tDQkGp/gsX8+9G1FtA1hW1/rbTuBsCuY863dVwu0ZzaVYug3NJS+hlq0o1tKpoeg12ibx+BjvY1+FFFRTTB1jZJiSAcWNAp2WXA+krniar+c9M/UrA/CfIVzQW3Za7+Jk2tD5/spcBAd0IM8A0Jebt52VbNaj97gY5IAT4HoEB4QtwLdg54SA6kEd+Bf/PAj637zwNuSS1yEFEJpNMHkfWo4fhxNGhcrrIouyDPYua9EVSHA8FASrEg1txa9pEqjipr+p2xC91iFSU1w== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0558dd7e-d6ab-4cc9-6da0-08dc306b1baa X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 10:19:36.4495 (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: KsW73v2vWNgeoR1QaMnWRpzzJ+626+HK9+InQ5NcW9enDD+QO1u7MSXll9nabcwpZk7fLDjhvnFU1os75EaPskKQqqemxtFVfsIAsTSmN/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0464 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791233799534943384 X-GMAIL-MSGID: 1791233799534943384 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; + }; + }; }; };