From patchwork Thu Jul 18 07:41:57 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: 13736126 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012059.outbound.protection.outlook.com [52.101.66.59]) (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 B70137E0F4; Thu, 18 Jul 2024 07:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721288013; cv=fail; b=gQm4J9VX/kMjKgexPKGb086rve9Bk7WiTyW+LolcBtubBkCmixv7D7IB7rp8cPCRIRCTzYHlo2M9PIMzfhYabbf8twIWwQxR4Fc02TW1myviWufLNwXaf0Rq672+FHeUxNwo9vh+4JF6sVvs2ntED06gQTeHbIkUNeX+r5GHGto= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721288013; c=relaxed/simple; bh=LQvxg4wjhO9FWV8ybDeg50raOjfc2rJ4N3Rx1dkcBxg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=S4CE85c88UQj+BlFOtLfmBfX/6YCe1dL52uhKZ2dwF/64UgRzmh2Xisa7FbEbQyy5NeYNTvL09YO8vgs7I0N7VX2IWoCr3xBKhdMVzDxPk7AnMs0Cb+eocdQzs6Gdu3pQQiVBP141QBjypET9wo9qkcW0o7abUuX3ULQqCGHNNY= 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=I6IdZLw4; arc=fail smtp.client-ip=52.101.66.59 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="I6IdZLw4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X5J8r8810dbs/UjZIfd2jcKokTZpdLiZh5DzK4R4l0mkM+3ccG4lLIj5Kx2M52wlQX4+mYwEKU3eQMR7NoVaYC2lMNzowEdqHiwrcKDAJ7pcsbOAPlFkn4D1axdPCKhkwKHrcfJ0mqjXrLS16cxaKxXHclIN/7uyXV89H2mNwtLf+JMpyr/zVIzqKfJooqWZh334Op7ysL8iXzcO0Ux7tmB4zH61TN2D2uFLQPJ3un6dVx08kXOndgpaxSETf+V+ViN8qfaEgptXwa5Tyt0hQlkgId8oaaFXlNzWOleH26ZFXMwZE0tPT0K3J0AF9p2Fz0fjvP7nVsY1fZQcH4jh+g== 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=wXWnNyENFwvOOk436wZLzLy9EPECI/uYXMmSwHoLlF1/E7jCPFM+AUJeQJQXvqdN0pTzosGe+Im6xIVdPyRNPt5rsWam/RiFqX2a6d0WKWVFmKLB7u4TwePwP5Cq5IqWn6ucaIEDtwwov7IaNulvL6ogFu+QTAy0fTqMB7ITkw/bMmZKsNd2ooRbgfr+YA1z46/WicvXOpEmmcNx/KHFbQ8pSS2Zbv5ucq4MRyjc732n5NTqtTkxNu8FVF2vQWqIWdm2uHEI1LrOXY7CsCxLR6wcZrn1hslCxquRGT+AXR1b4fjDOca0B3ONs9Waob8V1U4mzk4ZR3KKMsifQQUEpg== 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=tJ9BbhLwFgdLZiK9h91g5ImtM5fDYlp3ZRSCHB3HgOI=; b=I6IdZLw4HfeAyq0MCGesm/JikgEWbPoB8fyjfH6bZ3giJFo2RjrsKhNDUR3MQAnPljZ+vPImGC0dvm5jCmxjN7tijcATVzCNMjk1nNZWXb2sSXmWNbWDwkGhVpPTe5pQGbIxVhAf/5/xIPS2UJIka7nrUFh6rpiu3B+98lVY0ME= 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 DU4PR04MB10457.eurprd04.prod.outlook.com (2603:10a6:10:561::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Thu, 18 Jul 2024 07:33:29 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%4]) with mapi id 15.20.7762.020; Thu, 18 Jul 2024 07:33:29 +0000 From: "Peng Fan (OSS)" Date: Thu, 18 Jul 2024 15:41:57 +0800 Subject: [PATCH v6 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240718-imx95-bbm-misc-v2-v6-5-18f008e16e9d@nxp.com> References: <20240718-imx95-bbm-misc-v2-v6-0-18f008e16e9d@nxp.com> In-Reply-To: <20240718-imx95-bbm-misc-v2-v6-0-18f008e16e9d@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni , Dmitry Torokhov Cc: Peng Fan , 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.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1721288528; l=6495; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=D48dI8TueQeMQCWqqGsKwb9eBu8K4dfQ0em7IUIjo5A=; b=/iwcRLeSIHH5tHMuu6/haDyGHy7tIQzTKG2eT1qAh/kf+UM12oUeVhXa6+Bf6m4bdvOdwt33+ uTiWe3lLGJ1Cqt5/x5XE9AFulKaxfxX6tok9bWQRe//xH2zCBLU0EgL X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) 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: PAXPR04MB8459:EE_|DU4PR04MB10457:EE_ X-MS-Office365-Filtering-Correlation-Id: b81347d1-6d88-4744-80a7-08dca6fbeb49 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|1800799024|366016|52116014|376014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?g2eAhXKFKc0o19/BP2PVD7qkoqUI+Fg?= =?utf-8?q?XSEHs4S/qoxxy+0+OHKYVqJto6f2BfSVj4PrEOmpsvQg7yLJwqHIjuT4YZ15lSfji?= =?utf-8?q?QjlXX4Hqzgq6Rn32/uD8AqlCkwKMVQk6ui7e+05W37CiFRBguIMF9agtacVDRZ4Fj?= =?utf-8?q?Va1tqDL5hNC2E25iyC4DT6PzclkXkahD5GFPDbPb90LkcVSLnFh4dB1RroO5gmFEJ?= =?utf-8?q?DEiCez6xrKzlqDvLqlZPilPK+dKPM+YmYC4zRDaSs6c+32cqIq5kT809jQMh6Zk//?= =?utf-8?q?32iymgNW7oELlvNqPvnCI/5ShQ2bSkjH5uLyC/BZZcpAQegTCs1aiKvk27dN+5brd?= =?utf-8?q?/KTOqxLMjuiqcqvi3K1Fv79mMX2tXwRrPsNHpAK9TPP7/tY+tdgzww6WeaU8jrYUl?= =?utf-8?q?wCghh4C0FsubdzSHiRNWHSESHTOs2p9oVoy5LTyrsmhE51TB3VArPogeBwQx75tAm?= =?utf-8?q?KCAHLHKVYS+9W56KAyQDnv87DUNCXgASu7a7gqkU+hT3kBil/rGCf4MkxzwPARv9O?= =?utf-8?q?7IHJ/u+AK87l/IJfJjZW7fTehsIjpKkYv3CI/PE3r09vlq72K/IifkEoFN9uTMjEi?= =?utf-8?q?ezfL+Zvif7HXGcaFgydm5UCUtdj+ivOaT5AtoM2ttUQ8ee/mdX+VmNdcc/bt4Nqp9?= =?utf-8?q?S90uBJCDyjKuOsg+QKiI6peXFdpx7eUI1epaYLJOYRHjF1ag15BlRKFoiUSMTcfPE?= =?utf-8?q?wDcv+M5D5ot7QlI2MSSE85DfsT4vVeE82IbWgV19lVP3dM985QyDwcDrVyXAGQt3a?= =?utf-8?q?pL/bj51lRXlPum8hoohmaISqj+Sa0jp42xKgpfjpxKQf3GlXsOblaqMId4tp2FRDN?= =?utf-8?q?twK51rPmAQNz1Wf58WDVKstxCR0ywdmalNngu4yB5XrDvyU1icWYCTR9wYJqtUJeO?= =?utf-8?q?6jh3ZgMOzS9dpk8ZEpIJ2mSCr9IPclaNrTE1iNuGEHDGFgupFLfIB8TzvLvbWt9kH?= =?utf-8?q?qDra1Zyb4ssqr+c+VX9xim81hnCggNJYgI71e8jF+vs9bPCZBVtzbU13unuCW9eaB?= =?utf-8?q?3A8IDmXnNYVQLh3RA26DikbTq5Nq9Lf3Fi1pkvtyLOSk9CpYKNZbfsVTZV5zcGpdd?= =?utf-8?q?qbweBdWjIH/H2DmqGUo37m0iHDbmJmLIcUeGcCAu5Xhk+LlewqfTFKAcyKnE0WqHE?= =?utf-8?q?WlRi/cbyBGIOZf13wVHdYEQVWY4Z8psh7CopOo+I78t7fBeJd3vzSAr3TUo8rjGGc?= =?utf-8?q?D4+lFnmODzQ2i3CiZPaCr9fvNLuKVwD44zp96i24ehw9csfraVNazuiGbTMjLCGNJ?= =?utf-8?q?hEqL7Yjpwt50YqO9353t5WPfqIjmQGuAwTQuDrEeGr2Jw6Pb8mxIsoeXpduuWziuk?= =?utf-8?q?XkFL18kxDPsd5ZFM3fNzies9e/rLt5kfNneJ3T1mBvwnRJBRAt10IcI=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)(1800799024)(366016)(52116014)(376014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WYjuUTcm5463JHp8CSGSuhl6kxMV?= =?utf-8?q?nOeM9RH4zsWDBaCR8xAYXrjYtR91xIXkhSMJP3I6qBR8UEiJCBFsyfL+jn3pWWmqK?= =?utf-8?q?APoYB/x3ZqkpQ15G2N9yMdREAWAGMsCVVTffjGXKO2SsDzyWGNMDUG39bJuviUz4t?= =?utf-8?q?Ho5nRAHZWrobLipBs2zETdL5QBnBSgM1mI4BU5dDnpVuv4WC5Z5969hJVT33090vs?= =?utf-8?q?n5OwAVK2CDKZ9jUTnJNx91M1aighYg5Tf9f1b2LJ/JYtKgDZ7lf4ZBruhAJVcrVUM?= =?utf-8?q?j48d1XpzVm3PkXqm2MRSRQiCjAgKPMydvf+/+SlcOpX0X1kEE+UZ+FzssBVnw8z2P?= =?utf-8?q?3t1cEjsSAFLKDpc5C/kNFouXOUlei4/V3EGU+NqgUsmWoIhrIsIpCprBAxsBdqcKA?= =?utf-8?q?z3zV71LXFkn8ebDg64uqlRpWzyFbgZLwaaOpHxRJ90avMyi44dlMb6md3T06qmpSz?= =?utf-8?q?U3TK33BpaWtMad5Oe0vYgjQQV7y83kR6yD3H9ia+XQbuAlbtCuIO3xoO+MXwviKOE?= =?utf-8?q?EoDZ8ynJ8mfZ11eE0WnDXRwi6v01ly1newnohlvRZ96JlgaPyFt/FlwTwPDh2YN0C?= =?utf-8?q?/NgqACJQCTkuIr9jFfOCeVmQUgjsAxyy/XzgKWFHc8VSvWCAO/jZUqBD0KgszRCuW?= =?utf-8?q?40bxIOP7mn/CDyLlK85bgFCzZAOL+opJ0qO/tzCrGpA27mX2WvQXE/itSufLOY8nn?= =?utf-8?q?ArmkBQuqddRZoFNDY/V9IS9AQIaD4lyVWS0omS8HVdZ9KO8JwRIxFyLGi8L1XQmgd?= =?utf-8?q?dJVbIsDRDHJ9s8qjdWaZC/lauIjC3s5eygd8XV5hNyUoPupSzZQY4ymb45NXwej2b?= =?utf-8?q?4XUQf1Ea606BTyLKCplomJk76nVVfwdOCAXovgy6yUwkx+z4t03/uUXSC9WniCzcT?= =?utf-8?q?D+/D+sipZ9nIkXfkWRJhr2i3d+w3r6f7cJCnjbsBWVfia11iTHyEuzax7kjOGzVGk?= =?utf-8?q?8aPy0fbJnFyltw3G2FyvOWUhG1vVrhZNWwDfOqxwa/cEKib9vGFcFkz15sdciEqI9?= =?utf-8?q?FtbE8FeR1VYOcyqsa/SuDu0yp2EwEvUcDS9wlgk64cQy6o44w2xRPjSGWEXNvTx8J?= =?utf-8?q?lGYrnnY41M5fUCEq0PCWcig3DQDXREGG4uDSjIx1yiAZrzVoGvd5QqDMql7kdFr8y?= =?utf-8?q?Gy7FaVeDDvQSaUn2iI9Fkl7YsK1/8t0bjmu9QGKoA09NtpG9SyJsQiqQ4sTJwUrjy?= =?utf-8?q?wz9VbePNOsh5yyS/6O6FCznbKsV0tPfiQSLUkIsfQb8gi5pduhDb3f55TyEsbMgXJ?= =?utf-8?q?XW1gPwOe3URrIWTojTaaYz+EVmlarOw0ZAHV/olCTN/r6UvmpQ1NCo8vraC8BtkM2?= =?utf-8?q?OiAyIf5msGqbsIdQtpm7cL6fFjPfl1qupI491Ejx1WaXeiCv7m/8cneTTGWwXre5N?= =?utf-8?q?mkAbmTcbCz9jfKqq6DBlp1Jb3/CWWmLfsjpyO83xbqC4IjUWx4vX/bYtqjRAiFu0f?= =?utf-8?q?NivK08JZyF1CatujeLC0OH2DemcAxJCVW9/FDMqDJjTJFei8xXAKlJjILWrBHqUqs?= =?utf-8?q?s9eqFmvbW5kA?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b81347d1-6d88-4744-80a7-08dca6fbeb49 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 07:33:29.5608 (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: lqq5mxqtIOnzWje5AUl7JOytIJ40mg4vDvIs/Ck3We9a+G5DAqTYw/pdAWWjBaTqYUMCIxfF988XK0a5PeBz8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10457 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