From patchwork Fri Aug 23 09:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774791 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013038.outbound.protection.outlook.com [52.101.67.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BA2114A633 for ; Fri, 23 Aug 2024 08:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403436; cv=fail; b=Dq1TUZT3ts8A5l/GQ6GLByn2mu6o30I9RSU69GMijsi9hJr0YGR6eN5IxGZXK7DD/jVzCu9dZvPVk4MuvWJdz5AaElIDoRwQdOuSIsBdRbxHkz7ONQQtzx/t3Ygu+rVFHXSerpiEgrrGEu10mAz0wuDua59PeB9AGnC03PQGDCo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403436; c=relaxed/simple; bh=LQvxg4wjhO9FWV8ybDeg50raOjfc2rJ4N3Rx1dkcBxg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hM2u7ZUX2KMK+Rp4FC3pBJM/IpglJbrUmt/po8pRNgWyDPIzJhPjciW09dgRhdaRK+r1CNBDQzCS2GG8WieStBmWCcR5yx8Lt7HO90Rh/ZUZxXfRAOuZJ+4O+HCsA8Gd9NwSMqNUgucgGsJQinpkj+RqpVfe6KCG3z33cwu1DeI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=rgn8nF0X; arc=fail smtp.client-ip=52.101.67.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="rgn8nF0X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MxDUnTMMhuQ6TJDo52aw5Znk4LAvsWLaiNnYYRPOH/X3J8SOy9GzfS0y5XT0mkHyJpY28k6sYi+Oi5T5QdxwepYn0UfIfzXSp3k+n7veotmfcBHmrUGvLiDyl9dpMuuYQaoZPJxrrqcWikOEsBN5W0NIaaGEf9KJwHIQV9aHvrM9Bu01/FBP8D+XPhpVN6PzbB9QTLxhTjvKKHMkORWOiSvgVUNkprP/aVIDUFb7vRXvObqH5R4GTI2WQ3wuxNe2KkQQaXpyH/Wi6xcX6TZZ095Avoys+sLm1iiFYvjo9+cDkjBODN6mPJdSkQQjD+CpDVk6K7J86XCjxv+2F5MiRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=tJ9BbhLwFgdLZiK9h91g5ImtM5fDYlp3ZRSCHB3HgOI=; b=qJsRfSZDtJ9Lx5PSdmV0+ijop3SJ3YvrXrNpKd/tEo3A8eoOXzY0Ep7oRpe95QFjPFMhQK84tOBlYQ3tiaIzVkl01mV7sWhRt3e3AuS3ZaZhizx76BIWGXUjs1EaJzqvSostCh0ppEjqkZJXVDlpkWt+oOC0Gpb8rePB9M94HXwwAdEmHRWX+8E66AI4RvAmL0yjkOTLneW1/SIaoKLzUvUxhjCZPjRqLLgp7ApIO6zODXUZGyzqGxZgrN54l51GOVsStwpMNL/bz139vXNiUS9djm5E/QatHfMqYLF3Mnb4KRO33lIxkngYiadGnY/Whk2vC3pLFzzQzb14S/mUEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tJ9BbhLwFgdLZiK9h91g5ImtM5fDYlp3ZRSCHB3HgOI=; b=rgn8nF0Xyo7gromGBl00/pGQTktfHKHPsCMowwbNflJBxL8DoOFn287PqdhvJ/cVeVCaeQMSWavIUxDK1V5bhPMJ6JlbJnvLbVfrp9uFBR7pOEfpv3elnmpZ+Dxu5BJ4nfyX7jhz1f2aJQii1A/3gSl/Gu1Cg2ZB79iGCdwxk2I6Z/F5kFC8V3ib7ngue9yzYt/28alWk4RwHnv1xjoFAc3CazS5LKUBGgJlk58NVJDkPxeVVVtFzV9ffpw8AL24zhL2ijDE+QZIu+I/hPa7MqRfesnr9HRbtA5mMSYoTzdNbhuY6Bg1gwv/LWJ8FQFC4Zy2aMkZOgCjr66BHpAF7w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7271.eurprd04.prod.outlook.com (2603:10a6:10:1a6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 08:57:11 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:10 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:21 +0800 Subject: [PATCH v8 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240823-imx95-bbm-misc-v2-v8-5-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=6495; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=D48dI8TueQeMQCWqqGsKwb9eBu8K4dfQ0em7IUIjo5A=; b=RaROcmSbo0BoZ2se9ht7oYUj31+I7UHCjbskbV7cgDWJXtzEhHxQOHG/7vVB/0iMOLFcLWTwn cbdy+sz3X2RBdp0FaMvfShXIMF8L5rXAr4hd4MmF7ioIjFcKkgIPjmZ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7271:EE_ X-MS-Office365-Filtering-Correlation-Id: eb5c36d6-f949-47c4-930f-08dcc3519323 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Tg6InPquUgOrL5f8I0rfPnl1aeD2Vtk?= =?utf-8?q?UAEHvEan6obQGKCXc0SXs7Zcl5S416Ys+usKEZDS5lPqM9s4sS0k70l9ZBF5+1rIW?= =?utf-8?q?v1qLtD+BaKW8QEpYXTDGgELv+X6aiSuaFcn+wR5mxJk4Zl0K1GPflPOf4UbPYcvhM?= =?utf-8?q?FoSSbCxsF5BLFNx1OBjz6R8/KDY9L9YOfjqXRli2ZXOChqDhqC+5QrGIpEZjnwReu?= =?utf-8?q?qKMXI8XfIpM+4xFF4bzjyau2hwrSfYa8UY1bYkzbaT582Msq3rOPMGHS2Z9N1OCkO?= =?utf-8?q?ek9W5+hrFhjbr+YbJzpc7X5QGqKB36wN39I6mWy2WsvWVYv90Lz0xEmcdj25OPOdK?= =?utf-8?q?TTnIrGPpuhNXf0l5TVcYGx/vBRpqI8iK/tYz7+3wsZFsyku9SgOyquiVolYpNJBvX?= =?utf-8?q?dY6pwdpRq47+Z2FsUvqjtGvF9cjww5AdtaEgln/udnZlszEGdPquTaFbFum1Fry35?= =?utf-8?q?9qFpOEolytrjzgsU8cRYxJg6hV8z+zvQxzMNKxmgSqHpToxMB9eWCXfIpnLBoN69z?= =?utf-8?q?p3YM9JOLTPCJnUzqZeM4hV+FDimBXrMtP/Uk5Dcj4ZXlpQpiNyBPLFu5sgbdFnpPu?= =?utf-8?q?sfRNxlherlKZ/CJQN7jIhmfa2EwyxOlnTrCFuZCPO0sLWC/y69YcF1F8WZBHDmQJU?= =?utf-8?q?bG0RnT3CslrfzFgmNx4AVoA3KVRhIWvb13rIE1W4HHBKHafEc5/0HR5clIXmJx5j9?= =?utf-8?q?rBnVgHD/+vs128ta0AnDG+XYf8P5OxNPPX3KJQv7/m2cd98u7xK8J62ousscmfwhh?= =?utf-8?q?eEXYFg4XQKVLrapIIre21rbNQjYulbUAyihdm/ZG/a5xGpvT+kEqZCnjZhbBDIjOk?= =?utf-8?q?bUe37IztUayTwBBKNk1+KFxrtaVNyKjHdjD4cgFPESLkEUxvbMYjCk03GTiLo8KYQ?= =?utf-8?q?OGTMO9KIkVk9Ee0VPxRi4+7utDFYmOsE1LfO0uToHiMzE+dlvAfZXDbH/xBtx8zcp?= =?utf-8?q?WiSOoYarHyg44nHMWQCtg6+ToB41YlTANWQmTEvNK92kZO0Q7omD9JHTOU9cycv2z?= =?utf-8?q?tH04JaU76XWFs7jHp950RJRvq97vyNHHlN5i+r1HL3nRrCfSCWJE7orQkYmgcMcC8?= =?utf-8?q?h6tg1NXie+mKDGJrlKdTzb/O8omk/WVakdSBiFqDMaHX9m4cBEDKqnTzqmfifvQsh?= =?utf-8?q?yc/o4M9a813QQcbduEmJRRETpmJ4jxQ//i38uvmUJy5n3N7QcEjb2p0BhUHOXOTjv?= =?utf-8?q?RvfxeS7nWaQr19nP/cF3jn4jTzXrsaG461dCC6qpGpmgxg073yJmVaxz6tR6q+svk?= =?utf-8?q?gyX51ian1jEFxtAa29bN0Z/cKG3wV333BApnqmzpcFmJjxMXcvJknsecnsWfJcML8?= =?utf-8?q?jG5LdnkycYKnfk50FTGLL7hk508FL0yE+hxIvQK56caR1dKjQbGQSkw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Nw2iCnZHBdpJ+q1ilHWksCgfDN2h?= =?utf-8?q?+osXr1mNsUi+ATr1Hp3aStRuRd1uSczepo/AluJ0QDCk1ejQmgAtLX/0GXkV46UyE?= =?utf-8?q?w1oyCcbJpBFLrmr6y+P8FqW8WvIbPDQwViKmEMBQ9Zj2YnUjRb+7R38d0I5KK2ASZ?= =?utf-8?q?M5PGMy3Wxfd8uEhEUNJ4ofDzDU4f80I89nHqz6J3MjoyRx6//Lr37xEqS4K0E0CMK?= =?utf-8?q?vyxH0+76qavxyBvKG1e+CDUufw8rW1CRIP+iMfXbrpQ4k/CBEFVrKRQovHYZRHl4Y?= =?utf-8?q?txzo728FFkJcLLyu5MdXRCG65pcA70lM2ch7Ka2l9BOOEXpzo+zEe8CEqvW/iL7Gu?= =?utf-8?q?UfG5Tz8aOAGtVZt5M587ndM/xp2Edg1gwTncBkK1bSBOl3HoolretfAx2hbhv3sIl?= =?utf-8?q?qkQfQEqFQdkpC7DDzeQPpx6SxYThu9rXBTwuJfKmUuRtHi5S7zyGVveN5G3Vmnidx?= =?utf-8?q?CEe8PhpA2/H2eyrJEZvFGwN9da+Cbm9hSZSZvQ2ql6swbG4ZRJXR4e1H7ge6WvSQF?= =?utf-8?q?5atbOZROeE/8y6jtohrWbSUpUYHu2wEJvZgwtjdIM1HP8OqW7H4IXtMwhh5VnJqEv?= =?utf-8?q?WxC8Y7VtAmOoz/j4Cq5LRvo97/TsaJAqerLCn3Fxjv1P/G++xAGN5Kwch5NrARlyv?= =?utf-8?q?8UQychjCK3kbw03MCTjhQ2q3UBcqc++yJVYUhV80v6G3mGvb0z/aqyt9/9laNh84W?= =?utf-8?q?ymTqd8AXPg7/A7LulJKfWXZtUz7mxMWOzu9gfuhBcJeIPdr4GJb/9tR1lW7C+9oFh?= =?utf-8?q?a9xhFjrw35oZWjlMKxqPbdRGB8S4cX6aZoe+wtbzq4IQavg24OL1R6zdHq2kNBAMF?= =?utf-8?q?5c1BbuecB/jjtPjLWLe3L/viC3awzkmgml4WYwN1Y7d54TiIElP5FZXhc+D+WwJBX?= =?utf-8?q?X5YY6GKygt26ek7nPP6kQAw2doHsU92rucLGq1E0W8Y2epMEPpvs9AMNqQeNiH+F2?= =?utf-8?q?kcbPNBad95YxgDENRYyVt5ZZ/r+QlYCXTbcOweBTQ9l+H1jAdzfDLAcff61MCbVAn?= =?utf-8?q?cxLjTYtCK+wt6h1I9cPXJbXjHPAj1Nzg1YmBWsaInLwLdYUhURHli+s/8PUDC1eks?= =?utf-8?q?Kyao919L0CVKV+pISicBTbuzNqRIL40Qn0OuQ3iOWDlq1L3yfiOq1snY5ZU7PlDLy?= =?utf-8?q?DioihtFV1g0HnlfFpx23RpA1GdGEJjEbMrDdje1nwScLfwfn2qKpUVu5CoKJlPner?= =?utf-8?q?mK+rmdZBhyt0CeBKGNELwMfrbC8VuLlTnMQ6FS8+z7ohXUy1JNRShjx28fZzekHB1?= =?utf-8?q?8w0xA4n2pm+BfVCz+3rjfhoXcsPZCXwz63V27xe6wk1sGj5u9gZjxupWWLxGs446k?= =?utf-8?q?l8u16WoKgiWfXwUgM7/N/9RfLhMxRLLmQ9+SJ2+tCOJ7TL5hcwNwMqLGcNC8vECJ/?= =?utf-8?q?LWrvw2UvMlfjlwlhvvN/dqC65ikvaSOQXU0tkGaUkP7w5Z7fvJrf92dObzl/BpZM4?= =?utf-8?q?C2VCpewQp5hpwOzXUgLUzfDWeJs13MSyMv43OHHOtFZsoJAQA/qNhYKgrb3w2egnA?= =?utf-8?q?zEIdhM3GJ6vm?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb5c36d6-f949-47c4-930f-08dcc3519323 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:10.8943 (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: M62CmeufP7/d7BVpv6s1EpfgE6+arUlkFC+hbFWpop8QhlLZZ9CemTfpdgrIL10G6WVqvyOBYdJlTzpVMSm2kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7271 From: Peng Fan The i.MX95 System manager exports SCMI MISC protocol for linux to do various settings, such as set board gpio expander as wakeup source. The driver is to add the support. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/imx/Kconfig | 11 ++++ drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 119 ++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++ 4 files changed, 164 insertions(+) diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 183613f82a11..477d3f32d99a 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -22,3 +22,14 @@ config IMX_SCU This driver manages the IPC interface between host CPU and the SCU firmware running on M4. + +config IMX_SCMI_MISC_DRV + tristate "IMX SCMI MISC Protocol driver" + depends on IMX_SCMI_MISC_EXT || COMPILE_TEST + default y if ARCH_MXC + help + The System Controller Management Interface firmware (SCMI FW) is + a low-level system function which runs on a dedicated Cortex-M + core that could provide misc functions such as board control. + + This driver can also be built as a module. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..8d046c341be8 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..fc3ee12c2be8 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include + +static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; +static struct scmi_protocol_handle *ph; +struct notifier_block scmi_imx_misc_ctrl_nb; + +int scmi_imx_misc_ctrl_set(u32 id, u32 val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val); +}; +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set); + +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val); +} +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get); + +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + /* + * notifier_chain_register requires a valid notifier_block and + * valid notifier_call. SCMI_EVENT_IMX_MISC_CONTROL is needed + * to let SCMI firmware enable control events, but the hook here + * is just a dummy function to avoid kernel panic as of now. + */ + return 0; +} + +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device_node *np = sdev->dev.of_node; + u32 src_id, flags; + int ret, i, num; + + if (!handle) + return -ENODEV; + + if (imx_misc_ctrl_ops) { + dev_err(&sdev->dev, "misc ctrl already initialized\n"); + return -EEXIST; + } + + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph); + if (IS_ERR(imx_misc_ctrl_ops)) + return PTR_ERR(imx_misc_ctrl_ops); + + num = of_property_count_u32_elems(np, "nxp,ctrl-ids"); + if (num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + for (i = 0; i < num; i += 2) { + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i, &src_id); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id: %i\n", i); + continue; + } + + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i + 1, &flags); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id value: %d\n", i + 1); + continue; + } + + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + SCMI_EVENT_IMX_MISC_CONTROL, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) { + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + } else { + ret = imx_misc_ctrl_ops->misc_ctrl_req_notify(ph, src_id, + SCMI_EVENT_IMX_MISC_CONTROL, + flags); + if (ret) + dev_err(&sdev->dev, "Failed to req notify: %d\n", src_id); + } + } + + return 0; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif