From patchwork Fri Apr 12 10:47:12 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: 13627609 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 6200CC00A94 for ; Fri, 12 Apr 2024 10:41:29 +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:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1nSskgTDf6Y7FLTjJEAAQp4UdijMfcjRStDmFGh80kg=; b=XSfqMNzbuo0DhgyUSBTGdrFKvt Nck7UzUJFawUgDPqFMXCxBmZ3iBQWuRNPmk8L+R0aLt3USWhStOos56Ar+FeHTlOyBUIum2g4z0Ak FSdA2rhFlVlmi7XW0b9kk/zUwyMDNFbuwrEND1BetbbCbdNfQXA3GkAgq2rJsEH/qxcfj+JncBy7U 8mug6tcHMu3cBMSq5ZoM6n+/aSKu4ciqOY56e5bfuB7FqPoIbshE5MrhGq9GjJZMp1U9jNAR2ENoc n/krkhOhsC6RZ71pUTivQLsK3i6XWBeoKsSfSWJsWcM6Sl6nW2ORXu0211HxOqA5wtQMt97p80Kdu 1+FBAIrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELP-0000000GkSg-0177; Fri, 12 Apr 2024 10:41:19 +0000 Received: from mail-vi1eur02on20601.outbound.protection.outlook.com ([2a01:111:f403:2607::601] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEK1-0000000GjXF-2eCc for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:40:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3DLJkWdDJKtOaHEmJJT6R6E52rHTBR6ZKSK6oTINbNo+4YZ+NRsCUZvPmoHhmKArSYH+G9MUdzzELzCpImyt6fBTG9WxbTW5cBOMdcfZnE7kU7S8Dv2StqTF6sd4EGrWnM1bO98rbGgS2kct6Tp/+y3Uxl9jIeyca4NIxG3L2SMWPTP0jtSAIQQo6W3mQG3Sz6f/rKD5wqRE9qIUKl0FvtaKN2t85fQ4cuPkovLkURjEsSyC9Ulb0Rt5y4ADnm0k6xSMh0ILNZMkFm6b0rXgCdamkVEF0bQ+7RyP6nR3cyOTFBaLlLl4k5xzFpvVR9ojTAt48c4ISXu/kefgzK2cw== 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=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=MmK7po28Dogdg0Jv09RoI4o+tXEDf1DBq1C9JVzaki33xXLuLdPyou4vBSxHznXDUxFeLAe797XDYY3vK8w+0bcuwpjKRFI3pFlQGLbKpA6tCCfk7YPg2uBtxsgSQRArY6H7giPIOXWlT3HsJeS2y80M3z9saqrTkt7iqB+sTXUFjopqul+/aoLVeQCLlIqYueFHsMKIuvcUloOINWl0uWzmQL+UDjexL3k+0M6xU41tG6RkOQ3PtF49RneeSmhii6KZTgb/UrHx3CEWLMVn/oPF1G1Pz1HHkzQTm+ks5/CTZ+HIcmVEZjnj3zQAYD06y2LI/eB+i/u/asmCZF5cIA== 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=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=WXdU3DTRyLIAFaYxgCdVKccq9he7yS7ud6UlW4fqRhVPx8fiKulrBO2TjLcTv0TMcOSbwvEmNhEJOyM2Oig5ylNdoNL7gnpptJRKhUX944+ag0WvWcfBkI+vhaNSsmxafQwtAPJzeMxRN2U16F2PBLmSW8dhdf5jLEi/bDRwk7k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by VI2PR04MB10147.eurprd04.prod.outlook.com (2603:10a6:800:21e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Fri, 12 Apr 2024 10:39:43 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:43 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:12 +0800 Subject: [PATCH v3 6/6] firmware: imx: add i.MX95 MISC driver Message-Id: <20240412-imx95-bbm-misc-v2-v3-6-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=4839; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CxsTem4c2UkSyoEAgF9+D0rRRjQcCv/6gmp4AinHGy8=; b=MnmQFLlmxWxbr8VNJYoOn/Y4xHMlU3QSDhC1NmWmqVK4Jm557rYiLnofdQ9a8erkKvED215J6 6yVwHiJ47/CD0ys4iX56S80O+oVTBS1yzZr7xWdUx8rsJsEEBbnk/2b X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|VI2PR04MB10147:EE_ X-MS-Office365-Filtering-Correlation-Id: f2570369-9839-4ef9-7fde-08dc5adcdd93 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXypHQ49sSI6HyaSVGk0ohKV78M13swP0AqN6U3jMzTnt5yQqdoI3+tgB8g3KzsbnhiDKNK6/loQ+7sswCNZ6OBcstfrDjFTaOXfjRxG5PDrZn0io8L98coh8TIwEUQ94V5hgHggoD/qf2Pp6csmA50mkO8M3FQg/XF6WdZpL3n6UmjkdW8BE6bYaIpgaMOhm1DzSs/2rUSJ8q6FHCQTdNR0z/TQIe+FfVnByxL06dhUfUeJMRDP22HziWqvB7oGXiqFI7sc8PqjbYqlHUySrPQ0z9hgPQV+kS7oRB0KcJoilod9fLnE7Z0nvSGOiMPDWuHuMW8qsaAVNzkeyvzMrkcRo0856xKiwCvtdO8pyuUL1bGkPvTT8KlIFIjDHkov6nFvEACXiTaGFVxI8DdyHFlSuA3V7Y1T+UF2zCBU8buaI7kLL43HrG6WUZTj5ZeTCVUvB0ww1dsADaCxFhksiiNssd97ma1NhrkNx2Bkv2MhNSUcMCPvZltolraTfOKy+QOBxxVkBYc27RZgYbEyixfRNKKYCnI0DBAR+hN3b1rjFQ2weTS4Qe6UWcg6HJJUglWDNtnYBow7JEIclwYVxMqJ25J+oqeXbPSrcXO0vxdCNwfcQhT/ayy48phOrBq7GFz8BMwWEnTdqaEaSwaSJ1jvOPvI0s6qyRdeLrEKqcDxodOkyw9ripNlK1G/8vKtr4u+j6Qzahxoqf8Wuj9HjmpRJCoYTdeS51aRDYuxRiY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(52116005)(1800799015)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OKww1eExOHLRYGtfceWp0enryNdG?= =?utf-8?q?n+/IJRlpI4orxnLBn8upYhvsnIl0K6qQxA7g7UnWn9D7GNLQjNQKu4GHvETIcITaw?= =?utf-8?q?HG/iUasxlVCkrDuJxCaS5nqmRKu7KKX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9ljTosNq/DMapCu67HgkzrGRz?= =?utf-8?q?EF+a1CpFw5rmitOoGuQ7ku9TLS5PT5jxJDw1wY6xC4nZho135dIW0sZfXO9i2yNTA?= =?utf-8?q?vR4O1ipEYkGiISeKk04WIR3/Bcs1Rm6Dgt+LWQSdPjalgDxfvZclbMQo8oJNLdcB9?= =?utf-8?q?d0TKOrjDBLkNXk3CmyJ6DfYpcp8ih4vSFfcYX9BScqLVz0NtloF+6eEMQp2gIfs8l?= =?utf-8?q?JWYvT8qsATGjFbVsBpVk2KLHoicpvqneLCc/6DKM1carc/sXjnU85xWyIcHhf+gkv?= =?utf-8?q?xtqQ2o11cHAF0ux0CNYXawJNOVSzKXYeOMSmznKokI/7H50fiPwpzWm0WKEcRXq1R?= =?utf-8?q?j3+4phLR35amb7h4HAhOBKnacG+FGkbrue1pifl+G2yvLmNIbwassDxy0S+TVCWoN?= =?utf-8?q?dC20hemYq5z6NS9SsB0nMJgfWqhEu0j2Sxx9mk8BnZMX36oy0NttQPolAT8oQSgQF?= =?utf-8?q?bcvGHuC3RIWs2joqkU4l1wcjgKJGvJ923mah8DbmoP7r+Ep78YJJG0TmsGl6AA3sf?= =?utf-8?q?WCNbfEXDRmwi?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2570369-9839-4ef9-7fde-08dc5adcdd93 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:43.7931 (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: FKnb3gXw1zjSaltvFe8AoSpQqHzFPS8+UGmYdaB3hvfJI7YGHDSyrYTThmHi3PN7Zn+2RI9bbt8M8q2qLN8kHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10147 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_033954_334147_D9DAB7B8 X-CRM114-Status: GOOD ( 15.87 ) 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 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 --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index fb20e22074e1..cb9c361d9b81 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ 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_BBM_EXT} += sm-bbm.o +obj-${CONFIG_IMX_SCMI_MISC_EXT} += 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..a5609de426f6 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,92 @@ +// 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) +{ + 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, evt_id, wu_num; + int ret, i; + + if (!handle) + return -ENODEV; + + 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); + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + wu_num = of_property_count_u32_elems(np, "wakeup-sources"); + if (wu_num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + for (i = 0; i < wu_num; i += 2) { + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i, &src_id)); + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i + 1, &evt_id)); + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + evt_id, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %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