From patchwork Wed Jul 31 12:56:09 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: 13748719 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013028.outbound.protection.outlook.com [52.101.67.28]) (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 272611B29C7; Wed, 31 Jul 2024 12:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722430065; cv=fail; b=WxQI/Ao3jTOCMwk3xb+njDmJJkkI7bJLdzXc5o88OPHeCflxm5VDnCK9ID7jUptuq6/2+HIFber05FJoWCr/la5W/XXaonzTcL+i2QcjP/b4rmD0MmHOdL3UVWiF00VQ3XYqsUFcDcySr8wDf1fBmlOWT/aKHoTfZnURlErac0A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722430065; c=relaxed/simple; bh=LQvxg4wjhO9FWV8ybDeg50raOjfc2rJ4N3Rx1dkcBxg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=oL+Ve1/dVVStfg/ipadTBZ4nogMP1WFSICGRVGavwfuo+MRSwogWjXpciRortfoqoHjgSeB+63a3ZymP8IEEUrU8TRwUb+bFSUSziEfnr1Ht+0TBokSzHiE/0m8lmsMiJjubDLaDSUh3yJ/SfFhk6ZXnAQwW+kZV1Rf6UflXvqE= 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=KWNKWQxt; arc=fail smtp.client-ip=52.101.67.28 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="KWNKWQxt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kuanl3bY0ekqKdEGEJHplHXRETAzqYK76UuxOrjkYk9hXQ/cW3ZqBuf5EVe9s5Rv0wptQ3tIJDY6ta1w29/UxiW9KiA63AVyG6Q3jHUUlfZm5MsIveqtla/nYywOW+Wzx1KTsGGAbURJl9ociCjLlAHWbZS0gQHTs+5nr2m5IH67RFm9ED9HISe90q0BkyJBqxg7ivb6fIupIHO060hih8S8bzEKSLeOK7NnxHAbtU7vmE5taKeVsTmMBIY+suiWpiLoWGqnlrSQqCbcqDOVJ423Oq7O6iwzrcxYOIumeZFZS43tzIzaURF6wUsTB6iVgp2tqouVfAXD/ixsTHgmLA== 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=mwNXwtLt6Fglik/UnsnZY+S+ByT8DT9DYkaJy1z+n6wV7l+GtiaEmxMigCgxy36KnhXy2d7coPC1GerBvpTzcAPY0Qi4HtxZBdC8ud6mwPfv0jjq5nmYIQbOaf3fqYbdPo9HRLJmLDvh4lMzeuK4gowVyMLu0XWd9ZzUBSgUskPHmGRs3HcL5x613Ufk7MCRV5JglyYcufP70atg6/uasVspRWz59rlGYR4BsHIBYY4CiXfZQLCSr++xUI1hKrwykySSV+NKWwu7Bme8FyRk2bqAKGgo4PhYgISAUyLl7uwVbP5ORn05ew5B1ph5JowzpfQBtO+KTJBBSJEtEJAUXA== 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=KWNKWQxt6yHUN5FH3VpRF9NnN2Z+ZrbxbN7x7z7MJU9ZBKbinpmxXTQzPCY4FMTYjgO/fBSIZE1b30uDwttl2dYdl4xuEPLKQDnTS0nwM0LZTqygkmtQ1EkBQ0QolGJYzveoj+DFrmkxizV6IV7ATE3+k6Cmv91XlyJSb8+mkpxXIGhhnEl7QSt3zkDdV4fGoDNYpka7E/coDpFKw8zSLIVwMIViGEHwI0pUQpdBGyg2zh9pC/W82+xbPYI6NkxhZ+vf+xTdLHU96yKEYosH10XfKo21QwqgtNzxAhI2qlDJHSdfA6EVW35dwSFq3mW+5hNBUaVqyYu9UG3+LQE9wQ== 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 AS8PR04MB7735.eurprd04.prod.outlook.com (2603:10a6:20b:2a5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19; Wed, 31 Jul 2024 12:47:39 +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.7784.020; Wed, 31 Jul 2024 12:47:39 +0000 From: "Peng Fan (OSS)" Date: Wed, 31 Jul 2024 20:56:09 +0800 Subject: [PATCH v7 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240731-imx95-bbm-misc-v2-v7-5-a41394365602@nxp.com> References: <20240731-imx95-bbm-misc-v2-v7-0-a41394365602@nxp.com> In-Reply-To: <20240731-imx95-bbm-misc-v2-v7-0-a41394365602@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=1722430577; l=6495; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=D48dI8TueQeMQCWqqGsKwb9eBu8K4dfQ0em7IUIjo5A=; b=dud87r8AcWyVvperzZ8k/QH74Iwl2SpWgy2/HzNr4DoV2VzygOjY0bELANXYgqble5ECcXM53 g4HCj7Y0UsLCCCEsOWQfmQ/GJbgQlRRfn6rb7Y3YfflIY1QA8P4Hbug X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0027.apcprd02.prod.outlook.com (2603:1096:4:195::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_|AS8PR04MB7735:EE_ X-MS-Office365-Filtering-Correlation-Id: cac3b897-70ce-4cc9-3ef4-08dcb15ef650 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|52116014|7416014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/VsKSNntTRQtTl1tFJSe1KGPgcAjhUd?= =?utf-8?q?OXuXy/pRH5rT+aCis7VSBtDEPAMYP1m+tgU3Z4fNJpMIv/Sn/bmkm+p+2DthOR744?= =?utf-8?q?U1Ba8MQaQrFFFAtNTUX5CFmwDKsD98nStRCZd6s+zpNSAFtFSMOc/7druaZaJST+1?= =?utf-8?q?x7ckqy49/cXTucLxYdSfzLcLixMeVJwe8dLtSf0DxG670dVm7/EnQTCVijOW+5WLu?= =?utf-8?q?yZKV3xmQrNJK43I7aLh+0+hhpX6fWsA8ZCSPbj/oJ9qdRKO05oBHRezUFFOB9MT+X?= =?utf-8?q?JfBiDNyhkyKU1yToNu9dBY8nQhc1ihf1rvMel1+lSqpF4sLUaE7jVKyY42jnD1276?= =?utf-8?q?NUWKmFRYznMUdeTk5ypFtdpB1ai1DGn8L+a7DyD9m1clI71veQC6Bl1HTRUSWLhyF?= =?utf-8?q?XJrdjfonJk5MbRwlKfInqW24TwDwx1g2YpjM1rrcCZmO7HiwSQ4AaYWq418pIHx50?= =?utf-8?q?0TD262xeg7onxyb3bffr9eMYS1R6qgEi/QtdLwHMNYjocqYKomtveYtGRw5dMC+FK?= =?utf-8?q?3H2pquiQxGIfrMUYJb6TRjwkDmUkO5vlT08I+5EGbPFWgG4OV3iYsGzypwGDxJUPK?= =?utf-8?q?KI0tkdiG/SoHuEsBau0tFO+CwEF4F9qRzp171Ut6B6EYPyVr55N3zSkv6G+GAEnuw?= =?utf-8?q?LIxfD13kE3A+l3WG4AuIr8peqfCdZdUiTh4/INzfjD3+fPr0oiYgy0bhgEvxJa6Dr?= =?utf-8?q?cV1gfbNOey54dTCkPBTNn+P0o0GzWwk/qKh69IJgL2r2j90xTRF6Y+v6562K+Qx4u?= =?utf-8?q?m6SmIwgjhJPCVPPMBrfPOLHIj5S2GtBChpum2jEqGlpqoCIIIkN/M5Il81e7NWB8u?= =?utf-8?q?IwudrqcEpQPASfJceceL5BzFOGGqBQemTD0kpWbkwC1HIEgVYOAsGMiOEdmnrO5Q5?= =?utf-8?q?+xJHLD5qb1GUDZyz1k8E2t/KQ9TiDmkjgePCXBkD+WgcRVQqxIq5fdvR4QijY/Yl8?= =?utf-8?q?9tqnpMXLmvfdKtbgOb6nWAIbqzLxPQR8dR55bvDnn0RpH8nKx0tAZnj9kIBtRuUcy?= =?utf-8?q?cQRMePbpJRwfYlTFfLJNNxq+Oi06w7pzhxMHygOCaGsf/zYoVahd0z/L5xINfe+Uv?= =?utf-8?q?j+wjUJGMqiFVPc8Jp9lmPc+WxRjBVI5qGEQgsPrkd8rca/VgyVXJ0fhWRnC65d0W3?= =?utf-8?q?lsBdgM1b/V3c/r0EFQZsGUHNdwCMX/UU/j/zxwHxqmsvdG8jWvWseO/QSzg3Rrhy6?= =?utf-8?q?XrooXvhk3NGYam3bWIHr8jzmQDLyNchnJyPQCHNsNpZ3XWOxxXP+2xKbx79N3gybo?= =?utf-8?q?2CcuvO/w1qJEbopwx/vo0T1ATPpFRhlnEBGl4KN7iFkSVn4I3X+d6kWeG7aM2k9YH?= =?utf-8?q?IVrawEcd0HSzvZrGXXzF7KBilW7NRezSpVXma2fY1iT104EvTXra5Ek=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)(52116014)(7416014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?s80Vehu9IhFLIAtpHFd1PAc2rLO/?= =?utf-8?q?02V9G7RJh2ZtNwWXmVIRCre/hJmf6w5Un62yB7PC1FaUKkfKcpqpcLx3O1qVoQqjN?= =?utf-8?q?VO3oVyNpxRJD21XcucdIyiBjhrV5RimKIh5dy9eV4A1V5nBCpDEzFHbGMWOn/71Pj?= =?utf-8?q?7xODuRT9DZwxyzjqmc7cDvjds9qBj/XIp6ePVIlQI5D/RZlO1z/16+zlmtB7PDRXK?= =?utf-8?q?tqksc9Ilo36rB31YKstrdwRcps7wUO/jwJgRE5FCT0cVQjoE1mk71laH8VqMAuBan?= =?utf-8?q?Q8raNMOCq9qvfeZCGik2i0OETxe94j0j912elmJaHKPqBUf3RIF9hVs4Dv/8Hui/Z?= =?utf-8?q?GW1KbCW6lmGlNUfJeNWhZwgGximCA0AK7CLkAMsS7qDKx6eY0rJT/c5uo2NePjKpF?= =?utf-8?q?eIxLytYBgRNN5tShhoQ6Nks3lZtCvuvETbhtb3jy0evpbk8TPEdNTK97WWFjD3k3p?= =?utf-8?q?bpgQR6j52V0CdLSMB1xsrVWTfrea6P815W5GS2CuZvA+zD9Aeetqe1+AmykS5F6xa?= =?utf-8?q?bZ+D0pC0mzMV7WrQnDfdw5h2Fu2iQr8+v2RzFuYqAGa/Oaqns98sdmqkM4xkr3hj7?= =?utf-8?q?D7yetQfYbSFZ3AAvseRCRp6GptAy2AuXiagP+qz3Ij+dl+diLfm/+LKxkX6nMkEwi?= =?utf-8?q?qkiE3CQCjmj9QhJRjz6P5X5zRoc3CXU5FX83Jn8RRAyagkLV38FmlHaWIvDBWiMrR?= =?utf-8?q?BGY3Y3iGRvtKPOtm+7JVBT/Wzh0Cnrd8C5Wd8FjiluZOgC5YlrCUoGaCz0ggYyBaz?= =?utf-8?q?T2OeYXaMVcsXPKXAjDshvoSjlMx/udThifnX5Gd9+1gJWBHQpt0ZobDhpBAgm2XGB?= =?utf-8?q?dL3VPjRu5HylqaQWC6s+IaRXYSeIHRPBYE89sM1A/j3A5SCVJ4Lg2hv8Z58PMowE5?= =?utf-8?q?CiUJkj7wpeFpSguIcRUPeWeuzuovH8Vunyi/m6VKlQAOOKoxPqzENBF7z+hrspD+Z?= =?utf-8?q?BXrn/m1aa+/cxByFItBNpCgA/RrNx27qo3YJ1idUvimmCGgEmb6lj5gvdS5VKKJ4v?= =?utf-8?q?MUM7PxW9b3UGmK8xlUiXlBkpeUYzj0njqAEw9OgxdaFJXOAqQAZTxYMGtbKuf/a8d?= =?utf-8?q?cDwp0r4UyT8jiH+6t4LMDmwFPQZ4QHUB9Wxst1jasoyQkCbBMbgokM5Thbb1bpwgi?= =?utf-8?q?Q53JRrPcZmmvfsVjAgut199fEj/q8DzAyiFPooceXk9MmtyOgqU5LoXrRGSXvKhAM?= =?utf-8?q?5Eu4SR9PycMxZDwgID7W/JuOMaYiv0EWTg9yajZQvFH7WXHndtWPkZrG207S5aYul?= =?utf-8?q?+QgN/Wz/bR/v9vYfGdyaNfXpTjrgV7KwRZkncgBbvOyIAsHckaKOhiW+Uzd0DrkQJ?= =?utf-8?q?WYbdzxA61K8GLTzrq+h4UDTRX/BHAaE9LqO8tXkMIUQ8v14b0x4CmC8yyUAysdn91?= =?utf-8?q?n2TfQDGdCYbbR/e6FnKwvr/fll/1tkPo83HF6YwdnlQJrntpNH5z3zfZENBWVF39v?= =?utf-8?q?7mKTIHgU88cDTnsMN7kKBvt4IC+AX6JbCGMnoek8ZYpwtHfH1SxYde9IcuqGUbSB6?= =?utf-8?q?ePYEHDC5YZBO?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cac3b897-70ce-4cc9-3ef4-08dcb15ef650 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 12:47:39.8402 (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: Fa8LHzsF0HvFmwDqXXU2TQC0COzkyvVJlMgFmuWqzrmtvsqzKq3o9H4OmZ0qj2pbhem+skgRVuLiE7fSukTheA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7735 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