From patchwork Mon Aug 15 21:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12944091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 603FFC00140 for ; Mon, 15 Aug 2022 21:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YBOfdq82Qq4mS1G3VKoPNjXA+lpyFDtGYW3MX358oME=; b=25VxKNS40Lyk8S eYCN1+dfuUBVtnpK5PgJmOLqu1ft6LaYdjEnTymIlTEAxZvt2+YBn28kpjAiNt+UqP41tzCNGDKlB +kfR9aLwfDi1SG3f1AT87hXFaNcHCRzVpnuF5Go8JvL3vedRGIwX701M977tyA6mbGNo7gHUANwBX RntKbEDe4kZJugYknqzeXcUxQyubgHDJ3Kp7h5LiXS27V3RMTMWmzYUN8tcTffjiuNfQ4oZeDWxcb s8geuea1p1ewty1q2mEFwIzMXQLuwYTL11UANKSdT1EEVFW9SV4REVuSMfuGkxzcY97Ehz68QBMBw 8ULQ4s8MgZaN0M5LlNVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhp5-0061NK-ON; Mon, 15 Aug 2022 21:40:36 +0000 Received: from mail-eopbgr10055.outbound.protection.outlook.com ([40.107.1.55] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhoj-0060wM-Lg for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2022 21:40:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mE9MZJgE7bET3oMsKj/jWnmVFaGf4oyj8HQkWrTE3fvhjRba3vwvlNjd1WZyas+CDtVvmTW6fhzwM3Ju+QaQRpj112Uui9KNph1bw3dTlmZ4tlUwZ0w6P5W6xL6/fxeDsAhl5vSiZWCuKmkpG7B86QlzSmz1Rz5mmgQ5y2IRJ9OAC8O7rJkQjHf2bZdc/J5oGZRaBO+F8i+hgrgCCH2VxM6DpHuKkHXRmkGtZJjBnahMMrZX9bX9JvUxp0M3DWIZsKc0C5HeKWCfsdmHk7BojcKdGnwYQ7zY7nDzSoBuF5G0JT6rBLtfU1yRV4SlMSNlHlGu+nx9eaAzCPD8CjnIrA== 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=lxewPW8SK910D67lWGNBEcbKhq4EvkfSnuoGwHeo5QbxNtlMeJGaeCHXUGTAR9YbRDw6u7P2T4vSU9BOWOUwXYqTGyxBkOMrPfda+f8VgcnmH+cd1yeHWUMatEcxTgacSAMbtvmQnmuHR/DKDm+KbxFvBaWhgPvYEh64DBLpbyq/HsD/mxDMhsDlEKKuvoy9RWBAGQjV7dX5LaP1P6z7tENrXbewtnDYGo9kZxGtizM1J1BRmZdRPzVL8buC2xjmMT93tetj+5Hvem6xTgYLjZE3gr01KmYIZMUo6W48seftJpqoOSzIKNKwN7EEY+ygMUWr4rL7uGmwwbw5CKAdmw== 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=HOMMuUB6+q+zQQk/9c/fU70wCj6c54dhkZj0gOI24AfonDQ8llo0z7Txp79fhyn2pA3j15Xav46FBjm3ZGutQ5PrYyfrjljnkGC8g/vn+VGGkNUcf245qnKsIpdTt1Cr0P10cieyQKa2klSg2B2UxjkTS7TKLAOI009AD2111+k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM5PR0401MB2580.eurprd04.prod.outlook.com (2603:10a6:203:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Mon, 15 Aug 2022 21:40:04 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004%5]) with mapi id 15.20.5504.028; Mon, 15 Aug 2022 21:40:04 +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 Subject: [PATCH v5 1/4] irqchip: allow pass down .pm field at IRQCHIP_PLATFORM_DRIVER_END Date: Mon, 15 Aug 2022 16:39:33 -0500 Message-Id: <20220815213936.2380439-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815213936.2380439-1-Frank.Li@nxp.com> References: <20220815213936.2380439-1-Frank.Li@nxp.com> X-ClientProxiedBy: CY5PR15CA0006.namprd15.prod.outlook.com (2603:10b6:930:14::9) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b51522d-36c5-4335-c199-08da7f06b6b2 X-MS-TrafficTypeDiagnostic: AM5PR0401MB2580:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 24BcVxD3rPca4ujQiOFrqm+BC9kVnmII35aEoRLBKEZ8bTP18Vc5lzqYq+axJvz14JH2a5LrBbdnQ/4pMi7/1hxtu3/eQU7xOwaw3vUZ/cjNSTr3OFoUZxsJw/fJOer9D3P/1U/LxO881PuWRhK3cgxaMpYSRonkIeCfHJbWRNW8okaoVfaHbph+g69aYg7E1w0PlmbURbge0w3IsWNfRJoj2YiStQmS1GF9jhxuXvMW6MbUyUkCnO8FdY/JOciL7G0yNWJHlrWqzEyWGy7abrmp6l0bPw3/lZYzYkrnEXdjIGiKw2PfFSlJTGdDRUJk0EhEMQAT7WbHagP3j2EIYG2OyHryGXvwQn0cRmn3Ua1tLsQeUEl9NuyDxnZU23y/P7EL+93bxyCzckjhWhhKsCm5vW1ITgtse9/JFZCMi/9/hb1LMGz+vp0+fLujoMApioEhjT1EoU8lNqvBPOBw3S//AyWhdH+zZ9vTGfIRal2Ea4Q7AOMKi21+mquWTVUHnTf/tYew6lWrWzEP/uPLbuBRml4ud/OoQs0D9/cOhJqL+WH23tGBPYPhCaXWNlsd7uf3vkSCUIe9AgWC0cy107g6UfU7srNn7Vu06dNyJczNjTnebd34Ma2ZLjEo0uu879xH98zsu1fhDpSZ+FinqUgXAGryIjsNmdo6CW6mOI3CI8nRmfoENdzfFElPPqSznnGD6MEflSlSk2vj1sQDhzruthSYfGr8rs/b+9P7T6lsevfb0BSGbbWHwlwJC8zNm9ig/CnE3BdhEpBzo1V1sU3cTPqmyzFVZTVvrcyUNP77h/34cd+BiJWPcibWOHOj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(376002)(136003)(39860400002)(396003)(346002)(83380400001)(478600001)(5660300002)(1076003)(36756003)(186003)(6486002)(2616005)(38350700002)(8936002)(86362001)(41300700001)(316002)(7416002)(6666004)(4326008)(8676002)(66476007)(38100700002)(66556008)(6506007)(6512007)(52116002)(2906002)(66946007)(26005)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BjGVUjbg4q43hlsInv9oap3uRh1LN1PGvxKwZPfhjWvvV04y7+jW3/dpXS8sDtynCstZfEYl8mplyeGcTtrjD1sp5eYGme8bWmwYTbs8Ab53NVlnspfXchIya4awwPmvGwb4+clHh0yfPOsOiRbgFXg7aaBmO/ZDcqaNbUzacadIfc5MHflDaGWK+MS0KucAbOgKX/pKrEzIxXpm0IDWJrPYwTymvn7shkYMJ4ur/0ps19DYOvePx1LPGqHz/zPh7t1JcjlfIQqjquYojLm0wh/wshA7KSKUwo/56o7n+cy2bxspcj22+dcT3N1krc2ZuV+uY+bTWY3rGGRffAkjvjAyXNBpVI5lZ3lDRc9jDuBB9cIYXbojr0ifYv5kCto44dpkATicB0zX/mUuMGpK4GExxtKhoXrcnscLrA3x0tyWK37VehukhwVoLlp9KwEFnhCjW3qI7gHQuF6IlHNdtZJEFXTOfcbikkoQ8Bbagh3N+7IaKxvUXXqiQ9nffaB7TEX89aU83RvzDRMk2CsPkoPlzBrNqvy5VB8hocY/fqXeXOYHOGrsxPXAa2h+jwlEKuk3xPDkCj239julSgTanTsdDHqrNtODAxpSbptsvmmj3JkCo7ldYgepi2CugCmp9ywuXjQl8hEmbt3iRNTvzjJmxrsDVS0rNWbLRCoMKx9AZriefHXwJejIfpifMJ0Oybyh/dnjPuLSmqWTeFosyp0xv0ezXB3gOZq6Heg6BAzeVxyecIBifLFQJw3IqBckHzkd+86FHm0iUpc9K8W7IRN8FzNKcGreb0nNDb3ER6sTPJm2LNGPxnDyCXBRJ6P9+gr9woc8DhCaoKqEStnUFjkLUOiNgrsxM5mr07GkFeXagkCo7+Nmp6UAZBWcVfh1E3S9N3rRhcR2PSeAmUQuyIM8AMUd8I11tW9yfGlYeC6caDj4ruOIXInutJ9B9D28Wla47fLh05o46AAoQNzpWezx87gmlnKvcKifL2bg7/cthS3LWzczuUuSyEfNlx+EiAoMx6cTKRm/i6xc4W0Wf80Hy4sy2pxoWGoyciHhqIzypnWp6g9EiqW/6YFAyOJXlz1w9Ms+jnWIa+u02Vs9y38E3CmxWISjmPUyELjsceZ0q2wO+fsal8r9vzc1yEQ2FCQDrdc4bQE0tn+++AbM15KtpS2DOomvEY4fcQPPuPJKnHtZT8qAmNtvRYg6QUgivqsX8DJStFyzb6/ACC+tPvD3wYtgtN9Ff/m9Be9ofb3w7hN9VZXbXozdSpLShmGGP+i/itQjCWwk3pZEIQsP4X4YpKcIdKuvR58PcU31g4PeWjvo4Mwvw0GjiSnMYz76PvDX5riOkCQMlWcq7PUyjG59rJz6CoSg4jcfuGB9lsmi87MHEZJ5+8joh2YQiRUOFMJYFHiFU/NlANdcnZjZQdNR7eG3Va/FGA599QZZ5zrKMqAnr6wkDYzDA2kgQjTR9/UIzG3xqN659AXb3aGw1dVZA/q+BMUiA795zbcdq5QssVayF/w9oWAYHyvjiKMTV5mbAv3P2IeUnrmV1V8XTNEDlmC5NT7po/CBZ6ZGDopYwLOMxF1rsn4BDTAQXciU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b51522d-36c5-4335-c199-08da7f06b6b2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 21:40:04.1639 (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: 7kGclmAP5Sr8eJ9rvC8D04qDFVtdSJ0FQzvsSyB02+9dWQXv/8GSPbtAlKAnRlGlwvtypV5iX/d1pJdEvdz2vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2580 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220815_144013_749580_83CD798D X-CRM114-Status: GOOD ( 11.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Mon Aug 15 21:39:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12944092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FF76C2BB41 for ; Mon, 15 Aug 2022 21:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=maSBVoDfZnCZvOUlDwbRXP+5KvnwvTk86XpkKNbQc14=; b=JaOmRdSmxqLiKR MiQbhWoP0eIofWfXeADRaygvRysJCwUDFkOHPQcU0a5nVDKlKvfSGlu7GdJk+vk+VsKRTCYfmzD72 1UrE8W7Bn4CtSSTlAljwBcQcyYfaojbCBPkNd9TVykp+VrI8jmTGUZ/npbrHp6JXnnVJqgzBNCwOY ewTNl+tqmhxYn309oa4Rp9RGTJUx3eBbm2J0efQYXz5McRC1PqNsvE3+BIJGk3Uw2DwpuGgZzvSt7 qXIdgPs7+hWG6SIAyuld9kim4FwiatLBJxf7ixRWHF5ZJmW+Kc0hz2vNInD7Nk22ktLA6SqjU/XXw 5jla9d3a/iuvT+5MvFlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhpL-0061go-U2; Mon, 15 Aug 2022 21:40:52 +0000 Received: from mail-eopbgr10055.outbound.protection.outlook.com ([40.107.1.55] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhol-0060wM-E3 for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2022 21:40:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GGJqM1dNs5QV2VlKZzHFrkrbO2dkD7Ak/5sYzjWVnMw3rHjbVw4adQ+k927LR5DOc4SYNcqaDw8BG/QJnfI5AA3Nw0y5j69d4pJA0MsjWvndWdUD/HuN3xK2SKaN2g8Uq5gx/U/L9MEHsuMK+s9YCtlCwVKF/8i/ZaLzdEbP1CUfHAnw7lDuwQSNkMReud++7gG4w/Ly1gkMdVUvxv5y7rB2OAnEKogeZNTHnvG3lECNdQfX4gwEdI+ywEOXJiTTb8dY4FD23ugOe+ufulvwmpeAEeHo4mmd4nV4OAUzK+INCTRCZn9jiI7ujTgGg6B8FkVvXUyiu9IytR70J45ilQ== 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=aZ2qPOqRvUT4Stm6wP/WJGhBGkxLdX4pSj90vv1QdAE=; b=c1JQUe8DeeeWSmW5+rJrMC+slBXHT/i5jAByG0pOX3rIDA7sQAdfYDdi0ZJIDo2XrkYscoE8gMmhzZ7Mlws/UcgjZmNHi9E41HAmvcFG6e6UcNTMoYonLcwKWHKLbrowZKz3fwRUv1xAVSHFj93XXTwWrlnfy65rYpQQuA/nKABy7vTTqCIuaE6UilOD4JsP4m45ktN+5KqPZ4413OM+SCR2sfF2X6WEOHgzKXrmNboZdY3/Sxb6YUHtIltVuwxYTLwtcBrfLxjIEGd3KxaTQhYoZOSWiK8gQ+NVfnxZBTvUqxH1seIVfGGiwQqTP98gicnJFIRZECDKgt0oBInAxg== 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=aZ2qPOqRvUT4Stm6wP/WJGhBGkxLdX4pSj90vv1QdAE=; b=RTply/FWnt49bj4ULTzrMl87F5h4SNSs4wKRTOkqYZleWhbC1ZjXkd6b3bLSRiVVvZUJXCrZOjx8Y0nH/dU1njM7NjvuEmHNxfeZS6xWvSyOEU5jTS9g0PRBsgS4Zsq+SV4H3OjoRe3f1MElHafaVQX17vbxFEQ70udmRjbK2EM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM5PR0401MB2580.eurprd04.prod.outlook.com (2603:10a6:203:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Mon, 15 Aug 2022 21:40:08 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004%5]) with mapi id 15.20.5504.028; Mon, 15 Aug 2022 21:40:08 +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 Subject: [PATCH v5 2/4] irqchip: Add IMX MU MSI controller driver Date: Mon, 15 Aug 2022 16:39:34 -0500 Message-Id: <20220815213936.2380439-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815213936.2380439-1-Frank.Li@nxp.com> References: <20220815213936.2380439-1-Frank.Li@nxp.com> X-ClientProxiedBy: CY5PR15CA0006.namprd15.prod.outlook.com (2603:10b6:930:14::9) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52133588-543a-4708-9ad3-08da7f06b93d X-MS-TrafficTypeDiagnostic: AM5PR0401MB2580:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xmWDk2oW4TONyrgd961gFDABFUhKDIndN6/jgMukCbH+yDBV6f3Zwr8SujuWpkhQyxbIenM549TbMHryuAYXQOuJdSdKLc/7k9kjsmKfD7FZADSVKLSfDzLnZbFCYGVX9EiMpXByHR/PSF5rglT9KJKcXDlyvsq67A2kQgdClZBgrhzwCuN5VGzwCnClC1yc1IXpkQL6LylPHluTu7KvGWFilYr2r9WNsXXzQQr6w2dPPnAojuzUjm6T7Ch4AiiNNZzf3r7HWhtZqZl69P5TymkVRBKsFKWd0b9NHnaonoS0FXyeQdZESHE3fekuKHnAAeUDmbD0kw1Zp+LhU7QI++qYMVSGyH56K7xgchSk3ikWRO3Qv5/i21J6IBFNnvcKG68ksiawV+lGK3/EymsQnTitdGzLuwDEMTbpmURmC9hnL5Lwdy7F/B9GwH1D8SDKqpg7ubSqJBDwSXtDdKxddHt3OBP0IJ7sAwp51DfZloqaLQwz1IAH+RYKZaPzbUPHHOQ/NFmc4N0NcQoAh0nNr5kvYZIJaO6VJBTDOIengrthqtzzCNwI60NN59lWeK7fVX9FHyTERLOs/quImsWpBS0l5RUL0EFBD5OD/Jt+AJ6eVA6TfPpRYM0MwjaK3OarFGzhkAcfZH7j2Z+88Aegx4tddKfk2LMq7DLoPpWC2Ho9+pTPLz0IWM8XTeifJXbPFe5SNirscBiDRQ65EC+1Pn1bjrmClURhQLILjXRV1itz4/aicqFVSHphjbH616vcFWgX4RgESi03Bjc/5ZeUGbbHoNTT7ID4OiJeu+h3lYM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(376002)(136003)(39860400002)(396003)(346002)(83380400001)(478600001)(5660300002)(1076003)(36756003)(186003)(6486002)(2616005)(38350700002)(8936002)(86362001)(41300700001)(316002)(30864003)(7416002)(6666004)(4326008)(8676002)(66476007)(38100700002)(66556008)(6506007)(6512007)(52116002)(2906002)(66946007)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PcJuS4kZKc7SiPQ/rb93h2+sgkO1/XBRHgfwCYmlog0r+7h6kt64bRmJpEE6r2UkJ6xO/QtKqtoFRTKte8LmHl/XzgO5ZbMzoq9HEMLAikW01eGmnrMuh9f+7rkTprQ95TtJ7J74i2XDBPZXojTHifi3EXMIuIkT1GmALlI8TSgARxrJCwIYKSXJ8jljYZrF/Mzxs/5Ub+wl5FJ4GR3wBmthFCndVP7M+km7D97Nr8D+4EUZE5PGx3zENiQhkGvprPC1WbEL4InwysD2oxkGsHpNUu6GIDtSY+fM16K0W7PKdEJBMlAPPq9s9mIt4mzEvkYOmZ9lTEwcuHZGy3h8LhvKrHWE8IpIJkziM++hEe7WM3a3yhUoipvt7Xes75UXf1HUHdCuGHJyVpYtAcEUrsfWFvUGygftzCd0ipuVJJVUFBVjY4rnk08LRFFHxrOofLimlu2wGavKX/N21q7sx3iv0vzFx2g5MB/aG2zZJOtIVARcRba69Lq0ph2LjF7MP4i6eopBDRu386WozNL/AVcsEhDR/Weap6VZTwo7vi8k5hEsrGixWazyKe2PiIdq9RP/AHrY0Dx0JMrkIQ4xM/5MVVyrsl4KB0bet7qXc6Q70mIV5ySDHdAFd0+JJ+sS234qOUrp/ocBfWswTJxIwGR+UvDaFsJe2aYLzRMHCK7cuimIkEQU4zKM3wdR/EkRAFgJvZqLakECr3FyCPVu/FJUu66Fg2/V18i5s2lOyjsAUHzUJ9k2Z7ruxxbJd3H/puCos/u10MBRGHrayUEUcNKTtJHHg4jvNyRnmToMcaJaRQ3IaVY9y0JYLxDWTmIWhxsgqbwVjRRzwfGLqbnsXcFNYM2tVup8sOHS/GFc/nl4uVs6LDifJ2WAxjzdEN5whUtMLcJuUJIdTixB/0Ilg17sL+Wc2Aa1JsX0KqAAAb/dOxuGJ9yYjkxcQomB5LHuDfPzZdsV7FrFk8vVRe13lP8Evt9agrhvfA/2YuC6GXQtY7ORKUFHDtaVDS2s7cm5U8FWyJkcn0zp63ebqXZDlLR9EjB/PpC+kQ3DGlVdniqxJcywMaZOSdxWr0MJM2zlkjj/NNUjEba/6rN6svdptdDrt16eXLFTrqb8gAs9bbHrV97KTV7D/RiaVkYa7Ic4m6WkeYO5Zv4Dm+bHazzYwoD95G9kIROuYvSJOH5n1qKhn+oaxu/JyRXhRr4L0pns1TyA3mPNHSwZ3hbhTKAR6Hw8B+tgwWZhw9Z7RP8B0Wau0Q9eeK9aoSvO36Nos3UkbNpNjoO15YiA/7tA8FDvBpjfKAYTOiRpPMbHOZmkc6K10EvsQXRjfRE/ZwZp88HtQR8ZzOfdqxQeOWsQMD5TJ+iK8zYvKAhLJtr6XJwUnmOoWATIbuufo79l8R8uYFkO65kGiOQM7wEW2+wlF4AISawpwqw7niEmSEGlz6OLGjyzgg4A9vpL7KPF2AvgAAhDB4TT8dHXpuU3qWtFJjnUFB5ky/LJ9v/uBGQPbiAYG/Fps1E9uwpaW+n9WVLSM/usawOdS3ydtVXWN5u7WgBPVHY/ZZS9gTbhl/hzYiMc4KF6gFNJILL0a7iOvh9rDDd4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52133588-543a-4708-9ad3-08da7f06b93d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 21:40:08.2106 (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: E2WPF5sVKnayhiAWSOaa6d3QASfP3Co7aP5uj3lrNUysKfb02oiOH7qUzo/cB9H/adQG74dJO45NyYEAN9XDFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2580 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220815_144015_776399_906D1475 X-CRM114-Status: GOOD ( 21.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/irqchip/Kconfig | 7 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-imx-mu-msi.c | 451 +++++++++++++++++++++++++++++++ 3 files changed, 459 insertions(+) create mode 100644 drivers/irqchip/irq-imx-mu-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 5e4e50122777d..4599471d880c0 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -470,6 +470,13 @@ 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 + 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..1930c47c3570d --- /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 imx_mu_msi *msi_data, *priv; + struct device_link *pd_link_a; + struct device_link *pd_link_b; + 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; + + priv = 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-facing"); + 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-facing"); + 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-facing"); + if (IS_ERR(pd_a)) + return PTR_ERR(pd_a); + + pd_b = dev_pm_domain_attach_by_name(dev, "processor b-facing"); + 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 Mon Aug 15 21:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12944093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 407B4C00140 for ; Mon, 15 Aug 2022 21:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yWjEcPXbZKDS9LV/ZmXI/sgtVTqWTEZIFzOS1D1VELw=; b=mp3XRZqxmIWu7o jt0h4R41XOs08pqmdkmnvry5PvW4RSa/dxqFB1nBSmLjQYeYH5XPhQp1T0YH8SbfgGWSuVi9VuodN tw1yDFKyUnFuNUHFWy3Oc4Mq6b6FzBGT/P1PXZOOaGsyW8E0wCSMwwHi4T+5DkaNncnXV8AYWA3Ay irWdLoCQ6kIUh9Zz3A29CeMmXQDe3RqO6F8wMbK94XB8hhU2wsIsBEGt0jBf2Kco8g6TYNXUFJZrx fI4yqCMeFY5UGjiuMXPoTpWN/JHHo9ERZPAtf1r45oRqat1BxXX7MzZy5EZjDJ8E4kOVyI4fNaP83 PjNggAS/mYBD73vX7fVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhpp-00620u-3C; Mon, 15 Aug 2022 21:41:21 +0000 Received: from mail-eopbgr10055.outbound.protection.outlook.com ([40.107.1.55] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhoo-0060wM-N7 for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2022 21:40:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YkMuWDU2nYuG20sOI+LWNZ9nM9HVbBW1ApZ3sbe3Cz/AthUo2QY02bMRv8o4rVmlQIHJLSUkyA2kbtvGn+CTIxi90U4+6cbynBANBLtmugfFGg+3dgtweOPsisPqBHYubAyaI1JyLSnGZIqc3cV+uLMnzHBp6vh1hbhfLMtia+tDbdqqXigv/anrvFnNRL13g5pB2rZNGuFSaQlPPKm21tOkldRZwr5oNRMVW8pI3SZcHUpFwUShnwsVcIN4+AG57k9FeFD4G+SwOHW59zyB9yYbBmpAwJhqKkLl66ln+XJGNd7aBFV0uLDZST/jxFiEht4Vo4VLZovzMAafsilQFA== 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=OVFJJkHBYbxdRZKhWWlDd3nZUmM3IMXu087up/Kc5H4=; b=dNMQT/hW+SpUO22zUoef3U1N+BJ30UAKnvj5dC/oDzcuYAQ9w9jHlKajqA2sgbJw5UdysrQkqN/h8cI+5G0MQsXOdl3CgXFl+FJSPdQkoD9ScJIHPSO6HmwwFlQrbJiRSDoCCxu2Mu5C1Zk9YK/z+VCGbIR6xxe83aUa7yT1N/pfNfULbmD3sHyanTT9tcsF1fTfiwlG5jZZrTHxPYvgl9/6063/KhV2RaYKJRF8CeViUIgCMG71CMHQWYta3ln+94kNMhLaJ51cpuK/EhQJcouig3hHnLPYnATA63YU5Tk4RwIZ8p0/fS0x7Ozp8ud5ijwTPvz9xn39gtNnT7Lc/w== 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=OVFJJkHBYbxdRZKhWWlDd3nZUmM3IMXu087up/Kc5H4=; b=VtUTPuWZ9IGmWF7J8a1NPp54hW+L5nB7soCRWchH40tYO7lsT+sK1sP+/1JHdhRx31BvdiV0vhS9lHUKn+2riALBJcm4muPZ6VFgIY9BFNBKZVgXVugfQUsx/LhcoTqYBCMCTtaMJ9P0SqIivb/UCJICmFvnrT68zAjPRBkOjYs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM5PR0401MB2580.eurprd04.prod.outlook.com (2603:10a6:203:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Mon, 15 Aug 2022 21:40:12 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004%5]) with mapi id 15.20.5504.028; Mon, 15 Aug 2022 21:40:12 +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 Subject: [PATCH v5 3/4] dt-bindings: irqchip: imx mu work as msi controller Date: Mon, 15 Aug 2022 16:39:35 -0500 Message-Id: <20220815213936.2380439-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815213936.2380439-1-Frank.Li@nxp.com> References: <20220815213936.2380439-1-Frank.Li@nxp.com> X-ClientProxiedBy: CY5PR15CA0006.namprd15.prod.outlook.com (2603:10b6:930:14::9) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7b74b96-7dd1-4f00-3c74-08da7f06bba7 X-MS-TrafficTypeDiagnostic: AM5PR0401MB2580:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 823vaPcdn8QytzBsZzkRhhaOtJ+qtk80wjeG6B2mw45Nj0YjVwYI+oIaxPtvR4djkdBZN7Eo3n+OnenbpIUr8FeGf47MuAVQYYboyZb2/wwBHk1xWMt+LVnZlz9KkZjKmUZQmaHJN4BQwMkQmaSpTQdbz1rnWZOQO+XiblA7hnD0c5zZXQ/FFcZlsTbQ1hKSI3OKpihFY5y7Wj0t9/TgpidKUirlJC3ycJRShB5s9+tql+/NGBWwU8pOrjxQhnj24NfHBrtzE+lWPLOzU7Tx87JBaGXu9ccL+NTVQOlgzHTdOFdVsJcuUbuNkeh6+v21EE85z8X/NQxfsMk2DLrIKr5O8VfzOW48rdnlRrJyWcwN1ENs0fkJm3mweaBuAhVUod+IdyPV6vIZ/+PBxpVLplFYbVMwMXGqEGiQ4P7ML/ODge8IwugIrHT/vFhKUAnzslg4WLXz1Kdx94V+CO6rFRQ4RgOcQtkJhNd3WbNMbU2iQEwThpOQralIPtGYPnnlSdEElknbgLu3tlu+HUAXZF10ztY0D4rllYTtQ1MRDivQedHUlYRROGydZ+cuS/3+DQE12efK6rdM9mX5eCL0xdq7uVl1S+14h8Zqtb2zE5YgpZKF8b4HcJRY3zcWBm/hxkzhnDUhw2LJJHTHobE+L8WZUM4pnAc/xlqUp2B5mgvaHNJ5lNyzzLdVno4h53m4xly0GZXvMTYBndRzwUJwl7ew8QtAtuGPrgnShFw1xuLzgXNKLEipfEiydq2YR9bQIVdvgxNSroJdB6Z9lSM2I8HyGcagFQmz+y4dt+r5cjsrQh3B0SKKxjLU3yJpmX5nTNGgIDkQGeRbPyKYwfx/8/fXrprvcfycM7ZAK/g32Sc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(376002)(136003)(39860400002)(396003)(346002)(83380400001)(478600001)(5660300002)(1076003)(36756003)(186003)(6486002)(2616005)(38350700002)(8936002)(86362001)(966005)(41300700001)(316002)(7416002)(6666004)(4326008)(8676002)(66476007)(38100700002)(66556008)(6506007)(6512007)(52116002)(2906002)(66946007)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pxi1yxYHRuJwR6NSy6Nq+UXjY6daQYDSuCistELxJ/7YyA/+75t/WgRnEyKEFiDuJzZbTeS8I0haMGlEPzZHKAjoUGEKvf6pheZs5ojC7Bsn8aIIbWQK5HoTXgjewxbx7LAW6hQzXY2QCwXpMpBaKUk0M6cNxDv5OjNCcbYh9cmG2m2kkv1ibbiYbedom88KQFIK3Y67X36cIAjrent75hfjK8P9I1a8lrYw6TZHf3Yk8B3BvlbV+A5oP6e/UEJ965hug2AVz6oV3uAIev9SHcTCWGKldGMCtJ/BRcs87n6r+T3h141pi41FlkS2neiOAD3ngBn8WRYaBOzYz4AEbK4AmaLXI04/WPfsYTZJN5F8zgrrWYUI70ZzlArODGbwP7WhUJA3D6ULzHz8pDadNhmqJl8jZ4RKZEqgx3Kdw1o7pJwLxCr1UHDv9eX3It7/X+o58uIs/wbhZP+uosrKn73fsjiSxj3Z1PMS9yjJOlsju3hTpPAPB3NesOGyJ4u37pqtUYKfnTOAKqBb/4ddnYyHLgkZ57eHRN/tUF5ZHPh8v/JrVJAc7HBxof17MUCvtyuatuSaqc1O4a8Aqcd7wuyNT3sDvSl4o6tMAhIDB+0UP/5GZ/HLqI1ug92F7zv9HioBAzqB2XQn0D+YpYs/pW39c7AFLSR73MO78M7+ZDQGbgfH4HagidGb3aqJMnBwZR78TIpi0Xf+NRzytNGwo4b17dicYz7cjdFf4sio7u8GMU0K3S+ewqidRnQYZyGby59wcIYcoHXlO/sAjvqtOT24wHijfsfPSYD5DusR8JCdZIc+Q/d75wkaAnoPxCt0ncO+ioc12eL78s41MZL7r8AiB3MVIEHKQZzjwQWypM0EjtAy2p+AZpdDskuHo9T/olrNUvFroSf5eu9qOvigvzfrOKS0/u5T7drx+iwRGOuX9m9nLxC3x3D2LA2TVoNxp+Yxy/i5VDVXrqippHFoSYxh8XzAYWggmohx1W5l+B/Geohd5G+fNImhEi87TezEPQR0C6CGRf2s/NcrzhuuND3n7bfAJz7Z7ZiTwL+ozCX1SgkxUSPA8fljkQ9KwRhecP9oH/oZeWM4yuqKu/vl3jhdYyGoj6b0lHQdVRN6q+HdTrvXv5A8YoEnrFDgZBP8C662S8PB+LIodPO7wC9gd/PaJo6BjxWIqZd6q2ION5w3qYTQutUktj+kSkRDhSUZzZnbP+FBMdlQD3ZNPUuWZZGJIJlDfUJkV9eiXht1ehsRT4i8qScKxNX/AYtYFb2+Cy0wFANZjJ08/z4LB/Z4U9o7owd3RF9MBra6EAUBoYv8mZOqhryBFZIFhZXmpKd2tRLrbfXFGA0Tz124qFQbDKBVkZulfcjFd4e2AesxJNloddGbvvSafLsNb+E+bcv7Vl4dVq66UaAV/pTMSc89caeXYReY4ZjU/Kq9299QTNJGTHNfSJqsNk95NB0PmdsN4BdlKvlfahSaVNncoxCPsYy4unlBxzjIPRPfqzI343OeC6NhufalkhFK5R2mNtOhssqX+8BLCRdQycN59CtUh/WSvakkuED9ydLBqDFgTsKWD+pN5kfsY+w6qFUv685e X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7b74b96-7dd1-4f00-3c74-08da7f06bba7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 21:40:12.2739 (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: NjQxUPU7tI4J+UvR4+4OLgGEjzAZs+4ZFM5XYJwD9xbvoYpQJcjY4j36FW5HqCxCvcQ1XniuXkL/yDlIhT8RxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2580 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220815_144018_853354_308C0A5C X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 98 +++++++++++++++++++ 1 file changed, 98 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..ac07b138e24c0 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml @@ -0,0 +1,98 @@ +# 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-facing + - const: processor b-facing + + 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-facing + - const: processor b-facing + + interrupt-controller: true + + msi-controller: true + + "#msi-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - msi-controller + +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 Mon Aug 15 21:39:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12944094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40EDBC25B08 for ; Mon, 15 Aug 2022 21:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UdvQwyeaeWi92Dea9uIy1cBLbnvjSti9btrp/lpvt8o=; b=I7+vEBn4WE6IPO Zf8fGEuw5gBW0qHkCgO8pQTBnMgLRwJhsJGpkfyBEo52fGFoxSL9n8yUUrQFgcDRSNxcd3chbShD9 1ckBVsfttrkUfgfYhOFkHUslUA4yhblNqrUQ22dmbfXqYQtJMBw8h63xVe4Mp8aaJS/VEL7t813wO 1X7af9BEFzjKFcLj3oNMKt/LEfUTt3w1mnMqkkdfHzoIjLV6Wutw2M0NCUpRmde/AmlhwRl5lK3Nq x7ucdwpF4Hi1M7OkqJjx+bjyxvAnDJlbBqOezZ8wjsPFSVPnYxwK7EMkFw0SNpvFPEt/YYKsBCAXv OJkV5hjfAtUdgmyXLUzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhqQ-0062dE-4e; Mon, 15 Aug 2022 21:41:59 +0000 Received: from mail-eopbgr10055.outbound.protection.outlook.com ([40.107.1.55] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNhor-0060wM-0C for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2022 21:40:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U09tWjYbMbWPGFcg5jArO5SZsOgWn5vakCtu8ypzSC080QdWvMwJGVtHynGeKz+WYsAZf29BDHfkC7/yqlEEPoG9pvDtyM3sEa1tn2Z6sc24zWvtfXxE0I8cRGUyK3z6m799YVcDSWVo3HfiWHH5RKTNSXsCegT3C29iHccX8uW5ps4GTlSu0ZQ3L7tRQyAmcdYfF2pDOOKkq1CC0yPYiPBSLyl0PZs+rKZ5wZfUIYRSUu0+t45feMdeoz0DDFT0OfYiWIt95wJgfzeRpQHKPuzNZ6XeAWeOVoqJHe0vDD+5FX+KtgzbQ4sr7ugMTzz6R6aOrNAYnpQUlMWuLHl5nw== 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=g1NdUcLeUXF4fzJDgh+3FCiqhJxBXQ8qbrSj5WgwzKo=; b=dGVSt0ORMMQ8NlpzeOimNs2SxkM+lexFGeXAxFpxhTQQOpP7wXJXEZdb8G5nVSa7a1raK/Vh8rAX/Zp488koC2Z1iHSBhl9Y8ihm32rDh2tcbC4OUl/zZnFsJuDTIFY58GreAG6bCFCo1OfvQIaAcbF7qlwzmXiixRn7yBFUotAKdXR04/q9QzuuTd8sZ4y274/NLXiM/j//HVEs1Hb+RVi/PHzC30ETwK1jxUAaFmCjObnN8DClIGhZHwBS5CkLNfwPgUtKTzJqzZXtKClXTjtUxs34aGPQBfI2yc1K9JPKyrQ6xzA+btm+SIstVwH9nHOp7m+lzmhf3qWu0cdNFw== 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=g1NdUcLeUXF4fzJDgh+3FCiqhJxBXQ8qbrSj5WgwzKo=; b=XAJEEZbIfZfKGnXX6DjsKPWHY0IowbDPhiRP1WEF/BAGwKldnSYG4FHlhM9zWUySUWBT/kauJ5E+drFd3EEtf0Ifu8qe+P/yr6fGZ5CweVNHLWnwGmgJ0r3uBgntOp4ugHeFMtpzvW0KS9HHOSpNjT9TJBYyqt9h8hETPmb6EcI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM5PR0401MB2580.eurprd04.prod.outlook.com (2603:10a6:203:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Mon, 15 Aug 2022 21:40:16 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::c5f1:b708:61db:a004%5]) with mapi id 15.20.5504.028; Mon, 15 Aug 2022 21:40:16 +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 Subject: [PATCH v5 4/4] pcie: endpoint: pci-epf-vntb: add endpoint MSI support Date: Mon, 15 Aug 2022 16:39:36 -0500 Message-Id: <20220815213936.2380439-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815213936.2380439-1-Frank.Li@nxp.com> References: <20220815213936.2380439-1-Frank.Li@nxp.com> X-ClientProxiedBy: CY5PR15CA0006.namprd15.prod.outlook.com (2603:10b6:930:14::9) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a71fac6-145d-49f3-ae68-08da7f06be15 X-MS-TrafficTypeDiagnostic: AM5PR0401MB2580:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WiXYlFO/TrmjrcBxVAI9xpchPGoyQAV0JN7pE3UPK1X1jJ1+e/+MCL8oP3Y1qR3J8AIq+heUiZte1DtXI5zTL10+kcE7Kvf2Ybc7kGK53NbOamIEymAjh2+p8m3hT9HDstJXo/6q1vIN8x2QTilXWgh1kPFKTGBeFmNSYNyNgTdFRIyDHC3fBQ6fDH7hLv3YrnBg8YS5P6+DCNXZctd2Pv+Y24n7LsqFxxiL8+76iYR4ZI1j2bqzljnir1wT9RjmVggwi0FMsjCt+gmNRLu4d6Yf/RydNGjZf93c42qYW1iGQXmTvZnbYFEwj/dhRJj8carf8fhCRRWldQW494/dEXleAhEFmzv/QrOWJ810bedluNWJnNe2OfoVNq58p0Z83BNgHhkNumSg8ClMiB+s6i0D04ELBB5k/jp3TaxIW9HKy5XvvF4LLQTa40APlInXYDkl+ELCdIXX6K3yVH9mcAaSkikTT9OKpWa35qCMW9rKHOzT39ipsZ1DMiARPIZuskxYdLu1l6M6SZmji4yBfi+ZyiGhQrtcQHISpZtBtmJf9t0tEQNBtq3cgnloOtAqvO7CJuVpSkrvg4A34pm9XXr7rEuF5NmOkfn+3M+EcmSQLT9Wy3amNzMQV9IaQry/Fg3kdM4TiClXJrG8vWLoNFvHA9kod1EoKBMyRbBlCQ7mtZWj/bN3pfRYZgO+3SX/RrPBrb8P7PTPNunhoW2m0C7/dpQdGSFcSacnqkDvhRRj3+9Ds94jIK4iZ6447bKY9Mo/PIO8ewAh/VUOxPyHz2PGBhDdTvWPc/abkKjq5Bw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(376002)(136003)(39860400002)(396003)(346002)(83380400001)(478600001)(5660300002)(1076003)(36756003)(186003)(6486002)(2616005)(38350700002)(8936002)(86362001)(41300700001)(316002)(7416002)(6666004)(4326008)(8676002)(66476007)(38100700002)(66556008)(6506007)(6512007)(52116002)(2906002)(66946007)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HubK25Iz1mN1lvmH/AMOd+gAQYP6?= =?utf-8?q?HIKmV8aE7IJsk6g+dH+tARPXJu1Ra72OxlfpnSD7qcHFaR8T9W87uaNxvB/FWKQHg?= =?utf-8?q?aen4803eabIjpCdHreisqYiSHm07qSpgwkLmIz0tZYf+jXs2bS3XG48klzHy3n83x?= =?utf-8?q?kREFAqDmkrkGfBDDypWxLiMwP5NkSLHS/tRwb8y+K/MPyoml4dC2xUcp7XoTt57fa?= =?utf-8?q?XEI7ejQOWU3zrgxBu8m5FOLVf8ySO80jAceJwem2xAZU6PuvEEfm5GjwM+T7XndwG?= =?utf-8?q?yx98HvoRKSAlxxGQx/zen2GxHRc7k4QhPJQLgLG7IMaIuqkIi9Y59fE8TYq3RNCTX?= =?utf-8?q?e4WD9LWikxTs8SeXQIGr+AJesvNn4UUFQzryNQf5eovG2+jSkHPwLLlrlHERSPdRT?= =?utf-8?q?G6itotbM9L9EOEo2CqVzT2Ag/T3ElyNoqVAZT72CbvnBfXvAUhLm/0xsPtuLQ/ls3?= =?utf-8?q?sGCzApGXEvTSvDhx+pXCVbEhlE1GnVeOaBmCERK200miYSX8U7Mh8xPVmlRBugXRo?= =?utf-8?q?kS3qzBVweg08Ydu8iPWpSGFEXt+7yMErHxwMVxUUmgZlFlrhsKwI64cxsWgvKhAKd?= =?utf-8?q?fcps0918HNdN4r8ZSUmfh5npMd/fty0HEcI/7245UWAcIEBJb9ADCvG8OpVd3KRiY?= =?utf-8?q?sBU6u4BX0D6/ESaJYkyUefKfYX41NaV3ZXSi2ih4o1EQlq/8lm2kehiaF6EbGdA+J?= =?utf-8?q?96iGNkKhFiusllUn1RmdLtAcPYcCR79i50etJoVKsccpk00p88UWs4U1etDbuWOZT?= =?utf-8?q?MWj4aO/o2SBBh+qc8Xu5Uwu3EfWmCjS+AnXZvbh6NHSQqHuOKEDioLG4JwDnlTdIC?= =?utf-8?q?OKjwsnGnnkdTVg2qAt0Xdaw96gqgQUhLsdXnR8gGJqDr7PKwLeR3opTXt5ykNgP+l?= =?utf-8?q?3N3g14AAu1OooCgi5XfDFLP1WSNPThuhJ33QLl2X1UVgQHfMdS+qVFC2nbadfnleY?= =?utf-8?q?iEBWwG1vi9iPiAX820vWXtlsmtq+X74reXBlPm2koRUctOZleaGj/KNpwljG6LeU6?= =?utf-8?q?r9/77V6PRiDvXTQOVuYwULrZrenLYOVJNImnlmfneJvqNHrPYsr9Kzj0EdeQ8b+Xd?= =?utf-8?q?cQW+bGvxpcrE30Pg6u8xM6bD5EkO3qTfex/8o2elUlTWxbN/9q3Z+2PSvLTNVqc1j?= =?utf-8?q?rTM7TtbFmNVZmRfoL1rRCKeaN18FW/msKnxRne83bnrhHlb4KKBHAJ4QzE3z2AuS/?= =?utf-8?q?By8HQsLrueV9yh0/SveQJX5kAx+t5F98jRvIkby8DbVDeXjRfSPZ3q6Htj8mpVX3e?= =?utf-8?q?Fl7N6ynBdg/5x6v2Cb9aESTH9aKnuKGlS3e70VVhMJUvSHBNr+ghN9LfrH9Poct4Z?= =?utf-8?q?3vgVK9Hv/BBXQxnZr98QoDxdW3Dfg4is8Hln1pKFB7VV09ITW3Z8kJnCpKX6y08H1?= =?utf-8?q?qr/22PdvNAHSvHCx9+/o3hH6kIv9B5H+toCOaTf2lTkSVzbquTJWMjpFJtpvkey6z?= =?utf-8?q?qpDvM5iJNAk6lpnfdb3fJChbsicCd8YpD2MUHcO1naGa3wJK2Rt/qJYzz6UxdMV3K?= =?utf-8?q?FkYwTGDOmmq6?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a71fac6-145d-49f3-ae68-08da7f06be15 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 21:40:16.3844 (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: P/q4EVnQonnJtPAk6029ZoC4uMQ7z6LggR7Ps1GogxJTnrZo9PgyCfKl713xxHC1POuaBzeSElHSr7duHPneow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2580 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220815_144021_182240_5C0509FE X-CRM114-Status: GOOD ( 21.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ │ │ PCI Host │ │ MSI │◄┐ │ │ │ │ │ Controller │ │ │ │ │ │ └─────────────┘ └─┼───────┼──────────┼─BAR0 │ │ PCI │ │ BAR1 │ │ Func │ │ BAR2 │ │ │ │ BAR3 │ │ │ │ BAR4 │ │ ├─────────►│ │ └───────┘ └──────────┘ Linux supports endpoint functions. PCI Host write BAR space like write to memory. The EP side can't know memory changed by the host driver. PCI Spec has not defined a standard method to do that. Only define MSI(x) to let EP notified RC status change. The basic idea is to trigger an IRQ when PCI RC writes to a memory address. That's what MSI controller provided. EP drivers just need to request a platform MSI interrupt, struct msi_msg *msg will pass down a memory address and data. EP driver will map such memory address to one of PCI BAR. Host just writes such an address to trigger EP side irq. Add MSI support for pci-epf-vntb. pci-epf-vntb driver query if system have MSI controller. Setup doorbell address according to struct msi_msg. So PCIe host can write this doorbell address to triger EP side's irq. If no MSI controller exist, fall back to software polling. Signed-off-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 134 +++++++++++++++--- 1 file changed, 112 insertions(+), 22 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 1466dd1904175..ad4f7ec8a39fc 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; @@ -143,6 +144,8 @@ struct epf_ntb { 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,7 +256,7 @@ 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++) { + for (i = 1; i < ntb->db_count && !ntb->epf_db_phy; i++) { if (readl(ntb->epf_db + i * 4)) { if (readl(ntb->epf_db + i * 4)) ntb->db |= 1 << (i - 1); @@ -454,11 +457,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 +510,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 @@ -520,35 +543,33 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) struct device *dev = &ntb->epf->dev; int ret; struct pci_epf_bar *epf_bar; - void __iomem *mw_addr; + void __iomem *mw_addr = NULL; 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_phy) { + 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; + } + } else { + epf_bar->phys_addr = ntb->epf_db_phy; + epf_bar->barno = barno; + epf_bar->size = size; } 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 +725,74 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) return 0; } +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_phy = round_down(addr, size); + + reg->db_offset[desc->msi_index] = addr - ntb->epf_db_phy; +} + +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); + + 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; + } + + 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, + "ntb", ntb); + + if (ret) + dev_err(dev, "devm_request_irq() failure\n"); + + 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 +1388,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;