From patchwork Tue Sep 6 19:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 603155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14E8DC54EE9 for ; Tue, 6 Sep 2022 19:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbiIFTlY (ORCPT ); Tue, 6 Sep 2022 15:41:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbiIFTlX (ORCPT ); Tue, 6 Sep 2022 15:41:23 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80043.outbound.protection.outlook.com [40.107.8.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2252A80B6A; Tue, 6 Sep 2022 12:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aMoMldP/IF7728bFP0KesUfF955eK0gZ+oOn1k1gFJtO1O0K+ow2WRPvF45nANvam1QfWbHLTOWICA2fOb95VVszbgNsEbZ10dV+k0Cmf1YcC03NqYQwrc3LpyIZTeopt4ZUdtIr+MZsdhCNiuYjvjJIHPTC7GqJpqFMresGAaXotkvKWd1RIumIVfQwmYumqxtTH2zY/0d1lhftZ4UAc0GJjEU+Z5F2cI2pNLCBuNMD0hACrsMD+m9xvm1Bn8oT4UOTxxxFRLkTGyYsZP2G7sE4nps96rfJf3Qy25wFJot5+wO0g9GhAoOCUckJzyKZncaff8FpM9kWzAvjv2MU/Q== 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=PxyZmoQ4HPxt9JAZN3QVzBllZWpIazPpqniEWrzTllw=; b=nxyCGyRAgNaastNErCTC2xwzrqeSpRwRHhAE1xj/YBo2Fx9ZgA+dE40Bzs9+8zmgijHaNrfTLyF7FJnhO51xhsV8V1T3D+pJsnt6plVg1jE2yBoqwLk8AgGt4UAI7/G2MDGiTUEBIsF34delXlcJ/qCBpCtSR3EmjQzfLDJj1oG5k5GS+kC54Lnm9BuYaMYprfJIId7VmUI0QHX+ieOoWmJ1v4oDx1D/o33AsiFWFk3SyFr2HJ7WaopCBpPOkVP4L9ruBjJmghbTNxY4ViDIX/TDLWhKmOaRsy23pAhnCjZ7nN6daEOS2919lGUQ2lQj9ca9KHXBxZCpnVSl9W4BPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PxyZmoQ4HPxt9JAZN3QVzBllZWpIazPpqniEWrzTllw=; b=Tgk158fR3SMw9dVgmROs3Ns9r7InTwJ2/O1jUgM99F7Ou7cSX2cShJYTbKYUhPJ0by8hJmsAr9X88o1J/fuvwM7JeEkUGx6vQ0DunetcdGhmFDI3sD4gM6W+zEP/1p+GzLIZOSlnGWVDjSCHMizCuTt75g/1dJSOYfKg+Gz4iLg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) by DB6PR0401MB2358.eurprd04.prod.outlook.com (2603:10a6:4:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Tue, 6 Sep 2022 19:41:19 +0000 Received: from AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb]) by AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb%9]) with mapi id 15.20.5612.012; Tue, 6 Sep 2022 19:41:19 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com, imx@lists.linux.dev Subject: [PATCH v8 1/4] irqchip: allow pass down .pm field at IRQCHIP_PLATFORM_DRIVER_END Date: Tue, 6 Sep 2022 14:40:49 -0500 Message-Id: <20220906194052.3079599-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906194052.3079599-1-Frank.Li@nxp.com> References: <20220906194052.3079599-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0042.namprd11.prod.outlook.com (2603:10b6:a03:80::19) To AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8793:EE_|DB6PR0401MB2358:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d3962b6-a10c-44bc-e601-08da903fc534 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z7ei2ktQGTPrgxtaSYyAtkHb2tLavfM+Am6eY8vO7zk7STddx3nfn6ky6EvZY+Hor9NoQdjJOdbTvplO7rAvUqTScj4p50kgl3GxfwUqLi1lEsQnONdwU/RKxieuLKbQEd+PTMshaJTiwm3zi/ReVPk9g/RgovMCJTLqAMDPuxRvej6I5WB6VBr/NRUVwFVVeg+o4jWGOTS1Gi0ujVvYKuW4kbyLaMzJfmaHAhY+yEChSNvtfyPJ4uVpYhcB0/6w7l82/jR8Y4lBmv5N564DK1+mrLEne8KcULiKquDspt8yyjIjVJMfcB9JVe6GlIEcNlq/9o5j4tTIFCx5UvhahExMUMuj4W92HP6n/23WkoviEwHiY7LEaa6/aLlPJfWgKeL86d/9Etucuks16UNolLV3EyShax6ZkYXUDgRfvaHJzaxTryIBdP2CRIDQdlb77uo/RpKdM2fp9SOF1cUiYuCRoyzmvY5u9bNthDY2N6dqD2Pkd+qEYNjIciE8tOFuJLaN08n6jAlx67oOpM7uyVJdeeib+fpM0b+vELlrM5QuPgErV0BYLUhFf0GLY+TEXdy8Rcudul0TDxlUdCEOSPVs2Zt7NgLmCsRzuN0fGeacZDY+Grw2WE9ixKylmujH7G1ut3HAgk5zA4tZxOC56zWkUtyMVEjxlifCUYsdqEEg8nNuoaID8wPTtNhJQvY/L7yd/ehz4O+vzsnJa0lXycuADueftQzaTOuJ/FS4EHorNDiyWkR1VEKH2JiLaVUGtPyBFMvZffJV4j6W3Buzc+VIr2NI2FVWYtJknHV+jhE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8793.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(366004)(136003)(376002)(346002)(41300700001)(52116002)(26005)(6512007)(6506007)(6666004)(6486002)(478600001)(83380400001)(2616005)(186003)(1076003)(2906002)(7416002)(8936002)(5660300002)(66476007)(66946007)(4326008)(8676002)(66556008)(38350700002)(316002)(38100700002)(36756003)(86362001)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rV8nELxtFQBjk6vhn9y6l23UCRFS6ttIm5jKs4ATRtwsMgtfEb44FIfQyu9CTxlh/XJO78H+BkUd2SjROBiDsvMCLQkfXvUB0LKyluxfFiR5NNER1QsDtCF+Mvrh3UQC/wlt9iCRVWW1KQDXDlSAmiiNIBeeZzP9ChuSaONJuyI07krSeKsn5zlVOh1ujLPNNMZQ0Ci/SKk9cvfC5hvu69icAoDpPDifvDN2+1IqsP1aEzciYLnONT8GcaQ+mkohYz/oXrZ0iUTXnZgftMUQ2nACOYWCr8WnFC3AvVgJUe+VUhv82n2c/D+AbGIuVqZ7Kj7HQJTW10S5PsVdVyvL9qA9r0S6umANQk2dAL5+YT67MTZ7Qb11JQ7axy533V1yB4KAuyTKyZGvDlk1URx2PmtDuudQLu1oEIwmcm0RXbOpKxHv+IVlAO9YaRytH6EjFJZp1c0KqRFv6qG70Ek8IrVWQXuk33oi5xHgXCgkwQuoM0y7reuvpnWBgA1cCeFxDVp9mD8IqdafXBLX8GleM9b2rcdV85o58Rp55j8HG8/RcUroZwtikg3Wsyuen3pjznLDdmRNh00LhZI9cQriG3AW3EcYyaVEJAp6fmIs/MFLyzTPA4MS+dR0spOBsJM2fKggtI0OYJbJjLn0eIBuR91Wo4NDesRgOCkWxlYQW3JEpIlPos2LQKh85W/vqcPSErtc8OaX6jmCJzpL0qOsHh/rQLsMdYyOSx4pTO+Cgql/TDY3r4Jepd79QDa/X/hEjl9QcJjDaaxb2eeZM4UjrCY0tNbTSUoiIBCZj+jq2NY9jaS3nFRGBnwUt/p6ZB8oTg+zZ7aD7wljwbVJqjmHiF5OFPrOvUrp510sBKCwaROvbkWMlmtkqxGRZgUsDSGMQWkLXqAcboIGwmnq9DZptTHtk/D9oqywbyQMnpd2cUG4lcIhdy29XLSkKroaCRwqMJPi3t3JLbMZk81+jwmuRjkd+vYAV1dcVSy9qLSp/yrmsHwhFYmpDGecBHAN7pDV3g4BL0YSXxLUSKJ0EDsLaoCSEwaP1dU7NcEZ7fvyqzndXJbTsvXzwyx25Ui08rfSD1tG29Tm5Y3my9unODzIkByOvZNSVLp7OXierAyhwYPjTUUkiJrPoMMDIS4yFtZF/ZWwghaV6EKfpJOslC84q/11AYgQ9ZlWVJzIeakIFmkl5WOe3S4SxXjRmzZMKscFEgSTRjhKJ2Xd2hAcc5fGII36yUDfgSC9SQBMJsOdRTxaaEXf13P4YvA0oiThK5lTmaxq8w1Jd9lYWAB6RKvnB9MaxyJxeQ5SEqWQydR1Q0k7C+eM5Suhl1QrW5W9gOCrfX6bXTuPoVLO6XTqphQnwmaSCiVC1sv+e6PqHc5bWFZ/m3MeriJV39XOc8yRuFCvHRAH0j4gwTvHCwoFPrXzwa/8p0MMhhaC8kHO3YkdvyuYW4mZ0XiKvlCyh0keiPv1evvMS+5FgrpCP+xYu97kCYv0a8SM0p1wd3cBbgmtQubNifjJRF16WBD1v3C0PI0gI8Z+BbesO/6T5y1glYOMs7ptpXFN63AC+NvYF3koK7EGXYxKMbf3zLu7HrX8iRVb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d3962b6-a10c-44bc-e601-08da903fc534 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8793.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 19:41:19.6011 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9hWNKxJRKCYFTd5ZI1GHMmOUZUQE6yQvB+8Bmp3O243E6OLB7U0cQie4lejAUzACnMHiKwttOlImvwFUEVa6kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2358 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org IRQCHIP_PLATFORM_DRIVER_* compilation define platform_driver for irqchip. But can't set .pm field of platform_driver. Added variadic macros to set .pm field or other field if need. Signed-off-by: Frank Li --- include/linux/irqchip.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h index 3a091d0710ae1..d5e6024cb2a8c 100644 --- a/include/linux/irqchip.h +++ b/include/linux/irqchip.h @@ -44,7 +44,8 @@ static const struct of_device_id drv_name##_irqchip_match_table[] = { #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \ .data = typecheck_irq_init_cb(fn), }, -#define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \ + +#define IRQCHIP_PLATFORM_DRIVER_END(drv_name, ...) \ {}, \ }; \ MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \ @@ -56,6 +57,7 @@ static struct platform_driver drv_name##_driver = { \ .owner = THIS_MODULE, \ .of_match_table = drv_name##_irqchip_match_table, \ .suppress_bind_attrs = true, \ + __VA_ARGS__ \ }, \ }; \ builtin_platform_driver(drv_name##_driver) From patchwork Tue Sep 6 19:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 603154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F06E0C38145 for ; Tue, 6 Sep 2022 19:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbiIFTlh (ORCPT ); Tue, 6 Sep 2022 15:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbiIFTla (ORCPT ); Tue, 6 Sep 2022 15:41:30 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80048.outbound.protection.outlook.com [40.107.8.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757CE82D35; Tue, 6 Sep 2022 12:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JfZaVZpzoz6G5kiYg9Dr/yG340dV+LtsVGcYbuhOmCm2vaL8f8YMAqB3cF/kLeDokoV/4sAKPpevK2xqobdC7STx9hWqXnmcByK9DlLt7FrHdBG0DiOcXWXRLaYfn//vqTRfQhoeIeev7PRI90Fs/DTW9YNl4aV3g2axDCQPzL3N4dof4NkdrcxxdrFcZPqEyCVU0l+7HGiZsbS4FgukrQAjAdiHsM0FH+VV8N0lEHQU+3x7RybADBfcmFMf9kpTL6/1Emhwrmk63hA1a3TyvF01f6WfrQTIjg1AkTnIi/qbIE5X9LGVQ1vHw0uobaoHyMOVVy6OEZVtfKE27N/RiA== 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=PlVieAhKtWRBwmuk6JC3NkAMB19eUwTNX1A69MCBoak=; b=I2dOs1MYS7fPUKKYt5jbMxsdwhxxTLzL13vTDpo1dRjtLSl4kMhabiR6t84ognDRaWm3+x+Aenjz+lDyCxLsbpHjUrDMjvdwdbp84FfSUAxz94bb89wfAWc6qGZT90+iqfdPW/r/egpi6naZQeeSPfkwWtLYb+cQ+6Hs56Rgk2lnPJXrtKa4wUZeU5rUUGkhPK59zgRzUU290EU9QAKTBHjyH5DQ9SSyFPdKtJzNFm9SlD5q6vng6i33bO9PhhLt2JZlWv/TvA2AR6BIz6E5p66/QxljGtP57qtl4dWiy9vhgv+4D4RPRSFPAvBCt1D6hOmdQ3XWqGGcIyZyWlmvYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PlVieAhKtWRBwmuk6JC3NkAMB19eUwTNX1A69MCBoak=; b=BpGTv/jISDecqm1wM7vLS9QVZ51eCGTYXHFmYB0CIortvkvH2n0u4LoJ9f7MUbsNBP+xKoxNN4y+QFOMSZQKFaLXBtYEzYBH1fYr3ikFYoaEG3R82l4l0Kx9VaZnw6w76ApPlxh0KemQ7YP82r1OcHbnxWoEMGN0pNwPrkEph9s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) by DB6PR0401MB2358.eurprd04.prod.outlook.com (2603:10a6:4:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Tue, 6 Sep 2022 19:41:25 +0000 Received: from AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb]) by AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb%9]) with mapi id 15.20.5612.012; Tue, 6 Sep 2022 19:41:25 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com, imx@lists.linux.dev Subject: [PATCH v8 2/4] irqchip: Add IMX MU MSI controller driver Date: Tue, 6 Sep 2022 14:40:50 -0500 Message-Id: <20220906194052.3079599-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906194052.3079599-1-Frank.Li@nxp.com> References: <20220906194052.3079599-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0042.namprd11.prod.outlook.com (2603:10b6:a03:80::19) To AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8793:EE_|DB6PR0401MB2358:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f35032b-16e2-467b-4c3e-08da903fc894 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOex9yQ5acW3jazT2ZD5G8UdJ3hos2nMX0o1K2DnO8jH02jCg9w2v9+69SojWy9046m3MXonYNNAXMQQOKHjtKtLijc5ZQqqdguIQHNfX5IO7pXi/bGSjKXPv5pCnCMvu+hkQ9uiTYfjrLGF+lpVHwnVs76ct5SUMQo7nuM3vZC9yTDqoDYbJuSVbPlSPN+47/VusgU1Zjj6JSeFpz3FdEab/PX2jNNE+cz4nQbqdZia8eKQetUs6+6T7zQFs5gR25Hc/CQAFbcKKOEsHfKnjjs58BZwUQ2APsw8RNVdhMI571Vedw/jkDgRR0gYuJnLTdg2GxYCAv+1UbOASeJeKP0nT1KjzYUpmMTjp+7IQ4+QiaUmMvlRtK4Ly7N6OoTCUjcY00jPRvyd/7/hkTBfJkcJX7hB63eSk5LqBv5OJx5kN5E32Gwl7YsMaxnXz3am3hYeppazPCJbrCApEpRuqsMJtbmNjZLMrcEASWFXsLbphD5qk3YquJTw3K7ZmQCBsyXwuFD6vxypwYQztGSiThdzUH6n1wNqIv+2EnVAtTIoKR0qD9ld7IOLDBc95tJMeJ4ml4uyYEyEz0dtKmZytkgD9Y2XUYKCfC7t4GmJIzWobEC2vwrW0qhtoqTqflWOS/Vbfj4hlCGHjPlt6MyDpP/ZoNo/Umz76NafvVgszam/xeI/Qs3npAAcSkztM9vOCfUvNmMm3KLis/UP2GrL8SyTlThQaB3iulYpOVboUN+x01AQJ1R5MjyzeUDh+16w84i4FwotF/ywhZ7JWnSBrA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8793.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(366004)(136003)(376002)(346002)(41300700001)(52116002)(26005)(6512007)(6506007)(6666004)(6486002)(478600001)(83380400001)(2616005)(186003)(1076003)(2906002)(30864003)(7416002)(8936002)(5660300002)(66476007)(66946007)(4326008)(8676002)(66556008)(38350700002)(316002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X4bFhLWflByTbb9OkIpV2nj2xRK0/swrV6ZqmuJMNKZEGTi8NqN1h1FFYWLfmMjLS7MRW9cTiwShND80MeCR5S0e3rXCqVqljteOg8nTwGl+JGIWgYpZRdJVzjhHq/yHNFY3qq2rPDemqvXKVIFalrTIcveu1jNQMEH7QPC5Ck58aU6Ew+g3yK1iIAw0LkbbJodhh4gaK5yBqwKt0jejnYzBsv/HSwJr9jjSVOUDo2NcOTfBIIfzU8ZfXpTr1SrH3OHp6wcnpTdp6U9jjTKU/pNtpjR0jZMjTBeNfUYQlrkMrrywEHPmqP9TQ3mxhu9iQipy4BrtF/XMqGjwW2AFOnrqgbDK72XdcNOzejU1Xjx9riRC9LUcBxdSyJsXc0I9TQtS3nfTeTcdOH5z2OxkUQ6hbIlPAM8WO3hIZy2TqmlHPzo4B3evvia8S5FAALfc+s6NHog45B0SXYx7SMp9FrxFhjeonmgft5goHoGA/LGZvsbOAF/wowzd8KMOm8OaeQpY77Gtexjaj/vxiUAggsLK+U2k0JVKGkkcRujtWkHm+lzdbP9vh/0gHHfFDhLhh5GVm5OVQg+boREE+MER6N3HRzb6BB8tLnovLbSsZEvhQSw9147y/8wa/DaTlP9WiIxDiBeGYGCl5E6R9Bqtts4+5oC1tltd1QvGnOgwTpa5rXIE2T0FQGSL7KKDk9/qLgjh3afWeelWjyLg6WDwLmfvzKySVgIvFZN2oHJPbQUh2P8obmDJgKZ9D89nUma4O4BqY4gDVXcN/6BNOa/g/g7HQ5MnG1vrtHY4fPwMBOnDGaV7VhVdEPOvVUUv3nBzZekMMxBYKLFQ3Y4NBHeX03+LeSx5K0LN2Mr5z43EuvRiibD5vh9d6FLfROts9P5YK/LKsbUIlf5lC2CHw7oo441CWZCgqdcO0SBu1G1UXMATFK+ynFCp5G8G+V35gOX54xW1cmMSIYXBDzrCMT5RzIrxQP6fNHNqfnGw+q+XyVMlYLyNZnEN08DINH3fa7G85wUPVJRcc0fJtA3CAuZC2Qr8+UMYVVcjVvf4U7yRfx9SZE21yGQCKZ/gtG62yz0nlNPWw0+8XvloE+3Z4f5nmm9d0JpnmTHFugZC/alolM4VayISVFOcnDbs9Uqh1KDjLTNsB/faJitJZnZNVD3MmV0yfE8RrzOJ+jZutTzKjNDa7KZZHY7II5vwHmB6XRx82R0Qp3UkkbIWKfvCgJB6geXqodw8cv41SKUawP4n5CVrJvyIi2PcjfvpoaouNxPi4WgGrKyLVLweMS4DoqAn/IZWta6apW/4QnDqiiJ8dw5C9rpoW5M0ZNEjVu9IcUA4MTTS1cUh9LhovubCuyzm0/4C9tT8OzDXY0R9psn47I+kMzJmRTPtPMlE37AUFMta2vAcjIMgBFFfr6Us6Ym34/Q2Sr9aXwHmgGz0kUjO6Pg5klJawREjq2hFpsfmwqK3F4DYxZ3+zeCF93b9Z/MJZ88MOcbkp1mff08eo5U1F9UDExW+QDKHDa6VPMtw6RaoDkRFUUrAjzpwkvPX7mvcgRAXCaEX4qqhZUBWfX9lk73I0U4AasGBWX2kXOhHKs8n X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f35032b-16e2-467b-4c3e-08da903fc894 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8793.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 19:41:25.1972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fHLrbUMuxTasuIymZPFTnoI5oxxSgDeYDxdwLT9h+996ZDTqFCVALgr5j8p1JuHZOu+MQ6CY1OzyBfVcn1E/BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2358 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The MU block found in a number of Freescale/NXP SoCs supports generating IRQs by writing data to a register This enables the MU block to be used as a MSI controller, by leveraging the platform-MSI API Signed-off-by: Frank Li --- drivers/irqchip/Kconfig | 9 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-imx-mu-msi.c | 451 +++++++++++++++++++++++++++++++ 3 files changed, 461 insertions(+) create mode 100644 drivers/irqchip/irq-imx-mu-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 5e4e50122777d..e04c6521dce55 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -470,6 +470,15 @@ config IMX_INTMUX help Support for the i.MX INTMUX interrupt multiplexer. +config IMX_MU_MSI + bool "i.MX MU work as MSI controller" + default y if ARCH_MXC + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + select GENERIC_MSI_IRQ_DOMAIN + help + MU work as MSI controller to do general doorbell + config LS1X_IRQ bool "Loongson-1 Interrupt Controller" depends on MACH_LOONGSON32 diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 5d8e21d3dc6d8..870423746c783 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_IMX_INTMUX) += irq-imx-intmux.o +obj-$(CONFIG_IMX_MU_MSI) += irq-imx-mu-msi.o obj-$(CONFIG_MADERA_IRQ) += irq-madera.o obj-$(CONFIG_LS1X_IRQ) += irq-ls1x.o obj-$(CONFIG_TI_SCI_INTR_IRQCHIP) += irq-ti-sci-intr.o diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c new file mode 100644 index 0000000000000..82b55f6d87266 --- /dev/null +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -0,0 +1,451 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Freescale MU worked as MSI controller + * + * Copyright (c) 2018 Pengutronix, Oleksij Rempel + * Copyright 2022 NXP + * Frank Li + * Peng Fan + * + * Based on drivers/mailbox/imx-mailbox.c + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define IMX_MU_CHANS 4 + +enum imx_mu_xcr { + IMX_MU_GIER, + IMX_MU_GCR, + IMX_MU_TCR, + IMX_MU_RCR, + IMX_MU_xCR_MAX, +}; + +enum imx_mu_xsr { + IMX_MU_SR, + IMX_MU_GSR, + IMX_MU_TSR, + IMX_MU_RSR, +}; + +enum imx_mu_type { + IMX_MU_V1 = BIT(0), + IMX_MU_V2 = BIT(1), + IMX_MU_V2_S4 = BIT(15), +}; + +/* Receive Interrupt Enable */ +#define IMX_MU_xCR_RIEn(data, x) ((data->cfg->type) & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x)))) +#define IMX_MU_xSR_RFn(data, x) ((data->cfg->type) & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x)))) + +struct imx_mu_dcfg { + enum imx_mu_type type; + u32 xTR; /* Transmit Register0 */ + u32 xRR; /* Receive Register0 */ + u32 xSR[4]; /* Status Registers */ + u32 xCR[4]; /* Control Registers */ +}; + +struct imx_mu_msi { + spinlock_t lock; + raw_spinlock_t reglock; + struct irq_domain *msi_domain; + void __iomem *regs; + phys_addr_t msiir_addr; + const struct imx_mu_dcfg *cfg; + unsigned long used; + struct clk *clk; +}; + +static void imx_mu_write(struct imx_mu_msi *msi_data, u32 val, u32 offs) +{ + iowrite32(val, msi_data->regs + offs); +} + +static u32 imx_mu_read(struct imx_mu_msi *msi_data, u32 offs) +{ + return ioread32(msi_data->regs + offs); +} + +static u32 imx_mu_xcr_rmw(struct imx_mu_msi *msi_data, enum imx_mu_xcr type, u32 set, u32 clr) +{ + unsigned long flags; + u32 val; + + raw_spin_lock_irqsave(&msi_data->reglock, flags); + val = imx_mu_read(msi_data, msi_data->cfg->xCR[type]); + val &= ~clr; + val |= set; + imx_mu_write(msi_data, val, msi_data->cfg->xCR[type]); + raw_spin_unlock_irqrestore(&msi_data->reglock, flags); + + return val; +} + +static void imx_mu_msi_parent_mask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, 0, IMX_MU_xCR_RIEn(msi_data, data->hwirq)); +} + +static void imx_mu_msi_parent_unmask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, IMX_MU_xCR_RIEn(msi_data, data->hwirq), 0); +} + +static void imx_mu_msi_parent_ack_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_read(msi_data, msi_data->cfg->xRR + data->hwirq * 4); +} + +static struct irq_chip imx_mu_msi_irq_chip = { + .name = "MU-MSI", + .irq_ack = irq_chip_ack_parent, +}; + +static struct msi_domain_ops imx_mu_msi_irq_ops = { +}; + +static struct msi_domain_info imx_mu_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS), + .ops = &imx_mu_msi_irq_ops, + .chip = &imx_mu_msi_irq_chip, +}; + +static void imx_mu_msi_parent_compose_msg(struct irq_data *data, + struct msi_msg *msg) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + u64 addr = msi_data->msiir_addr + 4 * data->hwirq; + + msg->address_hi = upper_32_bits(addr); + msg->address_lo = lower_32_bits(addr); + msg->data = data->hwirq; +} + +static int imx_mu_msi_parent_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip imx_mu_msi_parent_chip = { + .name = "MU", + .irq_mask = imx_mu_msi_parent_mask_irq, + .irq_unmask = imx_mu_msi_parent_unmask_irq, + .irq_ack = imx_mu_msi_parent_ack_irq, + .irq_compose_msi_msg = imx_mu_msi_parent_compose_msg, + .irq_set_affinity = imx_mu_msi_parent_set_affinity, +}; + +static int imx_mu_msi_domain_irq_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct imx_mu_msi *msi_data = domain->host_data; + unsigned long flags; + int pos, err = 0; + + WARN_ON(nr_irqs != 1); + + spin_lock_irqsave(&msi_data->lock, flags); + pos = find_first_zero_bit(&msi_data->used, IMX_MU_CHANS); + if (pos < IMX_MU_CHANS) + __set_bit(pos, &msi_data->used); + else + err = -ENOSPC; + spin_unlock_irqrestore(&msi_data->lock, flags); + + if (err) + return err; + + irq_domain_set_info(domain, virq, pos, + &imx_mu_msi_parent_chip, msi_data, + handle_edge_irq, NULL, NULL); + return 0; +} + +static void imx_mu_msi_domain_irq_free(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(d); + unsigned long flags; + + spin_lock_irqsave(&msi_data->lock, flags); + __clear_bit(d->hwirq, &msi_data->used); + spin_unlock_irqrestore(&msi_data->lock, flags); +} + +static const struct irq_domain_ops imx_mu_msi_domain_ops = { + .alloc = imx_mu_msi_domain_irq_alloc, + .free = imx_mu_msi_domain_irq_free, +}; + +static void imx_mu_msi_irq_handler(struct irq_desc *desc) +{ + struct imx_mu_msi *msi_data = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + u32 status; + int i; + + status = imx_mu_read(msi_data, msi_data->cfg->xSR[IMX_MU_RSR]); + + chained_irq_enter(chip, desc); + for (i = 0; i < IMX_MU_CHANS; i++) { + if (status & IMX_MU_xSR_RFn(msi_data, i)) + generic_handle_domain_irq(msi_data->msi_domain, i); + } + chained_irq_exit(chip, desc); +} + +static int imx_mu_msi_domains_init(struct imx_mu_msi *msi_data, struct device *dev) +{ + struct fwnode_handle *fwnodes = dev_fwnode(dev); + struct irq_domain *parent; + + /* Initialize MSI domain parent */ + parent = irq_domain_create_linear(fwnodes, + IMX_MU_CHANS, + &imx_mu_msi_domain_ops, + msi_data); + if (!parent) { + dev_err(dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS); + + msi_data->msi_domain = platform_msi_create_irq_domain( + fwnodes, + &imx_mu_msi_domain_info, + parent); + + if (!msi_data->msi_domain) { + dev_err(dev, "failed to create MSI domain\n"); + irq_domain_remove(parent); + return -ENOMEM; + } + + irq_domain_set_pm_device(msi_data->msi_domain, dev); + + return 0; +} + +/* Register offset of different version MU IP */ +static const struct imx_mu_dcfg imx_mu_cfg_imx6sx = { + .xTR = 0x0, + .xRR = 0x10, + .xSR = {0x20, 0x20, 0x20, 0x20}, + .xCR = {0x24, 0x24, 0x24, 0x24}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx7ulp = { + .xTR = 0x20, + .xRR = 0x40, + .xSR = {0x60, 0x60, 0x60, 0x60}, + .xCR = {0x64, 0x64, 0x64, 0x64}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp = { + .type = IMX_MU_V2, + .xTR = 0x200, + .xRR = 0x280, + .xSR = {0xC, 0x118, 0x124, 0x12C}, + .xCR = {0x110, 0x114, 0x120, 0x128}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp_s4 = { + + .type = IMX_MU_V2 | IMX_MU_V2_S4, + .xTR = 0x200, + .xRR = 0x280, + .xSR = {0xC, 0x118, 0x124, 0x12C}, + .xCR = {0x110, 0x114, 0x120, 0x128}, +}; + +static int __init imx_mu_of_init(struct device_node *dn, + struct device_node *parent, + const struct imx_mu_dcfg *cfg + ) +{ + struct platform_device *pdev = of_find_device_by_node(dn); + struct device_link *pd_link_a; + struct device_link *pd_link_b; + struct imx_mu_msi *msi_data; + struct resource *res; + struct device *pd_a; + struct device *pd_b; + struct device *dev; + int ret; + int irq; + + if (!pdev) + return -ENODEV; + + dev = &pdev->dev; + + msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL); + if (!msi_data) + return -ENOMEM; + + msi_data->cfg = cfg; + + msi_data->regs = devm_platform_ioremap_resource_byname(pdev, "processor-a-side"); + if (IS_ERR(msi_data->regs)) { + dev_err(&pdev->dev, "failed to initialize 'regs'\n"); + return PTR_ERR(msi_data->regs); + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "processor-b-side"); + if (!res) + return -EIO; + + msi_data->msiir_addr = res->start + msi_data->cfg->xTR; + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) + return -ENODEV; + + platform_set_drvdata(pdev, msi_data); + + msi_data->clk = devm_clk_get(dev, NULL); + if (IS_ERR(msi_data->clk)) { + if (PTR_ERR(msi_data->clk) != -ENOENT) + return PTR_ERR(msi_data->clk); + + msi_data->clk = NULL; + } + + pd_a = dev_pm_domain_attach_by_name(dev, "processor-a-side"); + if (IS_ERR(pd_a)) + return PTR_ERR(pd_a); + + pd_b = dev_pm_domain_attach_by_name(dev, "processor-b-side"); + if (IS_ERR(pd_b)) + return PTR_ERR(pd_b); + + pd_link_a = device_link_add(dev, pd_a, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + if (!pd_link_a) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + goto err_pd_a; + } + + pd_link_b = device_link_add(dev, pd_b, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + + if (!pd_link_b) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + goto err_pd_b; + } + + ret = imx_mu_msi_domains_init(msi_data, dev); + if (ret) + goto err_dm_init; + + irq_set_chained_handler_and_data(irq, + imx_mu_msi_irq_handler, + msi_data); + + pm_runtime_enable(dev); + + return 0; + +err_dm_init: + device_link_remove(dev, pd_b); +err_pd_b: + device_link_remove(dev, pd_a); +err_pd_a: + return -EINVAL; +} + +static int __maybe_unused imx_mu_runtime_suspend(struct device *dev) +{ + struct imx_mu_msi *priv = dev_get_drvdata(dev); + + clk_disable_unprepare(priv->clk); + + return 0; +} + +static int __maybe_unused imx_mu_runtime_resume(struct device *dev) +{ + struct imx_mu_msi *priv = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(priv->clk); + if (ret) + dev_err(dev, "failed to enable clock\n"); + + return ret; +} + +static const struct dev_pm_ops imx_mu_pm_ops = { + SET_RUNTIME_PM_OPS(imx_mu_runtime_suspend, + imx_mu_runtime_resume, NULL) +}; + +static int __init imx_mu_imx7ulp_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx7ulp); +} + +static int __init imx_mu_imx6sx_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx6sx); +} + +static int __init imx_mu_imx8ulp_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx8ulp); +} + +static int __init imx_mu_imx8ulp_s4_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx8ulp_s4); +} + +IRQCHIP_PLATFORM_DRIVER_BEGIN(imx_mu_msi) +IRQCHIP_MATCH("fsl,imx7ulp-mu-msi", imx_mu_imx7ulp_of_init) +IRQCHIP_MATCH("fsl,imx6sx-mu-msi", imx_mu_imx6sx_of_init) +IRQCHIP_MATCH("fsl,imx8ulp-mu-msi", imx_mu_imx8ulp_of_init) +IRQCHIP_MATCH("fsl,imx8ulp-mu-msi-s4", imx_mu_imx8ulp_s4_of_init) +IRQCHIP_PLATFORM_DRIVER_END(imx_mu_msi, .pm = &imx_mu_pm_ops) + + +MODULE_AUTHOR("Frank Li "); +MODULE_DESCRIPTION("Freescale MU MSI controller driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Sep 6 19:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 603580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77026ECAAA1 for ; Tue, 6 Sep 2022 19:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiIFTli (ORCPT ); Tue, 6 Sep 2022 15:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbiIFTle (ORCPT ); Tue, 6 Sep 2022 15:41:34 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80084.outbound.protection.outlook.com [40.107.8.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34AE980F69; Tue, 6 Sep 2022 12:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HsKVIkbBXLxIOv3Bx8qJGqCzYtCTmLqbqQluxCfzAntm5rTBVLkhYMViuARQThhJnZ7zFp6L+LEgsEutej9gyF35MjEcyl7EE7Qy8uyHj1nTtJwrKJPjNKZNTlxoYwRBM5JhibAytz2OMFQW79kJ0Uqav1/t1mJXjEea8WomfZI6+dvOlGSmarqzW2a9GoGVZaEBLHK+ERhZ7LTIBvN4hyWuR53FZPzeF36/cNv2vLh5p9aM9kc4lf7hNQlQKBmBO+N9LOe/P6iayTXpXefNgCwLzKlqJZ1yfS+x/86JcxK41Scnyo4JW55gXLtA67bconN1DEamoClgxJzQtNTTTw== 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=PlNYDELcqtaOO3+2tamAaCCPR1txHEHqQqFIr51Iutk=; b=oeVoeXpmXoq4FZ9y6bM028fcD9fcjhn0PgBMyGT9a9G7yhJbYm43j0QOlT8fm9eKq2Z0Mpx7w0/tdBQxcWd1Zqn5rVSRD+DXHHe93OsPWvNu105Ly7XafYnIej1PC30zaWvILArUI7qCwgJ7MLdDANRNAC7Sn8t9b/jMMYb3ZCQk5kwYHd6Xd7Crcn7MgCfyytPsIcV52NABORQzQfEH3qeB3ox3W1YPrwNdQlZdFx33xhYm5WFV/0ub0NfGUTR8VO+8rP0UBDuytKsyiQW89XOPNgAWnisV/md6gCcVG0UpoZa0OjSh8NWem0hEpH2DdAIfCoCG/9Bv6vAmPrZdQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PlNYDELcqtaOO3+2tamAaCCPR1txHEHqQqFIr51Iutk=; b=NflKiMKyVBhHuEgsHlixhFk8ZLPTd+S01/zkaqLaM957kOEr7UvEDEkecj9eSkGGfJoYuvBuY8AtUInxN/KoqgHVnGLJKR1S5lJszXq/kR+W+wBFK3UQbnkCxYSa47tcK8olPm8VUj14HDZiovP5Zutdq+jorLtFL8H3MDty1Wg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) by DB6PR0401MB2358.eurprd04.prod.outlook.com (2603:10a6:4:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Tue, 6 Sep 2022 19:41:30 +0000 Received: from AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb]) by AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb%9]) with mapi id 15.20.5612.012; Tue, 6 Sep 2022 19:41:30 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com, imx@lists.linux.dev Subject: [PATCH v8 3/4] dt-bindings: irqchip: imx mu work as msi controller Date: Tue, 6 Sep 2022 14:40:51 -0500 Message-Id: <20220906194052.3079599-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906194052.3079599-1-Frank.Li@nxp.com> References: <20220906194052.3079599-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0042.namprd11.prod.outlook.com (2603:10b6:a03:80::19) To AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8793:EE_|DB6PR0401MB2358:EE_ X-MS-Office365-Filtering-Correlation-Id: ea6de411-a621-4959-3b87-08da903fcbc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C54gCqL9gLGZovVz1nAGfXhkgconW6WDyqYwIO0hJig+9hXYJJGuOLsaVZAFdZ8t4Hmh+FlRs3Cn22pXO1Zh1SEimtqZ2hwG2B7n0KZbL2otvphcVK2v5l+Ww4yW2p7M6I6Gy4hTk0ZWLTwdalKTHbq+arnECj3/6rY7FeHSfduZira/p0CD6vAfiXGQK12kgqjwSq3+GBWq+AfmG/AuX6eC52Y4wLTzRKxdznebAuhYwBslq/ekcgg5QXfqGT9gS4qtzGSFiVWAqc+bNrOjdyyZwVIhdFB2rxV7PnJ2DJTNx5bDOmfvsLas3hobN9oxfNDZ12evF2U4T4rAZzD4e63yYB2dh0rGipy6Z0dSCOo6NofYtZOQTSVefZ9SfpuVnOxvNEOnOq7nYdPwMv7BSWZQF60Nj+m0sqopJPCVRlp2Lv36f1P82fvqssp7ekUX3rp5wzcYCEVN78xkeIVhBXp7Pl70gX5mmbCrzbPZcSiso1oZy5Et1j4dLvbGhbUTnIcIQNUptELl23fKrGDBWd6wozPXRia1KBr1VKqsncfiZGUAVr5WA/Zb5quay1iYkaImaa8PNBeMoWI7xt+Vk6A3r3GwVRB3FkcLMMHF54c6X1OLQzjGgLzJrfR4dhy1Ygef5PQCy3MEB2UZzyH7YmfrmJSomVj9lsu1fEpthNLwGdfjc4Cb2QYKOQxTrVo4IiaKLplbVYMhFc7fTcAjrTSx8tf9U3OO1eThwWykyga3g4Ngn/Cuip1q3HWCo/rpBwxAd9pp+xibiZQkoGNaZ79HCABTVZVtz2rHZIWy1yXjfx3gjBv19sxnXaDI9wpGPtBgjTeWPgTAfu/v/mGOzA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8793.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(366004)(136003)(376002)(346002)(41300700001)(52116002)(26005)(6512007)(6506007)(6666004)(966005)(6486002)(478600001)(83380400001)(2616005)(186003)(1076003)(2906002)(7416002)(8936002)(5660300002)(66476007)(66946007)(4326008)(8676002)(66556008)(38350700002)(316002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jWeRMoZcLw9fBv945VZbf6Z0ToCIcoWlAoBXYm8ofCYUPPD/swVbHHH62T2219l1FJgNSI4N3TI7WrYOCpFjQv5Db/5aFDPn8g9Gj43+zOYh8zglcdSZj8YVa5hnb0b6Zpqfl95qM4tLCHxxitLji9HyJWXn9wMRjBeLIT3l0FmxxDwBQu8Y5bGHo7XHUDRYK6DtUivTv/5sYYIw+70gn6BIkmO4wPxggboRDX/pEnQPEJuTxRZcn6NVgn1N8XUSxdoxZ3V9Xizi9p5x7Y3jOYyrXzG7WdvuuGF2ZTOWda7cnVez4HYW7J60hhlTism/uEI2knP1vcnp7kAyT4hQ7K615w9RgBl5NLQkvb3zon49dZuHmhFJaw0eBe6sa5o1JStCC6k2oZztTAY6SCdlGNrvtRq3IJhGuCOZA0uts3NArxPgK22t6BbFkzYu/xR4bMUZDeUjwi4dhGgc3mb0w7o/BR7VEt89kwSJkYCRNDbPrZWIE4r2CBGaiMeEtq+z7/QnO/eu3tfZrkzLUhlqDupaNesAoNyEuZtLfHmwQsZWKuofboF7ElxAZleyKzSCa97p3LpmDMa41YXINXMwG2gIqDRA65sn/yZuTSP7ZctAlkBVSONU3445xW8BiJpItgyQe6dml6RxtXSCb4KD2yAvM1a8vht6M9ZD2sfna105czZ08Dag87oZkOBuBTugNubwhKMhYakHC+b2Q3Y9A25P7xrH6UITK6/xG5Vh5Jpo2xN1uxZ3Fal/UACdECN2j7WNRVAxcpvo2+gfeW6VrMFl38tAmL/E6OGjQ1KNP8moeR4q7LVQF3qNEgXKDTmhRP4hQMBrKH9DKE+uJESf4qfClSU4nBJBbifN7etFoIFE8DR7KWoPKymVKgtbeH1Z6RRcmf/sIo2FvUQTydTIbnKHpHQBc05GtNHDhPGQU/S3PEZgL55GZQfHvfsnS44n1VHHlkuuS/tVzyP7lEM70FuUa+f+8NWEjEMniQy2QX+HubKj2prZRut5kAjNgmyOVH56hXHQqiQqAGHhh/bUGJCrq1qgl7vK+JT8fBk2jgDqFuh+rD5LsbZyCWS/IAbApQo71jHiksMDpOHU5FSBU3k2+c2nyGbTi9iBExrZXxPhdeRqQtTX1Dw+sHyCUDLzA3JNcLgbM3ZpFbaNU2n6CEKWwLsb9LpfCOTRLjDWsjNnRXbYlDh6phFnABV+mvKHO4Vw8YpzGK5jkVXTHW+gBPCZKjSsiUVkDXcmwyEOAhVLSA7j4pDkC2DPd4HPI4q8D5F/+1mbC8yEwZ8dmDRlICH1fmDG36AXHZOVAD5zsODI9xUtUz9M4gjtAn3EXf603JEXxcncPWmuwYYf8jawpDb4GZtGs8Io/cLWJoN7rfHMKDu2GWvthSJS/6MjM1awlfk/uutd2MxqNreDudZensONStIr0NXs9KVjATM0ja9YS87MWeSdB3zmfkxsSR+g3pqBowXRAM8J3EFRvK6gEVFZy8OgZnMRb3HxPmSNuFazn/d5ITcJOvKWg02ylrVRNeb//J3q7CCfNByFAhq5jsXmT+AV57hZRzau0OIBS6RLmVaVbnGJ8FSCnH1N1cFA X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea6de411-a621-4959-3b87-08da903fcbc1 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8793.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 19:41:30.3530 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Il9rQo/N0hn9eYIk6ZpVFFqH+WqFNlS9I0EY9WUtd4Yn2jWFlJXU3U4wODfKeoV3U/EdnB9bHY4MfbjDcGa0Uw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2358 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org I.MX mu support generate irq by write a register. Provide msi controller support so other driver such as PCI EP can use it by standard msi interface as doorbell. Signed-off-by: Frank Li --- .../interrupt-controller/fsl,mu-msi.yaml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml new file mode 100644 index 0000000000000..5466bd19b703c --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/fsl,mu-msi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale/NXP i.MX Messaging Unit (MU) work as msi controller + +maintainers: + - Frank Li + +description: | + The Messaging Unit module enables two processors within the SoC to + communicate and coordinate by passing messages (e.g. data, status + and control) through the MU interface. The MU also provides the ability + for one processor (A side) to signal the other processor (B side) using + interrupts. + + Because the MU manages the messaging between processors, the MU uses + different clocks (from each side of the different peripheral buses). + Therefore, the MU must synchronize the accesses from one side to the + other. The MU accomplishes synchronization using two sets of matching + registers (Processor A-facing, Processor B-facing). + + MU can work as msi interrupt controller to do doorbell + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + enum: + - fsl,imx6sx-mu-msi + - fsl,imx7ulp-mu-msi + - fsl,imx8ulp-mu-msi + - fsl,imx8ulp-mu-msi-s4 + + reg: + items: + - description: a side register base address + - description: b side register base address + + reg-names: + items: + - const: processor-a-side + - const: processor-b-side + + interrupts: + description: a side interrupt number. + maxItems: 1 + + clocks: + maxItems: 1 + + power-domains: + items: + - description: a side power domain + - description: b side power domain + + power-domain-names: + items: + - const: processor-a-side + - const: processor-b-side + + interrupt-controller: true + + msi-controller: true + + "#msi-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - msi-controller + - "#msi-cells" + +additionalProperties: false + +examples: + - | + #include + #include + + msi-controller@5d270000 { + compatible = "fsl,imx6sx-mu-msi"; + msi-controller; + #msi-cells = <0>; + interrupt-controller; + reg = <0x5d270000 0x10000>, /* A side */ + <0x5d300000 0x10000>; /* B side */ + reg-names = "processor a-facing", "processor b-facing"; + interrupts = ; + power-domains = <&pd IMX_SC_R_MU_12A>, + <&pd IMX_SC_R_MU_12B>; + power-domain-names = "processor a-facing", "processor b-facing"; + }; From patchwork Tue Sep 6 19:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 603153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A7C6C38145 for ; Tue, 6 Sep 2022 19:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbiIFTlw (ORCPT ); Tue, 6 Sep 2022 15:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbiIFTlt (ORCPT ); Tue, 6 Sep 2022 15:41:49 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60047.outbound.protection.outlook.com [40.107.6.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBDD982D35; Tue, 6 Sep 2022 12:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jL/EGuLS/HViwsRcRPOMIkPQNs/CIFoCSY3OCVwBMvrMrOQfivr4J35Mu2RZvRYTaetFJg30Gwk50ETbO7bXNg+pX+MtJzX3koiAL5gz7U+QRfq9v9GtjIGm8IcSlW+dyIkmGa7zgE+1AuGvB0qtrO2yrSD1eggxwbNF14duHV8btuCqHYeEG+DO2VYEU1FaTGnMzAZJPJmxiEXRS3ZxaurOz1DlaLtUiWslxC6KtXnNfiph/k5/mu9RgMZ2LhgN6DEpXDKN2Cpifk3zXBHt1GxZ1tdJLcaHFwNIzfwSz+H1jVryBl1w2TM4/rIsX17kp+0Jodop15j8GCSpDxv1Ew== 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=luNuA87ZdAV700jTSvPtoctsb3rd8ltqs7Sjx4ZnBbs=; b=Y+T6Deyv09Y0rblMxeLsHKdi+By8kFGM9aR+QCDYr91bMJtM/SLBAFb1rZ8Q2rzxqDHY9R/yGLaiB+rGqrH32t0QirsWRQu36iryRhxzwjkaQCOQK9EtzgFhGuU9XVp4xAAsbLWAFnSMgykYLqcVDFCWe19a58s7rmoAeXnNVJS8uMtF/Dgt4TvlwD6kgnsQKA4kTE65vbL8MN3Q6PO3JDEnPJsQftBOMZz86q5A4QjGdTPZVAOSM6VtPu2NK0qeCDuvdFqXeodql3j9m0qs6xW062gfGH0AgbWLRe2ILDbrG0r4RL3rhjDAe0Byk3v2Ml/VM/rP+PItzttqwKLogQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=luNuA87ZdAV700jTSvPtoctsb3rd8ltqs7Sjx4ZnBbs=; b=N0PsTT+XRSgZM6m4dsen/KFVN74P2USpwgj3MucB57FI/jn+kaMIJx+Y9v6LtHIzGygqPdT6xWc1gxshaW2HU2eP01yuuwZtMe5dlb7LO45Zc4a9ci2zQCxQhW2BO1a/atzOMBBgYqlWVf9YqvBczJMli/Zd7Kv6oRuB88Pl2zQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) by AM0PR04MB5059.eurprd04.prod.outlook.com (2603:10a6:208:bf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.17; Tue, 6 Sep 2022 19:41:35 +0000 Received: from AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb]) by AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb%9]) with mapi id 15.20.5612.012; Tue, 6 Sep 2022 19:41:35 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com, imx@lists.linux.dev Subject: [PATCH v8 4/4] PCI: endpoint: Add vNTB MSI support Date: Tue, 6 Sep 2022 14:40:52 -0500 Message-Id: <20220906194052.3079599-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906194052.3079599-1-Frank.Li@nxp.com> References: <20220906194052.3079599-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0042.namprd11.prod.outlook.com (2603:10b6:a03:80::19) To AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8793:EE_|AM0PR04MB5059:EE_ X-MS-Office365-Filtering-Correlation-Id: 44bdd7ce-165e-4d75-06dc-08da903fced5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CPsYo9Ose6v/2IBYr6sc5tkO24lNRAHc11k1HIGiB8BxftBeqwRWfg21vPJsBsJFO6oYCo0pBf8+m/Pwng2OZ2aJGUGmWoJUfgHiwUZ8GOVr54ed5cXVjImyvf+hJt3bWyzBt1EwnDWUSOdTnbWx28wa0526y4OBUb1KT8J9JzC+0Hg+Mzw+yN08fseYc2bifZc+jLOLPVhLTuE9cXjBtSWlamTvCkGe9YzsAmOF9QgRvC00w0rDBFy7a+KeH4xse27Hd2ks0t+59+meN9FnmAFSwQsMZDM/iPvgZNOl/omgHe+Ghh+Lv367tTB/fABtl7ZhZ/FVOC1DxNfQqlGV6e0FHg+BEwNjh7NdJKfzD5E48+PV/HWY28WeoYX3UmVsK1VDjAQy5YLppZRdegEqSvHpfnHMVUkz42HPOobspPWKa3ESRqZ6aR3ldBPhpRROl7fYI7QCNB4IrUhfeWtEzyc7WF1eirmEGd6RhAqoJyJsJPNfjvycmEONdU13X+5ahgUPjL2XGVnLfzCO5jFJ6fHY5fPTC0Wo2vOXfVklQE3EuXqtBZNKCbza8YrkTpNxmWVjHPpPIIFC2bGq6njYf/j6hd9+JtT3NZIqI73Ua0ytB0F438M3IVJcipU3Q06P2yKE5eMa+T+pCVxTtoddm3OmebAq5FUtW7yaeCYhfZVw5vOzlC1D/ix1+RIOSWmD3dwNxc6dYMzpDagQwvpK9LH781dBpa6UZd4BjLlIh7uK77v+/FNsnjs53hGSS/BzvwD63GStOl6JvZDPcxx8bQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8793.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(136003)(39860400002)(346002)(376002)(6512007)(2906002)(478600001)(26005)(6666004)(41300700001)(83380400001)(2616005)(186003)(1076003)(8936002)(5660300002)(6506007)(6486002)(316002)(52116002)(4326008)(66556008)(8676002)(66946007)(7416002)(38100700002)(86362001)(66476007)(36756003)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4o9BNozVjW5AM1R//fd5VfgRsMtu?= =?utf-8?q?efqoQNoX7h+wV+FVmqMEpzw1xOqVQC1BP6eg0OT+RWCYmBbikmVsUy75xeSkQDfBV?= =?utf-8?q?9/Hj9WxnmlHYNzsauyfsBstEE8SP/C/mjTOUv1kgxOFyUz9PyOwJYbnsBIfZMS3i0?= =?utf-8?q?j0JF5JFfkvBJQELZekodTX6PKOErclGsYMaUkaagUiKRirF64YKfiW12XnIAOETlV?= =?utf-8?q?ouIEPb+hAoa2Uiia/kbjyhh08HzKa+rzGFTFhSU0tM4UO7HjAcC++N/PCBOraIRPT?= =?utf-8?q?qOEZ5r/xgWD4GyeDYPUF452SYeLrgFkdgVFnc0Lar74iW1U7SVOX3p8bVlfIjllBb?= =?utf-8?q?Dn/VBEoZIY0R5u6nK3+tlEi76RFmdHsqm8xoRJHcayqEn5DopmzsqH1Ct7UYHsHUL?= =?utf-8?q?WHsK6+RiKDJwEJceuW41WqY6T5pA0zIfGtyU5HcDh96Cbw1pkdw7cv1Ot7CjE6aI8?= =?utf-8?q?wUNCbxOHMEYXnILp98Bl6BB78xs/UYxvMk3QtAocqPXpsx7RL4phnHrZj+Df4XuMd?= =?utf-8?q?GL/BYilPFgw7M354ZIdCDa+7FANK0kTPkjRe7ZSmid+ujXr04dTQvp7x8eZQAKdC6?= =?utf-8?q?CI3qckqoaEqTh+D4LVcSz7GTgz9ZBbtysGwH5dTv473QJutt2NtsYGdhZOPFIK6e6?= =?utf-8?q?Wy4jb02rwYiRUug/91M1sfk3I2S25sV3VLcZH2cGMlFCs+fMAX3xwmc6HDkt3tNP1?= =?utf-8?q?9MpOv7ttvLZllLQDcvkWs5mdm35NUZosXOB0CziN5ydp0MwQXUhUhUoXhpGLIfSPr?= =?utf-8?q?Bzprboi7YJWMyHzFkXkMsSvVvekPLN9hFM0CxDDT/wb87mBs4Utx8a5yol6PC0DJ4?= =?utf-8?q?OBBCo7ewNEuXKNC3MSDNz33RhtgQxEP//l/NnJ058B0db0oPTClcBZXKARtpaNOpO?= =?utf-8?q?SznnnI9cO+v6dgXq2Zv73IVSyf1xVF3TaEt97Cabf7pwbCp/1KIx0QrdWpkXaI0wr?= =?utf-8?q?zy4/UBCpgp/qWP4nz1H+TRPsF1cmhd+roVpxOOUnHxflyolxnAM5qdegVFvjOLCUq?= =?utf-8?q?jezxZohZndg5r3/RjMWBMGPwE/nZ05uw3Vj34gb/l28sN7kZC//nWHv7tQDt+0sHR?= =?utf-8?q?oIkSac9ReDaaUzTAgSNn5Uy9sHT+woVNjuE4IXcEsgP9guCgVmz2Atj3gwuTK7zLv?= =?utf-8?q?gJyDqK5UoPAXQCU9F/K452x9fPF9/1TPKV8l9bYHzSLnIhR/RhrkscJUZ8jvOG8sp?= =?utf-8?q?6URYibce2ZiGlDnzB/Kcwm8my8MJuKqs2/9ScDpz0Vib0pwz1TS399fCkry520xkK?= =?utf-8?q?0bTRTKiLZSgOBtDnq4enYzjHNO7gIDhZWvXsx22Cf9BR3Rx8Ciip5DVHD76sWU/5e?= =?utf-8?q?HVsZqmbUWCrLRb78Lp+CQ5Dj/NeVF1cJ1p2+CisuDHHCVpxjMd2J/7XwWYDerthvF?= =?utf-8?q?jvzlZ6oCBUodRCidLw9qmbr8DcARmDcAXgHMNVj2lrv1m70R8to+ru+rLhxgp+g3n?= =?utf-8?q?mTBHQ70c9qP55iWlfUA8KXu9VnnbUbgje2Ay3weUqStOzSn6V03hu+opl4w/neyHT?= =?utf-8?q?oUeJzb1L4rSU?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44bdd7ce-165e-4d75-06dc-08da903fced5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8793.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 19:41:35.5169 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R5UDaGVdToQz/7FT0fRcEHqasyVPUpFlKjHGlEjMVhdgr+m5Bj0/Dixp+q36zQGIRcazJ2sVZuIRkJ92pTONTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5059 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ PCI │ │ PCI Host │ │ MSI │◄┐ │ EP │ │ │ │ Controller │ │ │ │ 3.MSI Write │ │ └────────┬────┘ └─┼───────┼───────────────────┤ │ ▲ │ │ │ ├─BAR_n │ │ └────────┼───────┼──────────────────►│ │ │ │ │ 2.Call Back │ │ │ │ │ write_msi_msg() │ │ │ │ │ │ │ │ └───┬───┘ └──────────┘ │ │ └───────────────────┘ 1.platform_msi_domain_alloc_irqs() There is no defined way of raising IRQs by PCI host to the PCI endpoint. Only define MSI/MSI-X to let EP notified RC status change. The memory assigned for BAR region by the PCI host is mapped to the message address of platform msi interrupt controller in PCI Endpoint. Such that, whenever the PCI host writes to the BAR region, it will trigger an IRQ in the Endpoint. Basic working follow as 1. EP function driver call platform_msi_domain_alloc_irqs() alloc a MSI irq from MSI controller with call back function write_msi_msg(); 2. write_msg_msg will config BAR and map to address defined in msi_msg; 3. Host side trigger an IRQ in Endpoint by write to BAR region. Add MSI support for pci-epf-vntb. Query if system has an MSI controller. Set up doorbell address according to struct msi_msg. So PCI RC can write this doorbell address to trigger EP side's IRQ. If no MSI controller exists, fall back to software polling. Signed-off-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 155 +++++++++++++++--- 1 file changed, 128 insertions(+), 27 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 1466dd1904175..426205b980a09 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -44,6 +44,7 @@ #include #include #include +#include static struct workqueue_struct *kpcintb_workqueue; @@ -136,13 +137,15 @@ struct epf_ntb { struct epf_ntb_ctrl *reg; - phys_addr_t epf_db_phy; + phys_addr_t epf_db_phys; void __iomem *epf_db; phys_addr_t vpci_mw_phy[MAX_MW]; void __iomem *vpci_mw_addr[MAX_MW]; struct delayed_work cmd_handler; + + int msi_virqbase; }; #define to_epf_ntb(epf_group) container_of((epf_group), struct epf_ntb, group) @@ -253,13 +256,15 @@ static void epf_ntb_cmd_handler(struct work_struct *work) ntb = container_of(work, struct epf_ntb, cmd_handler.work); - for (i = 1; i < ntb->db_count; i++) { - if (readl(ntb->epf_db + i * 4)) { - if (readl(ntb->epf_db + i * 4)) - ntb->db |= 1 << (i - 1); + if (!ntb->epf_db_phys) { + for (i = 1; i < ntb->db_count; i++) { + if (readl(ntb->epf_db + i * 4)) { + if (readl(ntb->epf_db + i * 4)) + ntb->db |= 1 << (i - 1); - ntb_db_event(&ntb->ntb, i); - writel(0, ntb->epf_db + i * 4); + ntb_db_event(&ntb->ntb, i); + writel(0, ntb->epf_db + i * 4); + } } } @@ -454,11 +459,9 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) ctrl->num_mws = ntb->num_mws; ntb->spad_size = spad_size; - ctrl->db_entry_size = 4; - for (i = 0; i < ntb->db_count; i++) { ntb->reg->db_data[i] = 1 + i; - ntb->reg->db_offset[i] = 0; + ntb->reg->db_offset[i] = 4 * i; } return 0; @@ -509,6 +512,28 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) return 0; } +static int epf_ntb_db_size(struct epf_ntb *ntb) +{ + const struct pci_epc_features *epc_features; + size_t size = 4 * ntb->db_count; + u32 align; + + epc_features = pci_epc_get_features(ntb->epf->epc, + ntb->epf->func_no, + ntb->epf->vfunc_no); + align = epc_features->align; + + if (size < 128) + size = 128; + + if (align) + size = ALIGN(size, align); + else + size = roundup_pow_of_two(size); + + return size; +} + /** * epf_ntb_db_bar_init() - Configure Doorbell window BARs * @ntb: NTB device that facilitates communication between HOST and vHOST @@ -522,33 +547,32 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) struct pci_epf_bar *epf_bar; void __iomem *mw_addr; enum pci_barno barno; - size_t size = 4 * ntb->db_count; + size_t size; epc_features = pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no); align = epc_features->align; - - if (size < 128) - size = 128; - - if (align) - size = ALIGN(size, align); - else - size = roundup_pow_of_two(size); + size = epf_ntb_db_size(ntb); barno = ntb->epf_ntb_bar[BAR_DB]; + epf_bar = &ntb->epf->bar[barno]; - mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); - if (!mw_addr) { - dev_err(dev, "Failed to allocate OB address\n"); - return -ENOMEM; + if (ntb->epf_db_phys) { + mw_addr = NULL; + epf_bar->phys_addr = ntb->epf_db_phys; + epf_bar->barno = barno; + epf_bar->size = size; + } else { + mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); + if (!mw_addr) { + dev_err(dev, "Failed to allocate door bell address\n"); + return -ENOMEM; + } } ntb->epf_db = mw_addr; - epf_bar = &ntb->epf->bar[barno]; - ret = pci_epc_set_bar(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no, epf_bar); if (ret) { dev_err(dev, "Doorbell BAR set failed\n"); @@ -704,6 +728,82 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) return 0; } +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +static void epf_ntb_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct epf_ntb *ntb = dev_get_drvdata(desc->dev); + struct epf_ntb_ctrl *reg = ntb->reg; + int size = epf_ntb_db_size(ntb); + u64 addr; + + addr = msg->address_hi; + addr <<= 32; + addr |= msg->address_lo; + + reg->db_data[desc->msi_index] = msg->data; + + if (desc->msi_index == 0) + ntb->epf_db_phys = round_down(addr, size); + + reg->db_offset[desc->msi_index] = addr - ntb->epf_db_phys; +} +#endif + +static irqreturn_t epf_ntb_interrupt_handler(int irq, void *data) +{ + struct epf_ntb *ntb = data; + int index; + + index = irq - ntb->msi_virqbase; + ntb->db |= 1 << (index - 1); + ntb_db_event(&ntb->ntb, index); + + return IRQ_HANDLED; +} + +static void epf_ntb_epc_msi_init(struct epf_ntb *ntb) +{ + struct device *dev = &ntb->epf->dev; + struct irq_domain *domain; + int virq; + int ret; + int i; + + domain = dev_get_msi_domain(ntb->epf->epc->dev.parent); + if (!domain) + return; + + dev_set_msi_domain(dev, domain); + +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN + if (platform_msi_domain_alloc_irqs(&ntb->epf->dev, + ntb->db_count, + epf_ntb_write_msi_msg)) { + dev_info(dev, "Can't allocate MSI, fall back to poll mode\n"); + return; + } +#else + return; +#endif + dev_info(dev, "vntb use MSI as doorbell\n"); + + for (i = 0; i < ntb->db_count; i++) { + virq = msi_get_virq(dev, i); + ret = devm_request_irq(dev, virq, + epf_ntb_interrupt_handler, 0, + "vntb", ntb); + + if (ret) { + dev_err(dev, "devm_request_irq() failure, fall back to poll mode\n"); + ntb->epf_db_phys = 0; + break; + } + + if (!i) + ntb->msi_virqbase = virq; + } +} + /** * epf_ntb_epc_init() - Initialize NTB interface * @ntb: NTB device that facilitates communication between HOST and vHOST2 @@ -1299,14 +1399,15 @@ static int epf_ntb_bind(struct pci_epf *epf) goto err_bar_alloc; } + epf_set_drvdata(epf, ntb); + epf_ntb_epc_msi_init(ntb); + ret = epf_ntb_epc_init(ntb); if (ret) { dev_err(dev, "Failed to initialize EPC\n"); goto err_bar_alloc; } - epf_set_drvdata(epf, ntb); - pci_space[0] = (ntb->vntb_pid << 16) | ntb->vntb_vid; pci_vntb_table[0].vendor = ntb->vntb_vid; pci_vntb_table[0].device = ntb->vntb_pid;