From patchwork Fri Jun 21 07:04:40 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: 13706912 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2050.outbound.protection.outlook.com [40.107.22.50]) (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 2E19116C87C; Fri, 21 Jun 2024 06:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952977; cv=fail; b=uQTFebu5jpvnCbYCrqjjEkiFwDxquipk4ZC7OQUw/fetMY5MPjz1ULDNbo0OjkCmlzSLR5HnLiBL/WyO4vePiU2j5TzCEaGfYiQ1dlJfMWHbb89aOIDoLYQL7gZt4Ox2rAfOmDgMgYz9Gx+qRSmgksOcHh+HAqcoDkKhfjN8dG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952977; c=relaxed/simple; bh=znwwOZYcZ/cOQiRbIjSJ/wWzMCcmPndge6mLJ8jCWiQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=CZ7VJf5wFi5zeXztirQ/h5RbJtoCGvIHwXCHXKoUjTW0gEzY0ZWOZC3HqTspeX2nsxp07jvc0MybRK0fE0QFxtzqVv0pciEUf1o+4VNZEyiCkPHBfbWL+M1xGL78D+whs5//9BVRFN+nHiqjAgLUj5oArFUAal0HrtIsLNUMmKk= 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 (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=R9t8s0Uu; arc=fail smtp.client-ip=40.107.22.50 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 (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="R9t8s0Uu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P/vPhHHiC7Xi6JRXjisKdhkhg1WAcjV8kq5CfirTgRg9aE8GLE/P6J2lunzsrF+6EvsPtfCpmELp9jFWkNubcdCRELZGeGHTU2ZvLEV8wbM6bxi16xoiYm53N9oXadaF8yylvTbHk6KwxFR4e9cvjCKyJHGX+LY76qlfbnOUrxTzbROzulzqv4IHvuAaVwSTENa0Qx/xWFdnHbD2XMS8iKlp9At7Rz6C8Aimt4oa86hTj86vCReRaQr9w0zf+vm7gkSky2S+p6LvisgqM/yeSDdFjPCclTcH53kyghY3l9bwgUEoGHsD6eo5ceDrqr9FicufGXARUrqgawGh74SOqQ== 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=7LVaQmxewtWgDieWlVI4F6SboEGpS/btxQN0knD2YWM=; b=Jo8sq/SnrBBw2qd5j1b7ZUNobA9ae0HrRd9pEjPO/X10HBZH1C4mayZktNf0RjDJQgIvfbeciMC7YYPKW7hgIB0b7kc7ZTAGO/nChmHZrdwC7wYdHAaBNSvbMR40wWl4Pg0rOMMzKP3pLm6/QtkrQC/sE8OzFMRJvvPI4NViaFUXhko1Le3qWS9s4LtxV1kCu/QGvbw2Eh3Zz0OuIBjwhO+jzr3ILJpA1t5fRiqST4T8DNIln1x8WMUOG46h5lhcTjWMFXDHa3jlR28eIiyqrjnEmzPKM/JH/+Q1te/B1VSyo2RjuFrbtDGVE1YLpAIASWsoGgFjzUTbTk+W9BARuw== 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=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7LVaQmxewtWgDieWlVI4F6SboEGpS/btxQN0knD2YWM=; b=R9t8s0Uu/QrFyhQmeWs05Pnf7WYkvgZxC5jlOmzv2gx0hZiBGiKuxEpXX+UaVjCCZeQlltNbu89JMiW6YYqdK1XYRIxw/Bpvrv8xgxY8jvWpqJ8HJg+QVWMkZBrATVpLoN6o4SJAGeD9dfUXBk0q8iN2mmd1LuDrGi5DDl5QPBg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:56:12 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:56:12 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:40 +0800 Subject: [PATCH v5 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240621-imx95-bbm-misc-v2-v5-5-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=6433; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=6mJryA2gjuHsLRyd9bfAMdNInUOb690lV8nR15s/uP4=; b=HVOZ0M8O0QK/VT0rwIgpBNRRnE0B9sW7iPNmUNYOQTEdL4mZm93qBOKNC9gs+nnxVOxTYJqPJ tDYyzIuTPblBuZi/ZkizIxInPuhc5Ug0dojz8M4dy3pPhpOaSdp3Ad4 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: f217f2de-d50a-46e6-06b5-08dc91bf3c75 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?k7b/YlhTgXVJfbd2LRyDyvylgb+gfd8?= =?utf-8?q?TlCvZgsuRk+obxMOpWXGnZ3+cge12mHxXhU6MWFSoN9PWoJiPsA/0JOIZCXgNSwrz?= =?utf-8?q?8K/zd3FVUp3854Lyh3T/VmO6nQLh+8VtD3XIkb9EUFuT8YUVp9zc8GA2T+r96fCAk?= =?utf-8?q?MShE0JTTrO2ZuXwVfgnXm1KODoZ316LDo1QRQJTk5EabsqTnf6jRF7+Ti6UuF1OIB?= =?utf-8?q?Q6I7tAOqoK332JZMN/1HSsYyQuHoz15b9LkvJx+qBvSoKKb+xXKZIHYSrdAO9TwUz?= =?utf-8?q?+k1PpWZ2OCFiGULUW6i1p77aBsf40nDkr76TBwAuLbi5hQtkwpSxD1yyDkeHR1I4s?= =?utf-8?q?o6dzCmUeLHg12dynXwPus8qZsgivsHWN0Ptpqo+emFeRfcQ2t5ukpLiHFvnr4a+L5?= =?utf-8?q?G2rSq6FHjS14CBd5gGt3MA0sadRQgOrjDT508sDMu5FEsmk369o/tiQsrnIg0e/6y?= =?utf-8?q?e9+qJmpylPtzByijFkz6wj6FRDjYRVcFBEp8wWc4FYbnzvE4QG7WKhhqftVoL/dJD?= =?utf-8?q?YApqt5obV/PcXIzqJntH8ad8jnHUn9twA7P4fqMZujpGMF9T+qdpgTdUGHI2Jcckx?= =?utf-8?q?BPy61scsrw03KGdqP5l9R+tJ9B57Ok3X7sQTgxkLpnkAmtr6piIBjl1rpxGjcfQMe?= =?utf-8?q?yDhBDMblvMRr4uYUqxT8dPoW7fUN4uoeYYOPHYLRpys/tYTQzR0mYu+tRc75F4i+y?= =?utf-8?q?mhs3rs1V4QZkNy+a93EMwHWpsQEeJWH580XzeU5rneLbBCSErjDfenVnTmjMjEfOV?= =?utf-8?q?7mvmis4ZiQT+Xo/CSKkJFoLThw25Jvxi/otDXyCQ64S7WCkK/2n0oRTEdMp2vY2dY?= =?utf-8?q?xr6NzO82JGYGXEcwzhXFuBmpNPy9cPSvQQ+EJnGOAotW3QXKXC+ok7EAUG4Vwdpqc?= =?utf-8?q?udasLFwTCRlVxjd85Zh58DLiYToT3AverT0KZW9LkxKFUDwALh7gc8d8XmzKIR6C2?= =?utf-8?q?ASuJvoQjHLME8JUqtKmquFm9ppvWDDGmsspABQeXo5MgSravzu3A2X11Fv7VDuAT1?= =?utf-8?q?DJrs500kISp1YiPcwI2ErR+nFRpR+RR0Gypg5wOHfEsu5vNNnRt5U0anrXVvujpwh?= =?utf-8?q?AbwEdF7zgPBm5kE9ElQu0iPlvUGKKDh7JUFFj6gCVPE430KLvjN+JXEP/QduoQsaZ?= =?utf-8?q?0tBDHYiPLEHpH56fa3A9dDfXKNd+M1gCMztSru++05XfJ6VChDsKGU5wBFAysvamP?= =?utf-8?q?YKhKSygGFJWmNOK0kL2IKkUSyq9bxNGQvZdAgG7ABKFgndaMUvU/5dOH6wPswbLLf?= =?utf-8?q?lEaIg/rGDEtrrOhhUuycuz8SSdcRWrfiJrw79QLgoGZ9MD//nN+ffOeItakkZfO1r?= =?utf-8?q?sa3hJl0nsKza?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zry7EPgENIAyUHDBnzoHYS8JH03s?= =?utf-8?q?LtQG9pFCJrRzUjnujt4rtSQjSgBHPHCdelvfeyPT5rPWUJAl8Iv/SN9vFmKggPTWa?= =?utf-8?q?klCqyt1Dcjc9UXPRyyxqjq0mGXH3E5OnVej5XGIfpHwXvGwSIpinsmDbnhBOIKKcG?= =?utf-8?q?p48iP82FXZLWBLLJDgSEjoG5EEoc8akVm+eOfQcaXF94srxG4g3UE2h9N2/IEq8TA?= =?utf-8?q?++8A/FDpoSfT4lNrVX/5HvYuTmTqprxwdUpzkeCvzNjV+Pq5cVSpY0aZ8gPMqWfP6?= =?utf-8?q?hf76qMNGk3TG+sVW92XGuwH/0PHYzad3XuRcSKsLLAQELNjyJVda5/I1BTPMQtqpl?= =?utf-8?q?UzUMmEvo8VSmEMQSS6VrumRUw2WZu9S8ApMGW9g13DtdZSLsJa1UTVl2IQvOje/cE?= =?utf-8?q?aJuBhHKCMkNPeonbfKom39DGMfgHQatGnkc8FAAYvcg2IE6sI2IycSwlO0LCWMCPs?= =?utf-8?q?LAtrRiNsoz58OibKV6joOj0IGdO9x11eXjr+muwU51ECjre/TREAa22iowo7TIMGU?= =?utf-8?q?ikkpiH5HLlpc6GnzJahM+tHCngDsCGEvrPkqHzcNmakSfhWp8bet6FnIy2TJZo7Mb?= =?utf-8?q?xjMtovNtaEU/XkdLl9Wa4/ba6zEY8jDfW05brHt8xtf5Q39DWydzFGHRJnj+La81M?= =?utf-8?q?QfICCMyr2wDDi5cxD8vFsYMvQE1vqpEVTUd4OgA2dO+ESFE8qmj6T4JiaE0GBa9FP?= =?utf-8?q?/xqv3AsxCV2mz70FJKBuWLM5RrvxePKHGbOLcuDSXYl5ba8ydwN3i0k2MunWySHF2?= =?utf-8?q?yWZyrkv1/AEkkTrHslzGE4QiG5dWeMOGn0VkmPx5PI55hHf2TBse5FJkwAH4LXTax?= =?utf-8?q?ubovF2fV4hpqHQm4aH4bcfuFs0YUBmSKC/wLPgwLnh8TfAwCmzyX9U1uWfmMDZMuj?= =?utf-8?q?WBfXimy+hw0kGvi2Q6uKO3yp/tdqLLxrHpL39MfGNq23XNWfWVxi7ir9mCvuyZOX1?= =?utf-8?q?Fvw+MDyLVyQP8A9hFoc98hbdhLVK5Y8wKm+9p5LZWEmDQ8pZyTlMUieHrt8rdX5R4?= =?utf-8?q?tOkImvytRnLVQZZjGXlXjKtfxnAb1Odxq/0CL6RoOh20koh4gq2oYZufKMsHEJL7z?= =?utf-8?q?O6XPRmZpDNLdOgFQ0rtJfvVZ9V9vHJ5e3V5XxD8q1C2WCrd6xFYJL3vUQvPvWskyD?= =?utf-8?q?7L2BMJ0UriEDHRc3zLr7BjEA3hVSWfUL8CFbDQtmfcc9ONuqAe710mbgKjEBZ8QC8?= =?utf-8?q?VvV+a6q+fh/IIBpjGGrXAe5oHrCoR07AaOZxi7sCNC8VL5S2gmHEItpgLI5SC2/ux?= =?utf-8?q?itZpwnO49WMmgZwNtwhO6NfaNyuKxTKF1W1yiOhqoDWA5IjB47DOfHSi8PWcZ6LQe?= =?utf-8?q?3nP5Jpz6E90Xv1dqtHAzyEwD8QcrPmn+ulxFRnAqiE7twJXhAfvnL9EiVA99/L5YF?= =?utf-8?q?VJSo0jDDYPJRQhc/Wd9CeiVA9JdldhieFPBzSTGJemVvT2yxvtvW4+9Pb1hnqwFFL?= =?utf-8?q?EmVVA2BoQYuOXItE84X2WrwLVtSMl81o2YGb0nxdgGsoXIC9MNdieARGRCIk6M6pf?= =?utf-8?q?GacZfKcUxgbX?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f217f2de-d50a-46e6-06b5-08dc91bf3c75 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:56:12.1161 (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: Ppkx2QiVEH+EDgOBCe8Pu3ZnnvUnJptFzTPsmbMoIrOvb2Oz8k7ecZMdnk+ikCu72fZq0TBEiDP8Nim7s4DA9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 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. Signed-off-by: Peng Fan Reviewed-by: Cristian Marussi --- 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..342e1254a356 --- /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