From patchwork Mon Jan 29 00:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp295481dyb; Sun, 28 Jan 2024 16:59:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGC1VRaWVl7Or0AKB3q7rNrCbRvkWv1/K+4oyQDvmGe2QhueUcGCZ33uOi6NLrg/enkVr3q X-Received: by 2002:a17:906:a252:b0:a35:6669:9fe with SMTP id bi18-20020a170906a25200b00a35666909femr3100705ejb.32.1706489998143; Sun, 28 Jan 2024 16:59:58 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id md19-20020a170906ae9300b00a35a4aaf31fsi709201ejb.622.2024.01.28.16.59.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 16:59:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42035-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-42035-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42035-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 9457B1F22110 for ; Mon, 29 Jan 2024 00:59:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 475BEEADD; Mon, 29 Jan 2024 00:59:26 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2074.outbound.protection.partner.outlook.cn [139.219.146.74]) (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 77F0F944F; Mon, 29 Jan 2024 00:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706489963; cv=fail; b=MTPhtwJ3K9bdbj/E8XAQsC5pVTQDdGYAm7n28ulQS4aI4dOxET9+8zkOCoohU0u1gmuMXatzeOgNJRaq9+2jNKvBVjHN85u9hraw2lUz0oMyW3E/VQ2a3HUwDASRb4QMJoYRBjBhBmUBWRcee1Sh9ycC8yx6WhUIh5pek+anj+k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706489963; c=relaxed/simple; bh=153z9nphCTtjtmLY0yRQaHO9ivj+TovGeZp8rlL4AZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=T51SsKKbOwua7pVS5K0FcR5zv4Ge5OLNxFTJ/wl0AF52dXa49JWVZ0WR42Tx4AxxpeuS6nRd3BgN2Pa1bpNH4rrZnSLAoo2oerYO4ub9h9fFocZOrp4y4Pg6LabBdfv5EQjdMLkZRp5hScF6ttJbGxzJait4KPXORIWZmp3rsDE= 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.146.74 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=LXT9Yy5JeM7kuE32uNBanMBy2aPgWBfuzZWMVeqAy0Rps8L8CpvmQVE2fj3o6TxkPgPoa2HdNIX3JKBIBhCxB05SKDMa8g0WazjBpnuqPvjQeACeVIvXaae5NN97X9TrqVQoeKWsHZdaDTAsPFRZHhn9uU/Tquosmx1Ydz12XrnlnECkcpE1qdFjqK2RbcLTD6ZBRkl2ygPH5FtuX/aa3wxZmqSJQLCXcHVNO6ZAn9KXOTcirpnuF7C1aGNWENQklOcycpGHCq6ec9Ia4CKw2EOSBgWsRa4ztbOjxEBBr/zn/mzvLLBWVu4Ij6dWYlJSNkXe2p7ltkXf0b9k2fesiw== 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=MBsYGoRO9KX0ebyIZ+Au6AvXvEvnzFKjFusZlTVoxYb61itBLpQsZLTuDLvoHwU2+tMCmckXyL77jk0zO67qLf020SEDp7qwf3UZc7aADfCMhwHUgeRwg5EBs748cbKPS9gP6/nH/buYnIVMPAe+vbltDYkd3xWurEhfgon9BK5UNBC9biUjVKsuc09kcVVAo0aMMGiphtrRDLafvMXBYYAQVJpczNaLOHqD/0opbdDH7sqaVpzoYEUZNyg78fpKqfLX4INGPUwcnDrVb+ndXOe7ea7R1w1ASPWZsg/c5oA/rq0z4UAv/5pm+qNw9Z/sv6pGtm40B/0jtttdYcIDZg== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 00:59:05 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 00:59:05 +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 v14,RESEND 01/22] dt-bindings: PCI: Add PLDA XpressRICH PCIe host common properties Date: Mon, 29 Jan 2024 08:58:54 +0800 Message-Id: <20240129005854.3554-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005854.3554-1-minda.chen@starfivetech.com> References: <20240129005854.3554-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0035.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:2::21) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: e44324e6-6ae8-45c3-d1b6-08dc20657dd7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NXU8MG2yF1afcvI7R+rHgU33tw2+zHVRt4qSnBrHqaSOBV2i1og2/rO6nHgFb6mnMHgKLz3af9jzWpBdyT2BDuUQZlD4fRAVhUlfnioVzvgOHjJ73MmDUrp57e6Yuj5seqMv1ljU8dT4/+9V5VVqPcX9e1Hab0UgqjtV6bDHj8xkvRsdPm+yE/o2zIJAbvUGGfO0Z4jHWzmWsGVhQsr5p6DLrHvpiSthFd0GpMCcbb65MI99Wc9IAHgT0m7wyw6LHoNHzJOW3Bv/h88AGj8rT8rkJhZ3NuF5XQGxO4fi+Ztz4U/eTylLxiPGSlHAuvNs7onP6o4JwSQBZxvi3g1JtzLq1WnmYKXxxKe2JY587H0C8ReBChxWO5m6tjzRr84pBCHn2mC0RD1DWyFPlu7G0AJIsvnxb9PyG0GzyMzQLD2Awqk+bnQPBfLUKJgDm0T62lU6hBfuDirkLKexgDb1ieenPjbEOHMDiycSyPgvbWOgzCmaKWCZ9YKqyNbulUk0FQHbhatS7y9LTtTOdOmP1ptQkQvmUZSYCaseYvXQhUOn3hcL3fwHX5mOEWZrnlUV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(966005)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FWBkwTFh5av1f7b2+Vc0Jp9kVM0TM61XGOg/4co21CdnVO+qugd9WJPwm/Lhbcb33fnEtaEI+FHHl/VJ0b+5/iqDMT2rEbzctxH/MFgWGuMT8IAlPJT0+LH0J0a+gxPdVmxtnXCg/xOOryPw0tfW16OmFisiXncNnpVXy99vgsRh28yRmmMoT+R5zf9rcYqaJ3M15UD62bX8YEJksuT7k6knlvi9TT7e6Cc4srTgBZiET+tlM7HY1gkK4Vf3UE636HbrO8/oKwNXgpx2xTWruLyE1tqk0o5Djk0yxmIHhS9xXNfiLLPulQbOzbEXkMC0DWNSqaqaqStY8P6TpAxxMljjpn0XfCdsxEZ5bPrM4+BqVt6cnneNsw8am9yw2VpLfatKiZliaYOLYYl+j5jFA5AwnwX804JQanq2HZ/WFLjKzCW3O0j957k6arKXUk5Q9JPR9nj71gOz18Af+mBNQ5AOiK/htgnqHxFNyltP6mAYTKreVhoLc/KmKnbbHz5SdtuxF43fsOWcRDoyIu7SPZnQPfEfRkp5RjT0SucSwWCJZYJVe/3qjLdCfvIaiIzhdnn4U6Dla8Ceqo0cR4uncO5VCTQGyRsBhqy4MJrmE8iFFYt7D9YXGf8/YwCzl4p6A81Ob6RuBq8THYNg5uewOy/Z2qcU/Mn520ZiiLs4ymwbL8d8aodELKqLpdCPp2N+X+cKXfB4rAm3JvC5l2jWVIHTzvjevCCAOKl4GXfqHE6VELxhM8couS2Y4ohHDvEMcW91EeiZj5wnQpYI2XPFzX0gWaYM0MntrsHNWBkDS9WILHOqNAXdT4QJc/JdsOdb+zZyEocDcfV9Bbwyiz5lIIvwCoS9zm1PBByKhYEhU69aVX7xtw2GgE5ZT3rvltpLsvCDnUgQJVdro9wZBgmViQ/z0J52w9kQbJmrzb1vCb6fqhMU3ynbata6gs3X8VyjZVgM9mhIIyxfgKmXFkSOwgaLANATuKJX7QApf9zl7jVJJ9YmwT+afuN1nwRF7mdYpIGSedn5qADxidmmv8hmQ3RbZXE4hIWf3b1azBxMrJlep6CzY2zUKRQ0wbbTGNPHje5pJ7+94Mw92cSfbKJIfvHK8j1MHJmcQwPFjNdVJFYuwyBfJvkL2Ef5LU5M5RbfbmqMa+rp7domfDoJnM98FcGBVkLtf645X9VH2C88Bz86i4PCMgfMwtBQyL15mEQSXUZ3zoHjcthxkYkdWeJ+sACoy5zudmBtboH9zE9Uta+IwaEWeNYWoqIysvD5QOZFNnQNTaxOJAFWkT8dB3PMbJWf7eOgBLhUEhlEEl1E3ejl5xPKGd13hqscQ+zuw8nzDWMmk7LaZuixPRNNUF5eeAGbSDmfBXVLmd/WZI9ZzKXTmJ9TV/Atya/C6mPvrKA1nSN67KTK9u9489Va/y85F7p+oJTW9TmM5HkvTZY6O7xu9TQ4GhoxpCs5wCHYpoFBQzXJ5gE1j79HhgmgG+L5R758oOwPRtiDU5Iozoc1bQTV7Z3G4lv5hTMlYaFFyu1xEv7dGRD8WOZBXMZ4X1bryJuUHcjyLlbgURBg396N2LaWmdDwjR+j/WIMeUHm7/+eO+yNwboSR9ysfKP7HJkj6Q== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e44324e6-6ae8-45c3-d1b6-08dc20657dd7 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 00:59:05.6080 (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: U6gGZOPBWmMhHQ+bJPbLya7wl9Ip9IHXhKBZDm+2RzorWWBfVCFXEMT+yJ3ueaYbbGz5RkvmszM68ozAoOny06vlOMNj38N1aUNfCldlI30= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384456161524054 X-GMAIL-MSGID: 1789384456161524054 Add PLDA XpressRICH PCIe host common properties dt-binding doc. PolarFire PCIe host using PLDA IP. Move common properties from Microchip PolarFire PCIe host to PLDA files. Signed-off-by: Minda Chen Reviewed-by: Hal Feng Reviewed-by: Conor Dooley Reviewed-by: Rob Herring Tested-by: John Clark --- .../bindings/pci/microchip,pcie-host.yaml | 55 +------------- .../pci/plda,xpressrich3-axi-common.yaml | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 54 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml diff --git a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml index f7a3c2636355..7c2d51221f65 100644 --- a/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml +++ b/Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml @@ -10,21 +10,13 @@ maintainers: - Daire McNamara allOf: - - $ref: /schemas/pci/pci-bus.yaml# + - $ref: plda,xpressrich3-axi-common.yaml# - $ref: /schemas/interrupt-controller/msi-controller.yaml# properties: compatible: const: microchip,pcie-host-1.0 # PolarFire - reg: - maxItems: 2 - - reg-names: - items: - - const: cfg - - const: apb - clocks: description: Fabric Interface Controllers, FICs, are the interface between the FPGA @@ -52,18 +44,6 @@ properties: items: pattern: '^fic[0-3]$' - interrupts: - minItems: 1 - items: - - description: PCIe host controller - - description: builtin MSI controller - - interrupt-names: - minItems: 1 - items: - - const: pcie - - const: msi - ranges: maxItems: 1 @@ -71,39 +51,6 @@ properties: minItems: 1 maxItems: 6 - msi-controller: - description: Identifies the node as an MSI controller. - - msi-parent: - description: MSI controller the device is capable of using. - - interrupt-controller: - type: object - properties: - '#address-cells': - const: 0 - - '#interrupt-cells': - const: 1 - - interrupt-controller: true - - required: - - '#address-cells' - - '#interrupt-cells' - - interrupt-controller - - additionalProperties: false - -required: - - reg - - reg-names - - "#interrupt-cells" - - interrupts - - interrupt-map-mask - - interrupt-map - - msi-controller - unevaluatedProperties: false examples: diff --git a/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml b/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml new file mode 100644 index 000000000000..31bb17b11e58 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/plda,xpressrich3-axi-common.yaml @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/plda,xpressrich3-axi-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PLDA XpressRICH PCIe host common properties + +maintainers: + - Daire McNamara + - Kevin Xie + +description: + Generic PLDA XpressRICH PCIe host common properties. + +allOf: + - $ref: /schemas/pci/pci-bus.yaml# + +properties: + reg: + maxItems: 2 + + reg-names: + items: + - const: cfg + - const: apb + + interrupts: + minItems: 1 + items: + - description: PCIe host controller + - description: builtin MSI controller + + interrupt-names: + minItems: 1 + items: + - const: pcie + - const: msi + + msi-controller: + description: Identifies the node as an MSI controller. + + msi-parent: + description: MSI controller the device is capable of using. + + interrupt-controller: + type: object + properties: + '#address-cells': + const: 0 + + '#interrupt-cells': + const: 1 + + interrupt-controller: true + + required: + - '#address-cells' + - '#interrupt-cells' + - interrupt-controller + + additionalProperties: false + +required: + - reg + - reg-names + - interrupts + - msi-controller + - "#interrupt-cells" + - interrupt-map-mask + - interrupt-map + +additionalProperties: true + +... From patchwork Mon Jan 29 00:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301639dyb; Sun, 28 Jan 2024 17:16:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/7pBD32Z0yS/9xbpkrLi6QUs/OM5nic0wkTGyHShxBD/w4j8BAOgwBHvVKvkDlh6JVCqt X-Received: by 2002:a05:6a00:2307:b0:6dd:c23c:ea4f with SMTP id h7-20020a056a00230700b006ddc23cea4fmr5101397pfh.5.1706490985586; Sun, 28 Jan 2024 17:16:25 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q136-20020a632a8e000000b005d8b8f09180si2869173pgq.550.2024.01.28.17.16.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:16:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42049-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-42049-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42049-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 55B672840CA for ; Mon, 29 Jan 2024 01:16:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BE87DDD5; Mon, 29 Jan 2024 01:16:11 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2084.outbound.protection.partner.outlook.cn [139.219.17.84]) (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 BFEE1DDA3; Mon, 29 Jan 2024 01:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490968; cv=fail; b=ovGNLywtrHZewv9GDOf/TeMBRAQB5T78K/R1Z+qP1oQsK62e+Sd1SXyif/OOWFn0Txiy1VB64pZ7ceaCnwFdLUktCmpxy9Wxi2JkJmhDySTSKmLOZEn0N9nguSdQN4exw25aLa5n2eR0qYRwMHwMcsIx6inapjnT3RShglGlnQM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490968; c=relaxed/simple; bh=JbW+UxZUp866Fhyk9NXneVY+ZT+ecAdOHbvukAn2S04=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=At6++/etSd81opNkIxWGn217TMGaBJDua7vhvWMpVcwwWvj17636sey4e7qFicb6li/y8AET1s+LId++7e1gzeZG43NfMEnPnCygIsHqvQo+iJubAbesGGFw/HFYgUaUx1W3E3vIe5G3qo8j8T3dv5UWiy0aZB5iwIQACTtWFzc= 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.84 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=Alrj7Vxcq21ly6tpjtHMByT5Pvv8nV1HMmhYdEAZqSn2PKZTLDXE65zEc7r5+MS9+h4yMmOgRh2b0osskxhEvCdbbt9QGDlkzKq8Sx/qnJTOgf2Vxh0dPHOTgGqrYPxCq3xpIutSy7dxjYgdTh62n+zyNcBR8cO/n00G1pdsoGeLjRui+IRmDyhwNG0kgg+xfy1WQHBA8WxflGtgOH8CQhewWztF4D7SLq5IRPPRzKKVS3Ry+ny+XyZgk9BFRPGmpj15ks3RcZw38FjXyRTBSBTT+Ajg52GqmTjI14k+phYUMofWkzkkrXZ1XpqCV7RzRmcblbHKCM5CrSJ1jjqOWw== 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=e32gHqF3/4Ta8V5kx4q5V2+D4dF4zhKKR6XIQgjmQYE=; b=JXvbwRknv3lmy514E5JUiihvQuVm2tyvxsGiWs+rr0uUooPdw/GreF3UP3J9lZYAF7h1Ba26ZZoBSOlCRxn7e5cLNpuZ9zIMR0GsfIFqHu04EvcGzCqQj30eczEHBOt/qy6BD/qdGvr8AYe7HzsLjm6CyuxdUVpn/tUMaDV4LFQ9+Hv9M7NGqGiGz9cn8JC2nywUKihcL0pERp/CdDsJfboSJ0q1xRHs8S7ZBfVmHmUL0oBUPWIxMl6ynBz/dF0JuNgpIoekE/9rOZ1v9TorVwiL4GDDBQb6zDAdxErXNsACAyrWnyycFEhwTB807j32boEBC37uhqnJ28EmxTBqJA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:06 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:06 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 02/22] PCI: microchip: Move pcie-microchip-host.c to plda directory Date: Mon, 29 Jan 2024 08:59:47 +0800 Message-Id: <20240129005958.3613-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: e649555f-52ba-4b64-d1cf-08dc2065a1f9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B8Q1RttqYNI21ZfZuxeUYXxvrrOynorQs7u85YJ00m6SoQjLFbNlDqN/Xz3dv4a9+5uCeStHApp0tXMTOdNepYXfhEFqH01seSv9nukzkBEuFvlDrRnMrpXcYqw++bEINUbu2/PusgMx5iN2Es5pqI3poGCQgFKqibS77qP/p+jXuz4Kj5cv1JI/IuGls63NG/D2BAwYP1nXQp2vSubLEG8YQh9P8a5t9bOItWMYjn09VEgQVbSKU75Nzvj40tzyWRB2WIBgqnoT7lupPl0yBIH3EogocGurSElAZLbX9AMOsnAxDkycRgBBb8/P6j2chFgE/RPsiU6SiWJeQ98ufz4sO/phHogeXwqWFAITo6Dtb/HDrpEVWN0iCT0resHGr6BbgjEL9OCpx04o+cZxCJwsG+eslv3VQEhfEXFtSOHJ8dmT+8BNA6AQdciP4GmNP0iHswK5hD98xtoWhhDC2zGWKa9Ci/BsHMyW8nCWTuvYq7W4qPYNbJuiPkoLsYfkY2PmuR9HHAM1ONk3Or/E2+JZivIvIS6Y7l8LUp5EPnE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(45080400002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 23XvUu1sQUwT6+bmg7YUS8ErmSQS9ig4dpbb7eu4qnkIQNUI6BkEuyYvT5iX6GJKN3UERJD1bLWvELz+9y5CEdqNkkXPyWTFaIdFreGb4AMHvYBygkL4yIPjRh4qrj2iwGCY3MWufsOLVVZFwwDbSyEfugzHgiN06bJnnGQLA8fev5DSD6J841PVQH655pIRIwZstfrWB57he5y7J/sjjRhdud1fgtYhhHjlpiaxh5ywM04efBEWrUkdVGN900xm7Bn4k7JBpzhazOshLW8amxD0C8PP+K2pKKTw9o3XRFrcGd+0RZ1mGCkZey4TV8FGJ6L41J7dn/0naJg4h3CnJstCFiPb0jEdinsZ2rG6Pf6ikiYfLh9/J163OYT8w8O5xTi7G4yt89tdOQM+OOX42/WL6jb16dKXC3gx+aJdA866TvWAADSQuPAq/d785H2IGpXi8xma8LpkzS39Mr5yDJeBc1dSV7PTeTKcE7V9KCDvZFMpDp5+kgw4x0dwGUU6UKOHmJCvpVUEbrXK89TJlS8B3jwdya/KluZU1P2pUrkVvoKficIWw2e0UYOp8Rd3uLbWuyrGr/PgPLd7m5lAwkNjWLKfR3IpO4QtyoZxBKBxvdJQSe9I0GmoF3WczhBN05pUizQDewuFgfnlvIXwPyGkZ4zgRyaoRlQdgLVwLQz4hTn/UCycqIOPLiVx29SM1fOBJBrJtNfv12gmTqkSG7yywSKKxKSWTY/GsY2H+RUnitcU1jwItVFaP6kVmm8YxAvONzleoGcZEn+DTQ9t+AMdYPsmC8AhEZuBcp8th7zUB6yAwOfdud6idiK7n9vqtG6N8SsTBW+ogdXkjhBQ/DGrqm/41uIpHsaqDZ6ahoqJLBjpUF48lZbVQplOpd+GxQqTUCPZMGFNEJyS2ke84n3hNaQexm5pYI2d3/uGV6qGytAIxLvFBlwsGOD4oRXjUhVTmZuXIuLX3F8s/LpnXhhUtG1nOpfJDMcJrw2V7LXKelQzzcCKDb0MSomE5WcHrmNcqpF5hv1Y+jK7i+eE3BCHVuKOvvzHwNW70xDVPzLHbJf4I9OjgbEyk04uD3ADo4xCykaBYs+Toemm2wzgz0n+9qELfCixrcdk2MotYhpYeprbb+weXTJvRh/S1mVdEpgul9DdRuTYpDm4U285njhK/pDX74h2HK7L6mr73+9vlfb1uetqkQNgiSu7pHOUcNoiYHfW5iCNYNv8Us+4CQN1q1oQF0A0sGYnTn83utE53zv7/enZzgZNy9DH9xERvhvs8KXddtGuSDqMuqo8vjqd+FIyGokvPUU1dACqCAKuz6UDC07oSiAZ/ayH23XhnGS93bLTO/AZliseA7gmRMzV+KN/J6gOKB5Plzg5qv/B9/6MxkXJ49ZfJDZJReM4qVHeQPMGXHilJ453hISZDQpPO2cQhPN1UOx+DXHuZ2s2NioqCrHokn8SYLiDh0QxFs4rSsAxORNAOjtWaLsuKhMu2Np24mYRh63JW9bXmLkRJnjkWNMxk98qMZb12rPz7chJzdJxOH1whaO78T+Ev1JHMzKBJmHm3Ilz/ri3byQ9F/0eh6ura+wj2j784FUHLIIruuM0f1XAqIJf5Us/3Q== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e649555f-52ba-4b64-d1cf-08dc2065a1f9 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:06.2077 (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: 3ga0AmoB9kNm0DyQsc5/4KWgkZ8Psffoo/LO9G39kIjMXyi8uSdHovtvnfeMtINun2HLzDjcnUC3mtlkH04rFtJbw1I/dzMeA/++2iVS1t0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385491966164102 X-GMAIL-MSGID: 1789385491966164102 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 8d1052fa6a69..44daaf962065 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17034,7 +17034,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 @@ -18827,7 +18827,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 Mon Jan 29 00:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301519dyb; Sun, 28 Jan 2024 17:16:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6Ec9fTRwOmN8NU4fSZZIcp08iGAO1TFjeQ1CrvP0uCrMhRqUV6OH5q4dZyyIL2cn4yJkT X-Received: by 2002:a05:6a00:23c6:b0:6db:9c1:7164 with SMTP id g6-20020a056a0023c600b006db09c17164mr6358091pfc.15.1706490966720; Sun, 28 Jan 2024 17:16:06 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g13-20020a63f40d000000b005d8b313de29si3392366pgi.650.2024.01.28.17.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:16:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42048-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-42048-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42048-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 7536D284328 for ; Mon, 29 Jan 2024 01:16:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7FDF7DDC6; Mon, 29 Jan 2024 01:15:50 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2056.outbound.protection.partner.outlook.cn [139.219.17.56]) (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 035C4D267; Mon, 29 Jan 2024 01:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490946; cv=fail; b=Nx2cetx+NSoT7I9QuMbE+HAowywbICOAl6xk3Q9cVcY7Ae2tRiRD65NfQDjGNTC9d2CxyVoJkBCjCtC5Tw/trf1vwvWNbWvYPJI1+TuZgR7f8JXRyjZKrzViDHNiV4jGuLoua5rSf1prqEBJxhkTrUIGqUOHZQfST81fCnZW7zk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490946; c=relaxed/simple; bh=J1Vs67zFQuxJfPh0mWcRE1H80ffa1MU7C06LvBAwQ1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ktwk9fJ6HCPaEsxSjhKjm0Ml02CO1NXYoQBvfE0QP5sxWA1IxXNOr81m9hjhO9KHhrPnmxTTnIUTGnaS7Ziv2P/riwBGwwjb8uuGfUmQzVqI5SQRINlmlNY8V29fNeHnRCuLQjxLnZYLBnOrgGw9XS3allCX4MVaztTwaMQeiUg= 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.56 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=LTryLzGzwujo7mnKS1MoivSe5PL4Xy2hDNCB8OdAsecarfRgxYj/Nmz3xjZfM6PN0UAFzmCw24KckpiUjs5TdbnHmnbJC+W0K3dej+chc60B2froF1TN+yQ9I+FUlyHnsIa0rpzG3IaekPwtAFYaW4xBhgu0fIBTWv8WjxEFIbKYxqvFhNO8oGJiuVVaXCw1uLGkyO+BMBiQegMr6l2Ut+dscWgKT38H7dUKGaFUJSO/QhW39p7ZHmfJpL0kyrM2rbhovXntQdqdbRjlQ7JwcSbhNioHXRIHOn/WN7B2DH86ycWBxhSU0YK8NhKuQYefs54vez/NRIT/NBAM1UaaZQ== 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=Itcg3aSqPauiN5XQFv7dSMmeVokhY5xZ4+FWKeBoZIs=; b=D7/6S015+vJek6eAcHzuZzoBHo9ykkzt+ZwE2gWy+MTF+WC+0H4VIvJGblyforRC4LEj3WOborLFnwAY4eW16Q8RtBnG03EH5UDh2lbC1Jxf2PQI5kjvHs1UyceH+Uu4K8H7e7u5RSj5b03fJhzYgwLRZB//roNYtjwvHmOz8Mvec7rOWonHwf1FM36bRdn83CWlnp6OXtoSpj1NxjfjhTZ6LLsa1lYcEtqipGsSHyBXxzDqvgGOjAKOpLRCi4qcaTujnbW5Jlle9PSb4hrr0Om3Mxa57kXJd6Gl4m6kIsJyH2HgH+dcwotqMkbtTQPwkOo96hD9QgLG9Wi9YkSuYA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:07 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:07 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 03/22] PCI: microchip: Move PLDA IP register macros to pcie-plda.h Date: Mon, 29 Jan 2024 08:59:48 +0800 Message-Id: <20240129005958.3613-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: bff46389-2aa3-47cd-3ac0-08dc2065a2c9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3hP2BF1MvR3TCgMDoyFqKmm7BxHOIZAtRUL9u3IxZfqfasgGlzoSIsfFSsJjDjRkgaYkjAozQsseL0ahCjm7Ph//D3hZ1FHztvJ81gLaplRC5QWuB8njA0mxQj6b4iWNaiB2qxXn+Fo9K8Y80uc52Xrt9qOSRfJbIFPuGy47DpkSM3Oz7JGKHEhkSLfxf7uCsMqDi//ievQUHIdybuf0ZuFFIvTisU+GmapESCMVl8A60K1UNwyFU86SsR8hxwGXgR+OPezrbfgUamaHK56bgc/nUsn+bjo7igixLJeiV88GTLhYTo8TOM8Mmj1CBHkmzZuCAoBMndlGJfVT/1FnPmD9tVjUsqqMW+l6re+IkFi0oV3kb7HPA7wY4i/gNtG6c9/YnbacW/CoWoQdJrtwwlDJ+pfol4Yzdw0DL9It7p5KZ7jbOGMbw+1rl+WlaLFpl/QOWYhxuxu93xaThJrqU7msB70dsnNBIvSp11GooJxMubNG0sk5XejQLxEjzFXsytDFlVKXMocyw9Bt8n9TjdjO403mweQTOyjJ45BiSWrWaZQpVsy6UxEENw5ffBc4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(30864003)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rlqf7olskp2Pqfiq20hQ33mEOhwyUxCQ/AZjlMy5QLZesxOvJwg0Q1mbmwihDqLDyiLruJwV5qJ0AUbCFt1gve7CuK6f3+UYOnK+6PHUUNu0wA5GO71r1Ol3atd+noQs756fgs2PWavld9y9w7cdjnPR+6ATFsI8vGpDl7Cq3GmUxsHMNlHI1H9lCUTa5S68aH89srs49Dx3Z8ERNyx3/cpyFv937PPR3SQIqYWi1qnQMpjit6hhBw91chIl+p35GhSyK6QRW+9A4PNhJHlmv7hopxZnKUW8rqpu4TwpnXcK+kItLmRX1MTA+lLomdDna1j3kRYW1H6PLIh11hz3gA46yvkSgAnySdLI2FJxw905JnaGkFOPSsZ8EqwvZ/+UrDptjD9usuFuPtIyYKGsnWhb+yLJOFu0KPIebR9eYU0/NDCmtzenqh4E/FrONJP5ntA+GVRXeMZ4gvAoZ7o2wTi/UOVWmydMZOTGpM/Mt+38fAkWXRQkreshMmttUSe4ODnlV3dFed3jnHexaLbA1ob0JqZeyw7Fd1haeTeVX0VDBsmzmckjt+9qXPVOMF5HOXHKgHc1b2cDi15wnwDKohCZKM/XxcCUY72dPGHiMuj2lF0tsKxKFtLbqehUlOZw0aH529G9sMPKgw6+UaKeJLLkk5McUp6DkY3MULlDIqhtMvOTtYrrbv9Pq3A9/Ue3MfDK72XEX4SVGJqY7fT8hzw4tzwv6yZ75uRjhhmPXHYc8RFQUAGlPYlIEo4/tfFG9akO4CqyryWjxfmfNCglk12UDD5e8KgkHFEYwrnR+ey1t3ejIp0pHhWRSvSI8f1ZQyHtV3Bj6mkEoXRpDgsa+fsGoaNSbkVSDUV9p2eb8JZKuFg660u9xqrayVT5+MHOqAK7c3llMn/T1f90kpMZLAlgX+p1pN2T74+UG4hmy+4WLfwlOvA767bvNFGVPApO5NEHcGdMpMequVliIqKB/Vn5kz/m0yQuesxvdIwtNVILzI+3jUAkCbquYn9q6GIG1nzmdDxkcmvge182TXYjaXH3N2p3T2sfARv2H4jxwaIomhoeS/H9C9OEj6tjCrBGIGhWchtzqO/TJlnokIlx3EZF66DcWcfVA67uKcf9QIZW27PWhHT6ofxzNtMMMOS5Tt34UOePdsMj7e9hMPATkzKVDdHDms8P6Y0oRFpEdMPhcGdV1QxEVsJAAguL/Neqzru0eZGbd8odUcorqqrzbqN3R/RYqozh87JB/Kg8ZUD8aWnF3iC7Vrhc8U4wRQEvjsSrNbJgyPKKafIbKJjAQ5tkL22NIUkAO2MZc6KtGdP5O+vVnSLIsn+hXg7ukrVdQDnN9w11SfRBOeitIeRKp6B69F62M+1sNGaUXO3Fe4W1hXBE//89agqOlLwUuLxgY0G11Uijexz2XURiEMFg0cE7QIAp6yky/wYw8m4ZJPBvlfKuKhEkAs0774E30E/ZKj6EurFTwfGd0XVlJ7MJhLfAaUBCNWn9q5bjRoeORRyo+JSoeVwYhNGV19BYEoMwdypmZ7poVYhnzTiLDqtpoHD66T77yzreFf7v/XC+l09AbzXQo7t5D4XqT5tepnp9fe3hzoKX+g1IbkKBTcmzrA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: bff46389-2aa3-47cd-3ac0-08dc2065a2c9 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:07.5926 (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: ghncKGugvMWn8DjrgYd3dvPCASKHf7nwuIevJ4dCA0M2GmDG303Tmky474Ju3pRFDb1XiH5bdg4N3mXYIi1fHwR4kU8A7c3XNufwRantLIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385471802717185 X-GMAIL-MSGID: 1789385471802717185 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 44daaf962065..3b8d7ba12807 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16802,6 +16802,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 Mon Jan 29 00:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301824dyb; Sun, 28 Jan 2024 17:17:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGq7a0j6dyGdA6FPftePx1B1GxHVSTjYF9/XpWcfFCYRqfzgsze+bgPXUg2ws8wgIxPzlXx X-Received: by 2002:a17:906:6b84:b0:a35:aadc:a522 with SMTP id l4-20020a1709066b8400b00a35aadca522mr1235677ejr.57.1706491024837; Sun, 28 Jan 2024 17:17:04 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f22-20020a17090631d600b00a35dd8d50e6si145ejf.468.2024.01.28.17.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42051-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-42051-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42051-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 4D14F1F225E8 for ; Mon, 29 Jan 2024 01:17:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA33811CBA; Mon, 29 Jan 2024 01:16:16 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2084.outbound.protection.partner.outlook.cn [139.219.17.84]) (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 D5583DF55; Mon, 29 Jan 2024 01:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490973; cv=fail; b=XwaueSaLR6Ksk0wPK2bvxW5uXJQHisIcThqNMIKhvPlqzxmd0+/Za9i9oPk6r/A95i9u6nujOPQ7ycqYC8sVpG9bIn5Hlyvb9aLzOIBfoHt6E53dcG8j2VQoSmnZYEKyjnRJgyA6jhC/JdTR5MyI1tKbbiKaoOkTHFnb66gPuCU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490973; c=relaxed/simple; bh=Jr9GqF0VedirT+pLXfWGwtgNFSVamL87RXSJnlSv/Rw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=anaQOPzB7BjHKBAjd37GSLXMhPZONo8wgW/Yz9E8XbtEEV5QvK/r3EYzAx892cHX7plvbBiXX3UQJbB2O15wSRcM3nSHi6+PoCBa0now7gEtD0EFQJCZrtrqUhtgetzlv6I6+eFkIRmWem74H9+jWIwH10kCDtldTMZ0dTDLoUE= 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.84 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=XXjW/5vDuV8iHPSYQgt6uIbfOukPGZgaAM4D+ZVOERvEXJCSg0GvGesBASmtZqoQ+ZwGsbeiew5re/xvYGQyUozzIXaz8xxM21a9ntcagBKNqpTQFoiF8OMg30II+rvQa7mGmGR9SIOtGopn4RF6A/u9d63GDgOkoF1Wr8ihz6ZLncCLnQGqbjE9mATQLBvUgdbrvVL72eYrhVwH+k85DqobDylLyWLIBDLXZmLYCXnHw6xaTPyuo/4CKeM4Jghp+/pGHKqWvpHId/Cs+tY/Y3K8DqSBRyrv+4DK62biPiT1iztvokE8NjRegLLD2fzFyMKg4016CmFki+ULVo0iug== 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=eG/m9MjlzG6UOe4l7JFM/MueIX1J+RZr/3I8kRLNe/tQgGonQxCLZzF0OJ3J1IU/xm0vh5dxXyFMx2fID0gXkFDKo85Cwi7Q/iInBZcA76EERtebOTZVZNeQFkVc/snb+e98mFHq3cumwOL7PT5gIoJZ3setzmYI1YsscMsfeUbvJZzsSj4UwGW8/Dqo/yE8KNKJvVbnHmgafoiEon9EKmzVzsUaa/1UGFPTRkUIKDuXmv0ne7ChU5bzmUrrMZAG32QUgrGSuynL2L2WvK9rohrk8kYEoyfo+wGgjltBOeyJO8Zx6rSP5M9fPEiwRhDiRnCvcPvz9hZA3qsult6wjA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:09 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:09 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 04/22] PCI: microchip: Add bridge_addr field to struct mc_pcie Date: Mon, 29 Jan 2024 08:59:49 +0800 Message-Id: <20240129005958.3613-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cf03b02-de5e-471b-a3a3-08dc2065a398 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rNHi8eq8oWESFD8FUt97KUJtxkUBxq3iv5JES4EcFkcWDhcLb8CQ1j8MXF9frOcA41fWk8HrkfJ49xNmZPSunkqPPkmMWH+q2WQ8Rdry+3GSs5tfDPW7EpNNoF74dBa+ZxJAge+8RRmxQmu/xeApZdN3Qw0C+/iehtZNWas4nhOxV6wkyzr3Gdl4yDtfNDbLLLRwRP+bQJDGLlk5lbIEbmGN4XpGBKxraB1skGxHrtaqDaBwNpLOJ75R6HPIrF5xaefhylP5RecD7FDDL4xDaaTHhjbIMwcXF5Nqivf0pEShd6qEPGDbpP+i8i69dKSBJ/lGctDwXCT/ygJ1UnZUilRVuuModA+IUhER4OKEa/rqCRMTsW6sNpPH3DJHGpqp8OmU8MQnZPi3zwvDN9dD+ymmiMnqotutv52Zv5AR5qsRJLBkKa1A5JqzYYZm7p34otpiEWIofRyYpJc5Uets0YhAmanSYtLBvNytAmT70ypaFlfvBm2Ns2hqEabhSVQ35WhSaq4i32as90giLfIUFZNc1DxNa0Akptd7FL3cD1YUIVMnls1dvqa5q9oBZvnk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ht74ElwsQXFWk8h1nVugZmN2s9UdKSxQDzrAR0gn1GVm3OKc5v2khFPTcY6mQDadCghco2mWxbRMjMdbkzGAgNZ9ySrDPPrIHSqePcGvfbTS+nEsW/i8dp/h/W62Caml5Tc/C86OAOtkYrA04B9G3fXvyX8UcGB/U9vplOeQTYr4+K7Mww5NjYr7zWlTbFfA4ZSHg8E5l1JrOntSq+WDMujBzQNqIsaDHuGROXrgOmbUMMvpfUCuLMzRUPeaKubhQouT3VTwxvtSonX9DN3F7/DzXqppJTQkIkayHM2T6Ut8FMjkaTe3ltSl+9XOMc0QUVzJkywG3XwcFQSSHUxSiRgPda3uU0sQsrvkkUvwn5cZYFGR2fx3QdxCwChrwW7Nu7pwG6P45pMG3vYxMKG1dC/vUFOtwWFSsIqYwbpwKON6LD5NcwxOGLPgNixvIRKbns9YoXH06S9ZwYC/UuSGHA2SlsNMRfVR45bh8jt3T+zEHFmf/cDLC6cO0ElFJJ/+yjZorW/KwSWUYcD4NKzy106ifEf9OvITgWWLJangcjrvDthwHsQ+XHvPx5Y59pxuCA3pPKrHnnyRGPsZl5EplI6cQRAJ+DETPTzzB7ISCCNxCdaVnMjIgTP7V1vQTR6caQXiluhMo4ijLQ+WNyMM15jNq8lxxMzqSSsOoM/qJHpJAJeIlaV+z25tt06Q5nBU2mBdDTvb1UhKe98satLzrzdl2HmMdDH01VROWxb23/dk5R1sMCVlcK+QX8msrHJjsTtj7/sJIIMa0c6s7fsgkkNRerkXgV7RA/7C3IfGDgQAmcaTaZEMTsRSPRnjgfORq+1RRSGlNTz+mQ95OlX6zRd5VMz5HwT5nV9LN0x/xtuUAcwA96wVNpgjmkj2PBNqqGgjAo6ejdxYSvmtHgWn0LZxToAz/FujgyZwRtb0mID9cOQVWgo8QTM1qItMDIz1UCEFzT7tHw1FxZa98IhxIh8hwr9sgFlUvKqd574z1LRa+qVbZ6eWLkXf9H0ILca/JM9t/ciD/ExpUMyF0QWdUCsG3GHBJn1QYxhD3pKcQQ1JoyT2Jxr79uybwORD2ylAmz0RKxDxhoQTNYjLL1wiAmwODtuZkyxQHIySk+AcjkkyAaIRSiRXTFu6EFpXkRl6ffbIitSlftlyA+cML2TIB7lsBK+CvwIO0PY/2pItvXEwJ0UkwmEmudQRUYn+9lA4LlL2qH7nPWj7H++8PWYgFw3ibwNrLFnCfu2eSEE7IO/Rvw4ILFtwfZET8qwrNTMLXXFf3idsgPe3AFQXcUdK9vH7FP0pZUy5feYHaJjqzO2nfo/amXuZfFl0gC7NN/wMxigRq2GNmJVg0ibxtC9jedByEehAlGpUtpXFWLPvZm3cGG9uH+aamUas+g2ZPrBiJd2jJ19v5sKn60edNdXGFST8s6JxeRDhTcC1yFPZQ/ZzfR6MdC37csxMLgXEZ88UVmze6O7P6FBqjeKyOcCQgtQOACUSQFM1tnvM7lRho3Ya6z4f4uYbWJysjn3Lnu6XF3YrsaPSbkwo3z2liVlWmxo81FPbbAnQ4BVVqMl0f9WTUxtuYslOhWlhbn6zHR3wO3+J1vpKC2MRXOkxKx4yhg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cf03b02-de5e-471b-a3a3-08dc2065a398 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:09.0687 (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: Xx1M8mzu6HZOqDEOpGFn7keA4rmJ1n8xrsLIeT5EbPEIj1s1FvZg8SJXNiYs6g4hetgst4n8JSHlXEX0M7YktxJJ4hpr98cMGX+c0vCDiuE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385532849526093 X-GMAIL-MSGID: 1789385532849526093 For bridge address base is common PLDA field, Add this to struct mc_pcie first. INTx and MSI codes interrupts codes will get the bridge base address from port->bridge_addr. These codes will be changed to common codes. axi_base_addr is Microchip its own data. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index d9030d550482..c55ede80a6d0 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -195,6 +195,7 @@ struct mc_pcie { struct irq_domain *event_domain; raw_spinlock_t lock; struct mc_msi msi; + void __iomem *bridge_addr; }; struct cause { @@ -339,8 +340,7 @@ static void mc_handle_msi(struct irq_desc *desc) struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; struct mc_msi *msi = &port->msi; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -365,8 +365,7 @@ static void mc_handle_msi(struct irq_desc *desc) static void mc_msi_bottom_irq_ack(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 bitpos = data->hwirq; writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); @@ -488,8 +487,7 @@ static void mc_handle_intx(struct irq_desc *desc) struct mc_pcie *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -514,8 +512,7 @@ static void mc_handle_intx(struct irq_desc *desc) static void mc_ack_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); @@ -524,8 +521,7 @@ static void mc_ack_intx_irq(struct irq_data *data) static void mc_mask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -540,8 +536,7 @@ static void mc_mask_intx_irq(struct irq_data *data) static void mc_unmask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -896,8 +891,7 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, static int mc_pcie_setup_windows(struct platform_device *pdev, struct mc_pcie *port) { - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; @@ -1081,6 +1075,7 @@ static int mc_host_probe(struct platform_device *pdev) mc_disable_interrupts(port); bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + port->bridge_addr = bridge_base_addr; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); From patchwork Mon Jan 29 00:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193214 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp307002dyb; Sun, 28 Jan 2024 17:35:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlhrRlYeNTbzzBO6q6nSMoh7fOW/BqNJCCzNWps7pCi7DOU8mJ3/+yJ5OKYT/wu0XVwVwg X-Received: by 2002:a05:6402:3137:b0:55e:b30c:e0db with SMTP id dd23-20020a056402313700b0055eb30ce0dbmr2725335edb.35.1706492107422; Sun, 28 Jan 2024 17:35:07 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f10-20020a056402194a00b0055e7e8a977fsi2226366edz.380.2024.01.28.17.35.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:35:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42065-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-42065-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42065-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 D6E201F220CA for ; Mon, 29 Jan 2024 01:35:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FEEFEED7; Mon, 29 Jan 2024 01:34:51 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2045.outbound.protection.partner.outlook.cn [139.219.146.45]) (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 35656DDB3; Mon, 29 Jan 2024 01:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492086; cv=fail; b=urqS8FiSpd80pB4iMfpH4yR6ZQlxxQzglamUphzf0lb6HSd1IIwPxqhhSYS2z9MSbDuIY/NjMC4waA75gqF6IHdWEhvkczcpeId5zFiN10Izm8HQJa85VF0IdyejSWfuGpSAHd7kscvT17DSovF1N3fyAPmC/1urg2JZNqEi96U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492086; c=relaxed/simple; bh=a7am6v2xZ49CNXVganzyoymQoDUkzff74c7Tk7OWT8s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SdInCNS/lhq+E4uhuNr0zHsoI0tAFKCaRlFSlAtGy0VD1dSkGZwVpkU1zJVaq4cFxBt/pb7lC/7BvPK1e6cCsdYWTXMgcK+ZMtERNzXlLKnHrlCOOoo7bSqE+6gUoSuVq8V8Yqxw/tdOCGRizj2JLUTlFu9x4xbn3MdIhanIl8o= 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.146.45 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=fRxXmpWmhteqXTl5Tq4WCVSoGLCNP573K5cm2WBpiakMzpjIcKvhAJqEuZjK9FmA54PU3yK//7H/6pbbtvqn7QM9joaQvwqYV5i/RFT7NkGuMALwvSsQ2Z45OXJv/xMWQyBwJe+cB0VsrI2sp56HCM7pdPss8SJNa9dZUrqWXdL58zQ6Wt9og4MCHiXI0TejTDIVMqLkbef1/E5NYeiE5dkqPhCyg2ahnHhiZ3/cxYZxWLIDFvZAJG1VxO0ILKi56BWptIVWK6E9dhAOCYJn7L5D/HRbPimifEYaZZ2EcbLUy8ER0DRzNX1tWB0bbJaHwMsUn0KbNehCi4+8ONQLqA== 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=cnQyrWdO1Y1m4lHQgtBvZj+D1OPrL3urs5k7XL6na+4swzLI1gOu9BhjsMVW6r/MH5UaX6460zBZHqurx0TMdFa18JzgF1woIUtLmcCA1rKC3kGtUQcZvnEoXf4z9zrIRrKPUracqAqofdLL10LTwaZ+jcH2nSib14ZbtfN43WjfRnB5CZOQyFh2+MwaF5SKws7yf8KGuVV1IG4P+zr/Pglwo4D5AZfQspuSiHDTA/d+ttf+z3AoFk2jK9rG+WvLulVGGQAH5laQ8I1hEAVnl6Qfz2DhlUfYhZAsR66ZtvO8TlZawfpD0+ic6xvgUGGMXFBIqSwLfbXFg1PRTnyRRQ== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:10 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:10 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 05/22] PCI: microchip: Rename two PCIe data structures Date: Mon, 29 Jan 2024 08:59:50 +0800 Message-Id: <20240129005958.3613-4-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: e4482492-20d6-44b1-45f1-08dc2065a482 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BusmB1gfWBcreE/Y3/WLbV7leVHmCXBAZcV5e2i+q+p/Iimga6/avzP3zGo8K/F7wV3WJv43gs9qN2HstSUNh87f3gRdYdoUZcW0YesFyG5wZRXIq+7d3BJi4eQBSbfSAh8/x7n9o9NrbtDFaERL6I0j95WU5NZ41OSKc/8eYzDckHe6FRZXYd8SV9hmRkZVrBDLBOi/eFmRCKEV0eRJxx4wZGyMdkipLLdqYYOt44wkhMAXtUVY9bOQn4PO6vL8lffs7dcP0iDrjfm2Hj4StrrlDmiCYcVifn1yHaM4L91q+C6isXTdChglNuj+Lh9LLRM7SZB5NMX7/h46t54Kdw7dP1O0loWlwrql/G8sPewOVjm2vIGVg3Cb3EPjY58A6yAksbK5eOa4ssRNkUmJtqZblwyQL9/M9KmK5R2BlwsUDef3/A6zib22433bTNyIJX0uYuAIFABFqtjtxThXUR/YE+Ns9PLKIrNgpc3jRVKB2S6rkwVQMTpxR9BpVN4bEonj2IWuHGd6+dx3y3ewKCKmOb6i69DDCuhV9PnkQxLOqPe2RLozdfg8+3hFEjSq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(30864003)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CXDoeaTgzj0YVEzxrhKFIbDY1Ypb7gARxiaNZmrbAMLBhTueKgW3yu9WTtg0MB3KHjZ2kbpX5LreMnujBfSb7hX4bDxkTOJRjEDdSzROXQGGwl8Q9zPH11CpnhlaHWHyVG+HYZcu7nBo72fYu/KUzZzPyjlg2Oj1/crz+Ab3v4s3nBooRUZ3MOMThZLOBYU7GwNqPHJy2wm81CBsQSIieimztyN4reyRpooWl8Q8WGvUlSNQ/+DB6sg4/6IUfS574+nqKOYz+T/vvKmCa60ei5Zg00OjLZ2spNhnuI29DaG2yoLJmiRKglXJ+Mfa71VpyHlGijqCpYj0WDvX/owEJSi++4HeJ3X6pvtXIMoH9qI1OLtm2KREeMG69xQiB12BfXq74crPDPq7AHftJabHvKe36N1WBo/OjIpJXdu1udcuRt8DQV/nXZHbEDpDQL2KR2DAN8kdD1JYKdAMPUGV6BA0GktP0UNL+Ty901BIcxFAiLBLOB8kMpPN9cwK//CB1encdODt8CBH4ZFhIboN93DwMPcJ/k/o8CBLwtfVUNyo0eI3ARhlDwQAxaEpuZNnG8ZOw8OsbfOltaYvJ33O0c+F+bSWt2OSp10Smo9um2GCslmHvMVeMNVqjYTBBseQoCd2J0A62FRlXD+CWgQR5yBp+4mSywMxgfnINd63JG/gF9Mfr/GwZYPesGXw+8i3elB4K5gs13LIYFaAh/3iyYRXgktM1pt/ewIKJX63ie9un9wRi30TQjb9M1VaFa/BzPjb37mp5/LLXorI+L5BXelfqoLLHm2aVgAojv6wE4OInp2ZyCPU7o9mM95zL6bmbzJIGMrk64MWwefCk5Nu7cvGwo/7kKCUnSgsZRC3Suxg3/VYyiHn5tW1QQ5O4Yu5uz6ygAS7iWg/wDmeMD+4ntUPeuhEUpPxw2K223ZVA5i+qHUrWBy6ddvhXMgOEvF+CbD7mg1j+uuO1WuwvnQ+b0iVlXVaCtMxIIojSzt1uzn5ihdbsFKZjRrYNmIX20cKg8tD1vJKZuE7Z4YykgLWLHJCbbhRFOmnm50XkXIgpP7wi4TyXZE08hcQVabDCuDBYpMQF0CqAzlsJN6RNDqW7GA8yGaMHsMWwhuBznZb5tgIVk/iqxYygrnk9Z6sHqOvIqWGIuwQ4NnsC/BM7JGN5/SWVwsFL/JVlkXUomcwLshKkNPMmwW6v/w8WMjRq76JBdmLSkt6zxdyhvSiUVyXeaInWqe9HKjLwsjduP494CmEeF/jtujIqsSON7SowDxfIeMCbjohmdgzw0XLjncJhZIq2W4v+92TJD4CGc1BLrs9O2NuuiKRcCvSoj8jUyqAnP3jljy7XGjijruGuV7CV3Vcp404DskpXVRk2CJdDIlwz3N/zEKPujAZrNfbr91myUAcOrHA85KG2skKG5Nz7O00985XfAPeLjTxD69MUhQ1LrSQAALMBFOgWokDkr8MNfvueNNim4dTv6wCiAPCTSxVPdCjnDBMZKZyYklWODwoBNRL3362MaX36mfw0BOdBs1ENsNjzrfDIMPorSSZwMfpEEoqQxiqtwe0j53rzhEXOFlvr/HRuO3zorA00KaSFkKot69BPghIZbNYVzEedg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4482492-20d6-44b1-45f1-08dc2065a482 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:10.4574 (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: ALG5xDa9RfRGJvUjRp9ZLEBF9574xFM/IjO0k8+W/ZBBGpvTatLVARoeosUiaxO2V6fY/Ot2cdRXzrxm4h7387fM9LYlk4eWjfoj9VeyDy4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789386667888615070 X-GMAIL-MSGID: 1789386667888615070 Add PLDA PCIe related data structures by rename data structure name from mc_* to plda_*. axi_base_addr is stayed in struct mc_pcie for it's microchip its own data. The event interrupt codes is still using struct mc_pcie because the event interrupt codes can not be re-used. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index c55ede80a6d0..df0736f688ce 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -22,7 +22,7 @@ #include "pcie-plda.h" /* Number of MSI IRQs */ -#define MC_MAX_NUM_MSI_IRQS 32 +#define PLDA_MAX_NUM_MSI_IRQS 32 /* PCIe Bridge Phy and Controller Phy offsets */ #define MC_PCIE1_BRIDGE_ADDR 0x00008000u @@ -179,25 +179,29 @@ struct event_map { u32 event_bit; }; -struct mc_msi { +struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; struct irq_domain *dev_domain; u32 num_vectors; u64 vector_phy; - DECLARE_BITMAP(used, MC_MAX_NUM_MSI_IRQS); + DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); }; -struct mc_pcie { - void __iomem *axi_base_addr; +struct plda_pcie_rp { struct device *dev; struct irq_domain *intx_domain; struct irq_domain *event_domain; raw_spinlock_t lock; - struct mc_msi msi; + struct plda_msi msi; void __iomem *bridge_addr; }; +struct mc_pcie { + struct plda_pcie_rp plda; + void __iomem *axi_base_addr; +}; + struct cause { const char *sym; const char *str; @@ -313,7 +317,7 @@ static struct mc_pcie *port; static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) { - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->plda.msi; u16 reg; u8 queue_size; @@ -336,10 +340,10 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) static void mc_handle_msi(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->msi; void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; @@ -364,7 +368,7 @@ static void mc_handle_msi(struct irq_desc *desc) static void mc_msi_bottom_irq_ack(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; u32 bitpos = data->hwirq; @@ -373,7 +377,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); phys_addr_t addr = port->msi.vector_phy; msg->address_lo = lower_32_bits(addr); @@ -400,8 +404,8 @@ static struct irq_chip mc_msi_bottom_irq_chip = { static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *args) { - struct mc_pcie *port = domain->host_data; - struct mc_msi *msi = &port->msi; + struct plda_pcie_rp *port = domain->host_data; + struct plda_msi *msi = &port->msi; unsigned long bit; mutex_lock(&msi->lock); @@ -425,8 +429,8 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs) { struct irq_data *d = irq_domain_get_irq_data(domain, virq); - struct mc_pcie *port = irq_data_get_irq_chip_data(d); - struct mc_msi *msi = &port->msi; + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); + struct plda_msi *msi = &port->msi; mutex_lock(&msi->lock); @@ -456,11 +460,11 @@ static struct msi_domain_info mc_msi_domain_info = { .chip = &mc_msi_irq_chip, }; -static int mc_allocate_msi_domains(struct mc_pcie *port) +static int mc_allocate_msi_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); - struct mc_msi *msi = &port->msi; + struct plda_msi *msi = &port->msi; mutex_init(&port->msi.lock); @@ -484,7 +488,7 @@ static int mc_allocate_msi_domains(struct mc_pcie *port) static void mc_handle_intx(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; void __iomem *bridge_base_addr = port->bridge_addr; @@ -511,7 +515,7 @@ static void mc_handle_intx(struct irq_desc *desc) static void mc_ack_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -520,7 +524,7 @@ static void mc_ack_intx_irq(struct irq_data *data) static void mc_mask_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -535,7 +539,7 @@ static void mc_mask_intx_irq(struct irq_data *data) static void mc_unmask_intx_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); @@ -625,21 +629,22 @@ static u32 local_events(struct mc_pcie *port) return val; } -static u32 get_events(struct mc_pcie *port) +static u32 get_events(struct plda_pcie_rp *port) { + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 events = 0; - events |= pcie_events(port); - events |= sec_errors(port); - events |= ded_errors(port); - events |= local_events(port); + events |= pcie_events(mc_port); + events |= sec_errors(mc_port); + events |= ded_errors(mc_port); + events |= local_events(mc_port); return events; } static irqreturn_t mc_event_handler(int irq, void *dev_id) { - struct mc_pcie *port = dev_id; + struct plda_pcie_rp *port = dev_id; struct device *dev = port->dev; struct irq_data *data; @@ -655,7 +660,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) static void mc_handle_event(struct irq_desc *desc) { - struct mc_pcie *port = irq_desc_get_handler_data(desc); + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); unsigned long events; u32 bit; struct irq_chip *chip = irq_desc_get_chip(desc); @@ -672,12 +677,13 @@ static void mc_handle_event(struct irq_desc *desc) static void mc_ack_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].offset; mask = event_descs[event].mask; mask |= event_descs[event].enb_mask; @@ -687,13 +693,14 @@ static void mc_ack_event_irq(struct irq_data *data) static void mc_mask_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; u32 val; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].mask_offset; mask = event_descs[event].mask; if (event_descs[event].enb_mask) { @@ -717,13 +724,14 @@ static void mc_mask_event_irq(struct irq_data *data) static void mc_unmask_event_irq(struct irq_data *data) { - struct mc_pcie *port = irq_data_get_irq_chip_data(data); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 event = data->hwirq; void __iomem *addr; u32 mask; u32 val; - addr = port->axi_base_addr + event_descs[event].base + + addr = mc_port->axi_base_addr + event_descs[event].base + event_descs[event].mask_offset; mask = event_descs[event].mask; @@ -811,7 +819,7 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } -static int mc_pcie_init_irq_domains(struct mc_pcie *port) +static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; @@ -889,7 +897,7 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, } static int mc_pcie_setup_windows(struct platform_device *pdev, - struct mc_pcie *port) + struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); @@ -970,7 +978,7 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int mc_init_interrupts(struct platform_device *pdev, struct mc_pcie *port) +static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) { struct device *dev = &pdev->dev; int irq; @@ -1043,12 +1051,12 @@ static int mc_platform_init(struct pci_config_window *cfg) mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = mc_pcie_setup_windows(pdev, port); + ret = mc_pcie_setup_windows(pdev, &port->plda); if (ret) return ret; /* Address translation is up; safe to enable interrupts */ - ret = mc_init_interrupts(pdev, port); + ret = mc_init_interrupts(pdev, &port->plda); if (ret) return ret; @@ -1059,6 +1067,7 @@ static int mc_host_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; void __iomem *bridge_base_addr; + struct plda_pcie_rp *plda; int ret; u32 val; @@ -1066,7 +1075,8 @@ static int mc_host_probe(struct platform_device *pdev) if (!port) return -ENOMEM; - port->dev = dev; + plda = &port->plda; + plda->dev = dev; port->axi_base_addr = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(port->axi_base_addr)) @@ -1075,7 +1085,7 @@ static int mc_host_probe(struct platform_device *pdev) mc_disable_interrupts(port); bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; - port->bridge_addr = bridge_base_addr; + plda->bridge_addr = bridge_base_addr; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); @@ -1087,10 +1097,10 @@ static int mc_host_probe(struct platform_device *pdev) val &= NUM_MSI_MSGS_MASK; val >>= NUM_MSI_MSGS_SHIFT; - port->msi.num_vectors = 1 << val; + plda->msi.num_vectors = 1 << val; /* Pick vector address from design */ - port->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR); + plda->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR); ret = mc_pcie_init_clks(dev); if (ret) { From patchwork Mon Jan 29 00:59:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp341894dyb; Sun, 28 Jan 2024 19:35:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJgzcCcZcce/1ACCxyZxezDvNR9B8dbwJx5ptni+WAH0ur+YjQshChSGEb6CiQiPkv0U7Z X-Received: by 2002:a05:620a:2f0:b0:783:aaea:12ad with SMTP id a16-20020a05620a02f000b00783aaea12admr4575230qko.122.1706499342194; Sun, 28 Jan 2024 19:35:42 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wv17-20020a05620a5a1100b00783f710e871si2324557qkn.548.2024.01.28.19.35.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 19:35:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42130-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-42130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42130-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 E2D831C213AD for ; Mon, 29 Jan 2024 03:35:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4AEA11C94; Mon, 29 Jan 2024 03:35:23 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2068.outbound.protection.partner.outlook.cn [139.219.17.68]) (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 DBA98101C4; Mon, 29 Jan 2024 03:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706499321; cv=fail; b=pS9kaSEcRgYweZUTNapcU20rQNT+6XZX17KVR85R98BKvTsiNQhLsoqIj4xeKzJinnNiN4DhZxIITeoWtfMLpuQb2wHS65ryT00OA8bjDzjY2uw7caj7BBsaATqu/980SkKr2UUL4Uvq24ZcOG+sdczPIJhSxTI60Z1I4QUfXqI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706499321; c=relaxed/simple; bh=Zr4mWUFXYvtyxcrmFpVmK+dYKLWMemI9hE1iMc5NAH8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=o3whNROIjBOvsBTOfWBis3ibB/J0vXNFEcBcSltRSg1I4aplWIuJmHn3g5C8DQbtcoFr6laVFWrHOy3NbdHWexJMQjY7XziVgde1DTVgHUBGYhrScx5XLdqV5N5uej6bBZSw8sp+bjIDq8iO1x66XozENS2/TdjMt4AuGHEiMPI= 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.68 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=oLDWesBiLGFcXAoFBSjjsp7lVykU96eHn2KjfdB/WXMdkpBZ9C2EWubLDYA/0SRsrwecveyjg8BRyej8aul3z96Fy2FMXpG5JP/BJ7zilWDip2cRMAKWLvJEH0azlPD/lQuyb8XgDqrgawkBFZGbcWC+a1Go/LWEaMioSrEEI3aV2ZhWhOP39GHRa0N213JU0OS0/T3PqP/KXD1osm1NxsIthrzK7nEnML8rU/QrPqFfrBSiFbKoOXcIyA7yu0JxnKy6mC+/XckbjYtHaNJQ/zP3FldXoFjx6u4dS9dduEju5wVU8+2vabQ+MmwPx2eiILkz/B6MztHZBbgym35k+w== 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=hO70NpuufTFbjPzdUC1mvJsoaX9rmusgS3XmcJ3CjgO2xkxD5+JnACG/b/GU/nHcsd9Ue45Qm9ioFefuV1NWLI67YrSqGvHvytEmAe9rl5m3y6am6l79EbmefBK8AN7TA8lzluOAqvSU6sF2+7+R/B/Z4s5+WimLVNQ0qFsQdVVTTGnCdu/1vmtubJliY1myETTTp5OUL+7CqWOmCW+KkbeQ696xqe7jW7DpO+aEzUkXSfjY+iGUcqhbAOSrOUSyoQGiwUStH9QGcXHVeqCsi2pBhz4GmN4u02vh/EKThuoc61yidSOomRMul4LLgBjx39xZMTbN47cjA4KREYauQA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:12 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:12 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 06/22] PCI: microchip: Move PCIe host data structures to plda-pcie.h Date: Mon, 29 Jan 2024 08:59:51 +0800 Message-Id: <20240129005958.3613-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: aa597cfc-697e-4027-d3ce-08dc2065a577 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RXXX1ZRZtH3joAuL7uIRfciliv5K1P4HOehVVMKv990OeKbNMc6Fa/eaf+DVw95YO4AARh4oHvzV2R5kKANRvHuyKkBOXdq/dsTOQ9dPOJwQPoK5vMoIIu3n02Q5Hr7L4xg0HyFED/Fh6C55XOpZ6twz+2q/3AH1UQwB6wQ4xzHPRtULtGtjN15lqz6xRzNRm7ds0TjHKsUofDaomoyBH9cn+L5c/1zjTZC0/PlqqnitSZwi5VuwryZcY4KyHcoW24uGlhCwABXhoWjQ1qz0hvfuobCwH6rXPuVauf124S04yW0EdZI1CEo/TBqhdVNYaOE5F83IZ1iuXbPCGu1ZbNPV7yp5sWq0D9XtI/K2fUoJmhhyeI7fLi7bta6UHwwaQLlH9A13NFM8QVDTyW/Tx4mS75tZ3lIOTb9Hv/tfyHbBnIlcskKXeYi3v1exie11/bsDFcg8Ie83/TTPGncaWDfR3qjtfzioLNO3QMyiLYqveS2B/cgFB02YWNy8GE6Gkb8vJHTWuWtHfnnZlYc7cTkzO2WOYRY8m1jd6QvyClqY92Q08jcoQRxUYWZtv1OT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5RRHy8WLR3qxOlVn5Kfa60DJqFaPMsQt9nfbPPNE0cLnhoRXmo/IR6lOD91XSLPqVVSL3sKfaGQ5BMKb4HuPMCRLE6JHI1aT58Kat0SL5IyJiAHyIq06bs8qzNSENrlFeLfc1G9+2t659W/7Wy9bsc7Oc0GDPlA8R9bUEQTJQYQl1WVZUlpuLHMZzeQLR6b9q5l3PchdfD6TV67BgFkds4S/KujsP6SSBoc36+QbOTp3QDdPlkE4LULlYNpgaEk1An5WivZQ64fyNuJ2053zn0EtFYprpFUMP8WtQPqZOAQl2NFmuz7wmAkpzVn5H52FJLkP5YcdFA1r7FcRIygXcGn+embujv3+kP7eGZD0YH1NUkj+BTGpPeOBsEwHNHA14jlb/6UCGvA3MT0mgC6MbSZcZYhksquIBRlhJk4BRLUPhDh70S77gCEPeE6Eqysn1YMfbhba9oFwkG3pLXvRe72hNkiEaQ3IPxLcGPWx0Zk6nqq2/Bl8W/m8SHKzguYwekXg2RBJ7LzlMHcbtRT996jGnJmjuUmxuQDKpJWlo9Ns92tFeksGpB0DKoBJDX2diOJlPgIo30kRuReGv/03TmoSYnKmc1xDoFn/ZB11UZ0rYHZljpY2Inqlh3jhcGEkyAv8qQQANXQCEY/7TeSY5jUz/HMtpPihX9aLtcPF1wZ0BDYdi6IHEBeexX8f3d6z0GDvEeSH1sGp0ZEn+9dh3A+O5uwT0YbGvg+nsSw0NPqaJdZDNBbaVlAI4Dmvco+iXtlWxtVSqC3n8alL0na5pbqCnGUgxBg9pASnJ0LXHyUw79RSV4+8wJpiGvdttE3RA1LS9wRUB96uiFCtvrY2skNcezIgdDyeH+NNdN9HDSrboY7Bzy5D2jmdRp3RWeBNrMuWpCGCEZ1WuIQqaXu7ZCQ2CcFnNX1YGlej9qoqyL5RSd+9WbAMufXN6DA0xIz1wvDaju4sLdHHF39+6LAGlwWfHTH9rNqPc9WuDoSEs/KVxwO6LVB4AVJj2AZDt4E1zQRE2IksnNqkElRtpvOu1jjEeTicII3qnJU2yny9EpcseXljtADk1bvpur/gAYdNFTQBTh7vkyEwnEQvS0UgAPI9cBhN2dCPlcjtF8dMmSscQlpRIYAKbuPWwRh6dw4XY7bxQYPmX0FH1MlGkPuxILoDk8FOluQEchfeOY0AnHrkDxr1a/24tGl8+xTao3Fj+dQuTUaY/s51qBXqwkSc5pC/kOXWIMzUt55svNC9Irsb0iuUEr4TF74qOOEqopLgwsc1F1ILHCYaxaHSn7C+qCTr8OVD0HknmHdc5Pfo4vh3LSY7OperURGzI+FGfXihT2ZzE7txoOvDdUifUW9CsZCbK/i8qYDHiMpw6AV2lRrhSNLh76+CH8M9X8KNcAGgDFAYCCdfBOWmp9pEOhv3utRYuVCPYEHkb0Goc4Udreqiwf0aVd9ZYkpJY6Vz3b8DJ8bwg8Ju6V6MHwJCGO4yIXobcK8hbzVuAYXo1sRb1qZ+cvCEW6cODywzP7LAi2yXhahzqnhbM67pbdaf7+NtFFA3IanOxRYaQFMoaVemSSsRSc12oTfrtWIQ9Kxykv1Is9gZvsiTK0OfjCsBCaj3CA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa597cfc-697e-4027-d3ce-08dc2065a577 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:12.0778 (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: DHAseEhrXm1zWUWC0jQKK1HLsE0WmO//avrYL4fB160hbJJGyL47Er8JohJocl9AN/wBTH3EOMVM7CBrk209hCvTbP5nIJ4OYHF+yeTr63c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789394254250347054 X-GMAIL-MSGID: 1789394254250347054 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 Mon Jan 29 00:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp306633dyb; Sun, 28 Jan 2024 17:33:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IG62C2XAYNc3TWVkDLoWHVoSWiqmlgMEkG83K4qR8zKPSWiHx8PNaW3qE7E/9YF+DjZliYR X-Received: by 2002:a05:6a21:1507:b0:19c:a6c8:10c3 with SMTP id nq7-20020a056a21150700b0019ca6c810c3mr1937735pzb.4.1706492034125; Sun, 28 Jan 2024 17:33:54 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b7-20020a170902b60700b001d8a652d259si4247178pls.350.2024.01.28.17.33.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:33:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42062-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-42062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42062-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 DB3852826A3 for ; Mon, 29 Jan 2024 01:33:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68FDADF6B; Mon, 29 Jan 2024 01:33:39 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2088.outbound.protection.partner.outlook.cn [139.219.146.88]) (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 EB730D27E; Mon, 29 Jan 2024 01:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492016; cv=fail; b=KOIFI5pU0iyo9n88bbSUKXD7giHwfyETg37c1x3wDoGpzSxvqSw4sv0WzRPTo4jmrrKgiTk1aKIr5X11bMOLQ09uaj0tZpx0Gd7p7LelSmCBCRunjbt/qyaMwdPXNyn24KSpnCQaZB0sbi6CAzzO7aFEjLR3Gm6PRbuAZGshTcI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492016; c=relaxed/simple; bh=Wq4Z/mmbsWDKhaXfuZB64deZXyVlxQgOmWnGhLzld0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=MfGDhW6sGa4KbT+XQX7GgrQzkSePEE2lyWvn/Ri75fBKfEnaaMhNLNTmqfm5p7nobn27AQaFA4bVJFkELA4MRImRMZ4OaR9sur5KjRZcH+UriLGfPnW8H7qbE/1SwqZtSET6+cTOkN6OpT8mOgzjKXOQcPevKWu9V/RHip+0ZfM= 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.146.88 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=km9KOjXi8bxbfJEwpus3ek/h2j1tPxOqCYbR8QOU8mh4hOaGMKFfVc6kqrPry4Ag3h19OP/V2NzNQAkyM9u+Qsm246GN13IZxZauEYHuu7CUV/jw+Sk1UtHn8FF6QK6sE6lTWKlxuZo7ha23DMrUNWy36+FpaxtLxgVGDW2rYeJ7gHsaUEjgfLMVA0FS5hFqodKgQFKCg2GQ+za+V4hSFhm7+We/KNn1yr9gvrtSXXhGbm99PzpFksncTo8ouQMAsUNSSH5YzeP9PCi+0COqwkM0dxl7yc/m1R4q6ilC4yUZY8BcyZiiUJZWVgGqi388Z6yTOiVQqGdV++m0RHDfzQ== 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=Piibm6atR1mK/iTBUgK2rV5tUSkwu4la2ImA9dz84AZ3Z8cAmQ1pbfrJYJLgo8MJNBGyjWt2bluXC7c2OAxVXOE42+OuabLMJVY8ZVCZ1Cyuv2gwmXBH6RKiaD62GIwH/2Bpk+wT+v5RrAaIxLGB0Hmpai2eHM6VdUpLb94kRSZ8TndnGfef94GHHUH5mWRx0RFVqGDNN2osUW9gbFgmi/l/RXn3mYqT6Zkmh7amQIuUz5+7ZnR68zJikQxoTA1H1smkH8P8iZee4woGV6wm7DPIYwl/wPj6i09CL35SY8UW1tMPivC5an82moyQ5EiS1ISbLlHBtns2DbKX8L3C1A== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:13 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:13 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 07/22] PCI: microchip: Rename two setup functions Date: Mon, 29 Jan 2024 08:59:52 +0800 Message-Id: <20240129005958.3613-6-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fe42758-e9f6-4055-da68-08dc2065a644 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rzPzAp0Vkssk5U6gcw6bK5awj4fpOPMIO/SheX+6E4eHhwQ2XyVBHkdPhJ2yGSCpnzJKS84W38hNYi6cpC97x3Hy3Ail1YUBPMo0EKhIGdJoz7azszeSQuzzKK2LXVT4Ienq8Y9/CrZn3RLiop/6eUDAkS8WpIj//W+o1Wk2glf0/WZtGMuxCteLTPEXWX6SDtW5LwMbZlviZKSPqksr5mVnIOSnhxVeE1tEcR7nHQzhYdx5ZWT1NkAzNnf5VoVMKtOzIKRMazcmWeg4ERJb7D9pRvOGs9cEcMqp1KPvWR05i9bseXStH5jEzBDQGGMUxSIPujNwGqyrXQlNjqpTM3FnOj4X3oR4xpSFq5m4O4FhKUe1ivJo7ux2U7vN59wTQORrp8Hc3oLowh+fdzO6+SvMm44XEJDCLYl0iPFIbvkDAWX6+iWEuYGglfhSHWI2+d6JjznTd+bo2zwrSTz9f8WAiyql54SBoSF1tLQo7bIYvZoPRcRp5nlnRlcEXh5vEqCN2Tx8Puaahc/OjX7i+JWiy8ll5h8lOrG8xVc534Hd2uYbl6SyNO/49EsSSJQz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t8paODpAQc+EwPIIz/znKVLyqCyAz9cguEd280gP3PYmaWhYANdR7ZoTuwPBXcLIpG5xKoxTOsHTIpbHgnclGPF9mQtXrV7VbfyY7eXeQCHIDDET1wvv2AVeEvHHOtxtPhcVacWhkEnYTtSBSvG1/TAy3IbFc7G0A8g7FWqmDNXWvJG3oXk3Gmf6SIXBXOwMQninlIVbBr0Ql7/frBblqIi40tarkVxy7/eEho3f3wbO5C/V4zeTthsd7SiYSfsTnL/SeUeNbPhQzHe3fE4g9UYezYbjwyYd7cUK1AZHQgfMvkEayh+CcuvRridXzHbmj41uWQWoCYZToQbIeX2nsWwn6XEgJvkWiLwQCLZK+U17H4wEuIfxSv0W/XVUoSIilngQRmvo3FHpWySbwR1BE7RwfP3D/G9SOyhAj8oXDi+BH+7Q2rqpa2PAdlXmjEL/Y7VOJUmLj+IgE0KS2m1YJGvzS7hDwnPMashYGWD5vG1b3Ec8j0viTqf+/XTYEdTItXCYwWU/LtUcoOukl+JrPGVZiZ0/aEEWticVjXkWJQ15eCfbmDeIOWBlPH38btO3nx3FzWH+6PcdEc1XyZ8ILKfAnRndjN5Zvi6e59Buprh3z8Hsgcugq6ScRcO5qms5d1Yjh83g4cP+UsZXQNi1iir5kLl0ylbI0weFlCnM0E5dZOku6J1aj1uYUjX56mEip224BcQ0RXMFa9l/+vekD0hYK4VgLEGoC+J0z5fqowoJFHFVa88v/62sBwuaVqqP6jqDuired1F/Gpj9h3nyX1LQFhheEbQsq/p9pFlPXYo2SygTiDO7rNhw5428DgADdXryPihQ0XCFr09jXAHXMJIzyrSYC+Nzgt9JFmAOtlq5fUd0JZRXT0z0oUzRzsjXZqLZARMe20HPziqxPz/Kzp7gbK4o6npyISO7yXV/Vw0bzYvUgdxj552YUkP97TulrZ50XNWClvfpKyn/K8Fpkz6APXQqrfs/+vKAoh1LBRn6LFpNPwl2HBr/+XygSb/O5wT6vZzjWy0owp66Q8erob8psjjWsNkLWjynRhzVxE/BPIohf0RF1RVFD8we8B4dCWQlQmTR0tgF9mNnjWhDAPFsfi3E4AihiAlmH4059RVCKhTsJ6Chlw9YHtwjyAd4nz0yXusFQzPDmuZwJRgmuBuSdEI6XQWGaY1O4/ewvVDPb1+b2FLntVvfd5l/NDUr1FYpKKosv5Id6VmZpaYz+JSMSZH2acvGyteCluNRVO/7jiVIEpZxKJ3BQaTmjjJusbYTKyQvRJgBUfdbTC5nW1m9BH5gDgI6Zs8jRkahMIgXaxHfRxbbXd11by0wpi43/kNnXeFDxZ3dz+GtfNdFcchwNGiasp+J43VDQW1ZDD4On0nRFQgzFTgCK3t2zZLu2V0cU+7SRctgsQQDczUZ9U5Qb8CiNy7Zg+P8lA7uy6W261TdD5HNtwed7hc5+utXJCkceANmrulEYQ+Pawqo7q2DI8qOwF6Nf4i7TxrZvIdnwVlXoGOwKhvQQMTcLVWDcXG7uIU7bkux5yR1icHlvBara7diCvPWOuXjC1Eu5mUDv8AqVQ9zgPkwnHCpYtX+d1tGYcZbv66+U21Uj6TVXA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fe42758-e9f6-4055-da68-08dc2065a644 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:13.4600 (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: gWlhorAeZ4naVaqpSI1mUQMqleuSMMOcs5n9EA+lPFklrv+9XXnOok8vkawACcakXFb1h3wZjyAdcNxofA69dh3kRjZ3OVUQQsFzpMZievk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789386591328554374 X-GMAIL-MSGID: 1789386591328554374 Rename two setup functions to plda prefix. Prepare to re-use these two setup function. For two setup functions names are similar, rename mc_pcie_setup_windows() to plda_pcie_setup_iomems(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index a554a56cc0e8..9b367927cd32 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -838,9 +838,9 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) return mc_allocate_msi_domains(port); } -static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, - phys_addr_t axi_addr, phys_addr_t pci_addr, - size_t size) +static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, + phys_addr_t axi_addr, phys_addr_t pci_addr, + size_t size) { u32 atr_sz = ilog2(size) - 1; u32 val; @@ -876,8 +876,8 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int mc_pcie_setup_windows(struct platform_device *pdev, - struct plda_pcie_rp *port) +static int plda_pcie_setup_iomems(struct platform_device *pdev, + struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); @@ -888,9 +888,9 @@ static int mc_pcie_setup_windows(struct platform_device *pdev, resource_list_for_each_entry(entry, &bridge->windows) { if (resource_type(entry->res) == IORESOURCE_MEM) { pci_addr = entry->res->start - entry->offset; - mc_pcie_setup_window(bridge_base_addr, index, - entry->res->start, pci_addr, - resource_size(entry->res)); + plda_pcie_setup_window(bridge_base_addr, index, + entry->res->start, pci_addr, + resource_size(entry->res)); index++; } } @@ -1023,15 +1023,15 @@ static int mc_platform_init(struct pci_config_window *cfg) int ret; /* Configure address translation table 0 for PCIe config space */ - mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, - cfg->res.start, - resource_size(&cfg->res)); + plda_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, + cfg->res.start, + resource_size(&cfg->res)); /* Need some fixups in config space */ mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = mc_pcie_setup_windows(pdev, &port->plda); + ret = plda_pcie_setup_iomems(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 29 00:59:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301749dyb; Sun, 28 Jan 2024 17:16:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IES/x7LKgFdKEUHp7dl0CeFzVUrVrf+2psE4azXypcLwH8hFRPLtN/m32qYA4CClV+E6eSm X-Received: by 2002:a17:90a:f2d1:b0:293:f46e:a354 with SMTP id gt17-20020a17090af2d100b00293f46ea354mr1148806pjb.3.1706491009897; Sun, 28 Jan 2024 17:16:49 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bi4-20020a170902bf0400b001d721ef24fbsi4885425plb.579.2024.01.28.17.16.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:16:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42050-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-42050-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42050-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 7654D284287 for ; Mon, 29 Jan 2024 01:16:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 525F4F9EF; Mon, 29 Jan 2024 01:16:14 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2084.outbound.protection.partner.outlook.cn [139.219.17.84]) (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 B7985D299; Mon, 29 Jan 2024 01:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490971; cv=fail; b=KDp3VB3jSEb7UmuYzpa5Jaof2NW16W/UcVTdrTXuu31a7KzYasCTV5eRJ8fI8x5rJa8XHakrA++5Lm4i8sm8EEYHiRULFdEfBIJOnC+HBunjUiPk/M0xY0/8WopdQ3zYgSae3qUU35jxNZ/Ala9DFFd0Vocx4RlO35L7Ct2n6+w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490971; 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=MjIFjPOzXpePctG54zupPV5pJ+QvO17fJUpd5J6ErXTCh0J49ypKMQa4L5A3/9Ja9jv6+yj1PalGG7NopX+6uogdtc7+jEXfdd2Tud2RSlcOXXZp4i4gm1j3WpxqciDHmGht3iwTA3mZnHtuNLivD+ag1kP+pBOAiOuLl2GhZ/U= 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.84 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=WP32VN3NTfLPQnIzB3pKsvEEdZlkUaLsnWeF59Q3xedwoOAUrwJzmp7b/0ievvXAnFpk7OsFNqy5AMYgdoFkSombUTxBv1UDt7xuOLgZgPWjjlORccZTB36+DXKI6gl2LMWNMT1ZebR6VqzpZ2VfvMCrUrPDuZtnjA2jo42FhHSHdtqczOMuBUVc7snZM7cnaJOlzjdKflH9JJ4i0K0BSzKFWmtqagLBAHLzlO315VnUfRcP3w5MZ7Z+opJUsJAUsu4514VJ8BcbXzLmwPqFclnjmoed/pxQmwR5PjyCBQj7W98fdzvrh//BJRpAnzJsI3UUR1t06JkfGqbX5s5q7A== 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=JwbF63A8TOx73cQZjK4+hUOTrRpfZL0IXrXrywbjk48SUjSNKS3OFBDIRdb7qx4UlgTRam+N9fVKeE+fle+2h7Zy481t3330QCjn/3LB+wJaegOluWpVSeH5XsA5XzJVGzkiaATY4quKIPa6AevCQazYmuWCmw3Wj2E8FPhYoWVFuaDZlq5vHpim5OPUGuTBW5bBVt1E7x0CZeP2os4q84xc3MQyzSengqGa8FVdbr9c43sCO9c4rJPnsQ3kpUlv9hmOTOg4bEcasXEFQ8ysx3VzjMx0wdRoSOezonkOnHvfiwGitPZ8aH7FCzvvuswylITITTWFejI4RDQDbd0hJw== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:14 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:14 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 08/22] PCI: microchip: Change the argument of plda_pcie_setup_iomems() Date: Mon, 29 Jan 2024 08:59:53 +0800 Message-Id: <20240129005958.3613-7-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: 24fb2ba4-3b80-43f5-6a39-08dc2065a71b X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jzMwlu+LhyacPBaPTmQgGKixstUJFTn/iCrCE7Jea0tqfDaoVQAcbk9yiwy36Fji4cP1yB2onD7BEFpm9AGV/hf4DgWEFVRkE23NROByqq3D+TjinStCyAUec5hZxRFifqqYD8JzcEZaANnONeGVLLZRcqLhX2GdqDXr1lr8G9ne0v5RiUwUkOjldvNvYofI3TW6Ppiadzc0efeXCciL2TfjQZQvymfTCA2QPorw1AIibpMMF+VztqhRzcs37suo4rAkSdMnBiueC+Ih6BC81jg+IzoQQ4npS9L24E7vGsKrZJlfLokDZB1eWqTsJz4UN+5H5EoLXMDWndBeKe9bcXTYNR5ZDXUrReUari2nIxGaeRIhEzWQ84n0uKrem+CersKWtv8KZA/dk/mj7LlZjOBw0F8o1l+TdcVtT0vWhGNswUs7HXs6XMEULWbbbdKdAgsDEiWzkRZ/XgDY7pun5nGwUEpRJVKoKznED2ISeLdBagGTE3PgNG9EI3xeX2DwJOcTYrRmvcCgqsUgrsFrNwx4yrOT01mnm7jTwEr6XxL3BHn97mGjujXMzQgyS63z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6DdxzyoAENBIoMnGdMg0ieJIUIxhQbUZn+8v/jklJSG7InEXIUaWKyVbd5h1i0JNH+AhG6SQTRArVhEhJ8UlCefrY4zbroIGlkPkY1UskFDaAXAOAvF59D17I3AYFjrv2wEKQDsBVZKmES6dPz7kcDGNd0TQKCmeqXdrVdnwV07w1CU+ApAAQbB36sW8K3fg6caHhZIlQtCjYd6S/koHSVjoNSCltMVysK3nKFgAHJyq/EGNOMneAnC9shLaLb1/jHqCi9wJY+crj+A/aBI0eeVix/idVlYQuKstIeMro7O8ZHywuUyqRjZwPkzbX0Rqt4ub5jz5JOXfrgOI7X8CZFGrqcDPPE80T7fPUFgqfx5P8VZWeJdnejRZcVOPhm6KGHzWTIhiOhypkzBeykGGhKBRPt4YkzexZdKj4Q/md9ydwTCka2PPaauMYPhZfLl0bor2djVgY45zUT/vk+GFZYdxcjKPPi/o1Kz+5ISStNVvjA0zq0ydMDSU0AGiXK0AGjdHgbYlCiGITyrD6tF3FfnWo5Sj/y6sfhxl/c6TSNsPZmCCLGYuLO+Hzr+nVHxmUWduTOzyW0B5GlEaKV2XtERKeughLVsZSds/ZWrJaFqY/mOKYJ6PKsH9YXfPlRTkFfqkJY02CTVJLru3Rrn6wscNlvSVyWW43diqrFBuRE8fh1Pon/tIyXw1l6vAb/LGdVncXV69OcPx9VKm66r3X7EuvmfE/ncshcPJ4AkqiFCnfC24vRO9ZQirHy6NaAh3M+P438jbWk9tO7A9sf1N0Xgya9YoMpm/6YoY18YMj7/eJ/e0Z3Sl/Bg0oO7QZRkp3zKLFu3qsKt24Kmm8SRcaOgFQbXlGiU2DsZ89aCfJFkl3Z6SV0JjPggb3ZSZMTP4aRDwfIx6aIjE0sAVtOdkc7qycEK1CqEb3nzNCEMFD2l6ImIiq5ojhNkGKJClr1QZGiZCpvX2P/5A7XYVlz0VH0Z1qt+brlAz4d3E1Ji57xrvaTpJisOln/tE4CL2Sj9WH1mj7RC8aWm3TYlH6riT89aUbfd3d9SFxR+XedCW80M8C2aDE+pOlVYU9nYH1uG3y0VQm7TD4J8i80g47S4I+fBMIWVqCQ9gi1XhgpQEvAMPKviOQUsJukK+s7uoIvhOfAPiRybdAkMCEUHRpQu8Gq/aFpkDaERTwHtZDxz+4AY2OUt1hKCiJuM3b3xSfrKHDRuw7AaP8xpGolXvaOkT+n6hPiSqWO0IkEsGplBOQAT//0gJsewWSEzWTN/yKmw1XrK4gwAYXgAKYeVI6iI+R59CwpdH+JhjnrqWLYxQbD78mZUan1IixXDFjujjWFW/gjJIfHnTwqlkmeM3fL5Kmo6836ZUGObSYmCMtImAYfBarKymWjm588eifgqXshGJ08ZO1+ZGW1MCFsHFzVjxn+OBDh2cfl2uAy74GliwMub0KRF3gXVqC00/Nvs/+iEsag9njlUukZNHJ6O7jSz5x2tGVq+DP63JL/HNBzzBaxE7WDfZX/3DGWa90UMUxOxQWKhZPBahJfq5D3AZd9PVkwXjce9FJb1O4R47eea5mZTuCgc8QeqN+mf0hF3J+99JGnE1S8zKvPiIxOLja9UYkA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24fb2ba4-3b80-43f5-6a39-08dc2065a71b X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:14.8060 (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: m6h7guV/WWW7GZUi8sPdkGYHxkb7bU25/Pae+rMP6YlkF3ho1fRK+FKIxq4rUIOzyZ+OjljuX+0nhwgxOw2Uqkp+HyeA1uQoYIdJ1qVnJP4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385517227544084 X-GMAIL-MSGID: 1789385517227544084 If other vendor do not select PCI_HOST_COMMON, the driver data is not struct pci_host_bridge. Move calling platform_get_drvdata() to mc_platform_init(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 9b367927cd32..805870aed61d 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -876,11 +876,10 @@ static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int plda_pcie_setup_iomems(struct platform_device *pdev, +static int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; - struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; u32 index = 1; @@ -1018,6 +1017,7 @@ static int mc_platform_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; struct platform_device *pdev = to_platform_device(dev); + struct pci_host_bridge *bridge = platform_get_drvdata(pdev); void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; int ret; @@ -1031,7 +1031,7 @@ static int mc_platform_init(struct pci_config_window *cfg) mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = plda_pcie_setup_iomems(pdev, &port->plda); + ret = plda_pcie_setup_iomems(bridge, &port->plda); if (ret) return ret; From patchwork Mon Jan 29 00:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp302000dyb; Sun, 28 Jan 2024 17:17:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwgwM6CHkrKorCn1qzymFi7HPmvODmQB1EkWrjzeL+bpmC3/aEfF8TN2ywFOca5n9mv0iI X-Received: by 2002:a05:6402:274b:b0:55e:f8aa:a56c with SMTP id z11-20020a056402274b00b0055ef8aaa56cmr1206597edd.12.1706491060554; Sun, 28 Jan 2024 17:17:40 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cq21-20020a056402221500b0055af917d3e6si3000107edb.413.2024.01.28.17.17.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:17:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42053-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-42053-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42053-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 F08711F2269C for ; Mon, 29 Jan 2024 01:17:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA677EEDA; Mon, 29 Jan 2024 01:17:01 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 4AD72D299; Mon, 29 Jan 2024 01:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706491018; cv=fail; b=kdyWdYJt1H/I1E7QvyqiG1PLovH1qCzhYSEud6AeGCPouDVkqBW/sbfJAtQGK/0IHBT6UCuTUxHFI7ELr+AjhPojy3Bojp4jCallKN/ezpfQC3KorPZbyJHc2jRSoxneeOCWDje5Ig2+MjxqRz1Jn8JSwDc6+c2wZUsxErasvvs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706491018; c=relaxed/simple; bh=6XCwz752cqas94FR5RuhUpZl6UqCr7+eaQv1gJiOKZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UkLSMPuYsKyhGgPhBfIJzEiuADl1sRTXZgSFlWHdgEzIVmoNVmnXWWmIRws+QRGuMbmW7dJa8nB8RXPZSTiEUE16xMDYA7mwtN89j1OUMjCtUp8QGefaoD0wmsTJd2YLSuX6bES5jnjZzvHaCSDeqLy9apcof2xo4McS2/nTwRc= 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.63 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=chhcm6OOOshjNOw/n502n6RTux7imGKr1es/O5x4EC3zt6XuDAvvlt8o33IsMQiFOCer3KQnl1HhdyWAPIpdz9bsj7XbCw93PAxa86NhQtgg7dy8jG/ovdnNcBGjPq0j2rYVqeKchxaduitXh4+UsxkuZCqbWcsaSabKr+9mtigs9eNI7UP626IyRHkUDzzRnQNq2s2XhNEWSSSVkAOzaqDKtUiIaChId45PdzsEr+PYaB4nifhdh56gMXcSc+66sII15Ri9NGQuxrcS51rKKgEFuAJ2eLiwsSYPZjcd2IdCnh1hpgttf0IiLzPHVoWDTNwHgqPPNupJn64qyL+kjw== 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=Ex1Pw1CSAMwq733koPIsIuNPnRtOzL44JbWWC2coux65kvv7KBcyJWcXacPt6wqCypgXUnuFSR/tYX3UJstoKSXIbxpaD2JcCewy2XRfK13UFGYtxsO7Qssw2W4L+6ax4lGSdHg12Bn86B5ZKrRuB+9Ce1PGeN7kEEcruUyI90VYl56anrxQXwJJqDXtfTRZRyb2yoaFce6e5PKV7x26KIPIO4EU4EjwaCgT7T6FB2zq5A7byF3OvJPEwK3Oen3rn2xpXpVthbmNPfpNyHtkmwdth6GfieN2waTzJo4CzBjERSNH2o9/yCyRT6OS3kdfsH45Inv8XKsg9M1806i9dg== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0630.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:14::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.28; Mon, 29 Jan 2024 01:00:16 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:16 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 09/22] PCI: microchip: Move setup functions to pcie-plda-host.c Date: Mon, 29 Jan 2024 08:59:54 +0800 Message-Id: <20240129005958.3613-8-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0630:EE_ X-MS-Office365-Filtering-Correlation-Id: 0eee3529-dd8c-40a5-70d5-08dc2065a7e8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z5qbqo1nPmaLXk8LiczpJsV00mkMllK3B7nEo3i9FlupimT2WQaLz4SGUmITUm6Na3y6HUwV53P8TKYZK1P3Fj4fZG5jwxd9uRje3lUaSn4yybl53niUeJaVeUju9Mpsa9ksQttTguddsiXWobcLXc4i4mIXl/+mzA4IjTd78TORaVO517DWL768CbyE00LpFBzs/sv86m/Gj+wTebnAdWSth375aXjWLWt4iMfOo0Q3bZtGhyBeivArGW6UCYV2o1oKNn+jgbnWj5zcIvKqpJtV8K6780o3jjDlfpcnS7cHw4GGwJd33Lwb5jBNFh0VEPl/qf3h1Kjkbjl0F4k5SiReguhUzDpEXaWS7oMMXKD64Hvkcx0y4BHskVK+GJgjM940bkgC+eKYMgPM5UU8kXGW+l1SGgIQqb6SMbMVXMy0sUmz0GIo+aP+KBF8f1s5gilN0CKb5OFubk4J03U0WkqAl+tq4dEFmOY8+sQnDlWzGXvBlNywUd7ot+ATvq6FbSqGYXDPhEgrCl+37Hk8j+9LZZ1F1mEq63q7zExgoCiqAuC90agW5eN9/iiRsjR6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(136003)(39830400003)(396003)(346002)(366004)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(83380400001)(41320700001)(40180700001)(86362001)(40160700002)(36756003)(38350700005)(1076003)(38100700002)(2616005)(26005)(107886003)(2906002)(52116002)(508600001)(6666004)(41300700001)(110136005)(66946007)(66556008)(66476007)(54906003)(5660300002)(8936002)(4326008)(44832011)(8676002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tJ7tY2KIXrQ3yfnMAT2IO89r791J6N9/u4MjvjZJqtatpx0Nb/8MXT9tmGZ4jShyk3uMqHqoeKNjWorL/Do7aBeP76pBI9UhrN7smUxneoN8NXsaYaxcxMHqXimXEv+ChsDjKzSR2G6KUlLv2rngZVVmT4f86aDqOlK/klcBjNsZrhZh/NMnMq5+YM1qJ85oEpuV29/LYZpCEu5PsOOUQJS73O+O7H3fXOl0r89u0tzAmAic8H3C7ObA467+24q29+IyoWiyB8DXNHysT5z13fvs744uVJMrouTDodqNR4j90SDEpom5gEAvRrM65Ajl/5H+gGFdyZoyJG1kpeo+RJzZO2OrBrEHgQDEVZ7QlTpkc83vZas2ijNQhkhGZ/KYmnotDwNHEEsrC18Ut+KEtKEJvKlzKsq1DbZg1hy9pbj9onPp65gX46D4wIYOWy5dFT98tkp7p3KYEzdWzm1jJcwdqTEppJ+x1rmfCd0Xtvk4NLzFELck5I6RIPpwtuWj1JOyCf12XOZ1OLy6Vwm05mvTqF/H1Y2SOu4YkfTF/p18/mzBLhVJoIyRZ5ZnpaemIk7w/ZWYruFGftBEazpKIgumRwr8vPQks1UNGLPEyGeoFgvCP6zM4jvbE8rNI9kqzt4TM1JGqe9yMBTkKq8NEZYTdPnXGUUHPUwboEs+tcw5mVwxPoqHzoZnhvfkwjhbHN9dYj/D1s3LDSEFwBQ/yDyEYU0GW5atoelTOARiywrNAifntXuai+ZB2OIX8FztFDhY0kg9idLQwciAF+2TzlZKqZk5USV76rnnOtPZqQ/nH3mJvtoztvj97PoPK5pNk7Jwdndtf/vEBkzcIbwvGYcY3h6Mtav4EXwtD2Rs6uVsVG11sg826zEzHciRWVGj7WQpzvM6Wa73fcoMHbx08Fo5D7/rmP+Av3wiEFY23Uk4MQbigpIPshOrGC03UdlbWTKwAjd/6xZP3famPf1ekT8NrbEjtvPAKSXbAoHYyD6aHvSIDpAvGaBJCCm9jhgBw0Ci/KBzl9jFwtKwqzHu1W9i8xTt76JrP6JNCiOSJnLXLTgCAtelkk67h9/i51bnGR6dwUfTUvAQmCeuY+PbkdBGcuvDjKMZw+bDNpiZZ3vk7GrM+tyowaR3PO66BxDtBBkDbgRG1QD44UkTOJx3ilg9DgRw2gWFYO986NUGUa6NQT1nrzmOp5FJgz4VYlVdENuP0HxDZvJATYLiKF9Nf3dIsqXt2p9h9QKiiU42t5mlM83NMhr9Cf8P2vgvUN8p7XpzE+EXwhj1MalZGQlMLaS3qoCzt4ROWpIyQQ4aIsUs4TX5XBQ9sdwI68M4ANJoMvdWGoS/MHISz1bqo3CCXLxgnXDL75K4EsmDtvq2gJJ5Py924sWx2BiaLEsAhXIfL2zQQ05fMvHrfjO2Ry3wMmYRVUoPncvMVfX8r8PWd217CeFv/O4SDHL5WT2TwDIhvmyrt378Lr/q+Gmi2n8BbunRk3/+m8vIs9Pe67+be3ALYq1/lfvdjxsLUP27D6LeqUisTAnSAchos9D3Nwk2X4ua843lep/mEgAtd9paAQ+mulSgwkZdYQe5cy+uFwLE59f8/lxbIZb7paZTihFuCQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0eee3529-dd8c-40a5-70d5-08dc2065a7e8 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:16.1833 (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: VNHhy1oH8/v32HTA+VuEYA52IYUpbj6b1ZaL9x9bQDRnSZ2vBSX9VK9Jb9ecg08Jx7rl4uBs9WvEkJf8p6Gm7MM0EFMGPb2BYT/w3/gYRrM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0630 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385570258158417 X-GMAIL-MSGID: 1789385570258158417 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 Mon Jan 29 00:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp341977dyb; Sun, 28 Jan 2024 19:36:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxOQVliQG/hItn1bU8WeMPs1R2E4ob8pKDNWYj5si4v5wYykznUi1zAiFraKj5ugfQZZlP X-Received: by 2002:a17:906:7117:b0:a35:3624:7f91 with SMTP id x23-20020a170906711700b00a3536247f91mr3613032ejj.11.1706499362922; Sun, 28 Jan 2024 19:36:02 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ch5-20020a170906c2c500b00a34e303e91esi2864175ejb.621.2024.01.28.19.36.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 19:36:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42131-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-42131-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42131-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 641221F21CFB for ; Mon, 29 Jan 2024 03:36:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7F29101CF; Mon, 29 Jan 2024 03:35:31 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2078.outbound.protection.partner.outlook.cn [139.219.17.78]) (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 66AD1125CC; Mon, 29 Jan 2024 03:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706499327; cv=fail; b=q7Eenelt7pTbE6p1NoJv3MO1DQujG47SJg3WZ1k0oLiUlwJ9OjvM5YhsWbnYSBqjp/DGOvKgOw/4D+1UgNi9u1OOqloVD0CWmmF+AevN+g08s5Ue6SgA6bQbAkUh7H/Quw6iBguH1vaEzpMGakqtns1KAisB4SN8N1/2scih3Mc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706499327; c=relaxed/simple; bh=22WfnNEhA24fGIAnSj8FnGthhV9+MdctziwxO7auJ7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jJ0Gzz+SzoLXyWp4pdS61DxcWSVuKEdLvtkOLpZqBLQi/L/xeLrJq07jYYcxD7y3mnhaZPOCa2uKFk3k6UkZlhMysotJvwShMY4zq7dTH0hN+D1UcHil3ZKYAr+RDg0CgQbxrkKgwuEmWW7GU2nWcqVoxGEDL9NDijgeFY4x2po= 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.78 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=kZ9gD+O1+CqEK6nkncwtJn73kfIGGetArHB1Su2Q4LbYH1ribav7ai5VqQhi0f/KmQ/SkMq+y8DVunApZLkYx73aGG5oQHnkwqB4dR7sM7B5lQ2Fi+L3g1+FOZ3rjhKYw18/T1qfa+8TltqtU/1Y8gYNUX9Jgy+0osiXlvkvgBPyqnt0hxUjSWhBGJlDVtNJBNbqMioBLN0yTnh1rpbEPh2a7MHowleODd61pRMTCqFDy/oC0VHsHQxIa6Hxsa5658cUdQeihtyFe8eE01Y73FfxVTKnk/ZlTjvZqwfrT7HZBZS5cHwOIn4mInDdUkNbAe2aQrua94Etg0WCLbW/Yg== 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=WTjXcpygRUfCSbZqYr0ImwWF63lNXOnHEeqqYtYSeu9MPUF3jwCD3NByPt+u87D8oyx8QqdkCjMaEMatWdL+rV3AkpVMnh6LfNu7L5gSGQ0C6ekIJ6/gL+xZV4psXKTqDtkXlW7RgDAYdWi5BUY1crjYiidSxC0WglKJNJeJaH4eSLvaRXOOs/EHU/X4KbB7bk8fkzeurMcmtCxg11t4jv4+q4qdSiTvgJMxk10Ht0ipMUs+93CBbC7jaEyvDz0th/wk6LwwY83DQDssKyAQ5pXuCcm/TYvIm5dkcuXV4C9HvkRcpMQNc9Q6TyTi2FCAX4YqX+fdZ0UJhk7pm1xtTw== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:00:17 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:17 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 10/22] PCI: microchip: Rename interrupt related functions Date: Mon, 29 Jan 2024 08:59:55 +0800 Message-Id: <20240129005958.3613-9-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: 52144970-609a-430a-3c20-08dc2065a8ba X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /HNTBNLw7etFyc+Yb3v5SIL6sVdLPAtjnMn0JqtRy40hb89ZZzjeHKzoWHUsoxjx/5O04IweSixuQZgumAM8EjbYir4V4WqSNxkBBOShUViiLCPxbAaWw4SiZ7KoMkWjbxV43s7bMQoRI0eQLBseMQKqixK1pT3y0k6tNTLsPmWvLP9WvotlxLZetwo7BY8LOjfuzhAlHQKMb2buBTlwAFcNILspCxQxQmTWEsAPO0pBKZAWOP0+PgGfMqOLH9q/dwk/cx+LbLbYzeiw5GN6wG9H+XU2Xj6QAmqcGTucUhkG4Rn/3tORzouB9JL76/pbJsVG2+qboIkXpyzGPIWxHUedTHMFiXl29SUjUpi9BIyfEZVW7Qz8Qfal6xcHzX8q57ATNqIq4JvJu0nOhbvR4xpn5PUltnwetCO+lDX5Ed0Wf3xvcplH6GGwJJXJZGsjZUsTBfG6KVAYzeufY4MNdoqkJrvewbQJ1aTno1EFfXc7vfm7AKI5RfS/6aDp6pUfpyus5jdsnuux4hh8prmWoQwBE6AOL5Q7TEqbsHzV4/tp4LbceAwcm5zX6uxgAMrz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(30864003)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vu6p7Vzo3oC4aagm22xgn43LqUpKUxHBmpvC0DDHGeDl/kOf72EEFjp5giZ06IJuQ93L42EZF+JHuJZwdQGUIbo+uuOVbGhMG7PKBpxI8DddrSiNJQ38GbcCsxddEyz7ahIN4+HKkrcjB9Jz27cRH4aIVzJhffd4+fFU9eXpBKERIIPEsMsJFilX6dlYmo69tRSCbW8twgPazO2dRyg/ydeIYcLAM4PvhwsyKZYUXfMfst09Pi3ZW5WN33BMvVI7mkBzp0425gI/P9cl6lIbeBrsQzN2h6sLL6PfdZPSiL421CVurJZ8bQ1lIm+4zB8nIbu0A1DR+5+gwTWkgjM6F3z4CHVdWSYfbgeghdomdLi/bUXEDYhILvb/GWvQ0J/eR6xtCjz8M/wEiPUv4UIW8zjPn15w86BBnQMFsi54rfi5J5503CBgkphtNo0SwUtIjgGX+TtVTQye7wgtXE60h+uvfB3HPq9zQ2NaUtzK9gwJB1gYsjQvoRPah4/6JoeEsRqDnSUGZQG9mB+e76jJYkpTmxkvIe4AovQ2o35zlKJ3lAbZv289fsCTJskPHncbktL/vMxVozVF5HZ0pDDYE1XJQWo1GbyWEJgHFljBMBKad0MPaUhL7+MSS/JStUkO+qBcORjMQZrjhrS1wSjXK3CNB7Mf2DBFWUagSwezc4IgTa34NjN+WlQcEkGcRUe5l7KANgiGaDBVv3rQFca/p374Ue4sqhL0XF0I4CwOKK0eeY7T39Q4ChZiy6WW66iYWDWG9JhHay3MHn8JN3FdC10GjPl6muXNtGn83E17Hdp+8Qjxwj7QYbqHvMbNE/JeTRXzsiy190Jtc4rwYCgtLo8JRYlsEHUEp2qpW2IILqtaDf6klwauOulrrlPAWCXFyp+lcALZOewtPGC3CFlEFTTpa4OXjsTOrRgWslTE/bVY+WKIzl7rUXmY3GkI7YkedmFGXtfb3Ub963lpfnbFVgNdu5KU7V3d5moduQpQwmQ9FryoT9fnXT83PDm52ldcLC4BNeLhx0xqMpz2HCRm5jS7i264R11kPsll16Iyi9KGJ+zvATrq1ocXAasGGcabLhrZAejxQJStezcfRb+orvEwSEwnnVbtHvjZv8P5V95ssKolMv0lp8Brd/buLMjx/ry0gqWXxVpqM15ppP0szHVqeln4SXhl6q5wRTFQsAuGImGDq4WZkqT7LBQgQxafGFxv6AxNP4kQGgNh6GeMboldenYF9THxWM/OCBS98G5BFW3TjIo0Nz5kCLfNmwgn5yYmxUfgxOLWTqYAqwolWC2kX45etE16qnwqqXXw54wpxi18yeHHeybg3J4RGHqpt8SinYghWrJjK4tfvOyUsKdmWUp4AOyzJbAMnNEQBZQpdzvW8YE0fOAPqTUMPkBisIza/gF30d9010p7ZlU5pd6FrEfaQTEK9YV1rqMwkXyjRohJDUjqbpiC7z4nbYtOToUC9KuG9FX7GJKvhLS6vey4P1tGKyGQXXzrUHH50s61vN8/hvupNgDB5pJDSlJ7/vTQ+qlKIgRW+dmnQVzfgzwYmdSB10XKdxgjCALrzAsfTO2p0NT1cYVHz6bIbQgbWtRFSHtdm0wUW3otNx3F7A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52144970-609a-430a-3c20-08dc2065a8ba X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:17.5205 (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: VdwvwRkc2GeBiQrd2iuf+Ne6e31MyIXOkNAMi9JM0nYEn9aOhNBCbuF536ln+kwI0uHthCUWxivxCMb97zC6Alt+izh3G4p8xnxTsB7ZMvA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789394276314449008 X-GMAIL-MSGID: 1789394276314449008 Rename mc_* to plda_* for IRQ functions and related IRQ domain ops data instances. MSI, INTx interrupt code and IRQ init code are all can be re-used. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 109 +++++++++--------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 573ad31c578a..18bc352db389 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -318,7 +318,7 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); } -static void mc_handle_msi(struct irq_desc *desc) +static void plda_handle_msi(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -346,7 +346,7 @@ static void mc_handle_msi(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_msi_bottom_irq_ack(struct irq_data *data) +static void plda_msi_bottom_irq_ack(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -355,7 +355,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); } -static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); phys_addr_t addr = port->msi.vector_phy; @@ -368,21 +368,23 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) (int)data->hwirq, msg->address_hi, msg->address_lo); } -static int mc_msi_set_affinity(struct irq_data *irq_data, - const struct cpumask *mask, bool force) +static int plda_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) { return -EINVAL; } -static struct irq_chip mc_msi_bottom_irq_chip = { - .name = "Microchip MSI", - .irq_ack = mc_msi_bottom_irq_ack, - .irq_compose_msi_msg = mc_compose_msi_msg, - .irq_set_affinity = mc_msi_set_affinity, +static struct irq_chip plda_msi_bottom_irq_chip = { + .name = "PLDA MSI", + .irq_ack = plda_msi_bottom_irq_ack, + .irq_compose_msi_msg = plda_compose_msi_msg, + .irq_set_affinity = plda_msi_set_affinity, }; -static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs, void *args) +static int plda_irq_msi_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) { struct plda_pcie_rp *port = domain->host_data; struct plda_msi *msi = &port->msi; @@ -397,7 +399,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, set_bit(bit, msi->used); - irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip, + irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, domain->host_data, handle_edge_irq, NULL, NULL); mutex_unlock(&msi->lock); @@ -405,8 +407,9 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, return 0; } -static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs) +static void plda_irq_msi_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) { struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); @@ -423,24 +426,24 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, } static const struct irq_domain_ops msi_domain_ops = { - .alloc = mc_irq_msi_domain_alloc, - .free = mc_irq_msi_domain_free, + .alloc = plda_irq_msi_domain_alloc, + .free = plda_irq_msi_domain_free, }; -static struct irq_chip mc_msi_irq_chip = { - .name = "Microchip PCIe MSI", +static struct irq_chip plda_msi_irq_chip = { + .name = "PLDA PCIe MSI", .irq_ack = irq_chip_ack_parent, .irq_mask = pci_msi_mask_irq, .irq_unmask = pci_msi_unmask_irq, }; -static struct msi_domain_info mc_msi_domain_info = { +static struct msi_domain_info plda_msi_domain_info = { .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | MSI_FLAG_PCI_MSIX), - .chip = &mc_msi_irq_chip, + .chip = &plda_msi_irq_chip, }; -static int mc_allocate_msi_domains(struct plda_pcie_rp *port) +static int plda_allocate_msi_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); @@ -455,7 +458,8 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return -ENOMEM; } - msi->msi_domain = pci_msi_create_irq_domain(fwnode, &mc_msi_domain_info, + msi->msi_domain = pci_msi_create_irq_domain(fwnode, + &plda_msi_domain_info, msi->dev_domain); if (!msi->msi_domain) { dev_err(dev, "failed to create MSI domain\n"); @@ -466,7 +470,7 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return 0; } -static void mc_handle_intx(struct irq_desc *desc) +static void plda_handle_intx(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -493,7 +497,7 @@ static void mc_handle_intx(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_ack_intx_irq(struct irq_data *data) +static void plda_ack_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -502,7 +506,7 @@ static void mc_ack_intx_irq(struct irq_data *data) writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); } -static void mc_mask_intx_irq(struct irq_data *data) +static void plda_mask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -517,7 +521,7 @@ static void mc_mask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static void mc_unmask_intx_irq(struct irq_data *data) +static void plda_unmask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -532,24 +536,24 @@ static void mc_unmask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static struct irq_chip mc_intx_irq_chip = { - .name = "Microchip PCIe INTx", - .irq_ack = mc_ack_intx_irq, - .irq_mask = mc_mask_intx_irq, - .irq_unmask = mc_unmask_intx_irq, +static struct irq_chip plda_intx_irq_chip = { + .name = "PLDA PCIe INTx", + .irq_ack = plda_ack_intx_irq, + .irq_mask = plda_mask_intx_irq, + .irq_unmask = plda_unmask_intx_irq, }; -static int mc_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_intx_irq_chip, handle_level_irq); + irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; } static const struct irq_domain_ops intx_domain_ops = { - .map = mc_pcie_intx_map, + .map = plda_pcie_intx_map, }; static inline u32 reg_to_event(u32 reg, struct event_map field) @@ -609,7 +613,7 @@ static u32 local_events(struct mc_pcie *port) return val; } -static u32 get_events(struct plda_pcie_rp *port) +static u32 mc_get_events(struct plda_pcie_rp *port) { struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 events = 0; @@ -638,7 +642,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static void mc_handle_event(struct irq_desc *desc) +static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); unsigned long events; @@ -647,7 +651,7 @@ static void mc_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = get_events(port); + events = mc_get_events(port); for_each_set_bit(bit, &events, NUM_EVENTS) generic_handle_domain_irq(port->event_domain, bit); @@ -741,8 +745,8 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; -static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); @@ -750,8 +754,8 @@ static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, return 0; } -static const struct irq_domain_ops event_domain_ops = { - .map = mc_pcie_event_map, +static const struct irq_domain_ops plda_event_domain_ops = { + .map = plda_pcie_event_map, }; static inline void mc_pcie_deinit_clk(void *data) @@ -799,7 +803,7 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } -static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) +static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; @@ -813,7 +817,8 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) } port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS, - &event_domain_ops, port); + &plda_event_domain_ops, + port); if (!port->event_domain) { dev_err(dev, "failed to get event domain\n"); of_node_put(pcie_intc_node); @@ -835,7 +840,7 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) of_node_put(pcie_intc_node); raw_spin_lock_init(&port->lock); - return mc_allocate_msi_domains(port); + return plda_allocate_msi_domains(port); } static inline void mc_clear_secs(struct mc_pcie *port) @@ -898,14 +903,14 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) { struct device *dev = &pdev->dev; int irq; int i, intx_irq, msi_irq, event_irq; int ret; - ret = mc_pcie_init_irq_domains(port); + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); return ret; @@ -938,7 +943,7 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp } /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, mc_handle_intx, port); + irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); msi_irq = irq_create_mapping(port->event_domain, EVENT_LOCAL_PM_MSI_INT_MSI); @@ -946,10 +951,10 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp return -ENXIO; /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, mc_handle_msi, port); + irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, mc_handle_event, port); + irq_set_chained_handler_and_data(irq, plda_handle_event, port); return 0; } @@ -977,7 +982,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = mc_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 29 00:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp324171dyb; Sun, 28 Jan 2024 18:34:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnqUV/jMOM3X8ddMQsw4imw1paIqQDC2OTxYR++EMpmebpo0S4PKlS8wGZw6Q0jPbtNuAc X-Received: by 2002:a05:6402:27cc:b0:55e:ea35:19f5 with SMTP id c12-20020a05640227cc00b0055eea3519f5mr1521643ede.27.1706495670692; Sun, 28 Jan 2024 18:34:30 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s6-20020a056402014600b0055c20f726fasi3217824edu.594.2024.01.28.18.34.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 18:34:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42098-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-42098-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42098-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 2956B1F22A73 for ; Mon, 29 Jan 2024 02:34:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 788F1FC0C; Mon, 29 Jan 2024 02:34:08 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2081.outbound.protection.partner.outlook.cn [139.219.17.81]) (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 4FE261E87C; Mon, 29 Jan 2024 02:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706495645; cv=fail; b=Y6iNaGiZQzTGXd3pdOdorVjsArWGdyMpX1H4g941IsAOoSgnp/lECvaZDugKJiFgp3zPc74YL9rI+m4ubTvwmciCky6vKKITNW0nCxWOEBG5Jn+OeyHKd7h+hVGpBbeBlotaN1xPR9zCdadGBKNqb0EPDVceKTGhqq2q1JMMt38= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706495645; c=relaxed/simple; bh=/4PccNbWjjS+4Uc+iPMog5YcbODT2POYLU9j4TmmDl8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h/BHUMzDyeGIE0sNPFK3mE1WguOubI57M1hWRr3+GfTq1k12VorM7aHRar1XLTNpZSTvj/gVwaRjVmROYk28CkGq49CqoseKxbtxDC9mzTxXqswv22DYirlzsWeqdFqerYTakcn/0GbKUAQ1WPBsMnxl+guQ0gTvlU99mZrWjXU= 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.81 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=HucYDtINYK9ChABRao0CketMovrFc2tmOwm339JtreyMR93cDou+/+Ga7IG/6PrGc46IbP2MqDGVylv75WeH9qn5piR19S8uOjPZShIJqLWtc6LjFaDEVdPP4BJKbzwzdhp8Y3B4Lv7JlVtA9V/rtgM/47g1/2xZDm7q4Iqq/rcsQL0UYdXWY7Xersy19iwVvJXZoxUn86g0DWpK1e79At2Ppx/bFukc60P6UjhciVzvY7lGWFlXfI31Itb1eVAtApx59mXqua3JYobQV2TTNYv1qUq1oFAXFLm+RjcQt2u/gEgNo9pfG4NEHmxIvisTYLNBLmH2ltS9wVgF4THTVw== 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=JHmQKTNruuhI3QDVYpmH+X5fmwz+3nI1mRW0vyi+HH7B8eMRXL4aM7Xls3ZKAyFc/1Uyh9WBD5PoKCWuHHaZu1hWDop2eT0y35/7nQ0W6cjvkWWZQuzW33OXCcMGCsxDQyWHGQuZyP0e9AuiKXhYcNHBajd76MSFZqWL9LiPBePmujQ+V9Okw/AEutMv3tmxbkwinexuMXvA+yW//HPH6PaXWFT79lhxAGXDxSroSa1FsdWDccFFde6E0t+2VRk5BsZoyfWvFre3lFNqA+lQb2OwhExtufxSp8lBPTTgDbUCQWyiTracHfheEKVW37/gNwZH6Y7FWVSoyvHv2k/01Q== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:00:18 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:18 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 11/22] PCI: microchip: Add num_events field to struct plda_pcie_rp Date: Mon, 29 Jan 2024 08:59:56 +0800 Message-Id: <20240129005958.3613-10-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: f4c5de45-dd09-4554-e05b-08dc2065a984 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AvgVLtwPFIIuqEeqVl65teR8ecWcPxgDn8qo8mm50J7w7APpnLhkrjIdYUlG+gzYckt0OJ5o6LHVn2PrFNA+5yIOVY3IPIduRuQSKmmtKB2Zoptw9MDpwUxu1ZcGfMNJE6tmN3I5KnxYnIS/k2KF23LQcmdTlCX+o1db7euTQVtmWZyBbIYRWwDZkHT6y+JWhPWeeuSxCGWR4UgwwE40mmxnh4aIIEtXmmzDCoFyfXZCBmdaFou74KdRPZ5Gyi3ouhlSQFlrVEUDcoBLMiev+zhLtoJOygfcbTaKxOjFEBhpEvq18fV6DTkZcDg8Fwm4RiAUKOOn/2VwhxhcvxoFbOrLYqyE48kk+Qq0sMBgYIoa9/SwRZilfsv8BV3hm2T+kbBIsy2GjvU+g72fQxQ5USkiR7oWnhJmRHoEwJQ8xGylCrZCiotJfFbyP+xP6vtYyJkPlMt3Q1AeJ0eyMeSHPCIEt7xtKpuFezwk6Gf6azmog7UBiO2yv2vW/3RxH4ifRLbqcLQ0D/1w1VyzSeVXvJWqpehTtUJIRhTlje0bJ2aOc+TUw3fz9svlyhnpSPoo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QsoC66fd1Y6JRISLmHoOsCJhOYNYs6pteYAnolT/gvDb3+qsownihOAX0bdz3Hm+if+HUZgCC04yg6yPr5Pxyqnv9bL7sNANcYBNgxcj+RU/mlR3geTcLBIx5G6+oLv/aWvp1zDglATY7+tO5KIVZNgsuIBtceujOKxBfal/N5DrvZM5Iyh4KPin/NfcjMs8SXLvgZ5DQOOoFq0a6bwNItXNLec4AmXQUJuMInvmPU8TBVbZhREQHqbUPG5+OYBX5uInw4e76jOHXUrPqbJNHRjMmQ3msudpcTqtCRTZFdho8Yqp6RGxQIG0fGU7AuuabcyusXOzQDdrev9s8ZCmH0396LoVJwOorToREdw7rYncMBqsG64+sdbxhpNh0rQZyS5NXxz59UzYvu8cXldzbQOJmLDgNFIh+mBOvR3XFljAifJiL043nUFG2FFheuHU45rrQdNEkxWfyMbIBlQyhRdNsWDZGNaiT6UMsYdFoUgFV7tMcNcdC+uhQTybdHnahhOk7OyV5vExm0j25Qtl6JGyhTxCCt2HtClrAMtytvg0zsGaNw4YC15QlXtcC5n/QUai1x/T4iaQjwY5FTm/Kevx8DghFGinJZS/DWhl/32Fb0xNznrzvFxHznupqqYVV6mqjnJVXXNv4QhNb46E0oUF0qf+bqYHvKIdqSkX5NjP39Y6ThyVvTBMRz0BWfSzIIj1hGEC0xFgIw2VrMkK9an/VmuQUxCUNeecaxzyoUV9qh1LY4aLzThPaNxeipL5HD0wU0I4CkmhceSqGDyFUxAQZGHQ8MEkYEacB3CKeIKJAw9cPB1A5cf/Tmos0NjthM2Vh1hULqrAdANTOjTh2Joiq6ghBECyw753pgaVcB4ePDy4BNc5dF5kEjcGXLEa/bR8EXL6xYKfLXjU7gXXlDhFHu/NWnvHHqsdAW35DXgLMHz1IowdIru3tQApmgPlknJtPR9D8BdfpFYU7RAU2r+8lw0MRLZ6tkZoiKV9iDFuC6oudcIc6BfWg8GMhJZ1GdvSWlOj6dOkYrA4WzmajtdBJh4Iy4gb76kInFl/lYXrx+0EXSO6EczecvWRuu5q7b0izG63SGdLWR9GGJ9atCzS0P/3lMOVVb+GFJmSWAbuxG+Cyc5l/Clo4opwztsRdlsJckEmzRp4FqaE3aDYVPOWPYN8ULS9W8bbVNT9OmlkngBvxjYTTvCUJcSrYAbQkqanS0Amd3IeNsGvb3KVHRPekmiumTsE/F8D9amSZvrlObuFERwEA76UAGLw2XcnL7v0pAviGdHGGcVRD96Yk/dOsLNuPnvRqYrp/qM1l69NSBDwtzCGAPEEoBQI2y7IERGIRn9PmAnnBER86MwJ9/tKRB31Hye00TQ8GLvu1Rn0m06/Q4Dm8siDg/suaD2fbjFb12JANXPxapHH3SnLW3f1L0jeg5D3vsTV5biYbrMbrMMzm8b4bbzWiT1EA8EvxEULX5fcHHhEgR8oEVjc5oqmY3XQ+zipKbPPQJO6Lx36S8A/EjmmCpXKWhIOZWFJU8v41ZfuBPmAFJEwH7VhHCUAe+k9pvJifWHF/2/6rul/uWzM5hfvzAcsl/LACoCkYL8dcuBKRYDQVJLKupATPw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4c5de45-dd09-4554-e05b-08dc2065a984 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:18.8556 (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: aBskbvOvjcgmqP7VmNpV4M1qAE8fElRehYWuECD4bE5YbPsQQUwqB9ioJrosdFxC2gashvX8W6xXBDH1KfliH9+f7bHoeHCU7Dr1QBplZoY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789390404035802886 X-GMAIL-MSGID: 1789390404035802886 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 Mon Jan 29 00:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301193dyb; Sun, 28 Jan 2024 17:15:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgEQLI0jmdS1BSVydzAfi83WgGPP02RnQZCcZzbs2SS/Yq2CABqc6utAEt0ecvhIK3rXlb X-Received: by 2002:a05:620a:4587:b0:783:fa37:1f99 with SMTP id bp7-20020a05620a458700b00783fa371f99mr1951460qkb.33.1706490915806; Sun, 28 Jan 2024 17:15:15 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g25-20020a37e219000000b00783f615bc7asi2529690qki.775.2024.01.28.17.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:15:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42047-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 (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-42047-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42047-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 5BC6B1C211D0 for ; Mon, 29 Jan 2024 01:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67EFFDDC6; Mon, 29 Jan 2024 01:14:58 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2070.outbound.protection.partner.outlook.cn [139.219.17.70]) (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 F080CD27A; Mon, 29 Jan 2024 01:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490895; cv=fail; b=hGEfPk/iqRzE1LnaTX23O2GupbocwaKhf3BkjAfXaRv8gyxfyEpu7guQ6nUc0Mqd7cLigZnS8ZSPmyZhc0fguifUH5ofnVb16XrWmYOQzJYrjnSXAEnAL3w7nQOBaZ/ft6ZzPem1Q+WnKYFBLi9VVHADCegJZd2Zfy5R8B+qPGE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490895; c=relaxed/simple; bh=CK38PTJKcJcw90VpcidRxBv9FWVT/PDLFLiHaWgmHaU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pgurIJdENBrveh1aJcmF8QL+0vdn7ZkZ1txeyLq6DI3ZdabLwo0oY8RXQ+VrFDhFcD4xQUwx4EO2X1b60NF8wfXSzfC2Mm1DmQBn/Plxo0t3+1ZzAzWaO53wrlI4Ni2lebOwPm8GiKo2QmHP8SWHtwQNDAAiH0N5WfZ14cPThBk= 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.70 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=CuscITfDmNM9+7+zaRWOt92p94mpf3WizhTNkNwiRt6ac6rqQAw2Lrdrg4hlRa9fVN36sd7q/wZVT3n7QIfc54j1YsaiarXlBN/XRbTLeDLdHAwmaGMLJzRBKo54cpKxPfxoNfkLpkWJVvhK6VOVtxGHcfgVF7UofToSThYkMV+BytPHe9UCrUrvzkLHNkpcBs9fw1hs6QBDoQky5FSLycwQ4B1cxwrK6CfbBt/z1HA0HbIrsxKpAk50ZbTuUtBUUWp7gys1V+OY4HFAeRj+zuYaR7S6+HYCCYYXa3ImpU8WY5BMtieMF4t7ewB8uuBWoO9hsT8IEuBGJuRKjx278w== 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=w95He89+nS3O0/n7azFj8FLXOgq0kCSQDRtJPpzHt7I=; b=c+NzXSKYMDaqtmTrbVqOTYTglbTuXnAcPVBg6Avkf4Y55EOOpHIaGTR2USpvlxhEhd8koJ18jRkybD4HNHQanEjrAxNGmHOFjbUu/Jh7qOt5Hm/uPFivaCMz+fV+nT1P/j8ixp1xnKETuib4oEOyySSHJJz/I2g/yLGBTfNCNOlxM+o5bli3Ra22HdtQ4iXAwAwU8lQQ2aiHpM0OsPScmmOxeWxdwD+03MW8o1XD113fl1PFV2RHaYTYqP1+yPLkRAdnqv/Eg790Xfx/akB1CsXhKK7kWwfLESHvSGG7QRF0Qe6PwKfxLkDJ3XPYYhFqkkOZDT39nbg7w1t1SMzxzA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:00:20 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:00:20 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 12/22] PCI: microchip: Add request_event_irq() callback function Date: Mon, 29 Jan 2024 08:59:57 +0800 Message-Id: <20240129005958.3613-11-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129005958.3613-1-minda.chen@starfivetech.com> References: <20240129005958.3613-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0010.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::19) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: f213fb1d-c271-4683-494a-08dc2065aa54 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8cM2NAM5gFkEHpJOp9ipX068EK9e5N11g9lnpJfbbYjf6/CqPP9ldENAO2vQ2nCb+11xqaeMpSitwBucICib6R0t1nyzmhWmSjR7BT28/2YEmkcUxYjVbnlZzRh6eyAtEbj5h7E31TL6w1apPmsg3FLcuLoDRRD8eos1OIgtnasV9GVi4480ZI7BsLi4qErjOzKhXeSRxvuZ3besjBFXYoSg+ZV0mKfPeZZFXYJPbmWCiNYKv9HuWqAFmTVDPLEzhykrjYg5/yvU6t51m+9kaFyPKaBj21wlcpC0U+2i4fOYxi2QS5B3FF3K0o2foCjs3V5QxPNvujPMxF9aBu80n+X5NNufkxx8Iq20QfKgIUzCCi4QBuQyGr+G6Hpq7kurOa6fog2HVOFrwJTopVb0bZfloGBSMe/9Uz3mNn+4ruXjLzRPAyl8SbHiLNbWQNG0waAZOlvXnRhPnzDl7XlZB165PnPWsMMCLZ6MPvIGbinHFqEzU4j2YmdwZnamAI7QWwmwSV7LYc+FLqKGbnjg8gogUhtG4IbUafm5uoTBPz4z72lJLj7ULzv4BMVyu71D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jBiqwpWkEQXWjD6Z9162bgIKC/21e1HwZEjvwUIiGESBZOrhpRQjrPrhqboPg+fCkAX75Z+u3kvXA7xkbl8tOaMmrSsGk5mQONFx0tArprgyt25fKobVP3gC8/FcSj5WxvmAQzdGIGMpyXUmOfQx77uh4btZJaTyEbuppltiSVxbX1xHKLtJs8kzbfCYFvZVHLr+VLlkhrtO7EQby+Oy5X0rJDjlymDGk4R+l2C8tnXHH5gt7Vl4m+P8ojk9PqJHR2mhpD/eOwluJW+yQfWaOlmct99tF5o9TGnkw/N7NuxN4edw5/Z2dqY7psrAfqq3WcxHWFRllL3U9dnOf5A4LUb8aR7p03lKSdG7Ahfdz0K8+kfFG0j7XG10giP/CWtgsGGhebMakapzmeTpDA4Bi8WDd3dBA2mv2nLICs8YICI5oausjMUmsXsnvd3m7IX9vGuIyugouq0SylC5Mrf0PWq2g5mMVt/DM7ROu/iQzHujMi66vGNoQXqvupLEj1tWjbK+NgPgaxdcRkEk5Wo/hXVh7TmyFHQPK+woj0kFo8d/bHkt03FS/hfuCyoS8hHBjTAiCLIT9G0v+Q0D7VcdTQ5WbbvsI9IcGDgCDWAY/JzNGwK5p09I/e+kZ1f6BNlJVygjEfNAFWqkHsKEdt5YT5UZO9w99LewLqQSQAg+Pgu3lNkUr72WQtwoGRpocZQLwwNMg1Vyy/8meOJUb/Gs7oirg0kEl7qhVZsWw/gRsg1AsjmON0mDlLSwizJqKjeS69uyWn50faq5arPCfdXL6eabIxDvsa+fMMejGZafdylm9ZzHhvQJZEl4bFmDm05TecfBzjjBax+5dCSq6m+wkyAV4T6SlLjpJAtzGNwH5kjTMGDc3c4YIYmnM7Jh1QlSMqOboU0On1Clc508skDuqvWmg+qd1No1iLDR5gjkZLd6T02Bu7+KpGY6fokHEGZRvJ2c8ccbqHd/DW7HtLc6ye5+ZEA/u3URBFaVgtL0BGmF7YsG68NoFbqBXr2zapLMbTZDdj136Bjozu3nbYvkdSav0tKjqoCbbdoBe0mU/UKdFInK6aJ+q/l/tyWMDAtZjyDGGHSDQhpLgztH/r562vi463f23hD2wD0R8RN0jl15/HaDOnueqB9lDP9o7v4DcE5uleStKv5Jr1TPpQDgiDyFQWkvqkI7W/EC/rOYJS2abAJCv7o8Wkna8/OPOdvIKVM8dtTbzrEM99hLL2x0GRoRICxzSobcRjHimQSVOJSvCVWjDnJvLxyV+70Z3W+qzFaWUylWYeOpTg/aLwm63x2s0/8Sbq6cvjl+x64YNJ6FkMdxIJW1LDgbO7UR9yBUUPm5XJbdlV7hS65dShaY1jQNDXlfrpm7aXknBlH2oeOtmW+zluTgaRIWSqgtw3itF/0jLEu/JNew8bLo7/xNG3dnwhUaZTvwSubzBnkuIh4MSDKYc14YsgfEYXWGJ0/2+9wmlCzCpv08TJDHZAtnszPO2pLAfBFWfRJQTvylYsDQuLXr3jUXquzOV3g9SZaFxf9//ICsiWOKqugXq6NE+/HU4ROH2DCHGgkYQ6SD6Yj2j8dPE9iTr7g4HpIikKe+Yv69/mT76Hf8RaJnETCtBw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f213fb1d-c271-4683-494a-08dc2065aa54 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:00:20.2550 (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: atqgE2ZnPGwnkY5gHXIYaasKuv2lL1fjM+z3k7eIWjnBjo49kn90UI/zfBJ81Qx2T8zsmteuJE3c/Fd/lcnUjkzuS9YbXomjwnqMlXrgXnE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385418371482916 X-GMAIL-MSGID: 1789385418371482916 As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showed, PLDA PCIe contains an interrupt controller. Microchip Polarfire PCIe add some PCIe interrupts base on PLDA IP interrupt controller. Microchip Polarfire PCIe additional intrerrupts: EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR ... Both codes of request interrupts and mc_event_handler() contain additional interrupts symbol names, these can not be re-used. So add a new plda_event_handler() functions, which implements PLDA interrupt defalt handler, add request_event_irq() callback function to compat Microchip Polorfire PCIe additional interrupts. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 31 ++++++++++++++++--- drivers/pci/controller/plda/pcie-plda.h | 5 +++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 0a5cd8b214cd..bf5ce33ee275 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -642,6 +642,11 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t plda_event_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); @@ -803,6 +808,17 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } +static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, + int event) +{ + return devm_request_irq(plda->dev, event_irq, mc_event_handler, + 0, event_cause[event].sym, plda); +} + +static const struct plda_event mc_event = { + .request_event_irq = mc_request_event_irq, +}; + static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; @@ -904,7 +920,9 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event) { struct device *dev = &pdev->dev; int irq; @@ -928,8 +946,13 @@ static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_r return -ENXIO; } - ret = devm_request_irq(dev, event_irq, mc_event_handler, - 0, event_cause[i].sym, port); + if (event->request_event_irq) + ret = event->request_event_irq(port, event_irq, i); + else + ret = devm_request_irq(dev, event_irq, + plda_event_handler, + 0, NULL, port); + if (ret) { dev_err(dev, "failed to request IRQ %d\n", event_irq); return ret; @@ -983,7 +1006,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = plda_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda, &mc_event); if (ret) return ret; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index f7e900b395f8..935686bba837 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -127,6 +127,11 @@ struct plda_pcie_rp { int num_events; }; +struct plda_event { + int (*request_event_irq)(struct plda_pcie_rp *pcie, + int event_irq, int event); +}; + void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size); From patchwork Mon Jan 29 01:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp296395dyb; Sun, 28 Jan 2024 17:01:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG41mdBM7wBtVMhUMC4LDb7eV4UtODMy3Iclnx8YLvLh9/xE6IUYB3l6zfKJ4lgKJKsbuK X-Received: by 2002:a05:622a:1707:b0:42a:7e2a:bd4 with SMTP id h7-20020a05622a170700b0042a7e2a0bd4mr5199616qtk.71.1706490104453; Sun, 28 Jan 2024 17:01:44 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x17-20020ac85f11000000b0042a9547696asi3611254qta.702.2024.01.28.17.01.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:01:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42037-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 (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-42037-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42037-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 33ADE1C21E69 for ; Mon, 29 Jan 2024 01:01:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 685CBDDD4; Mon, 29 Jan 2024 01:01:22 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2048.outbound.protection.partner.outlook.cn [139.219.146.48]) (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 2CD7A8F5B; Mon, 29 Jan 2024 01:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490079; cv=fail; b=qGnWQ45CV9xgfo4Hxt9PpNZR1kz2okwLcXiNat0BTA+iu9u8aYjdvUru9vgrRbYkPW0OWvNU4TTPKb2KO/XWBsPQVEXxr/GEX5CSRfd2CQyqjTbB9mNgJqnEfY7L+IMLlGU3z16/gct8WGToTGXSERnM2wngvenNWc4eA6ytRys= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490079; c=relaxed/simple; bh=SDRluIKdtwPtKDRBugcC+G+YH4p+OtMs3ZNtesAlOAQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=a6qyJ/334fNYcygqsuJB+IXlsji+hyaEd0a8FBbzjm+nVCqiacgQetdswM22+o1ma5APqu9onLk9p3ZRQYq+I2ijsgsefeErhxeL9nOWz4ebjAjzKH7Es2SU3G7mJDLTLxNeaNIZ0Q1Y7X5zFAYq4zMlnrKmW2hXdUMsM4J2JQo= 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.146.48 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=DA0IpsiXXisH2MjSJVwAtb3BbhSwuDxFeS4NXGcSiEJh4Pk79gcGRelQM1fY0e2Duinuas302ibDi2Aa8w1Rprvx6kMsRh1Onu0Ya7L6/FtDWfeZb5e+yl/cKcGOtoAbQQByF3Av9RY4wqDptZlIhKOnp+nYY75CJTpoAM27LtWEUnozZOrny0ht8IetOTPKpLmd6FOq1B0lyIB8jfAHcOGJEid8MfYSjzCrTu7MmAbZVHJyTWnY8lrqFX66ngMMSafuixFFzwCaJgf9iKa1ZvUacvdu6NLPf+ewTyWBgjOzGlRCfy+cXv3EuQJtS2RYjjedBiuib3J7s5G1EEgl5w== 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=HPJUAlSCE+qZGpSB5Q9MwBwmdThp4DzgQA4UVluzw0hzI3Oq+wQNv8lp25lktXiBf/nCytYW80rwZcFmGjekgZ6T81XwWzwIHdXo+7a/6I07dVoOHw4ji3XJOcAuxWaOZX6NYn37lfkTJk97pYH2rg5RARz6dEkEZa9QKiS39uZbY5KxfLTSLh/7u2c9SQ1ElYWxotbAuqpZU5YtyX+fXFOZAciQp08RYHzVBOl7of5Bm9vNFuCi5nY+dpCiSsuouCQw5SJ7o6rahzDjVd6fJVipQVRBFdSLoWdQUrmChf57Va3Mlcl9FzNLdJjVaTblFeDjUht4JG4lflL2RQwGiw== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 01:01:06 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:06 +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 v14,RESEND 14/22] PCI: microchip: Add get_events() callback and add PLDA get_event() Date: Mon, 29 Jan 2024 09:00:58 +0800 Message-Id: <20240129010059.3672-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SHXPR01CA0016.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::25) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_ X-MS-Office365-Filtering-Correlation-Id: e232ba0d-33e8-4a64-32eb-08dc2065c5ff X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kaHYvomQUXeLgKDTkto7eL32jzgFplMJKXlwfbNAOPC8/pf5Owxb01UHFGqSkHLXOy39wYiNB9K6Nna/astfZ9ZI1cQklj840kqviJrqX1N9EgP5Ziqims6RhJ7LnoiD0sVSxYU17KlTEY0R4e5Xb03CELiOigSPCp4XkdIg3OLAMMu4q+JmhsQ00TqheZjRQjf6rmPFpV/PiIb+/gZgMzAGVIAY2jem29oc553lYtRSvSuIHcL4DnOu1YZa5pYk3EH1xaXCuh7ocYcK4Z0qFS3LaYQ2gwHRGdOEZ3q5x4EB+W6XdHyjJ5/e4oChaoegmod1LQDyVsDqAU+mJn2WXl0AyjbVFR9Sar+BL2YhQxFM+AoQokNv4jQX/mPP3nyQ6ejdWlb+yOHYWtVquo32VzkEgk77IAaiihrcjrrDUBA47qNjg/CwKuMgeYwKoys8lwdBmO/EerwmO5BL786gyLGSkI68YfGmlpZ6SLgGYQBM6La7NS4VpS9IyrqHvL6I1H09KFEeRQiq8FRummCG0oWk11Co9hthQ1khFmmWRwUdIII41FAlx3j+2QqsaKgw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(366004)(136003)(39830400003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(83380400001)(107886003)(1076003)(26005)(2616005)(38100700002)(44832011)(5660300002)(4326008)(8676002)(8936002)(7416002)(2906002)(508600001)(52116002)(6666004)(54906003)(66476007)(66556008)(66946007)(110136005)(41300700001)(41320700001)(38350700005)(86362001)(40160700002)(40180700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZjumFRsXCaIu/HRUdtPMADSY9HO5OeQw78aL/NeICTGhrB8ZoEEFORvvM3BS+hI7ZVOllZ0wI/y2r7FGGfZsoJu6mAgR3nhrQgEhpI9OejYPrwiIk2PtXeHJMXCK1weboKhQhUjY88jQxwMFw9RM9bJpwIN/EMPX8n9nG3ROwykWAbtRVU1mAF4hQy2h68A1BH1lFPbprT08F70QXZfJ2npXXztczJX3WOc3xHm4lRg6yvDPklok6zI7UspfQqxKeqRvHt/rsr5OrPqhQner7yZy/RbD/2kDqNHZ/arG1F7nvMAtmYrtPQtSIFGGkQL8eV/pB6+XgPyPjnbd3cc4ZkpF+SGJxfo11k3Y04dAgbDM/+HQA2lG/bYNZZ3/5bgSaTU+TXpi0TEwqu0PbnH88eNlnzkYNVM/0ZCp/uXqo38IanRMFdeMgc91x6kRHWA1Z9wKlXPLyOd3jkkc+SKVZuMz+0CNzgXPpfLEE7vCgK30kaorppVcN2OPGprkxdO8Eq6eMag9pzbMs4V/qIq4M/n9fCOst1CmuyoT9/Rgfa1CCNgTD+tJDKONTjDhxu8UhrYB6ZNYfHfBVmQu7FI6h7NeHIb9VbKK6+dhtCAPm8vbUAEtjG08ncVei1D7n/Jxb8OCN92u+b0y7J/wQ3P0SF/8uzuADAvhDRCfgsb2Rne/Br4RIAzQ/2MdScJKiZeET98TDxLOEFIFFeqQ44bvvms9O0jDi4+VZa2ZGiNWHbOc0nqpLr2SSkhjjzI1M/1MxsGaTizlHtq3XLhEL+b0VSJprZzhVWFBiGJ2ltlIZsBoqeSwXB2dVFKLNt6kf+r5N9RHNTQBipA0kCnn7CF/vEvwnO/rCAoK9eVIrRUW2sWlQ7XPfEgsXD2HWEMRUsRDWOFSQMwG+CUkhM+/ISpuEA7a/BbUTyNPEt6fvhviVMmdGim+4zsb5kTYkJuy9Huipk7t53Laf8dGr0rFchlcj4EykkD46rCPZ+ZY/DRShlE8Ex/Jnw4kmFIkDfXe/fddtpvJj7a7vy3T6MaNHqvHwFI8REgI0IsRmjep7rjkvGrS8Ki7uRkZpJN44a4wspf6uyHP5T35gRwx2eZ4msKHSwGEzdDtqqe5dtVK8XekLsuTP93CVdZ8pj+pMVGEXVjpCF5m/j68gmBhaniQ/YayIzgts2Y96bR87H3cO8mur1pYeVthFTXG6rX1zyK+EluRLdNYTqjIbC8lxXs5P5zX2ELgFyOmEz54TEBUrQuZIu5Og9NRCt+jdDKf32xfeX12buQmxyadrDb3KvvxV9vRJkRa7R6oP2vNuAKttrpj7y0CAsitjtuCX9krQr26S184dj9f/JXYRfs7nuKd/3HBzr2KbXIaGxfNuJJf+dGEPcK1xxtBkmlAi7zbyqdOLK0Z2GuiHz0VbuiCD1BOS5GkQHn0YkBk7vmjlruL3m+UipHwpkb9ZipsmTIJYv3iZbTVvk/VIex6UmQEi/yvm/Dp2iVE/+pSz1/cU9Ok/QUD7yhUG+w6kCHoPXo7vCs0IDX7troKeXSPqbsJW+QlqbbB0oq++GO3q8qxRJsStudm9xoeRhCA2tQJEAEYs3S9l5lnP1NXRUx4mKjiL7HlS3gN9w== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: e232ba0d-33e8-4a64-32eb-08dc2065c5ff X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:06.6691 (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: qkn5H445W001y5xh4u9ZRAGW1G52tiRwIXrpB7niOdedsdGujmw30lPKteswH2m3SQ0/a6pg4TM5BiO4QO6eQJvVKO2iDeXQWO9VJ59Y4b0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0855 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384567923623646 X-GMAIL-MSGID: 1789384567923623646 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 Mon Jan 29 01:00:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp296481dyb; Sun, 28 Jan 2024 17:01:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbMKzu81geES1V6NvYKXgXRRaaBEjiSUVdES/RwSjKRA2xeHUrOCgaBskcpMJZqLsNpZTP X-Received: by 2002:a05:6214:aca:b0:681:85b1:f416 with SMTP id g10-20020a0562140aca00b0068185b1f416mr5851210qvi.108.1706490115392; Sun, 28 Jan 2024 17:01:55 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id kc19-20020a056214411300b0068c51f19f9dsi136292qvb.94.2024.01.28.17.01.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:01:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42038-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-42038-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42038-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 23D831C21FB7 for ; Mon, 29 Jan 2024 01:01:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94FACEAFA; Mon, 29 Jan 2024 01:01:24 +0000 (UTC) Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2048.outbound.protection.partner.outlook.cn [139.219.146.48]) (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 A72D6C8C4; Mon, 29 Jan 2024 01:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490081; cv=fail; b=KQO+v7j0vfJh1aX8dGzEd9P7vrFn+iDORKL/hlYCpbXaVQZ+/3TxiNEBv57BtKNjOtqSP5K7Cm2KOogYxpLhkfI6DYoekqYsexJT8vrkwaQVlK6OYY43MVD9hRI/RpGBcseYgFOIuDYFzq9c89XByqnIaTVgQ/9GqthoL8b1Iyw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490081; 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=t6Jaiyyr1urjqRS7bbvl3Pqzyr7fCNvZGQnj1eAppf2RMZL4OuC1Akt+ApG6InhRyhrl80r1oOyoYldPvyErErkp4tlru3YaNE+qXtN8S5b7MtDt8E5GF2QHqe6ab52tFfyhok2zxIG6pbn1F1Hd7/NlfqeSQLKVMgwc/O+sV98= 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.146.48 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=GChHrOiKzvMH263KmNQ2zY9Snm8jQYR1d0aL0Jr4H9G1cwe1HMzadVmng9xe/Z3l7Bw4+I25hbbZHTgrEHgt1HikiHfnOcv6H5VGuA4i8oed3p9Ad9sMsTFCDFn89dVEXYOYkbBk9/Dp7VYXNxQ/n4C/nz/YCYY6ro7p4po1Q+6PnfBQM3pjn8bUcoEHeRLGz9Y+pj+rk/wMP5MWsNHZWVDsv5Dg0ED2uuZUoPw8aWBgPvbW+gb7TWIOK5aD6nNdVUBcrg3RXUeUaqC3x8KNpkpKsieav+IRpZmw0MF9JxFSXBq7bJnj1fGmfCcUzDYHpm6VmruM71mV9NWG5Kvg8g== 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=S3ZBUfdKeztQ2FlUn4IRqnZzxW9RuruEjejHiZSacu/2q9TuKxDlk7cQqS1XTggyL2DU6Trx17gNLK4GWsZ/Rcc9AM6peYrZemdy1bHjfZpL8VCIlGPQ5jsuV3KkfW8pbKypMlMwAZ2jnDfmV11O+WOsIHFAbIRpSpkb/YMpr9x+GXoN3Lsipdl7z93CSP56825IDYHOFw3LdafcMwYu5Jvto9I8En3gn0NyQFj4E0KagRmfKVCf7o6B+3rvqp0YSFCt2xfBIfyq2kGuitzavOS1FC3UpYB1m+QT/uti+pGK1ghyir5uxR0Egrt8hKuuj69J8+VOKqGrBRXI2OUz7Q== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Mon, 29 Jan 2024 01:01:08 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:08 +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 v14,RESEND 15/22] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip Date: Mon, 29 Jan 2024 09:00:59 +0800 Message-Id: <20240129010059.3672-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010059.3672-1-minda.chen@starfivetech.com> References: <20240129010059.3672-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SHXPR01CA0016.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1b::25) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_ X-MS-Office365-Filtering-Correlation-Id: 97d1dd78-fd7a-4791-603d-08dc2065c6d3 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AnAkD6eezUOJje8Nv4upUnoTvFLprQ2QWP3bGLicdRiABo2wn+U/hcb2YPPKadV5W8K1KTl4pLaWLx/3fWEtHJ4fVzlZro0i12Cahi4hQW52If51d+D0qiI1BuYp+m1kxF9+va0SGwxeItWAsEzydEr2cneZBSPgDhfphzo1X8rx9IgB4msMDsS0bz11KhhZh9ouk/4gZAiz6L9KIIaONEJczA1CwX/Z86gTE2S5BYBYK7hKTCUZjIBHPsR7FFUPImKh6zOfeBiscmKbFoKhFHRhHxj7bCWpCp8lEKC6a3btz+pNoYNB49AXE+GmRj0IyH5l3wltFEZoof66vWw+lTN0+TdRQd7p3ykigALB7iceyeQjeDcAR71WY3QBc4wEO/rVcol7IIgXfWM5Pfsa/8UBRpg4mY+z3NzgWWh66DlTuZmkaU5WPQU58l7mx3CjcjkgbPVJW06Ab2LgeR7b672V5a9XDHgy5FyCFKHQOtaVlMbYlS0G3Qp9ZwGpBLrcVUyV/C6mZylYrqPmw1DZ/hR9qYKWWJ00fVUDT1JX39gwU1nhtynb3k9Oi7f7kI85 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(366004)(136003)(39830400003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(83380400001)(107886003)(1076003)(26005)(2616005)(38100700002)(44832011)(5660300002)(4326008)(8676002)(8936002)(7416002)(2906002)(508600001)(52116002)(6666004)(54906003)(66476007)(66556008)(66946007)(110136005)(41300700001)(41320700001)(38350700005)(86362001)(40160700002)(40180700001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: liJfsC6IQh3Je/RiSly5rUntpxz/OmRVmcf3d6w1O+xNu7r1mshknfYxv7ssoJjTnknT/PQ5y3h3v2RMUc7HXH3KnWmooP2sGt8JFsz3TCQG6X/ZSK41RABr2zTdPpxem40Jc1Fg3aGnekE3v4ji0sMldsBCahMP2z8dNE+5VY38V3ZeqhvuIgf4E04q1GhsCHdYVL3W+aB7Ta8OtEqS7G5Pkao5kpWrGeruz/b+cHCNHsgUF0VngJMUKGIRuFU4sFZp07g88fYNzL8RkEI7Znxh3NCdKYykfAwbbE6eSyylcaco9DUnvYgfwgJWGeLlfH6OdbM1xzBL8wvEQljHKe4pjIu2tBYgpakHnqHHiU6bqUdenq6pqm9w8VDTY5ywn06HMVFagKUnLtIGqqUSBZIPPFh0kDknIdEOlsQRMarnpDMHdn4UNRXpUynROFZofRtJ4znYwGUPI98SJItPK44Xx878fR1EIvmETHqSejhx4LptdIeSmsqvxBd1m1gFk2uwdJph10hF4eV9/cOZZgx1EnCneG6MTVUV3fgkJdCsrkaJgRm8cQIy3Qvb/pfq8DExNGCx34Ye/UYlk6yv8cjsPFRD0cTXe8QyWdqWqBLMOlaTjYluzDZONVZWKuHfD1RqQNMyBODE2IRpjK85skbnPUxUjLz5VmBp1QbdyJ3K1KkzaQztUU+wgFbauuGWCacEImqbpg7TORxvmYJbwQdk+pVO+dVGY3OfuFBn3NFq6fKbLFtPn7dmLUzaeN4WIN9w6UVZmjkNjYH7KtXb3xu2KnVrzDH+tgJ5DQX6XP2XKbzxa3PMAqAlujLmqbg0BSQTo7Ps6d0liNDdCuSa3L+2JFXcD8/aRbb1ZhjAceSuwt0GBp4NHTn/j+vOGWvkor22/fyc4kR+bBnXUJSbLv4oXUmTwuDtHqJWhoYFF6ROS/6LTPVWukEkcRQaAdOffEo5h2pccV6yhBAIt7Q7kb1/vzH2ii7YafimC8tEm11pSc+/03gmj/wbVN+Z0vsQUIoJfbnTkTKgDFYySvpqOJqs4u9JOTIK7hft3qILsWcqTaCDAckRdTnC6RZg3g7K8Yx2Npc5w1hV/2kMBQ3Jf8s9rccFh+eS5dM2x3BZgBb83W3kvBVDSNr+UQrpmtD1iGBTSA+ukFzU9sm/RBcLqNp53/AsjtK7u+NhiY4QOvkiJZ8Jt28zLprkJvTyAmylRToe0ZUhcYvDBqP4oEhqrcRwNbdKOgcKDjNHKKqSpDl7ySYz+mFrv/9E1fB8mNicJL2su7ZV0rTrx3uP+j4kw3bV0qjwiW7Xkwmp+B6q+lbtqsrZi72y3Axh/0K2ne9cLQXC6B9kHpHRw0gPhlMx2N4czOal4BIdy+vjJA9EiSjfHYjHHnsoW5FgBt7Xj/yMI+p5eM3MCbNT6dQ3QBLvoYwqb9WCLqNYuzGPdKPBmVg92DDxaeFAz9CjtEmgJ+p1Kh3//CcXFunp67VzaUncYAclOrNS6iAaV/jAraJODJsRmxyc1+xUs+wft+WEYQweor+vJ8zRX/9syKZONwtTmvgLltfOW88QOydLkWi2wrq+wkTZZDN64e/PM9o/9e5oVR9Y2bf0v+HIJ0x4gFLUIg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97d1dd78-fd7a-4791-603d-08dc2065c6d3 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:08.0035 (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: CKy62uAlQ3tnUSqv0Zx9c629DvVbOzttP2+pApfb5ekqTcB5GwyElE10h7e/ho7kae30Lf08AFT9Zpin/ewKCSi/ufkhg3nyirlDc91SIq4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0855 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384578902105922 X-GMAIL-MSGID: 1789384578902105922 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 Mon Jan 29 01:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp297030dyb; Sun, 28 Jan 2024 17:03:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFSmcWFzevYz8MGwrQ4QrzGfnR4/66rDNx3HvqyfJKO2sfyNNB3Z6evJdw18vmQ+UhBJIP X-Received: by 2002:a05:6358:5328:b0:176:4fce:25 with SMTP id n40-20020a056358532800b001764fce0025mr1767736rwf.55.1706490196590; Sun, 28 Jan 2024 17:03:16 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w19-20020a056a0014d300b006db9cce8e2fsi4906788pfu.280.2024.01.28.17.03.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:03:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42039-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-42039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42039-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 4D3A8281FD4 for ; Mon, 29 Jan 2024 01:03:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB24F10A0D; Mon, 29 Jan 2024 01:02:11 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 7FCD5EEB1; Mon, 29 Jan 2024 01:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490123; cv=fail; b=bwo01aXByz6ViQh8T7421YhXjppDj1kPiVUpN4ZDAfy/dUwx0I7Wop41h+VeQaKnj7s7DhWVNE78tS3L1GehwkWS1Fc9knPwXKHPCI/U7QcTLIMbLAQ3aW2x0fcH93OUvdtOjzUCpIV/QBZgGn5Lz5ourIc+DrGIasG4iifkdp8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490123; c=relaxed/simple; bh=ggawvIbzZ+PVOvsxbzkoIgKBxmy45+7ZS0uM5XtO8PE=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=Y1Vo8hyOx9jhAAyQKEyRt3/bDLs3pccuWsnpEDUhXN/xML/P86xi27uGZWg5njeQBb/jJyzwpv/LHt/audgoc5r9yXckQCrlSuSvVF4Rj6V6uLvDXXSHRReWTw+gYfNvjJKHzjyVxmdlqn34J5vLj+iBgk2OSEFaTZYxH8XGkbw= 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.63 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=B4PlyDaEoJMOEH9PiZcJBrshrMc/tlApWroFzX41ri2Z6m4CRSXjAHFEM5qx/aLw2PnghthMTY19ahrg1Eq5zl1ncdy6qiiYIH0rCOrjQFFZIGhCJmPEpSYVqheQw48lMeTUHjzwLs9P0ipYfuA/lFoKhA9+FmdYR3Dv0NovpdcvCwP9yZIe44nEpk6KvmwssTTNi2X9/DXwzI6+9rT1at+FL47djHKh6pdiRBkb0DjHKdg/USVxc5QdlMXHujAtreiNQwJIHm2YNxwsIXryrxHGaJwYezVkkEDNdYRHuR36cHIPSk6VnAIz+Hv9VMWMxv5/DXceuL6wFipnSA/ZBQ== 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=Ipj/8Hkr5WHC99Yl019pmbpK3veAdxAE9FBnTzT2y4mOtIEWFrNdb2HxKexN1fhbH1jc1GSN/TFB6RE4n93zzkEVEIYOWPSjpPzeGoTz609gPSW1bPfMo2ZJbDSoaQ5y893dKK+rrwxcbqRZqERakS6nWukfHzez6b6ux7zhnX/WKaPMAL71Kj49mZMGRoixCXM2Yg+PWoirvdrvcQl9jclGEJeHdLxRPFGfOlQwXTNXYad3hj0eM74zHs2BByyZL0PUMC4Fbr4At8c45sdiNjc8BPiHfKH57LTmMALEYgaodc6XNa7GYX+brkPLTsDKMNvgVRB0T/rFDfeNmbXc+A== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:50 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:50 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 16/22] PCI: microchip: Move IRQ functions to pcie-plda-host.c Date: Mon, 29 Jan 2024 09:01:36 +0800 Message-Id: <20240129010142.3732-1-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: 2840ae97-17b0-416c-1c9b-08dc2065e042 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKkM/yDVtvewTg/4i3MuYF/NZHUCisA8v1ZurZA4QApIpkSE9kSN3fsM+2pqKkCzo5hGqLqt/GSfvpiBi10i3plKuDFTFoJ+uhnqZADW1JhKoxUIqfWAC9l7ktOXQv0GwA57t/bUnf6HG1tIIIjVDeD0iNfuK5o4r2MHNZhklKf38pjVBeBkIu31Y3xoMf7aL8rsaO0PwdF7oy50ZYq3psWO/8GeiO4GTA3fC/8DdAw8rttqhgyIaOoayOX7sEttMwqIU3R1ge2Hk3y88jthl7QtENeYObdf1nQu2FEjDgoapt0EpUb1VTySOVF/o7DbvLlwW+NK9gFEQoHhRRcdcBGCFHl5s+X9aJpp6+wSeUioNSXJXtmxfec6pbH6Rkga5jf2nVza5jB4PrZcLcB6XbShSQWlWc2jH66gvN9FbvoH1CzAcJxkA9gE8zfRr+9K/GM2SHW336Y2+py1fWObo7A75+MMrG64p+jkGuZgju3zczy6YQu8N95XAqZFxHaEngITANwrwXM7sSYdARvLwgCmwby0ohFnnrNljMQOB9mqc0kYrFGvd/KXhyMo6bW1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(30864003)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7oqOjzw8D0NXDEWWqUB51X1WMnmWdconaHd50guWMCWk/J4gmeEc9DxoS6o6FgIUu7ZdlHPe5siC+oZAEGzEFyzZ8VQxcDT5ODi8gcxUHgfLe9gjSrnsiGcGWAggziYu82eEw9SGGQRtKSNAdOkh0oxk2ETL+H0P2dcW7euZV+9ZoNYfA8QxLbFlfCaIsCqstcKmo1ftd9+Ug2pvzneiM/7e3JQInEiJJZcpl0vtChSIEV9Z0gmPI2sH1vrR011sCCNwkqG4LGwRSxD8li5A5bTh7ZVfBjkHE54rk9EJV0eWRFUurUqcSoEkj4VB3E5kGB1QGvtPZlEK/TarQpm0SDyr9RSb8ukzowL3Kr7BbTakFCa3nnS6rEqGKProWoKin6igJKGcV+Z0+65UOpDFDxnONrHx1d15cbRpwwiQEGmVYJU1KD3uSTa0B9RcJXqHKfBBUZNd0wAcIuGsm/JtL95HXpZd/xXbdEIZL0oNiGt5AVyZHcLVbws9kylae8xHP7/QeeSK6CZNej9t9jIFyHH7Qjxy5y+/7DWYkXThp5mzh+GKAPCaxEp1IqDAf/oGFu67FaXyk/lkYCYxkcwG45FwerBKcf3DENRr+7ps3A0YBlzjNxcNrhtwEkwWa+3nQYhDDjJSbI3uT5NQp35uJEBDT1gkGGAthm3ekn1DM3a3RmREufNfaSpcO+RW9pl+kLQ0A4N/KhfaRZN9tmjn4YEFsDB3xy1SeRcDo9mCN+8vZA85lrfCMafbbtDkBzQ3uMhvprUk2KqVZwBelfiFPPqh3mHcRsWFFjhc1xx6tqGjByf0KMlbHEQYXg/wYznidoOJuNEFv4Db/LSVlUjMB2yCUElHQBj+B+jdEi6o17npSJza8QXPSwNkQ/AViKS77YPKwiCfDRhuXGgF/weBn/wHLhoiVO2emKhHlUd9ZzqrjteY5TatlobDo/froARcgaKT7vzrmeJApRergFxBbz2+7UyQQDhRzXJ7IBnr6d+njwp0P09E4+mfLoDBMveXz+Utfvl5OnhcVGr7En+iac18aGRDVnyY5hv1oOgU72Q84YGXDfs0mgASXgJ/XxUg5vPNvUQfm8GRRlyCjaJm93UYJm32Kl+rCmpNuPF98EZTi+NsiZc+Gd08zMSXEBq9jtGXu7HbCPT97EsckT19Gi+LyjA0LjkeeAGuq3KqCpX8muxwiaKLtqTjSGPAb7FHMeawI6enADNDnCjgGfJc3fv9nr5HRbHTNv2d137T6JtrlQizOVeVtoJZ9ujfUoIh9r7yslE+7c5YR4kRJieEDURB1HQH8S4dPLJhwXqJBQbtOMu3rZQFRlLEncmbRxi61uI2+WR/ahUMhIUzL8fvp+DbtJL/kd4isfqJImYuTFMismEzLbWK4DsV0wZcR716xb8yg+hxVnYBpmW3G1IE8yEDvzuE2tJwDLcVCSyoAt8jqiVVBA102pLOnsJVybaDQtd3GsdGl7Plmc6bdyvAvtQ7qgMgw9kEvT6GZdL63NHnti2XJM16D6BL711wFV4kLu8uu1jlQr0MFd7NjmSUCvi7BZLesJkpUB5/oQknfwCzxZm17yJFQEBIXBFWTaOBb6focHiHXx1jngKEWSvnxw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2840ae97-17b0-416c-1c9b-08dc2065e042 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:50.8138 (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: wg7N44OHdT7oQX7uTu0uL/BZ7w2mBQjj9K3F6/iea9tEyb45tyanhvai8Eji79YB/bOi3KPIxdCBNrumNFdUTrLFOBIkNkXASaIvHuYZa0w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384664797558928 X-GMAIL-MSGID: 1789384664797558928 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 Mon Jan 29 01:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp307420dyb; Sun, 28 Jan 2024 17:36:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IENMzxSdncmyEZzj2RB4SMMII3HAlj14BQdSvV25loq7Cpt+KWsnxLZKNzIiRKnsGx4dcxv X-Received: by 2002:a81:ae65:0:b0:602:c6ac:890a with SMTP id g37-20020a81ae65000000b00602c6ac890amr2200016ywk.51.1706492179573; Sun, 28 Jan 2024 17:36:19 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n29-20020a63721d000000b005c6b59c91bbsi4910088pgc.654.2024.01.28.17.36.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:36:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42067-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-42067-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42067-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 4E59C282A11 for ; Mon, 29 Jan 2024 01:36:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64286FC05; Mon, 29 Jan 2024 01:35:52 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2068.outbound.protection.partner.outlook.cn [139.219.17.68]) (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 1DB4ADF58; Mon, 29 Jan 2024 01:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492149; cv=fail; b=f+MEZRbEvIScwkkPHu4QznZIX7+wD/iAllVEvOQCt89eeFmOYahFtueFWQ7DxqCETe3FQ2Y7Ss+X3Awcc4tJfe4KePLPuD5gz6ixEkIAVmY6KZezIn0L3EnLFh/JbSMqdu9t/N4n6JZP5shLZs8m47WmIKa1TLENinRLDmzacxU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492149; c=relaxed/simple; bh=9HFoWB89oSWytU6cFushowRyme5a5vBdtDh7hRmVzsU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dVsSWVtPiy3KG84mEp/7shFSOIqSrFhcbKZpYD3MDiNCnj1ydxn6GZY4SiKX3Vc56UFMvP0nXxGfYln/ZT4dzaK9IlW1oE//v3sd1y4P3dcSqbn6tnwnC5jQ9Ed/zi7jlfDj88JYUicgwOK+7WtFOij1Anx7NV8WuW4S0mHwZB4= 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.68 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=RtFkqp1/ZI+JsXJ46kVPnq7qZdOgHk1Mcysd7JH+E//14DmHpXUpQjCadMI7LcItk07z9+ezBcbeRwRqL9LfJZb8NHrKAepLuVO5DLkBOPOIzoW5fa87yPJ6gDklCMJO3ysm4ZoYWTKH5nMmhmdxB5jDsWEwwSeiuo5wFVNmjYU3WLSJYrgFMC1neE+Q68tuqoNLiuRazbV+ROPHr/zqjl8DzBgi393GfOe6NjGeTK+YDEq4KV4NFHEN29mpJnnB9hfbAQgdaDl5rBYXFvTfr6IpA7aOKZYvGB9TsUnIFJPA2XzfWpAfCtZjDJxNI7HpPfGojQAXlxPm5UyEbn/Oqg== 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=GwGhQceEMCZyl+DbKD8B3JXg/HGzJIuadAZXispaLnsX0jDVXBmsNicL7QuqSA5W3/AELiDDq+EU1nIo7HOg3jJbDWiRFj8f/O9ezJIfPJgckFioNUu4zDmYJCsjQOes94AZDt5ikLw7Da1PHx6ZEkROz3rdgSSNH6yChUPr3znmWXooh/NUxt+1BB8PBOBvu9Nn1p/Y517/BwjjANUCBetIG4RqKWiwy3N8cQxasMHEW8kSR5sN/K6kuuAVCXM6biQrVtoJK5mn4ug6D+dfoeSvudVBfTmebyOOvxgz1SGQ/9Z+8FrEbWIbyWJ6vtJLR43VipdbZjTGl04uSLvz3g== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:52 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:52 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 17/22] PCI: plda: Add event bitmap field to struct plda_pcie_rp Date: Mon, 29 Jan 2024 09:01:37 +0800 Message-Id: <20240129010142.3732-2-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: fac92d76-dcf0-424f-1f0c-08dc2065e14d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NYsKG2CaR+he7j91waYA4jemf+grVBhBSQdeSkYt4oK64EJ4zWaPOu7qjQGZ304xCiw4FbjKxV1+AV4b6RKBFn2g8mqdi+sFjWlPrqCnpnuYSMXUarw6CEQMbBrFTAVGny16kQvryRFiqD7gIx0QXlUOP+pyMNIU0R3RaiBTaKfthDGGrGSwHFEWxf7F0Sx6q+fnwMemCVYGhAqnOIew4NPYzWXOTp/fH73nI8ztkJYoiBouOmqYFaHylR4T08bVZNygl1nbT3kShpDsksWqjQ2Melsy4hlEutAFioySGu2cjLeAFAZrfcXekEvX/pt7sFrHx/MSd+0tMt09GU5DgPwUka8JQD5P7XEyryjy3xI1sCb1i44ghKGyLi6BzC8iW9xCQ32JuzTbP/EypeWxs+hkbo+WMfHqLIkFtpon17eygmhK0bNmUDTq8xyWragoZWBgowQLPVa/Q0tY5QKpFV1bhTYHMQ3RV1lS78RgL6t8g9fPBw8Wzp4nVDjHmQRA7Jmk7bxjRHk8ytGEWYaLEZ6GLnfOyVpnhkiwfFG2J84pv/9n2uGidfRv0DUz0pZc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7Bv9/OkLiCIGLlxfFgC1iV/g91KWp0qBlYD/3meqIAOOu0Uo8sBEIh+ZQMjj0AKAAb2VBcNKaJ7arqMFqDzqubmEei9h6gNEtjYz/6+5zI3Lqjz+jVclJozyBFtlWlL3tWEJdpxsvJ1GClWg1e/qljypXLiUd340FivWjEnvjgghy5bsKopn8abdLWZPbLJztGQkc95lEgQxogEjXuCWp/F2Ps6Dv1BEOqFeMu8OtQ1VpzyTFtQdpLmYMyIcUFyPVbLhQt4j0azKwGZXUlf6LPvS+orgR8jaFRHg1gJsGoOVY4PvhVXULqabYm8WoW77nxo2sDkaURTUdVydViyZzRKmsyXe395RPp45OLcnYXvUMr08Y2aPYPWUgpH7dhqwjdPF4jrYDqdW9M028KxH4yU6KSxHEaZO/huNs00X4+bL8lEM5Z4z+1QFN/zK56gljdjiJlBee20WL+Pfi0PefDvbIIR9lcjq3LnbAWCFf1B6n2FMy6VefvG2ovf92dGWkMEjNHNQ9l0a2OWQ5le3ARTF+2xkrE3GFpapWHLLol+8Ki8Ugeu1UG5wNrc+UhHVTm1F1U6GU0qmWLD2qGa+oGOblbIzW6TpGTbhHfvmIazzSXJSYHWPA6jrZrbWDMXLidHbi36f+UP6W8dBldrPaRKg0Z7afqaE/bSjW1Y8Z+SaOARG1UYY1/RRFnBRF2tx8ySKOZLasccY/drlZj2NThGNU+HM1GUEZCaS7V9BGH7DT/SnN2LtXWQL5Ciumh2/AbUzW08weAO5cBPA4hQr6UEr1L4RmnWXUwsMdIFoSzelovqXxqPwxCWg0YgLJQ19a/RBbDg3kbj8QwAv2MERhPorl6x0PBy0E8OpRmIk/0QCUkydU17lE8aiEJe90kFo7EYq4HFuwmLHIEduijbGSxSU4rlXbAU3a9Xngls7vEYDFhW1eA+1pCekPZVF2SXlK+r/95I6BSYokNyeP7Y7Hcuj4RyrNdMZu+3eyNQFcA2z8VmLzjDakmvlLOmqng5IPLXpUquSVcObItcQ6qVXx/y/ygkBgecQxDOjtDF21q6OSShhn5VZ5lvR/LL8BFa0vqEzbQPEEqPW7eqY3PmtCUZYHqYUO7zMYe/UwDOPk0TuK/YvfRPRvXwmsA0xkLau7wwm04Bz+SqMnR3mRazxrV0Pl7gbLw7Lb6rXccx8904j0WjfwzWn50b6A7g0R7vn0qWsRH9cMifK8xVSJRNbd7RNU2kIW+vsy9EzzHqU67JLgwdDu24sfWO8V6GodTn+e9auI9Nmabh8jPXbzwSw2qzW9Q1WFx7yRu7vzOJKNwDc2wO/q60ZP013uNHIL7SDSxvK1Lilm4a1qh34zY83kPRC4c/OlJDElB7vN+DUoPVwhkwZ6KmV+lS1J/IkB0b4wWmHGSQ/DBPYMvatm19miguQFljISO8xw0Crc1w+xTw3Sug9Uor2+olu5SbZ64whkn/gqut+5PY0iTYL0KwSzALxkKqz3Vf/J9JiwBC04bWp8aD642o4TExEFhsUkdVLM16kxZikRXht0R3gyHcBeOdgDrmW4Di1WYM3QOip5MTCz0DMRUV47p0NM1kQ9A0hMleJJ1KgqsQrHRXGJvly4Q== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: fac92d76-dcf0-424f-1f0c-08dc2065e14d X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:52.4844 (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: lbozE4B/Ei0z7NIgNRqQBPE05ylyq+Oh/pGt0tcAB1Jz8CL+ID4/YgphqCwrJvI5LAqQKcXh3tFJPgWsCdHX4WZMruo2DWfOgAY0lfK8oe8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789386744067593453 X-GMAIL-MSGID: 1789386744067593453 For PLDA DMA interrupts are not all implemented. The non-implemented interrupts should be masked. So add a bitmap field to mask the non- implemented interrupts. Signed-off-by: Minda Chen --- drivers/pci/controller/plda/pcie-microchip-host.c | 1 + drivers/pci/controller/plda/pcie-plda-host.c | 6 ++++-- drivers/pci/controller/plda/pcie-plda.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 105964306b71..48f60a04b740 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -636,6 +636,7 @@ static int mc_platform_init(struct pci_config_window *cfg) port->plda.event_ops = &mc_event_ops; port->plda.event_irq_chip = &mc_event_irq_chip; + port->plda.events_bitmap = GENMASK(NUM_EVENTS - 1, 0); /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index 98c51e594efe..a040e7e5492f 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -290,6 +290,7 @@ static void plda_handle_event(struct irq_desc *desc) events = port->event_ops->get_events(port); + events &= port->events_bitmap; for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -420,8 +421,9 @@ int plda_init_interrupts(struct platform_device *pdev, { struct device *dev = &pdev->dev; int irq; - int i, intx_irq, msi_irq, event_irq; + int intx_irq, msi_irq, event_irq; int ret; + u32 i; if (!port->event_ops) port->event_ops = &plda_event_ops; @@ -439,7 +441,7 @@ int plda_init_interrupts(struct platform_device *pdev, if (irq < 0) return -ENODEV; - for (i = 0; i < port->num_events; i++) { + for_each_set_bit(i, &port->events_bitmap, port->num_events) { event_irq = irq_create_mapping(port->event_domain, i); if (!event_irq) { dev_err(dev, "failed to map hwirq %d\n", i); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 6672a231a4bc..443109d04d59 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -159,6 +159,7 @@ struct plda_pcie_rp { const struct plda_event_ops *event_ops; const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; + unsigned long events_bitmap; int num_events; }; From patchwork Mon Jan 29 01:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp296837dyb; Sun, 28 Jan 2024 17:02:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8xto1DHvtfY6JgvC1/I90yb/ROyUiZS5l/ZbOR+EE675N6Vs4o+XLsuhb9Khkj6PP+xmX X-Received: by 2002:a0c:cb0f:0:b0:68c:476a:a5a5 with SMTP id o15-20020a0ccb0f000000b0068c476aa5a5mr2300497qvk.12.1706490166522; Sun, 28 Jan 2024 17:02:46 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id hu14-20020a056214234e00b0067f747a7cddsi6529215qvb.439.2024.01.28.17.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42040-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-42040-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42040-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 4532A1C21EA5 for ; Mon, 29 Jan 2024 01:02:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20AABEEDC; Mon, 29 Jan 2024 01:02:09 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 5B8A3C2D6; Mon, 29 Jan 2024 01:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490125; cv=fail; b=Fyiypyc+wSKJs5h9vnfR6kz7ej3noOfv8JQzyqVftsjZ3uF3bBQ4sGCa3GP1fYMcGi4tT5a5T98NTAeWatimbOmhRpVlcMqu5g5DSazAM50OJvHCAb5uybrf+7/+t4ljsk93zPMnHqzxrf+1OwAurlsSFGE+jDb+88feOQ6Y3Mk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490125; c=relaxed/simple; bh=aetGwQfCj81DGzrZQokscKBANT6NK6uQQaYIaEMk9io=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=C9YawmtgGBrvYPO9PIE5Gpre2WuBD6VUoIC76QuoiQOqt/m4yjzLldlM0Jn5UxFk1u/WgfoZ9QQnR6N2yb623LJRsAP3sNjnPYblow5a1rIQsUsLiFjcvzqhGr4/UQGNhwJB+mkT08TVrfhP0gM5Vv4AVnKZH2S5RUS9G+KwEUc= 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.63 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=l1S9bqUSQxH5L4n3bSt1bHOVo67jpH01dStrCgD06HZB+1mq5/6FkKfCa2jAM5q0mt1A4ZKoU1zsdgNEvhMeq4lxSsxz0dv8aMEkqkOn1nvNqvyewHjsJ3tTNRUvoDQXIGJuyyusNT7Vlxcv64jwyDvzu3qE/lVwhmTz8lmqYT3nlYbN5y3pJGmtS2Cp/Wm6l4modc3Rv/U1mGF9sbSiWkX38Nvitw7VsFhUPoOwHmxkt9ejEKlhjf+FOcJZSPkuJBJSQ9SP+2Zp4vrA630hcexti4HcmVmXTfcxAM9YOeNtL674IHakY1w8E9NtrZzz1WuyuikEMLktVPtxM9SFGw== 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=EzCFWgd60E+HsBPIuOk1ST80dahBVtNQ/WIr6iEhgFTLAHVaIYGfVOGezS4JSkpiGK/+TFG1yZkSTv3iHk4kTDPAR1muX6hytD8/QlBzdOJKCsBfizAFZNN4W+VwgMCoKf1bNa3jVCGGzYEoweXS+defEggKmzcPJW8zBQTOAs9KA8brpEKlFpJwUmJwwkA55ySNaomM/Ms31p+5qWwVM3LnC0nhx/fAvJHWJo/z5pUBlziPkBAKDmpbcaKohwivpAzUQHngkdI2Hko0GwjGiCLXbCvrAX6Bc229tmsv/CM1L9rF66N1c7FNUt+RhMBu0YfgUcm0vBJj5fzzE7YFLA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:54 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:54 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 18/22] PCI: plda: Add host init/deinit and map bus functions Date: Mon, 29 Jan 2024 09:01:38 +0800 Message-Id: <20240129010142.3732-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: bd972af7-7ac2-4dcd-35f6-08dc2065e24c X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gqez4Z91gt1vO0cFkvW2kJC8RhKRzd6gi+a92PZ5NixjCued2zdawKvQ4tZ8/z0gCufgvy8sSVWNWNuzy4m1pKXcte7aE0V/j3JdtEsd9VgSoYQuK6UL8yZPQLpZ20Ud2tClM0sVnJK21Ya5Muc5nVMAHMBQA8Aar8K0Ym9eqGPrhdXU6jZ0vrnURpoZ5bJUl3Wie9ELMT8lWezRKW7b8PB+22+qmmUVUR0AvhJjD6TsC31QyDte+ge3u0hK+7llezPXkznatnBqWIwAo2G/DbZkL4zdYSCVyShNUy9tYol+++Bsg/dRr9EMQ3g1vKT6xVwtLke9x+NbzJO1TKJ+3r9WmX0LaSCS/3zb1B1U0vZqafBsbaWWdVUAVbUxf3MoZw54gHbHrsBOLZk99LE9hEP2sF6DFUj28aLSr80lBOVWANlga9DZOglnvxUcQgZrL1l2T9iMftKH9HehL8jXWzmaUIPbcS5cT2DQRqkBalqflw7AtmYLFbGsau4k9wMcgXmwA+ong+1HPqUq2kVSacaNzU9bIf74ItIqtWKXgWkWqNDw9aLAOx5fK1pv9Vmp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l+pZrWumIDBOrVFOxTlTG0hzphBMeG3tqvm+IV4fZDZ0EsDISDTORnsMKLw1mxTfXKrW2ezGejaO2MKoel3fU7fAanoLWqZ3Sbk8TX61KQOulkX0Fe2FOXUJaeUzMABTJJgJI0SjS8k9hu5CRVFzaAZK+Qajcl2Ox7MvKdJGKhkCKwjM1n9iRBaEfosufntgKzp8CiUABaYhQE3aBkYcxQvi/oMEPsXfTGixR6r+1X8sFS1g/8NlGx5CmB8PqC9WfphoIFmZCJbSm3ijYpYLHSWT+6IkdPnnkvrBymOp/qJyIEZsKj3gcCB1Crb6YfMx0L6eLsJslFgW0ohureWxW6J0dZkCvihbwxX7HeojAHcIHIFOamimwKU4/ZEeCkUUNlbbM0UqKtXsjsVJY8XSv5JxtDgcK1/llwT9L2jXa2n8J3gYmEo3Dn2YGKAB/AYKGNqWjW/xj2n5wdv1v2X4oE2kx1bTCCROASY0VlyGd5uU2sdC42NL6IYKR2pgf8rLuhIIv6gxxS9Gf2yLFpGoNUnajSc9raJHzbrARBJe8rjl9yT3AG1rukziYKeGbAufGIPAh0ufqzgzvOBfuSi2IHRURA+iQASVjPLAACeC6afch2lLKhAgbXcRIDRroFVn3SJmBnPnAtrygsNhW/lQ+DryrGEbvHRFYvLzSsSk4LKHsg2FZwiayzDLQndcEAuMwRkbjko+iYQbB9tZpliYlr9Jhwg0StljC6gqycKw8qxBvpM8QykTOIAR0VxqINyPA9SdNZ4x2tZ/VoAypYdXyCALgtaoTy7LRNOdKHOwF0FlKgn71QXNFn+XnJwowzfFSU4jMc2JxbcrBHxAlg5n2Z90h6OYSCKbMFDjpmcJtBRKczfzu8o5N3R1ONG2wEZqCkByEcn1xOu7lvOxSEncQ04U7JNt9h80oT7Um8ZBh2pUkDgXrZ6br0hF58844oDIbdwLCe8IyLSTuy/wD603W4vbF5xhQdj4ltrs0fjFCaZCoWQmguSiz+W2NcVNXb2rM7X1BUqbucIRobyzVCVCpPgeFGyA2DD0RzbDSqGvIMmJkoYzv2cTnPgjg50NT9FlOZwVkc5ZNLFx/bMdbu6jx7H/Uoz47CcZBw3P2x4sPZQ3qfIZ+egTzzOGI20mWqoUVXSHU6eIm4oEOxqAlHNDn2Lyg0o7jcgrWfzZs5cTCMfkg/FSLGREDRdQzWk4fujtGZP09mDw5ySzAxcb2mK8aQHVLUkyVNH6yR2vT6Ilxpvujf5CfWAxN0xZa+Y+7ln5juegWOXB6ZJ/c0/aQl6AlPWUu1sf1muzpC6CrtdPwkLlSo/LF3CpuJDGRJ53a1oDT/pRJXaDw4SR1emTlXna4CN12VT7SCkmGExrd6jBlMjiAN1Izo7sck6vNI/B/PUXTsep+FSNrULYHgqPVWEuNt2Q8+JW4XHyrz9YHrvKbr4iss3FMjZvvxlzz86L5UqQ4ZFKXyOh2xBcwdCromTK1OX5AY3QSHZeeH+xuUow6PGMiWsG7vrYJqYUAZCsGFAAFcWvKFR3QHhL1QOTSBIUqQ7NO99L3xC1Zb7hFZGoojKTaPlU4R/XbcPDk6GQ51Rxee+kXriG/hd3RojiH1r62A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd972af7-7ac2-4dcd-35f6-08dc2065e24c X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:54.1270 (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: V/FK9t72sCKtizRANn7ZiY78Q26a5g0YSDz2YJnJ37yenFz2eN/cyYzNUwh+PPsvDo9RNOb5exYi0CXDZt8c6dwXNvQnsKdcDcDe/vDiAf4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384632691141235 X-GMAIL-MSGID: 1789384632691141235 Add PLDA host plda_pcie_host_init()/plda_pcie_host_deinit() and map bus function. So vendor can use it to init PLDA PCIe host core. Signed-off-by: Minda Chen Reviewed-by: Mason Huo --- drivers/pci/controller/plda/pcie-plda-host.c | 131 +++++++++++++++++-- drivers/pci/controller/plda/pcie-plda.h | 22 ++++ 2 files changed, 139 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index a040e7e5492f..a18923d7cea6 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -3,6 +3,7 @@ * PLDA PCIe XpressRich host controller driver * * Copyright (C) 2023 Microchip Co. Ltd + * StarFive Co. Ltd * * Author: Daire McNamara */ @@ -15,6 +16,15 @@ #include "pcie-plda.h" +void __iomem *plda_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, + int where) +{ + struct plda_pcie_rp *pcie = bus->sysdata; + + return pcie->config_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); +} +EXPORT_SYMBOL_GPL(plda_pcie_map_bus); + static void plda_handle_msi(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); @@ -420,9 +430,7 @@ int plda_init_interrupts(struct platform_device *pdev, const struct plda_event *event) { struct device *dev = &pdev->dev; - int irq; - int intx_irq, msi_irq, event_irq; - int ret; + int event_irq, ret; u32 i; if (!port->event_ops) @@ -437,8 +445,8 @@ int plda_init_interrupts(struct platform_device *pdev, return ret; } - irq = platform_get_irq(pdev, 0); - if (irq < 0) + port->irq = platform_get_irq(pdev, 0); + if (port->irq < 0) return -ENODEV; for_each_set_bit(i, &port->events_bitmap, port->num_events) { @@ -461,26 +469,26 @@ int plda_init_interrupts(struct platform_device *pdev, } } - intx_irq = irq_create_mapping(port->event_domain, - event->intx_event); - if (!intx_irq) { + port->intx_irq = irq_create_mapping(port->event_domain, + event->intx_event); + if (!port->intx_irq) { dev_err(dev, "failed to map INTx interrupt\n"); return -ENXIO; } /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); + irq_set_chained_handler_and_data(port->intx_irq, plda_handle_intx, port); - msi_irq = irq_create_mapping(port->event_domain, - event->msi_event); - if (!msi_irq) + port->msi_irq = irq_create_mapping(port->event_domain, + event->msi_event); + if (!port->msi_irq) return -ENXIO; /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); + irq_set_chained_handler_and_data(port->msi_irq, plda_handle_msi, port); /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, plda_handle_event, port); + irq_set_chained_handler_and_data(port->irq, plda_handle_event, port); return 0; } @@ -546,3 +554,98 @@ int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, return 0; } EXPORT_SYMBOL_GPL(plda_pcie_setup_iomems); + +static void plda_pcie_irq_domain_deinit(struct plda_pcie_rp *pcie) +{ + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); + irq_set_chained_handler_and_data(pcie->msi_irq, NULL, NULL); + irq_set_chained_handler_and_data(pcie->intx_irq, NULL, NULL); + + irq_domain_remove(pcie->msi.msi_domain); + irq_domain_remove(pcie->msi.dev_domain); + + irq_domain_remove(pcie->intx_domain); + irq_domain_remove(pcie->event_domain); +} + +int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops, + const struct plda_event *plda_event) +{ + struct device *dev = port->dev; + struct pci_host_bridge *bridge; + struct platform_device *pdev = to_platform_device(dev); + struct resource *cfg_res; + int ret; + + pdev = to_platform_device(dev); + + port->bridge_addr = + devm_platform_ioremap_resource_byname(pdev, "apb"); + + if (IS_ERR(port->bridge_addr)) + return dev_err_probe(dev, PTR_ERR(port->bridge_addr), + "failed to map reg memory\n"); + + cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + if (!cfg_res) + return dev_err_probe(dev, -ENODEV, + "failed to get config memory\n"); + + port->config_base = devm_ioremap_resource(dev, cfg_res); + if (IS_ERR(port->config_base)) + return dev_err_probe(dev, PTR_ERR(port->config_base), + "failed to map config memory\n"); + + bridge = devm_pci_alloc_host_bridge(dev, 0); + if (!bridge) + return dev_err_probe(dev, -ENOMEM, + "failed to alloc bridge\n"); + + if (port->host_ops && port->host_ops->host_init) { + ret = port->host_ops->host_init(port); + if (ret) + return ret; + } + + port->bridge = bridge; + plda_pcie_setup_window(port->bridge_addr, 0, cfg_res->start, 0, + resource_size(cfg_res)); + plda_pcie_setup_iomems(bridge, port); + plda_set_default_msi(&port->msi); + ret = plda_init_interrupts(pdev, port, plda_event); + if (ret) + goto err_host; + + /* Set default bus ops */ + bridge->ops = ops; + bridge->sysdata = port; + + ret = pci_host_probe(bridge); + if (ret < 0) { + dev_err_probe(dev, ret, "failed to probe pci host\n"); + goto err_probe; + } + + return ret; + +err_probe: + plda_pcie_irq_domain_deinit(port); +err_host: + if (port->host_ops && port->host_ops->host_deinit) + port->host_ops->host_deinit(port); + + return ret; +} +EXPORT_SYMBOL_GPL(plda_pcie_host_init); + +void plda_pcie_host_deinit(struct plda_pcie_rp *port) +{ + pci_stop_root_bus(port->bridge->bus); + pci_remove_root_bus(port->bridge->bus); + + plda_pcie_irq_domain_deinit(port); + + if (port->host_ops && port->host_ops->host_deinit) + port->host_ops->host_deinit(port); +} +EXPORT_SYMBOL_GPL(plda_pcie_host_deinit); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 443109d04d59..7b69891700a4 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -141,6 +141,11 @@ struct plda_event_ops { u32 (*get_events)(struct plda_pcie_rp *pcie); }; +struct plda_pcie_host_ops { + int (*host_init)(struct plda_pcie_rp *pcie); + void (*host_deinit)(struct plda_pcie_rp *pcie); +}; + struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; @@ -152,14 +157,20 @@ struct plda_msi { struct plda_pcie_rp { struct device *dev; + struct pci_host_bridge *bridge; struct irq_domain *intx_domain; struct irq_domain *event_domain; raw_spinlock_t lock; struct plda_msi msi; const struct plda_event_ops *event_ops; const struct irq_chip *event_irq_chip; + const struct plda_pcie_host_ops *host_ops; void __iomem *bridge_addr; + void __iomem *config_base; unsigned long events_bitmap; + int irq; + int msi_irq; + int intx_irq; int num_events; }; @@ -170,6 +181,8 @@ struct plda_event { int msi_event; }; +void __iomem *plda_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, + int where); int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port, const struct plda_event *event); @@ -178,4 +191,13 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, size_t size); int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, struct plda_pcie_rp *port); +int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops, + const struct plda_event *plda_event); +void plda_pcie_host_deinit(struct plda_pcie_rp *pcie); + +static inline void plda_set_default_msi(struct plda_msi *msi) +{ + msi->vector_phy = IMSI_ADDR; + msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS; +} #endif From patchwork Mon Jan 29 01:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp296930dyb; Sun, 28 Jan 2024 17:03:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXbQJKgdVfeazhgMYKkinNIwTSIBzbSERSdkaA8nTzFepkZuhEf87g0pSDrLXH+vsCr7vE X-Received: by 2002:a05:6358:5bd6:b0:178:6211:804 with SMTP id i22-20020a0563585bd600b0017862110804mr1666515rwf.47.1706490181312; Sun, 28 Jan 2024 17:03:01 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y6-20020a633206000000b005c5e24d4364si4754625pgy.428.2024.01.28.17.03.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:03:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42041-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-42041-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42041-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 10D38280EFF for ; Mon, 29 Jan 2024 01:03:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E71A101D5; Mon, 29 Jan 2024 01:02:10 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 48D5ED516; Mon, 29 Jan 2024 01:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490127; cv=fail; b=L6XfEM1lUW9tnSXWLDgfY3Sq+DIfX7b1mllwKJSBy1BtRrNxKWnlrxFCYli/OHO8ObZfuQCVWlC4BeDJMN7Qyb22RDcXXjSCFR4na0psDQ0l13ES4A9KIwqjQ24h9Efp1yrY58sG5R2n9cdB5tdIrS1hyVkLK5BJYA/bAJ83+5c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490127; c=relaxed/simple; bh=ezVb01ARc2sotdU/DiPWhdNByguKOhyFg0gEaneG3TQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rDLmo6OfKFc5s5/FGXtUb15GWz/SP3RZlxizpGiD2VXrqy2uDXSczHM6ix7MtIAMXbz5oiyZjwr1DO07AKkhHBiU7mlJ858cXF7K9C3x7cDqzdFs6fmnDWudwDlFWRb2NoNirJfFSzcWY6BvEU/OO6BZFM4hxGQWNubwCE0Qx30= 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.63 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=jzqJAzmk8vgXsQ502wiyfWoxYckhkM6LYYw7djcG37GlGMTbkS3xJ9ak7tRZKNY8RBae/gyYYE725fbVmyUpeaPB8XJuYtfnMxGTLSwaeF4S4MVyslKSJyqBn9mWCqR+9xtZum2GPRzgXQqlcIKgvLxkp5+zp+py7uOfJcQel/ucBZjPN0oDfjCMHrWLVMyFNtlwQaGp/KKU/ggfdAEgtet0UQiCQdapryKilzpLOOoombG3ngZ2wgdDBoxGBxwk/IrVbD169Sdrg4v1NnE/jfCFfZTJ8rI2f6EOX/6gOxEk0gFiaPqkIZPnrdL0ga2XQtj8ApoGwLl0xbS0AiTirQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dKh7nmkaSdzB3ghyDF6RJecUyhtYIfwA0UmbLzDOakc=; b=gE981KVI8esifrKHs9CkxdMNUDyvWLquLq8U5DCuJIxOhrZnHeHed0VLvmlPL2eZI+gyFmrWd81ZzzfgfYpUj/2J5HTp8m9FSFgg1kb7274d6gB8Rf6PSSX37e2LKxNpAfzbo4+rB2zWGv0bRvg21lUjmO8LBd2Wd+nh1gxovVYgUuRIOaZrUo/Ktof7ttaIFH2wJpZqQa74fIQo1UuW9swhot1J02MXKS1C6NMeAW8JrOKZqfjgbJiEe4J1rZiTN/CnuRmqfLCyh74Y12eb45tYd04taTl/FGWvr5+LE/AvUQRjOm91B9g7An5g/0SE/KJm61jOoWmdqf1e0KTBmA== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:55 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:55 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 19/22] dt-bindings: PCI: Add StarFive JH7110 PCIe controller Date: Mon, 29 Jan 2024 09:01:39 +0800 Message-Id: <20240129010142.3732-4-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: 865770c0-1e48-4d7c-9ec3-08dc2065e31b X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sLhsQLLflWbB8i/ovcbxgvc6m03VH0Y6/HcX34QPoDNO3XEEhxgzOB+k1VQHOiGO7PlxROw9FIaQgFRfCM1YEYXW3FXa0UMVSPvEysKaUBMyYvv7kVTxrk3jSQLzxpNhFpZi0kzNnBCRxi8MvtJITdlFVS9/jV2h4LDXnjm2Qhs+fAWOwBycQrsx0XqMy8SOw442KS9Bo3pvNBgKS4rDB3RI2ip5C6lvEIDGu/S1LgVoZfaMU4blaL1jz9Dnq1inhHV5+MHfFK758ytTgENRSPA2AAchpmgkTuBkK4aUp5WgHx8A7sz+Y5Vn1Gkkzr2kE9tE9kPh6V7k+qTMxM0PZhVQSF+/Wqvl2mNBWWl2eghWkE7wFFDhCPwU6iVNWoMtYfMXUQSN/u7+6CxflEwYualD9Ni1iQNL2mIz7to9V4buamuzLnmdZR79zTNZj+GYtgPe7iptdL69OqiulXlwO2Blkolk43Ci5JoXX9hGMaq/yeWQmIEuutItCBtaHFhz2ErRQzXfgd9TUBU9dHUcg6/pA1jpAL22eSaEXNtoslSPHV9LtAwMmIopPQtAci1j6SM+JJrU+GbcuACf2zweSg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(966005)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008)(449214003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rm8awwv9YKBRDHEHDxDhLDTdh5SUUmwwSs1CBjDK/J+/DAkJ4bs0hMUM3/MpaFirIRg3r4TiHafCwwDhq+m5m5/puhr/aXUcGhVUI8Y5kquEDIcqPpA1BRbPJ9/S8OxsuswirLz+x/zFnzLl4kBNvivJxJAjoRja3H1TUqG/gnfP3cS1z+wqw5ckX5AU4/9cInOayqSsrJiu3vVjTA88Y1bt73cTIiP9sSBxfiHiCAjAiQ3988tUMIt51hzNR/YNpuH3XW3Il9v40b4i4ODdTlayulgF31Slutua6WvUIpxtzPf4MS6rExHJhNy5EisrhTr7HAJx5/ye9q8Mqgt5bdq10wFYthyTut9bk6cCqqJpoA0Kt6e+sYKfu6qTbSzo7asf1QWmqljpyaDjhOQ0gfmzOaka6U7Ocuw5lvfXTvEwtmMU0IsM0iDo+Yp1X1fNIFNAQcipBIVQ4+a/peRJDTDjdZXtHCaSDdGoBatIBaVxZMJ4isQ49fz/5gZw6NYeNIigJwiWsPYEnQ80yPvvQtq7dXlV+MSdUnrqZvr8+PNYg6fAemssyNQBMZJ5Gb2t5rFLTpeYFKd8GqMSJFgP3k54Zx2W22dnt5+b4Miyj9lngID1mlnB8x5uDumHixg5rU10XecNdsH4PcEaFeKFAb/7wGOxTdjNVSfD87NIaGS0SnLzYH1Mtv6y/kLgxFFx3Xxi9AWEG+S2ypP9bZiGsc1oSmeSlTQFJNjke5tMMIgKEODjwjWFldhhmIr+PDoEGltWPeHOm0PsfEeZkOAvj+wJpWwiL34VzMTiWfmq7bVlC4rD4hVBWfHqL+xW3SKYNb8ywUbinpd/4F/pEMCRiS+0cU9hKaFHhOs5xgn3MLxNKq8etGGOwq0gbofnMJ7At87dKCJ2j/P8nxWrEqn8YXtBGDLoWTs5SX/ds+nYjPvbDcrD/1OEPDwh7PAf8AFdn8yWessm62PKF53wM31wqIZ98bwRpEjYELMGGvJ1D8ifSL6IUnqI9oktrfcJzqwVJwcZKjaUloHspcmqXNXwWOkXAwA+KVtUMjvitWbgpwYvHjXT0YlJMX1kkiLQn1zTXh71ZmQa9Yb37wiqQcJeNpwRPEWyPhTWbVCeBMine2k3tdl4pYrEmxCSwv0Pqp7vZCgvqED3CInOHOJ1ZSeNHBxKLzHK465uH1sIqqqPVQOkIhDcpPFSX4LiOKAQjDpAZq+eQCJIQOHFTmMJDQJaqs+qaw+kF1oCufgsJiXI2p96RBFYR0dsdAktB8qbdmn8aon2yM3uxbrtM5KPd7Hse+BcegsGl0mP/qWHd6IUhbIBraV+dXRmHNRC5WE+oldLvmAz/sNaAgVWy3ih3C67ci25ldBdquh+ShM7FrQ0nhhocPNRMV2UeOvjsKoHHK0lhMe1g2TB5PkutMYlyhQUPdws3VidMbyDAMM6YH4/O7rVk6pG0Zc3HH9jH3kGTXhbiKztBBMN/mps/BPG4vMGIKaijNalisEZyUjM7AWfUg3A6Bwp/YYvUcUb0t7lkHTdD7TlXiMxuAIzCTVncyKSJsoNE/sEHWswkeQLqDalFaT7Dt8zgOtn4sMHLlWB5Y73hakXD+X4DIHb5gvBVgI8IQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 865770c0-1e48-4d7c-9ec3-08dc2065e31b X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:55.4645 (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: mHOsxRetB6Ft5nNgGOGG0p561gphIVNLI9MHygRGeraqCCnjVjtRh0/KUeGeV27i/li8XkTGmAloYo+7zHsRbmOs7PjFhirQGfCGmM/ONAE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384648678726518 X-GMAIL-MSGID: 1789384648678726518 Add StarFive JH7110 SoC PCIe controller dt-bindings. JH7110 using PLDA XpressRICH PCIe host controller IP. Signed-off-by: Minda Chen Reviewed-by: Hal Feng Reviewed-by: Conor Dooley Reviewed-by: Rob Herring --- .../bindings/pci/starfive,jh7110-pcie.yaml | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml diff --git a/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml new file mode 100644 index 000000000000..67151aaa3948 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/starfive,jh7110-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PCIe host controller + +maintainers: + - Kevin Xie + +allOf: + - $ref: plda,xpressrich3-axi-common.yaml# + +properties: + compatible: + const: starfive,jh7110-pcie + + clocks: + items: + - description: NOC bus clock + - description: Transport layer clock + - description: AXI MST0 clock + - description: APB clock + + clock-names: + items: + - const: noc + - const: tl + - const: axi_mst0 + - const: apb + + resets: + items: + - description: AXI MST0 reset + - description: AXI SLAVE0 reset + - description: AXI SLAVE reset + - description: PCIE BRIDGE reset + - description: PCIE CORE reset + - description: PCIE APB reset + + reset-names: + items: + - const: mst0 + - const: slv0 + - const: slv + - const: brg + - const: core + - const: apb + + starfive,stg-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + The phandle to System Register Controller syscon node. + + perst-gpios: + description: GPIO controlled connection to PERST# signal + maxItems: 1 + + phys: + description: + Specified PHY is attached to PCIe controller. + maxItems: 1 + +required: + - clocks + - resets + - starfive,stg-syscon + +unevaluatedProperties: false + +examples: + - | + #include + soc { + #address-cells = <2>; + #size-cells = <2>; + + pcie@940000000 { + compatible = "starfive,jh7110-pcie"; + reg = <0x9 0x40000000 0x0 0x10000000>, + <0x0 0x2b000000 0x0 0x1000000>; + reg-names = "cfg", "apb"; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x30000000 0x0 0x30000000 0x0 0x08000000>, + <0xc3000000 0x9 0x00000000 0x9 0x00000000 0x0 0x40000000>; + starfive,stg-syscon = <&stg_syscon>; + bus-range = <0x0 0xff>; + interrupt-parent = <&plic>; + interrupts = <56>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc0 0x1>, + <0x0 0x0 0x0 0x2 &pcie_intc0 0x2>, + <0x0 0x0 0x0 0x3 &pcie_intc0 0x3>, + <0x0 0x0 0x0 0x4 &pcie_intc0 0x4>; + msi-controller; + clocks = <&syscrg 86>, + <&stgcrg 10>, + <&stgcrg 8>, + <&stgcrg 9>; + clock-names = "noc", "tl", "axi_mst0", "apb"; + resets = <&stgcrg 11>, + <&stgcrg 12>, + <&stgcrg 13>, + <&stgcrg 14>, + <&stgcrg 15>, + <&stgcrg 16>; + perst-gpios = <&gpios 26 GPIO_ACTIVE_LOW>; + phys = <&pciephy0>; + + pcie_intc0: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; + }; From patchwork Mon Jan 29 01:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp297048dyb; Sun, 28 Jan 2024 17:03:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYY0y/ObJifvtU0un2jAPbm8sNBReoEFtDhrxUQNLh5WPPdYqhOmkLsM+qIUzmPixlKoIV X-Received: by 2002:a05:6358:9490:b0:175:c16b:86f4 with SMTP id i16-20020a056358949000b00175c16b86f4mr2315554rwb.56.1706490199175; Sun, 28 Jan 2024 17:03:19 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s17-20020a17090a5d1100b002905bf5778esi4767771pji.181.2024.01.28.17.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:03:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42042-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-42042-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42042-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 0FF30B20E24 for ; Mon, 29 Jan 2024 01:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8850111A5; Mon, 29 Jan 2024 01:02:11 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 5D09DDF46; Mon, 29 Jan 2024 01:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490129; cv=fail; b=OkwhLaNWtdftmw79nLhrhSG8r/Dlz308upiESUFAeTgttihhExDSvJEuWvq57gVajP8UAlth+khKgvdhkem761wgHO3E8PuKzn+AuVmI/hmbDBlBZ0NnBh7O/TUa+hq2yS5xBDGnw9Gsjbj+KVvxbEG6BGdxnUr3mjWJd4Ff9Ag= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490129; c=relaxed/simple; bh=GQ7qXJo5MKWyH40Ex3HVziIEH7KxJvBXh0pR8GnF8Zc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SkceXI3jS4Je9umO2pOijQUfPkxPP4fdlQMw2VEcDaYiC/wGvD9bs3fI07zd7aCQJSaaaqmzpcqn3ghHfsZdV2ZQsO6xLkiMNbl3/DkW5uDxSvnZi2Fn8rlsKGB3WgWOVWfQmUAXuR9CRxLYfF0eI7GwBRNODmM8n+0igSsW+S4= 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.63 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=WxrF9/9m2PB/gfjwka9TrQLwkT+ORyx9gmq3b7O4ZvCXDgMzEkZf8Ogt7A1IgsxnqOFWYS+kjuESXALV2A+UVB4YsEEk4FTMipztzLt3l6M/JuadPaSPs+MATH3FfGCH0a1FpfyYEBrwPtpPiq1qbTTcPvpAnn8AmWo9jMVZUzEoWccQwOkJroSDn3ElQRCH2mrHEXRJwcsgwVKknDpsbF9DKLk/wUV8znj0yxj/PVLM20CtFAxD7JBtQTYV7NiWlAPZcthZ51CdkkwTOmpcPhJw4g/y94zqa3FmRzV2GbNddABzPXB3WZ1SuUAQJVKFEB/EDE4dFchqz6cPWh269w== 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=qP2Vis3RtKbGjNEiaOaeGcLrec2A0EyTP5CqIfMTsdw=; b=mx0gLEWqaUHP8XDwaELUGun7f4JMflc5Gn1vCZeNuzbBUVGymGwkk1CVxmzYieFrxDZPrGaTY4xXrgiOg7fsLJHsu7Cav9h91eOxFfhb82o2xGMVp71Kc9uMogsegkq8QsC0W6bfG/SvaZ7r6Ole/q8Eym4Im1hf8b65GWjSRIMNBl+jBVD2X24eoBruwLzP5VyhiSJPvZqmJwhS170ttKw892bpJkezl3Z0rELiyYUGv9FyTDxxaIzzfMKoINjOJa0HI/gMePKGzw3loL3TDLNse+bwEaTqDEb6wRwivMrAi8lkErpp2eTTnGxUMJluC2a4DCPOxZcRuXmYssFN8w== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:56 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:56 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 20/22] PCI: Add PCIE_RESET_CONFIG_DEVICE_WAIT_MS waiting time value Date: Mon, 29 Jan 2024 09:01:40 +0800 Message-Id: <20240129010142.3732-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: 88dc84b8-79df-4977-42c5-08dc2065e3e6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YbHjR+sc7i34CpQ2zI2ZOAe0s3hjmz+e+hym6hw8WnZJ9et21ToxdIUOoaK/yL9EqRKUml1VEXAMBvqwkN/1pHkqeNtaOnW7OVpDiL1bkQylEjm80YUgqMX074Du1kYXmGo8FCidG2fh4EqTPOO2rwFy75I+X8/eK8VYTDr/s+GN3apYFySaV5mjpMzbU8TLxcTlvCikTZIn5zyyILROebmZrID3iN2/tYP8FaIEvp4+NBON5sBwACFrvPP9ocxLoOcRBVSxQIvkCu/tlmL92qzcRMekUcOsf+Tovu/g9+nlShZV8X+uiLJM6bsT6V9t/sL5zHe2izqcbkRzzAAKWnJOrrShTfeYIMr2gSP9VXgsVJT2OyPg3QgnL6Q0YxfdVWu0R8QmimcwIqZB6kWwi7U2ktvy5ExtLrj0VUq/bN//p2+xVBt6kWdcqEABdPQVzuPKIZ9rRX0eHP/2HaaKwoT69xVEM6M+57hfVbXFgCKmej7ki2w+uACHUtFCHxGotbY4NGgimuo0+GC9nX2d9lt9fBqwBhirlJ1PADOJ00JTgEMO2NNpfrUXI02Cn4fU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IeHav3IBZf61OPSEXfVIzu7GPdrxrHMeFan3o4SWQbw+9KUfgaSDgFPZc8B5XwP2x7igWuQUIbG00Wip6ZuKftOty4+L1h+tsz2EG9ka1Sy+gpfyt7DuVUlDLFCXi2KWuFxfZj9WP1tSaLSnuS+PqY8gc4HhoLHkrlcmoDvM9KiUtPstGQxAXYk892DVmckMQy7IrCHHRt3b9zoY0Iq6g5CulO4D1cdMFXPlfl4G9mJI65IpBtJjZ6Xomp3vvT+S7kIAJAijEPLyOLnh12WBvlvq2eIEDYXalSrEGXSfcmBvd1k3as6xn1D0dpupdfnD3gFH7IT91cdEOgrzC7Yi1jH+B9vWWT5XPjQRUGiytRHtnorhVdptLzBfM+9/7oartHFLongQkdIbwhawLmSWx+IDJUZLHSueDelrrdnW6d1sULeQEWUaI5/7DXwPDXWyv9TnORX0SExziJjwWMkJApUByCRHdo5lN4x3xUyQoc+adg4EmKeoRbf+mWkddht/HdpdqgHWQDODbksljpoCRVf1VdxMe4kzg1p++K0EWsRXrGfjGohDn8yo2jIfmyTgZRFzO3L/wVOXamRX2KPTplP/ckZxQUCFOXxxiRLFFMGC7kfDGdSWVZZr2b/fk+86tPz5q2jVG3KsKaRRNWzw66y7HCz+yFLARbVmh8EalYXCt3p9hPicOhpV4pkCt9d4nfKj4Cqai3eaSAQhNSJyAAqe/VMjR/PExNCdElAtNmh7Qtzp1J9lqHhfEmt08GoHvmwN5Hch/jW6WQ8nXgA8HcIKj2gPQCAsmOpWWhGWj5hKliD5q+ydm5Beuhg2wp/C9Wm5GTC5zwAGXK/G6RuxFwmkI4JxO2UFncrYezsFOfHY0ZTh95RPFocEaaVmzG4hZp0i0j69tKI6Acn9OnDKFEdMXYapTcGlIVKiap2XNjaOwSrTyJ7dQcq3zAsP3EhFgXZTmPYkAuX5y3QH8omoA160CXf92OcPTEmh225SIDTxfNx5NVdkFMdbNP5XfWRLR076bA43B4DYQCTQZ5YZYjahjyCMgMxFM2WAHu3Dfdi0KOVdUdw6njnt3pwCThTqTIbcRcUZBA+W0f4R9t6aAHn588OmC64eAdkQZj8Fb6n11MPcPHRvt9vKmLzPygpKuqnJWwRPF8+MQfm5xST9FXvi9WOlGlt8JQq2BEDjKsxPqsTfHogUB8C7xsHyXFc0SPLCQO+bAlbcTmMSJuCfx59qxEz/WqFdcnBA9a2XLtsFz3g74LoFQYEFmN9sAdQBrj1MG6T6Is/SUMfzQKF1A6/Rmv4XQ+ONybGT87eh9aHi/wfP5xeZ3x6goHozBoeVYyR6tjNu5UZALKYZ3LxVYmu/pFU2npuPiVMQY/OGjriwSdJA7Yb2/GejFYK1c+GK0s8WkX1xmd15yyfVyEAMk//7zMyXLutK22pfH49D2Mn4ZlaJYgF6VeuwLKAWskHJ+qKN/ZwjqaA9iL4Oj4sqQ4MCDMg2N6vHdWe5N6gr2F1zCT5IHnzXfd/4XOsDoDXI3RWiodQma0EButr1fl0uE951mH3zjNfDBWhN7a6QOKUvj4bqmbb1WZiwluXB5cmFir88sDQJNJwikGasi1ZGjQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88dc84b8-79df-4977-42c5-08dc2065e3e6 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:56.8445 (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: OgZjEArD8s2KbjCFBFyjnKTjIVnRr6DMyOIkFOCUER0gqZ4Mf0M7ticWh6F8VDVWpRg6ylE5vPUSsKtsLW5zNeX4dgdlbIpfD2stVpBVcjs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384667462192437 X-GMAIL-MSGID: 1789384667462192437 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 2336a8d1edab..bd38b3a69d8b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -22,6 +22,22 @@ */ #define PCIE_PME_TO_L2_TIMEOUT_US 10000 +/* + * As described in PCI base specification r6.0, section 6.6.1 , there are two different use cases of the value: + * + * - "With a Downstream Port that does not support Link speeds greater + * than 5.0 GT/s, software must wait a minimum of 100 ms following exit + * from a Conventional Reset before sending a Configuration Request to + * the device immediately below that Port." + * + * - "With a Downstream Port that supports Link speeds greater than + * 5.0 GT/s, software must wait a minimum of 100 ms after Link training + * completes before sending a Configuration Request to the device + * immediately below that Port." + */ +#define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Mon Jan 29 01:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp301994dyb; Sun, 28 Jan 2024 17:17:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGeC92OGgG8ugB57kOwSbLh02HD2W9A4fQUa7VbBApWN/cUW5TMJivgriZ5d2i8vogU4xG X-Received: by 2002:a67:ebd4:0:b0:46b:1408:bbad with SMTP id y20-20020a67ebd4000000b0046b1408bbadmr1296625vso.14.1706491059856; Sun, 28 Jan 2024 17:17:39 -0800 (PST) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t4-20020a0562140c6400b0068c4761e134si2209747qvj.423.2024.01.28.17.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:17:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42052-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-42052-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42052-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 914421C21060 for ; Mon, 29 Jan 2024 01:17:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D639BEEDB; Mon, 29 Jan 2024 01:17:01 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 D70E0D512; Mon, 29 Jan 2024 01:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706491016; cv=fail; b=aeI2Bqe/Pk3a/zDwVE0laUosEM3vHdMz2JRYl484pYHg0JPBSTCl4fHRhAoOUcZp5vuqK7b8uRd+lt2YUhWCi3lLNqJKy5rOE8leGgLViodEgv8HTZoUnL5LytOAXd+hXo1nvMhcHw9cqDXnla01MhBDQv0bDTLVm7JvY/FkivQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706491016; c=relaxed/simple; bh=91W9ciCN2jGpnACYuHki8eBz8DNHRX/e4mBoe75tlX4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EYeK+LIYvesxid84k+4l3cCC8gls81gCqyXPN0DWWTjXHUH3PovA4FXYQ4sZTlkgBuq9tx6EO+hW3bGWE+TWZcx5EGi4PIepDHoIQowRhFVCyuBp9V3gco3PbKlueQoYa89MYvGr1xgzkhJccUGyn5CTmEWVpzNdW+QrAVcRXCE= 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.63 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=VhEogP5jg8jmAIgwqO2PwbVJjg9JaouLFEvng1IhXh9waW95cH60ATEiiwWl88YFeC8cKd8PkbHeoPrA0qEwUYI6GwapGdqvMEfUOqNcEsRSNx4uqqfjGmfW2ydGRT8gH0vOz15fuzD/tTIUf51u82KyAQZrTt6nckFIGc4tstyUNYOgZDbjMUDrQ/Zc8LwztQRw4g/SLMY45fxpCw9EXaxknLFhGNgmZ3/ZrZVShmCwwHlbE5/yq7d0kc0RDxfwqxY1mDik+bM4okE4Zkdalu8PpaEhYmMlqsqMO+swzrI5XF5mc2zudw+/D6ZhaUe1YyHewA5t+MAMv5HVcEiqEQ== 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=v7zFSbcRNWzakxCdWm0fsqT3+pKwO94pk0wGUy/uucY=; b=OeyiOk/ZL06tkkmL14DC/avjE1M7NxV8GmHKZOzSoi5EC2QZE8I7M1CCORV6CCKAUxxRyTdA6SsqYpEYQECc/+dZijd3d+0QFShSjWcFuISUCrNW9PW+bhaxndn+RI/rNODs93Qv7jIkF543sz9v6XRP/cJpAGJSjSW+5dcWoM1m77uHJYJwAtxREP9yfJatGpu4tWyXZMaPVYVaIOXEdvILKDUHWaNmo4O71mVqzUQK3Dx+a/MjRIOP7elXS64DpH877c3Y0c/M7ZcTeKPS/0Mo4GegSXcqKp70aQ6CzyoXQV81igKVU1STFABFYw7jfLGqTikdi1rqT56xcVSYsw== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:01:58 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:01:58 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 21/22] PCI: starfive: Add JH7110 PCIe controller Date: Mon, 29 Jan 2024 09:01:41 +0800 Message-Id: <20240129010142.3732-6-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: f40b0ed3-476a-4ca8-32c3-08dc2065e4de X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R2ucHFzxhIQyggMSasaVizdI0AE6J3nCVXjfbbjl+0KX7sSv7BbmyXmqpLf4YyHRBc5BXFzj5sfSpfObINu8XKjYTpx4OH1wjFMzyBWGXDtdwGRweKgg6eBmMqQlfJzp5BENgX5Nx7D73A+lr6kD8536/y/Wfsq5NXnpY1VJrsmHJxsBIVUxMmxeduwmnFTPfTi3ytg2osBnSEk6Je8kwzWeP5eL9gvzfoYMvYdcq/o4kTjlD2vLIHey1D9JVSkLxSFOMWQqfoq012IhTInjbt8z2wZ8jOYqmBM/0GlTgRaWbYhZoCSon8GGZgJLN+HopGttAXKeJ9/Qlf0QAqZKFcTpmHFJPc1RqJQcjHQzvM62JgmFFgTeGGq0GmKNUAklLwuPrY4hx4anNw6WCabM48Yz4OBqfBHbS/dUb1oNuvXpRRorlVhv65dAGWqA5UqqVY41J0Evxt0fcAeq/hC3lwnGFrNnBcVBzmPY7KR5q6JBmq4Ms+Qrh2PKe5mEwRUySxUShDEgbOzloja9EMkDASqkfi26n2dvNhQvRDqDbiqGNMN/5XQ9/th1OM/omyXT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(30864003)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JjISzC5qm4PZC7c7PF/C77+F5SZNB+Sf1k6vPfaLe1HgTzqZkcVGCYqQUV2k0mztkVOwd1dan4xpJpPLxBDG3DcnC3Mh7n8eYsftz+pxD7S2dM6rceGqvT08yaIqO/fwWjAR/ESNmwKmArHghZmqzFd2GKjLrhTSLtb1V9jAHvqsIhs8c8ppws0gn/hlXI1uigZ/pj9srMD7qaY+TY8Z8axAYFLC8GRx1ciM0qG1TltQauwjBbfaDRZIBGKWt+QTysR+5oaZm677hkq+bCCCdirjqKBIqbDFsJDc+C1e/BQxhYrQnPSXTWoXEklmpIZXQ6f3RbDHW47tCmly7rkoKwThPKHoE976F8Lmln6RK/8pnPerMdNpaLsvSNjW7mgu6NlQVQnGDLXNyk6VA/gk7NsO8itDvVEAbS3sBjxPRcQ+1MP6qlg8UFmlkhsJjIwndNHVtP8RyewYVCVob68N7PQSq2BC/fQvov5u5brD29OCZfFTOAwEH0q3yG5Bi8yVxM1Bkw6xHCtJyVdqKf1OMavZRw/6TmU/HIx5/8fgMcXFDq5o2A+smjEvrKYni0VIzFnS5IOJx5X5QoEvPPfgVvoxvzoDnKSgItf5mO+P7lU4PF7vMVQDb13LSdQDYpzvyfNT4RiJySd5862+BKtmqIcNiqRAnAAHxpuzsrsIzUkQksf3NFkRw08js14oXebnTOZ/XIVFu1DIQzzbBdqY2yVqTDNJr+dx9RCqvzkc5cnNmZJ+d312uL1nQfiJO4pLtJQA72UF3fDVg1kutjOOZ5EGzgv7v3hQgvAhvE2CnXqQ6DmiK6Khr435K81mxUeJYpilo/g0+a7/OOt8Ynmu8fLOZk9LRTEhdfzDvKjtagLOUCBKYZnoB1HbVrdgsq8iTR+EstY6upAZX358LA8WWRCGP6FomDp+IADMfPAyLMl0FyhZER+HkAXhiTtPq9lpyxXdiMGWiG4UXuiQCBIwb5B8LFNN+K9+UaLLOCw9eDx0l7bX6LgaYqE+8X5dkF132LAkNS7quLkgNNAJ7g5+1WSDmTLcdFCpEAOVeiCa0Q94HwgJy78iyCxOmvwY4ILlI7GZgo4SKewDZsLangdSPH3qLYKeQJfEwM6kBnWbG6F3MiDHqD6vKDmvXlBXXLXi6/T1r7eZGVAkXxfgBWNVcO/5SHc3Ety/YD+yy3LAXQQRj/X/n8pgzalgahg2ZpXphCRLSOC2Wj1CzbaW9oppijB+EPVKAb5iPENXKF8q3XYAkjFEnrmkHE7zgB0HwJXqUkYLZAwqC8S7uzokfTO9CnVdq5a+IXlDydsXRMIz7MTxey9j2y4HCbMygTHgUfrIDnnXB7VfYR+LG1mpwm6+2UH08F0jCzGjpbvdw5zd5tr7y4GsQvpzH2ywUeyFZFePlig5NbF4UwvBcBWYxVn+oz1uHwZo62ANWwqRzMQAnxHo59IZ7+bIWMPltHmdSGfzIRN8Opfs3R2q/5NkD4hsUOhO55XRO8v8xjRIVL6e/0y8KqwhDKDSjv0YWqJ86l43coeRDyLYsJr+vVZrtoWVfcOu10kU5gbg++BSgOW3gbSPqaPzrnRoa2Q4c2K6llatI9N17y0ExA17MM85i6xzug== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: f40b0ed3-476a-4ca8-32c3-08dc2065e4de X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:58.5251 (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: +JyA5E9vWP1c2yunEUTuf+99oS4XsM8jE/YKtaD9C5mzOjUxYBVPsuVlbpcj6PvuHHxOSa35aYeLqq4OE9VWBEm9FG+VYEI/Cx7TZJf6rms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789385569595889031 X-GMAIL-MSGID: 1789385569595889031 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 3b8d7ba12807..2cf2ca64d89a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17066,6 +17066,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/socionext,uniphier-pcie* F: drivers/pci/controller/dwc/pcie-uniphier* +PCIE DRIVER FOR STARFIVE JH71x0 +M: Kevin Xie +L: linux-pci@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/starfive* +F: drivers/pci/controller/plda/pcie-starfive.c + PCIE DRIVER FOR ST SPEAR13XX M: Pratyush Anand L: linux-pci@vger.kernel.org diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig index e54a82ee94f5..c0e14146d7e4 100644 --- a/drivers/pci/controller/plda/Kconfig +++ b/drivers/pci/controller/plda/Kconfig @@ -15,4 +15,16 @@ config PCIE_MICROCHIP_HOST Say Y here if you want kernel to support the Microchip AXI PCIe Host Bridge driver. +config PCIE_STARFIVE_HOST + tristate "StarFive PCIe host controller" + depends on PCI_MSI && OF + depends on ARCH_STARFIVE || COMPILE_TEST + select PCIE_PLDA_HOST + help + Say Y here if you want to support the StarFive PCIe controller in + host mode. StarFive PCIe controller uses PLDA PCIe core. + + If you choose to build this driver as module it will be dynamically + linked and module will be called pcie-starfive.ko. + endmenu diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile index 4340ab007f44..0ac6851bed48 100644 --- a/drivers/pci/controller/plda/Makefile +++ b/drivers/pci/controller/plda/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PCIE_PLDA_HOST) += pcie-plda-host.o obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o +obj-$(CONFIG_PCIE_STARFIVE_HOST) += pcie-starfive.o diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 7b69891700a4..04e385758a2f 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -10,10 +10,20 @@ #define PLDA_MAX_NUM_MSI_IRQS 32 /* PCIe Bridge Phy Regs */ +#define GEN_SETTINGS 0x80 +#define RP_ENABLE 1 +#define PCIE_PCI_IDS_DW1 0x9c +#define IDS_CLASS_CODE_SHIFT 16 +#define REVISION_ID_MASK GENMASK(7, 0) +#define CLASS_CODE_ID_MASK GENMASK(31, 8) #define PCIE_PCI_IRQ_DW0 0xa8 #define MSIX_CAP_MASK BIT(31) #define NUM_MSI_MSGS_MASK GENMASK(6, 4) #define NUM_MSI_MSGS_SHIFT 4 +#define PCI_MISC 0xb4 +#define PHY_FUNCTION_DIS BIT(15) +#define PCIE_WINROM 0xfc +#define PREF_MEM_WIN_64_SUPPORT BIT(3) #define IMASK_LOCAL 0x180 #define DMA_END_ENGINE_0_MASK 0x00000000u @@ -65,6 +75,8 @@ #define ISTATUS_HOST 0x18c #define IMSI_ADDR 0x190 #define ISTATUS_MSI 0x194 +#define PMSG_SUPPORT_RX 0x3f0 +#define PMSG_LTR_SUPPORT BIT(2) /* PCIe Master table init defines */ #define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u @@ -86,6 +98,8 @@ #define PCIE_TX_RX_INTERFACE 0x00000000u #define PCIE_CONFIG_INTERFACE 0x00000001u +#define CONFIG_SPACE_ADDR_OFFSET 0x1000u + #define ATR_ENTRY_SIZE 32 enum plda_int_event { @@ -200,4 +214,59 @@ static inline void plda_set_default_msi(struct plda_msi *msi) msi->vector_phy = IMSI_ADDR; msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS; } -#endif + +static inline void plda_pcie_enable_root_port(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + GEN_SETTINGS); + value |= RP_ENABLE; + writel_relaxed(value, plda->bridge_addr + GEN_SETTINGS); +} + +static inline void plda_pcie_set_standard_class(struct plda_pcie_rp *plda) +{ + u32 value; + + /* set class code and reserve revision id */ + value = readl_relaxed(plda->bridge_addr + PCIE_PCI_IDS_DW1); + value &= REVISION_ID_MASK; + value |= (PCI_CLASS_BRIDGE_PCI << IDS_CLASS_CODE_SHIFT); + writel_relaxed(value, plda->bridge_addr + PCIE_PCI_IDS_DW1); +} + +static inline void plda_pcie_set_pref_win_64bit(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCIE_WINROM); + value |= PREF_MEM_WIN_64_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PCIE_WINROM); +} + +static inline void plda_pcie_disable_ltr(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PMSG_SUPPORT_RX); + value &= ~PMSG_LTR_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PMSG_SUPPORT_RX); +} + +static inline void plda_pcie_disable_func(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCI_MISC); + value |= PHY_FUNCTION_DIS; + writel_relaxed(value, plda->bridge_addr + PCI_MISC); +} + +static inline void plda_pcie_write_rc_bar(struct plda_pcie_rp *plda, u64 val) +{ + void __iomem *addr = plda->bridge_addr + CONFIG_SPACE_ADDR_OFFSET; + + writel_relaxed(lower_32_bits(val), addr + PCI_BASE_ADDRESS_0); + writel_relaxed(upper_32_bits(val), addr + PCI_BASE_ADDRESS_1); +} +#endif /* _PCIE_PLDA_H */ diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c new file mode 100644 index 000000000000..9bb9f0e29565 --- /dev/null +++ b/drivers/pci/controller/plda/pcie-starfive.c @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * PCIe host controller driver for StarFive JH7110 Soc. + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../pci.h" + +#include "pcie-plda.h" + +#define PCIE_FUNC_NUM 4 + +/* system control */ +#define STG_SYSCON_PCIE0_BASE 0x48 +#define STG_SYSCON_PCIE1_BASE 0x1f8 + +#define STG_SYSCON_AR_OFFSET 0x78 +#define STG_SYSCON_AXI4_SLVL_AR_MASK GENMASK(22, 8) +#define STG_SYSCON_AXI4_SLVL_PHY_AR(x) FIELD_PREP(GENMASK(20, 17), x) +#define STG_SYSCON_AW_OFFSET 0x7c +#define STG_SYSCON_AXI4_SLVL_AW_MASK GENMASK(14, 0) +#define STG_SYSCON_AXI4_SLVL_PHY_AW(x) FIELD_PREP(GENMASK(12, 9), x) +#define STG_SYSCON_CLKREQ BIT(22) +#define STG_SYSCON_CKREF_SRC_MASK GENMASK(19, 18) +#define STG_SYSCON_RP_NEP_OFFSET 0xe8 +#define STG_SYSCON_K_RP_NEP BIT(8) +#define STG_SYSCON_LNKSTA_OFFSET 0x170 +#define DATA_LINK_ACTIVE BIT(5) + +/* Parameters for the waiting for link up routine */ +#define LINK_WAIT_MAX_RETRIES 10 +#define LINK_WAIT_USLEEP_MIN 90000 +#define LINK_WAIT_USLEEP_MAX 100000 + +struct starfive_jh7110_pcie { + struct plda_pcie_rp plda; + struct reset_control *resets; + struct clk_bulk_data *clks; + struct regmap *reg_syscon; + struct gpio_desc *power_gpio; + struct gpio_desc *reset_gpio; + struct phy *phy; + + unsigned int stg_pcie_base; + int num_clks; +}; + +/* + * The BAR0/1 of bridge should be hidden during enumeration to + * avoid the sizing and resource allocation by PCIe core. + */ +static bool starfive_pcie_hide_rc_bar(struct pci_bus *bus, unsigned int devfn, + int offset) +{ + if (pci_is_root_bus(bus) && !devfn && + (offset == PCI_BASE_ADDRESS_0 || offset == PCI_BASE_ADDRESS_1)) + return true; + + return false; +} + +static int starfive_pcie_config_write(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) + return PCIBIOS_SUCCESSFUL; + + return pci_generic_config_write(bus, devfn, where, size, value); +} + +static int starfive_pcie_config_read(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 *value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) { + *value = 0; + return PCIBIOS_SUCCESSFUL; + } + + return pci_generic_config_read(bus, devfn, where, size, value); +} + +static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie, + struct device *dev) +{ + int domain_nr; + + pcie->num_clks = devm_clk_bulk_get_all(dev, &pcie->clks); + if (pcie->num_clks < 0) + return dev_err_probe(dev, pcie->num_clks, + "failed to get pcie clocks\n"); + + pcie->resets = devm_reset_control_array_get_exclusive(dev); + if (IS_ERR(pcie->resets)) + return dev_err_probe(dev, PTR_ERR(pcie->resets), + "failed to get pcie resets"); + + pcie->reg_syscon = + syscon_regmap_lookup_by_phandle(dev->of_node, + "starfive,stg-syscon"); + + if (IS_ERR(pcie->reg_syscon)) + return dev_err_probe(dev, PTR_ERR(pcie->reg_syscon), + "failed to parse starfive,stg-syscon\n"); + + pcie->phy = devm_phy_optional_get(dev, NULL); + if (IS_ERR(pcie->phy)) + return dev_err_probe(dev, PTR_ERR(pcie->phy), + "failed to get pcie phy\n"); + + domain_nr = of_get_pci_domain_nr(dev->of_node); + + if (domain_nr < 0 || domain_nr > 1) + return dev_err_probe(dev, -ENODEV, + "failed to get valid pcie domain\n"); + + if (domain_nr == 0) + pcie->stg_pcie_base = STG_SYSCON_PCIE0_BASE; + else + pcie->stg_pcie_base = STG_SYSCON_PCIE1_BASE; + + pcie->reset_gpio = devm_gpiod_get_optional(dev, "perst", + GPIOD_OUT_HIGH); + if (IS_ERR(pcie->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio), + "failed to get perst-gpio\n"); + + pcie->power_gpio = devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(pcie->power_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->power_gpio), + "failed to get power-gpio\n"); + + return 0; +} + +static struct pci_ops starfive_pcie_ops = { + .map_bus = plda_pcie_map_bus, + .read = starfive_pcie_config_read, + .write = starfive_pcie_config_write, +}; + +static int starfive_pcie_clk_rst_init(struct starfive_jh7110_pcie *pcie) +{ + struct device *dev = pcie->plda.dev; + int ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) + return dev_err_probe(dev, ret, "failed to enable clocks\n"); + + ret = reset_control_deassert(pcie->resets); + if (ret) { + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + dev_err_probe(dev, ret, "failed to deassert resets\n"); + } + + return ret; +} + +static void starfive_pcie_clk_rst_deinit(struct starfive_jh7110_pcie *pcie) +{ + reset_control_assert(pcie->resets); + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); +} + +static bool starfive_pcie_link_up(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + int ret; + u32 stg_reg_val; + + ret = regmap_read(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_LNKSTA_OFFSET, + &stg_reg_val); + if (ret) { + dev_err(pcie->plda.dev, "failed to read link status\n"); + return false; + } + + return !!(stg_reg_val & DATA_LINK_ACTIVE); +} + +static int starfive_pcie_host_wait_for_link(struct starfive_jh7110_pcie *pcie) +{ + int retries; + + /* Check if the link is up or not */ + for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + if (starfive_pcie_link_up(&pcie->plda)) { + dev_info(pcie->plda.dev, "port link up\n"); + return 0; + } + usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); + } + + return -ETIMEDOUT; +} + +static int starfive_pcie_enable_phy(struct device *dev, + struct starfive_jh7110_pcie *pcie) +{ + int ret; + + if (!pcie->phy) + return 0; + + ret = phy_init(pcie->phy); + if (ret) + return dev_err_probe(dev, ret, + "failed to initialize pcie phy\n"); + + ret = phy_set_mode(pcie->phy, PHY_MODE_PCIE); + if (ret) { + dev_err_probe(dev, ret, "failed to set pcie mode\n"); + goto err_phy_on; + } + + ret = phy_power_on(pcie->phy); + if (ret) { + dev_err_probe(dev, ret, "failed to power on pcie phy\n"); + goto err_phy_on; + } + + return 0; + +err_phy_on: + phy_exit(pcie->phy); + return ret; +} + +static void starfive_pcie_disable_phy(struct starfive_jh7110_pcie *pcie) +{ + phy_power_off(pcie->phy); + phy_exit(pcie->phy); +} + +static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + + starfive_pcie_clk_rst_deinit(pcie); + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 0); + starfive_pcie_disable_phy(pcie); +} + +static int starfive_pcie_host_init(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + struct device *dev = plda->dev; + int ret; + int i; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_RP_NEP_OFFSET, + STG_SYSCON_K_RP_NEP, STG_SYSCON_K_RP_NEP); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CKREF_SRC_MASK, + FIELD_PREP(STG_SYSCON_CKREF_SRC_MASK, 2)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CLKREQ, STG_SYSCON_CLKREQ); + + ret = starfive_pcie_clk_rst_init(pcie); + if (ret) + return ret; + + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 1); + + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + + /* Disable physical functions except #0 */ + for (i = 1; i < PCIE_FUNC_NUM; i++) { + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AR(i)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AW(i)); + + plda_pcie_disable_func(plda); + } + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, 0); + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, 0); + + plda_pcie_enable_root_port(plda); + plda_pcie_write_rc_bar(plda, 0); + + /* PCIe PCI Standard Configuration Identification Settings. */ + plda_pcie_set_standard_class(plda); + + /* + * The LTR message forwarding of PCIe Message Reception was set by core + * as default, but the forward id & addr are also need to be reset. + * If we do not disable LTR message forwarding here, or set a legal + * forwarding address, the kernel will get stuck after the driver probe. + * To workaround, disable the LTR message forwarding support on + * PCIe Message Reception. + */ + plda_pcie_disable_ltr(plda); + + /* Prefetchable memory window 64-bit addressing support */ + plda_pcie_set_pref_win_64bit(plda); + + /* + * Ensure that PERST has been asserted for at least 100 ms, + * the sleep value is T_PVPERL from PCIe CEM spec r2.0 (Table 2-4) + */ + msleep(100); + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 0); + + /* + * With a Downstream Port (<=5GT/s), software must wait a minimum + * of 100ms following exit from a conventional reset before + * sending a configuration request to the device. + */ + msleep(PCIE_RESET_CONFIG_DEVICE_WAIT_MS); + + if (starfive_pcie_host_wait_for_link(pcie)) + dev_info(dev, "port link down\n"); + + return 0; +} + +static const struct plda_pcie_host_ops sf_host_ops = { + .host_init = starfive_pcie_host_init, + .host_deinit = starfive_pcie_host_deinit, +}; + +static const struct plda_event stf_pcie_event = { + .intx_event = EVENT_PM_MSI_INT_INTX, + .msi_event = EVENT_PM_MSI_INT_MSI +}; + +static int starfive_pcie_probe(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie; + struct device *dev = &pdev->dev; + struct plda_pcie_rp *plda; + int ret; + + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) + return -ENOMEM; + + plda = &pcie->plda; + plda->dev = dev; + + ret = starfive_pcie_parse_dt(pcie, dev); + if (ret) + return ret; + + plda->host_ops = &sf_host_ops; + plda->num_events = PLDA_MAX_EVENT_NUM; + /* mask doorbell event */ + plda->events_bitmap = GENMASK(PLDA_INT_EVENT_NUM - 1, 0) + & ~BIT(PLDA_AXI_DOORBELL) + & ~BIT(PLDA_PCIE_DOORBELL); + plda->events_bitmap <<= PLDA_NUM_DMA_EVENTS; + ret = plda_pcie_host_init(&pcie->plda, &starfive_pcie_ops, + &stf_pcie_event); + if (ret) + return ret; + + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + platform_set_drvdata(pdev, pcie); + + return 0; +} + +static void starfive_pcie_remove(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie = platform_get_drvdata(pdev); + + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); + plda_pcie_host_deinit(&pcie->plda); + platform_set_drvdata(pdev, NULL); +} + +static int starfive_pcie_suspend_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + starfive_pcie_disable_phy(pcie); + + return 0; +} + +static int starfive_pcie_resume_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) { + dev_err(dev, "failed to enable clocks\n"); + starfive_pcie_disable_phy(pcie); + return ret; + } + + return 0; +} + +static const struct dev_pm_ops starfive_pcie_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(starfive_pcie_suspend_noirq, + starfive_pcie_resume_noirq) +}; + +static const struct of_device_id starfive_pcie_of_match[] = { + { .compatible = "starfive,jh7110-pcie", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, starfive_pcie_of_match); + +static struct platform_driver starfive_pcie_driver = { + .driver = { + .name = "pcie-starfive", + .of_match_table = of_match_ptr(starfive_pcie_of_match), + .pm = pm_sleep_ptr(&starfive_pcie_pm_ops), + }, + .probe = starfive_pcie_probe, + .remove_new = starfive_pcie_remove, +}; +module_platform_driver(starfive_pcie_driver); + +MODULE_DESCRIPTION("StarFive JH7110 PCIe host driver"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Jan 29 01:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 193202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp297152dyb; Sun, 28 Jan 2024 17:03:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFE1CWbCkP8LKKQCfgclfh7nevGeQBMNV2uYUj5yTS8BB8sCSUWUAh+QZQ265fqTqQHrO5C X-Received: by 2002:a05:6402:1a33:b0:55a:34e1:4d13 with SMTP id be19-20020a0564021a3300b0055a34e14d13mr3274288edb.17.1706490212774; Sun, 28 Jan 2024 17:03:32 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d25-20020a056402401900b0055edc52f437si1240581eda.511.2024.01.28.17.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:03:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42043-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-42043-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42043-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 3DFBE1F232C8 for ; Mon, 29 Jan 2024 01:03:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 850F814A85; Mon, 29 Jan 2024 01:02:14 +0000 (UTC) Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2063.outbound.protection.partner.outlook.cn [139.219.17.63]) (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 3AB05F515; Mon, 29 Jan 2024 01:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490131; cv=fail; b=ex6QUsvx5DZmR0ZwwJEE9FOOX+oM7r0dxwnvGgU+mmbyqF5Qp2kD54mApgSutjFdnHcvcLJ8iDoRriQbcKRl05nDvOh5A8so5WAyKzeDbmAs+0VBFS7hALbfMUkM0ZBzZ8Va3hcckAOPpYkiyJk4CWyGpBwG9OM5m9CyH5BJVfs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706490131; c=relaxed/simple; bh=S2lDL0gD7pPak+dReXlI6JFdBr+tBRJUw89XXRjBFG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ovnQVjn8fuW+Dze6qsOmpUFy3pqFeY6b03yOZ+NYtmm2TmGyI/h/gr5QFICxz3QaCd8MXKoyllkQTfEgcs53elOwTVIxlIMqDgZGeG58ZG6y745XxUliXL9VgqGpkLTONpMeQNQA+es60bYOKdXL33U42nlouFE3r0pcDad7ZsA= 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.63 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=BcisV9TWTTWpRcb63z0QsLALaQRNlrFTYsrmbVa1h9P+t76y7/YqJOyhL3IFeB4boTp3B2xJ0uL6pPXuc1x01XJ1kDWfhrvJR4Gvlquvk9coXQPL01gpHdJqV3QyYEAwV5YDnqlnpS6D2Uv35Kwt3J37vfiSAfGTzsGl+nJo0cdol8Z+GsoNRmB44q07KMuAOVHDOZVSc+hayKL0RYvoyojGW7XaxxNEKSNJugd/92BbIFKYGU/3CDwtJKGpDR+PiE5NaxSk1kCDf2bapH/dXseZf0ZvFFdWqCFeXQj6jRAqkMjdQfKeLPBvpcBAyUd3AUaIf4sWjLOEl5xYB2cIAA== 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=D2FR9lBFHVzrWAZjiGqeE5REc0AOQqhmlEZH6PMg33YUT7YgE9XwvJ3o3JOsuw+1hDlg/2TbXZdXU/1ByFh6Uor/0ueqKQdpjMN5UJq/IFD0/pZOwxwdfha69n3G8EIdIDWn0q+MGehen0H7VPZiYj01rqrZ11kxop+VEI8GH+nko+nnjeLTFJiqlcR0BfxuNn5c/0UgMlZPNShAHBsSIeK3TkuFhZNlrPR8BAT1eD/ms1VztwhoTxUFlzHMDppvCGf+PoFnrjG23bJX295kcm6YQ97IyQTbdudcp4obcfvOwfUtiMgjaQqdv71IBMOVwo0CH12wJehItvx65mqOEg== 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 BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) by BJXPR01MB0552.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:13::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Mon, 29 Jan 2024 01:02:00 +0000 Received: from BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6]) by BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn ([fe80::1ea1:19d5:efef:6fc6%4]) with mapi id 15.20.7228.029; Mon, 29 Jan 2024 01:02:00 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14,RESEND 22/22] riscv: dts: starfive: add PCIe dts configuration for JH7110 Date: Mon, 29 Jan 2024 09:01:42 +0800 Message-Id: <20240129010142.3732-7-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240129010142.3732-1-minda.chen@starfivetech.com> References: <20240129010142.3732-1-minda.chen@starfivetech.com> X-ClientProxiedBy: SH0PR01CA0003.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:5::15) To BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:18::12) 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: BJXPR01MB0855:EE_|BJXPR01MB0552:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d90048d-25de-4956-adeb-08dc2065e5c0 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XChOFFnG9VdyXuQFXksUq9g1AAebnNe2piVREg3ZUiJ3LXkVZTVow53Qqi/AfFAJfjHzrPIiFTuYBJXUdYjoLpJeMPXHK5hGxIG+k203NBdpdNQwDmYgyhtTHR2rzSjsJu9iTLnqT27lIfhVhm4EljsFPRtjk6PBE2aYv1HJjd81M6H5f1mJm4fg4MhuWsIKoiblXR5UVQWoi3GULkTMhPda2+VY9CakdqzoOQClCHt0yfhxc9bk7MgpkeqgZkQg7aZ3C+CoFSE3N3shTsiqY7QrcVQQF2CEXoMczYV/QhQ3ZmpxIMeTPK9k+Zgwc2/v5+DzoqCa33c8I1STtzuXVakFDQ3D2C5IW4bGl9XqAxtDZwiyd91/6Ak8jpPQiDBFRmOqrttaql4dbOY1jwSDzpudYYMsSfxR61fsmqgM7C4ktWpkCDD/li7/647Z0tKOBvYpNdDkN+DTZ68yNDhe7YO/J+ewgyZ/vAByvuI/Wq7QTiamc/ROFqa7CEW4HPJjT6DAFtlQeE1dx+3t6qoxbd5mtmDbbbXUdf31DwFGKJmLgp/v407NT4DUf7BZvnBY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39830400003)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(107886003)(2616005)(1076003)(41300700001)(26005)(41320700001)(40180700001)(40160700002)(38350700005)(508600001)(6666004)(83380400001)(54906003)(52116002)(36756003)(38100700002)(2906002)(66476007)(5660300002)(8936002)(86362001)(66946007)(110136005)(44832011)(4326008)(7416002)(8676002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: suqYYL6Z0Elz+9dTUfe35YjsAt1H45+EFUtbQDgoNuWAkE3baJU3eZ2Bn+N0wWfNloboxBTInLduckNtbFOUqPfNgoz0YUEiJY0o/w48KtuykZLw5yWsKpX2+2JAQahF6Q8GrUMIV8sWua/AmNnHuH8sbY5AqeUZAvDBuzJAU6JxMqp9J7aAay38D6du+DVtxuCICuIC2dwl91Ajc32tmQxvcD6iOZOPS6jsCLgCUqMjkPUkHhvJZFew4kMDAqiuwNhXM2ZIIyX4Ff4VURGgCTw5wjgsmVBocELAci3WcCHYhUU1o2PyhszB1ODsUX9lRsNWFhpK9Vq5FsqFTaYQCegZeTInZZkQnuKPamANDq5K+luKPDmOF3CL0Mdhv9T4wyilgvMuNudhzatsH+Z3/sS0vsEZ6IZ2nRXBqDo87UHZM65T05wRIu+Xb3BtIJtQNoNLW1PP9OaQJBdZ9eosRbc82Md4U+cY8zLITwN6SFXJbDhOrlvC8yRIGMlnwih0GEWOddNQA3SP10lugTt3C2lTsusUOgw0Zz/SOV4jK6YrHkH+//r5UpXg5MSt/v6Dl6qIZzJTgAtsf6VUp4KK9JG2Z5SzomDgnsviGAk5MaL9USlTLF3yQEQxHfVOS3rgPTQBgduBOHnorGM+4IpO0OTmqt9UgPrMh2qyl+HraY15EGxQqiipm69MBToQkwpHxLWHE7/KckzdaRaSmkh5DIeY7L494iTx4sgwlaL4bl0Q9W18GsC4VvRlePSce6G4I9QOw06ngg/RRQyIoM7INaO+On2kK1bpeeb4pkerac+t0fhij9Ktfw++iXfVvVnO/l1TvWy00BSjvAtfNPqa+vwzXFMSJ2k3IGVEvlqfPG9AFhBAC8cY7GfoA/2EpS0Stu33skunBpZQ7/eEWuGHQqF0kbX4uCMyUGHIjT2csJqgVYvAfpk/9J3aEEMlj49l4VOJhbJeiKAmTlMmDIAVux/yrSM4hJDzNwKWV3olAcrcDEjxnN9KzG9sFZ62OHbIL0H2WMgimyAh9kM0Hqh3u5BDm3iysnPAUaujqAcfXP56lr9V1Qf8BC7wFltq/5xDCEhttv27frKt0UPRXqLnwulukR34Xtace84/PduyvElM7rogUs3AK/CPNrbLXfmsCe1bRUc40KgnJb0yFHQdG2cZQAME6zJDfcpdIGAH8RTraNddC9tWAf67JMuVr6qFtCt0RQ27ZElp369DkjgScDYOzXIZ0CsNwRR/pnb7vTtm0GOEirFuAt1IQH9r4nmufQOr16JS8K0VGmXtYxa1Fq22E1QgwICEKWZbC4VZWZct52C7vobJlF9DF9FpVCk61nt3fqVcztF1wPShNpm4d0MwAjnHQidqZbz5nE1tifHfGGMjN98N2VI2YMURsTRIz/2VZehYCHKsSio70kdEAIQUsVvhLtgDDnxJxJyAagHrWan713UjWj+LBme6KBSBWborE1uKkxgYqWT6uY7ouDaoSmV+KVDYdO8ugj3ARdjDEbMo0eZcLohPv6Ro7n7+tmoxFH3zuGf7A7arztu/wM1D65fo63+nN50E7r429gdU4DEGDALP19NVYTdh3lC7SsKhfI69OXhxS9BxFxF4Yw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d90048d-25de-4956-adeb-08dc2065e5c0 X-MS-Exchange-CrossTenant-AuthSource: BJXPR01MB0855.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2024 01:01:59.9357 (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: /9BAYzmTeGYnWOATaiTflZkXeKGzcHvwTchJ0849LZF750nI99rgDJ9kYH6ONCYWE5pke3lqAjt+XGtWaZrVr34UW3SxDnOpMdLUzXj83CQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BJXPR01MB0552 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789384681000724565 X-GMAIL-MSGID: 1789384681000724565 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; + }; + }; }; };