From patchwork Mon Jan 20 02:25:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944688 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 6306880BEC for ; Mon, 20 Jan 2025 02:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737339998; cv=fail; b=D9UzN0co1+srZF6SKq+F+WFH7AsJRfzHX78Exws8pSe6ZJ41wzesd5ozSxlbAFBFbg3ecKUFVNXzkT1FRGzSR4WyWedzuZrZAtDMLuZAw8RTfNMbKNbt/Ue517odaZk8uZoVkfgFwZr9zw3nYM2j0J3igkh9agEowAaKm1eGOFo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737339998; c=relaxed/simple; bh=ejvXjbREx6jsDYMwviDEBcgjeNY8Ej7gDUFVvLnZ2UY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=TmJkwPrIoE0X0+S3fljt/Nm+s61Mejmyc8K7dR8HJgWBhutABVs2YQY2+ZfFZ7vJI+6m9cr6n7BHRXMhFnUsFP36g8cvE/8jdD3wGSEbZ7K1XtZPCtvFNVJ3LUdZvIpAdeTFxLMLZGCBWuhCNd8MsZx3zE2VP92RRksQIdqL+fc= 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=uluGuIkF; arc=fail smtp.client-ip=40.107.241.55 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="uluGuIkF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iHOgH65Shon93aVQXNbAd/g2t/8+bwYhm0sBINgIACczvbkzr4UqidSUnpcTbgRH0ezbVFhCtifF4mFWu3kw11mCDGQH9VLc3M/+hEjhBxDPhwbqx89rhDo9y3+iIs/hVGP2gPHZ2sQkCc232gPoJXd/KIAlipC9rHH6+dYKmVRfSf39WkB/19n5t0ZPywMNj6SM/6vCcW3a1sMe85XOHKqjdxiHZ8KC8thEGBu6xQvuhW7T1hDEt3hUaOFCL00lMkrHVtCGZva4IZIkA2giEqvY44o7b1nz7K2GDhIoiDUbozk12nMKa6doXv/gLLjWNjlLKZJ2FgMgJ2ZaKdSkjA== 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=68sNTPGQCgbbRgyuRWHPeD3AapuURVy2WR1PynHpbgI=; b=Q/G0naYNIJKj3+LesrPThWL9RaR3SJ5G9fr+bnGXWETFz3/nrpu+QWX2N4Tc8c8zfY+3huizqdv38a8xCZtWq4GNIqL1gdM5Czt5KXWsO52h6CxKi23LYrpt0vwOPn/UmNkaRtKkUZQgOmKQmIHukMauxAyL57yGOfi3xjujAWNHu0QfHxjQkeOVWDXarV6qJUrf0EJxvP8pkwCJ+2F42zAin8Dtdu3b09/sQH9tCf5WATHLZC7LyE4GLB2Imqr15bdl9ROxeJBotG+tzscrQwN3woH2h/tvvPkvy5nLVVQWdyvanL0FmAQToYT0X3s+zj9lGpfD79JmvBkT/pJdSA== 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=68sNTPGQCgbbRgyuRWHPeD3AapuURVy2WR1PynHpbgI=; b=uluGuIkFnskBdQMJn6yWhnBTLl462RJXskZWSM5caN+Nh6SSXm4Sq2GMhyTv2Zah6OrqNZRsIzM6eKOpCzawiSjWMAjJm9Qf59rUMHzCdoYxKPtknAQW5DGX1PgRd3RAVgU8Ydyx+rE3yOP/Jg5BSLMMBcRTU6hzHPR2Eijs57yUAcckis9FW12gunICDQOSB+KVE4Ml47Wp0MzVHYhRnbv0bGO21Y/IlI+g7rkiw+z5QknzQGl1QVHBCAYeSYvLmcQcBZBcIzPlsW0iRvaHloP7EsUDJNfUvK9jTE+VRDsVk56tsyEmu+eCLKSBIu18GAPDvKKATUY/i6IU8mOqbQ== 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 AS8PR04MB8690.eurprd04.prod.outlook.com (2603:10a6:20b:429::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 02:26: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%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 02:26:29 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 10:25:33 +0800 Subject: [PATCH 1/4] firmware: arm_scmi: imx: Support more event sources Message-Id: <20250120-rtc-v1-1-08c50830bac9@nxp.com> References: <20250120-rtc-v1-0-08c50830bac9@nxp.com> In-Reply-To: <20250120-rtc-v1-0-08c50830bac9@nxp.com> To: Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737339953; l=2331; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=tqpvycmCUkKZkyc9Cyg3oUuQKAchfg07LHtaTpoAfgw=; b=cZyiewEjAmB1rjpHMTQgKi+1YAmewsz7J4uTr65YE4idYJ7iZNowzIsUkETz9iGboewI8NNQt rC9Cs4pddSMBaoEpkdP75XhPUFqLttJYPeetXe7XcK/3V0w2X6XyaaA X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::7) 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_|AS8PR04MB8690:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a8c5149-07b0-43ef-d69f-08dd38f9d91b 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|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FcROdBhQmP6B2g00JNu3HP1AuvskHsq?= =?utf-8?q?updv1JZAF0NxiLkQHGlbrqfUFtxhKQqV+vQQq7CfZYR7wD1g1B7wX73wvFybvOeTh?= =?utf-8?q?h66md8B8hwzc8E3DJAjySToMQX1r+HaKxQ7IHIrsO2iLr6tL8PMkTTTCUjYoYsRx5?= =?utf-8?q?NiRpVlQxIXYP2krUYiaNJFnMSTaSZi070ntHCgN+WG5IuCh6bxDeX+95HJtwaMr0j?= =?utf-8?q?iTy5WCckn25qC7Z9IN2MLrVExo13SmptrGE8WoMb56hAsuhy/HQppPm9jTATXXXmP?= =?utf-8?q?HyTRZJZbJ5pahTKi2O0PIPNVhoqW/b5vjhvlq7cYbEnCJAKz0xU7IwwlRUaiPIsNl?= =?utf-8?q?aAT3LwoDGxXyaxtXAfqupBYnyqEWT/2b62K03gr0HHW7DHm/zcmbfRbtdxCHjYsjO?= =?utf-8?q?FoS78tqBRjPfzSlbQ5tZGye2RK9iHqDOC2DJJbs5iP9apRsfvsV0vzo7IDA9mGTe6?= =?utf-8?q?uqlwK51gZ0Rcww6JA/GXAZg22Iz6RywQErT0f3QxrG3jHtzxv9xRgMusS5sE6TFx2?= =?utf-8?q?UYRJhlqOINGE/EXuzpkwKg1MtETlju5CS3lHDiR3CLu459hap2+AS8Nt7ymmNJWUG?= =?utf-8?q?uEu2pLlZq64RrxD76zud8vzwKbd/F+iUAiV4rLL/eCfubiPf8frvU8RwkhmUDrUSr?= =?utf-8?q?+Ip5hgi1fsJONXjGcpyQluUxDgOKt+Opx8fNIT4tG5H6bHk3tHyxYNvEPE9zm8CaR?= =?utf-8?q?3Osm/13GZLMingcXdJcHPe4DBp9k5n+9mx67Klo1HxjXJt9ZSLr9Xh9hDumNOwWhI?= =?utf-8?q?vv7MWANLhWs8hIOyxde/oDM0W5fYqLOkhHmAwMaPHvNGDZPNtqE+utDtZHTV+XOfR?= =?utf-8?q?jWQ15OF8YN6kiC7PAiZysCnorwcq9q98wQQjEJAldNelqxn9SZvnwYRTy78rPoUoC?= =?utf-8?q?GRvUaHpIacxiQ7hMkB1uX4TBdIQMiJt8JIygPuLM9DMt5rcyqwU3IOaSIyq3jF7lT?= =?utf-8?q?KG1B6lw9AIrJhJ+/FbVvNnv4oRtz0TU8BldG+J7K18NfRMUJFfgvNcAvB/C8Gqua/?= =?utf-8?q?Zgk1q/m23Er7snSxkjynSKezYjQJoA/0ly5UqIzvONIcNhhM1ctFCvkJP+K4xGswR?= =?utf-8?q?mGMHW09UNUfjn39tvRJ3Wixedy9xp14T0NY0oGhY9Mh3BWvoaP/JKx6GZrmGIYmEH?= =?utf-8?q?VMF7CkSLbqx3CQMzsT1bTss36NYdeU4cDttg1WeQpoyLJE7PnaQjjg1V1saWu5Knb?= =?utf-8?q?F/msJkXtxnyCPjBwOuyM2Sc/WXHPohW60JNEIAYE1j/P7VHKe1fPmJZPuXL42y20l?= =?utf-8?q?203CLZUkj0FnqjFjc4+BhmZGYFzQP1KcpEblXZ/N6zxGgeQD7fHP5O3MpzhFyYVjQ?= =?utf-8?q?XRO2ZRza9DuRz4cYMH0Rbcc1SYq9XKH8MmiVgeGIYCa0jE7N+trtA/u9HRxA0HujU?= =?utf-8?q?SWszZt2nIdJ?= 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)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?l5hk/OBCtZMY8Qr0rdHDE52VPitb?= =?utf-8?q?vtB59TIn920M0f8N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rmf57pW6KuRtNCCir03EnBEuNdcZROWE3uGM7RxLwk05Tzk4+?= =?utf-8?q?FPRJIB9sOUd8usKNXAH4CKMA4JJOQkCOzY50hYzhxkSI/zRZp6tAM4V1VrZW7gFJU?= =?utf-8?q?MdOoSfFvkIA029LJcFArQxt1e3pH23LVnwx4X/Z1fywfPo/fwVWdQVc08uRRloil9?= =?utf-8?q?IW94AJvfU7ZXxK+UcYpziq/vBaLrJJCjN3tTSVrR3LvAu8ZXifXY5y4x9/nXY4raY?= =?utf-8?q?tHB8qQngV6I99SQDjQhjLfXnClkSlSEoe1U423aJw5POQnpQddCPkSCrLiAtPpzdU?= =?utf-8?q?FVsnoNjIR6wExnWdspw0adMMnADMzykj3nDKI1A91lxIRujCi3QOguj5u0XZMtXOY?= =?utf-8?q?cU0TrA+MqIOSPfgoDmGEeDouCxhZ4UURbC9NmqwHXTf+DGG4Cxbyvajv4z2U6+OaQ?= =?utf-8?q?ID7WwENMV37DN5SBxNqU2n6vTlb40QoehzNJsxPLX/ofCuQNK9scYWJgla/IcF9Ke?= =?utf-8?q?hGiaEE2p5YvA0ZGArsnO9zwzMsPUjupa9mntl1l8qgq8BkrsHxrowiTwglT6ZV9fF?= =?utf-8?q?RdrTb7d5L7/wEjKs9d/OOAe5OLWVNRo+664XCdhOfSettxYnjzwaWeIfPtBK8ZvBw?= =?utf-8?q?pHJ5LtGzIUGx?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a8c5149-07b0-43ef-d69f-08dd38f9d91b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 02:26:29.8057 (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: FFjijZmvwVhi1s2TgjZhZsDqtFTIQ93LpK2y4iNJHZFqMWAPDzYasxz3GZSrgG4HHf6IggwWngQrxoE4xxjmPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8690 From: Peng Fan The i.MX System Manager BBM protocol has the capability to support more than one RTCs. Add scmi_imx_bbm_get_num_sources to replace num_sources which was fixed to 1. Then the 2nd RTC event could be configured. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c index aa176c1a5eefe4220e54e366cf3a267de639fa9b..86fadfe8e3560b1cab5876a1029e38d91d938e2f 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c +++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c @@ -128,7 +128,7 @@ static int scmi_imx_bbm_notify(const struct scmi_protocol_handle *ph, return ret; rtc_notify = t->tx.buf; - rtc_notify->rtc_id = cpu_to_le32(0); + rtc_notify->rtc_id = cpu_to_le32(src_id); rtc_notify->flags = cpu_to_le32(enable ? SCMI_IMX_BBM_NOTIFY_RTC_FLAG : 0); } else if (message_id == IMX_BBM_BUTTON_NOTIFY) { @@ -156,6 +156,20 @@ static enum scmi_imx_bbm_protocol_cmd evt_2_cmd[] = { IMX_BBM_BUTTON_NOTIFY }; +static int scmi_imx_bbm_get_num_sources(const struct scmi_protocol_handle *ph) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + + if (!pi) + return -EINVAL; + + /* + * There is RTC and Button, but there is only one BBM button, and + * at least one RTC, so use nr_rtc as sources number + */ + return pi->nr_rtc; +} + static int scmi_imx_bbm_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) { @@ -220,6 +234,7 @@ static const struct scmi_event scmi_imx_bbm_events[] = { }; static const struct scmi_event_ops scmi_imx_bbm_event_ops = { + .get_num_sources = scmi_imx_bbm_get_num_sources, .set_notify_enabled = scmi_imx_bbm_set_notify_enabled, .fill_custom_report = scmi_imx_bbm_fill_custom_report, }; @@ -229,7 +244,6 @@ static const struct scmi_protocol_events scmi_imx_bbm_protocol_events = { .ops = &scmi_imx_bbm_event_ops, .evts = scmi_imx_bbm_events, .num_events = ARRAY_SIZE(scmi_imx_bbm_events), - .num_sources = 1, }; static int scmi_imx_bbm_rtc_time_set(const struct scmi_protocol_handle *ph, From patchwork Mon Jan 20 02:25:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944689 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 CEA3435968 for ; Mon, 20 Jan 2025 02:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340000; cv=fail; b=CutXiBQV5tpxFCCV5UnErml3Vl53OOgA+XXxSaPvVb/qb5JBo+264VWe2W0vIbGIClkl/KjF3Ez1y+6LjmVIpTXTaM9I5+RBeIlmls+TKBB3CcgzOLep5FxE3zAVf8fVeUafMQujfdUttwWvLpDr0AIIQr/P8A/15JLQy2XpP5U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340000; c=relaxed/simple; bh=EN2k/2Zt+hegS4CGsu8OPcUqieIFeCVz8DbmKySo3N4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Qi62eFG5FZIvnpcZBDLx08jk85oiKmRAtqNHpDgyMw7WqpjxuJjWnHtKi9cNw0+feDAbxpyD78OptdkU8/sN6H0MrT+Qu7WRSKCNw7LIobBT1ohYSAJQridpTswe1KLM3+GVbQBdADla88RstblJQFW6x+XydBsQti3bG9g6Lm8= 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=ELMshrkR; arc=fail smtp.client-ip=40.107.241.55 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="ELMshrkR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LqaWj9B4rR1mdIp8NYx5i7joq418deYoUeksWOkaXLhBs2ZNLNzp40itY1d7M+9EHiitR4kYU2PADZyJq8OzDq41+p9HeomkAz4H5AtIZv2hloiE7vXrVyrzVUXsjn18Tlt78t0dZcDTHahnMqu6IPPBwliWP8qF7LQmDuTug4Vpv/GFEnU1Gt3Td1+8IhUbenbxvYONlcr1qpq94wwa/p+qM5iSCh2QW3MJRaSp/JMvQ1n79T5/sirIKL9NbUkPdP4TOFDQrto1s3M7BM2CDIYXUcy0f+iCe04SHxQ+IE2HNTvgAHMyFOwZbPCbqSpL4MaOs7kR72Pe7wMhShz2tg== 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=lxIy1MINgP4AsV84ZZTh16+5NK6mkgDtqnQlGJzhFHU=; b=OSQt6kYH8eLJv/vBQqkDKCZdlhRm47UfguDau/vJ7xj1GKvNp11sMKh4UKpkax7YBBJ3BvUdJc+8mY3eMk4bSMpgTTQa75TrOiVVJ6Wq2KsvaDdc7Pvc8HIHWn7bc8Gd0YyzPl3W6eM1h6i2dcpsO+cUHQYeczpKvk/MQdFfLBCBzsMQrIegvxumZM8EHd9gTUH4ChJ7BwrzLKOMF1TaUdP3F1TK0MuTm90O5Zoa0Xh4zB0mdP1BN1bl7kpjo2bccwHsGa3h01LSf/VPaLPDiAfY+M3gOGSzxD6HdKjBPpauXC18IOg+isFq9tb32zajcJUb1WboyJ4FZBIHgSEMmw== 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=lxIy1MINgP4AsV84ZZTh16+5NK6mkgDtqnQlGJzhFHU=; b=ELMshrkR26+uA4xheVICMQwNQbXKIRl8DQULI08xl8uxv229ZguOE8sfCuwSvgWwcIuS44p1Izg6VZp9sWjrWAZE8EXISZMzq8mVEXQ2PVO3PosS7xUpsVGuDSIQ6zVA//23q7Q2o3fvRFW4FDqebRRsI8SaqFlohLf0QsA49j3AYaxztBTmgu8PSLgZ7tGCFk7jEZyrE7p6CGS976n0AtSlx9vG5tYzVFI7+NZj1IXx17lUBvhoTVaT9VT4ek9ANiFMVl2Grdni3PiqEyTjoiclgkOma7678ttI8bp1xnoQi/GUVXu8aQFtnBYi19alLShJP+TMdLhEbXGnx2ij1A== 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 AS8PR04MB8690.eurprd04.prod.outlook.com (2603:10a6:20b:429::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 02:26:33 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 02:26:33 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 10:25:34 +0800 Subject: [PATCH 2/4] firmware: arm_scmi: imx: Introduce bbm_info hook Message-Id: <20250120-rtc-v1-2-08c50830bac9@nxp.com> References: <20250120-rtc-v1-0-08c50830bac9@nxp.com> In-Reply-To: <20250120-rtc-v1-0-08c50830bac9@nxp.com> To: Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737339953; l=2191; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=64KNtg8mNAuAOCB4DlUfZa1lYCiwprX7QtiyIFbHFiY=; b=37Mi4t0q7VmQ1QxBLvoDq8DPeGqXFJNc75veDumeMNc74VnGPhOQUImE39+2Fm8gibHvXfqiJ 8/3KARqnvY+DVa9A1DzLHrTbTW8UHM0NkMViLayvmeXulZ1NubKxxQ0 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::7) 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_|AS8PR04MB8690:EE_ X-MS-Office365-Filtering-Correlation-Id: 801d0328-b084-4988-8517-08dd38f9db66 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|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8y7ys20I/SJL+9jGd3LxzdOyYZ8PihX?= =?utf-8?q?GyO6Lx+yL43qBmgKcvzCUXrb6oY95GmBzAFkFbPbV+efJuiSS8EhkYc6ed/nEhPaC?= =?utf-8?q?H+IqlbsfsoadNIyD7Wgxk5AAKawGRHWLHnbKCME+yyzX3ITijCJ4qdXOiJRQpPou2?= =?utf-8?q?jig315cbysFEu/lrfFCMRkQDuYUijgK5pl+GUf+askeLm3iye5w3kRFtOiz+bPHqc?= =?utf-8?q?TV/CXoJkkFxcT/l3PgDSJD6MubT8bBGTN5EVcoKBTU6+KKcUR+2xblf3VrDXKQzoq?= =?utf-8?q?LfyKE/rj0Mg41kyyUuriURA640DIMtzI/ImT3WwRvRAM+G+CAuYJmlDUck2pCHQ0p?= =?utf-8?q?LBSKaOkVn58avkBoLgQPAO4A82q8giu1Fwd3jcvN3Ru1mISjk8S+bbyQWJ5YRn9M4?= =?utf-8?q?FjtWNqBd43gZLTeC5yfFYKKwikiqImtI9bO7+Mxq16AFAI7gU/TZ0XKrrDecTyAgn?= =?utf-8?q?rPl+LNCMLXl+pJM9s9KVqRW+jwsUxk5Xxwikb6EsP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wVLXQdURuuEa7Hl73?= =?utf-8?q?IgnoKp+xpuM?= 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)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qF5+HfhUXN9dthwQJhzAH++s/nq9?= =?utf-8?q?8LUgjUPMTrdxPOwScoXlRNSWyJ3mZAenXCu4+HCGmMea/HENfe7W/UMFYGp3VKads?= =?utf-8?q?HoWE1lmdLZPKFifUU/zQyiGW8fbq4Uucb8/phGEe9QpPxebeU0imtD2BQcRpBtB+e?= =?utf-8?q?0eGUyC4VYsq/6C9bn+dzD67IAQs2wJEwscnXZtsKjHLM6QIf1IhWH+1ideCEqsIxd?= =?utf-8?q?sdYNW3i7F68u3xFrPVY5lw7PHnrnKdQDqcsYLWymibh8sqI1ujyvskv5WEv/QJZcR?= =?utf-8?q?Li/eNZ2LhngChlSHL9amQYyZCfnL6pLqz06BkEwZxslvZwyzyqxx5/QgdSgkFj0rQ?= =?utf-8?q?3KPgIzhCiZlqnkmINadobXPwn5QERcL4FoVvDDeyn8nATi97OjZCRFrhr0k31XEEl?= =?utf-8?q?y+rgXqUvvnECYBf7K0U2l/C54ZYXJ7JZpB0x6n4CcWc6AUNT9FwhTdfdeZbI1RU2v?= =?utf-8?q?yuveWHP2dYGZov8SFt5u7hqiRPTvqWDwea3tZCitoAiIrof6dlUaIWVRWiXllKb8e?= =?utf-8?q?HoHxTDNYIi75yLTTdyST5Ise/DeK4bNDOIBdeWcgaCSNJGexhcms7BG96nKjmq6wa?= =?utf-8?q?12Z0PzVK3qDvXmNvV7yN3ZqRJ5YuKMyPuL2a4J1kDep8benu42luBTiBehi3OhACt?= =?utf-8?q?XX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riginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 801d0328-b084-4988-8517-08dd38f9db66 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 02:26:33.6457 (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: bc1JfUdcDuRbI/a70ATtzSOCF3JFh0Yp0t44uHJoTAIvBJc7jknOxJPnSPaxmAFF+AIE7NuNo0NBfBbZd+6ibw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8690 From: Peng Fan Add bbm_info hook to let BBM protocol users could query the how many RTCs and GPRs are supported by SCMI platform. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c | 15 +++++++++++++++ include/linux/scmi_imx_protocol.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c index 86fadfe8e3560b1cab5876a1029e38d91d938e2f..9d40ea817f4bdd2304c932bf3f52b7673a35eaff 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c +++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c @@ -246,6 +246,20 @@ static const struct scmi_protocol_events scmi_imx_bbm_protocol_events = { .num_events = ARRAY_SIZE(scmi_imx_bbm_events), }; +static int scmi_imx_bbm_info(const struct scmi_protocol_handle *ph, u32 *nr_rtc, + u32 *nr_gpr) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + + if (nr_rtc) + *nr_rtc = pi->nr_rtc; + + if (nr_gpr) + *nr_gpr = pi->nr_gpr; + + return 0; +} + static int scmi_imx_bbm_rtc_time_set(const struct scmi_protocol_handle *ph, u32 rtc_id, u64 sec) { @@ -351,6 +365,7 @@ static int scmi_imx_bbm_button_get(const struct scmi_protocol_handle *ph, u32 *s } static const struct scmi_imx_bbm_proto_ops scmi_imx_bbm_proto_ops = { + .bbm_info = scmi_imx_bbm_info, .rtc_time_get = scmi_imx_bbm_rtc_time_get, .rtc_time_set = scmi_imx_bbm_rtc_time_set, .rtc_alarm_set = scmi_imx_bbm_rtc_alarm_set, diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index 53b356a26414279f4aaaa8287c32209ed1ad57b4..a0e7e99c4f43ba3e735f50b9eadbfa07a7803947 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -20,6 +20,8 @@ #define SCMI_IMX_SUBVENDOR "IMX" struct scmi_imx_bbm_proto_ops { + int (*bbm_info)(const struct scmi_protocol_handle *ph, u32 *nr_rtc, + u32 *nr_gpr); int (*rtc_time_set)(const struct scmi_protocol_handle *ph, u32 id, uint64_t sec); int (*rtc_time_get)(const struct scmi_protocol_handle *ph, u32 id, From patchwork Mon Jan 20 02:25:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944690 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 3D99535968 for ; Mon, 20 Jan 2025 02:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340003; cv=fail; b=mZX63feCEjh6NrlyPxF/zt6Y6wBPSE4JjCUEMykPvMuye6a+N6qbt+fQJGarzrHLCUzVyW0Bg+bS/XTLYL7D7Hf7ocgtm8W/ahxvX9cVagyqT/msgbl7//5ekbIonf72yD3oBBuWVv/gPh4vIr3MQ+5aZ123p4uS6SeFcAe9VuM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340003; c=relaxed/simple; bh=S3TiT74+c6cbS/0OYDBl578TfCGtZLQhnlEXJ5xPqKU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=b/JF/5hPXXQJQ/+2W0tg168b4N6aIlxuFNSUtZp+Ex6JhyldWsWJH/722g08kmo1k8qoNp4dTHgEGus7P6Zt8rzV5GFqRzthaU6nkKJplLgikJ/PxhD2kQYUQUlz/A6vW9sQQFz1iodaWjFBmn4U6rglk5TqcMc3Gs7Em64JPUQ= 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=A5SbAMLh; arc=fail smtp.client-ip=40.107.241.55 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="A5SbAMLh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tJPwDu1WKYEL5NxvtLoCNez8r4qILx5JGhcTwe39u0WDTa9KWMIVPbxtqvBoHkIC53sxrlaTOq5BYm1DU1OlFylQzaEiIw48ramjeiW/LT3By0J29/Xou2MJeDUF7kyllV5wGvIyovNn8nrI3B2muDwS0JOjrVl2zpGAFzvlMjcr6u8VwZjzD1bWY8yoxmgRLmXOdXZl/GQxzksmr6AU8xy4PzRJaeJ3pn64jydmktoY4TNTgFQP9wa+XdL15EvtAAuICx3twZA8tnxqVxlXVtQ5WOWy7Us1FOhsp1J4r267WFDVGS6F+bSPywKVvowh6JNOTyzq3LIYp0bNef6SJw== 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=uS0I3mCc295EBaZyA+OocoFOODJEqDmZ8GPyzx+KJVo=; b=PVyMWji1zXxPBP0SYL98vZkKtDrhYmyRGaP44C4NTquGebs/M7ki/7Hk/nGnmDvodCV1vKl3m4IIGYZPeLcziwdmaBpzEoCZdIfFJ+g+fZ3k6r+KeDYkwlEUeshhPE3djoONL2TiuvPTb4aJcTh0fRW+RFfkf+/xTY2omcSCa1bI1EMR6cJF5RjwoEkq8njBwSSc7lRwo0vMBSbVfT/AXN0s2w3KrvOTYow7jte5O+xmYp++wvG98M3+OEGnZVQgn6jsZaTdROKSoRe3G58uRxZnRpHJenNXoXPll3x4bexkI3JaS++SEuwMpvKU4gDZEcI9WN0zEfe6aLIeI755hw== 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=uS0I3mCc295EBaZyA+OocoFOODJEqDmZ8GPyzx+KJVo=; b=A5SbAMLh0A4B/Ia2/KBp/pHoS1ehNKINTceOmQdSoiy798Mz/2Dp8JuYPwebe7P2LCXlQLPy3N+pcjTfgP+dotGciUySEXPV6TAlacF3lg+M7dwTJaciqgzw4+72RVNxrxJSkV2FX+LfIKPbTy2QcX/nu83fS0CV9Pg9hSOA59KwPq6kXgYyvJ1aO8dL1ZCP9oj1/MICIP0aiZXBEc0qsM4aOkbLmy6gVuFwswg1m8B6xX89d5cT0+vmC6Fb6gXqIp+3dvSO3w5D4V1XWqOBSysi34W20Fw0iH9DdleBjFDJaj1O1WI1aESUtTwjgjGJ+xJpraBfXC4AXKN0af8Zvg== 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 AS8PR04MB8690.eurprd04.prod.outlook.com (2603:10a6:20b:429::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 02:26:37 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 02:26:37 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 10:25:35 +0800 Subject: [PATCH 3/4] rtc: Introduce devm_rtc_allocate_device_priv Message-Id: <20250120-rtc-v1-3-08c50830bac9@nxp.com> References: <20250120-rtc-v1-0-08c50830bac9@nxp.com> In-Reply-To: <20250120-rtc-v1-0-08c50830bac9@nxp.com> To: Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737339953; l=7539; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=bmjnxEYUzAa6HVdDVruMYsPIBr6KAocDxz9TUR0lnWI=; b=YcnuPCTqDzMStsGS4pHEqTuj1IjTom/OT/HPgxVwZkJWxo4DM3jgTfZWjdfblgP9K1VIVBN1t /NrUI4e3joICLuXCNWslFEc3vER8ti2ysxPbTUjrUj5/ysQ7YrZ+bfh X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::7) 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_|AS8PR04MB8690:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d2223e8-6a5b-4404-cc02-08dd38f9dda5 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|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?btWofoHkfosDIcgeuOQD6RPITXZxYxD?= =?utf-8?q?CZNZgYLYe4WBEdaOri0gAU6SX9N3XKC4QPEKxhLBqm4bYn88SC7y8Q1UnApHMgyMb?= =?utf-8?q?r07sV/NwV404yorWASzMO8nuogADgtV8OuK9CAENkMsiy0e/WA0pGS6PenbI803Aj?= =?utf-8?q?YHzuNt5Ux46ffoiR0LxnENOdx5pJEVP31at+MZfniIDQBGG9fU14rW+xIajg+6459?= =?utf-8?q?q7HZqF/oeYGGmuMxzm4XW0p1wN791JrcKyBUTPZ2G7pv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3Pj+R37W8CEmWy5u?= =?utf-8?q?Ei0+qb7vxa8UiS4iGcUV2wzIUczGwUb2E062H9l0XwPM4vjeAVGueJHffTlKB5v6y?= =?utf-8?q?jMXXRJ6kIP5wKfFrRWrvuXrn3rRI2rRkUWBLG21Kk4KZkdHAh311sW/atWvY1qCG2?= =?utf-8?q?WJ9pRrJTdMGmfLACNCihKCDQYOcY7x5IejA/codbO4OzD5BaFAXPE+ljkYkk6o/Ou?= =?utf-8?q?TvpElAnUg4QU7dinKNN/0M20rWAUu0KdgTrGF/5GzupUjmdu9pcTAZ5WWg9mrfEPu?= =?utf-8?q?KV5/oQpBHEm?= 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)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CEMsgqCA+6sEQUuh2MXjvKy7QIuf?= =?utf-8?q?lWysLpGI+S9BGN27WUCpqhO7URXdN7DjGe1Etj3GMjMbqNOXRQNOrYq5oQ6Og7VdI?= =?utf-8?q?vZf4eKg3v3DCkpDqvCtmka+1QfZvp63FStU8P3LeBx1RHGrA7ZmUBo6TYEh7EDm+/?= =?utf-8?q?gbFP8s9sEqWbHlN+QN4JkzA+M7jce1zyY3Zw6frEU3SGqdelNVlMnMKhR0asIJrAH?= =?utf-8?q?wX/pOaOZ5geJsuOV9NE+7JyyU8g6A7pwTuxeqXkbYLUkWjtFF+PQW5B1RwYmmrgPD?= =?utf-8?q?XfBPd/953RUKzCFNWdvI1qUFeU43Z3eNioMAGfcC1ZmwGI3f8cmCqwUcPwv4VVkSf?= =?utf-8?q?x9aJtat2JJ2jVTz5iEv/AMAd6RXP+UPubbmD2Ys4Pc+kmKMBOoDMAl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?= =?utf-8?q?m+0cnX+MyerBQi3FGqRz8J+r19grtao+bo34OdE6pioak9sabmovSIPpIjm70ogVk?= =?utf-8?q?rB69XoWb1V348YmTQ/JtY2SmqHEol9NRke190SUchucPyVLwCsCyqskYwLXfi2C0x?= =?utf-8?q?8IJuV8ifHpIUBUcmmindp+QMTTzki5wHbneKfvmt+Qk8AWKo7czo8cUD08YwXuyNL?= =?utf-8?q?w00GTJk2ukYn0uR2jqgSn4zKp2S+EheHmNXnQpWd+EFmfJhKS77lrHMbH0BMo1ai/?= =?utf-8?q?lvfI+iCt1ZoS?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d2223e8-6a5b-4404-cc02-08dd38f9dda5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 02:26:37.3957 (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: uFMXonDB1l9nD7gh19/vWLKx6Ltm+p3o0RpThXckuXkZz9W5RU+GK3E/pdl5jJ5lW5RAd1iRGuBLXO/aTFxbmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8690 From: Peng Fan Current users of rtc_class_ops->x are using 'rtc->dev.parent', so there is no way for rtc drivers get rtc private information. Take i.MX95 for example, i.MX95 SCMI BBM Protocol supports two RTCs for i.MX95 EVK board. Using 'rtc->dev.parent' causing driver not not able to know the exact RTC device. So introduce 'priv' and devm_rtc_allocate_device_priv for driver to set rtc device private information. Signed-off-by: Peng Fan --- drivers/rtc/class.c | 9 ++++++++- drivers/rtc/dev.c | 8 +++++--- drivers/rtc/interface.c | 16 ++++++++-------- drivers/rtc/proc.c | 2 +- include/linux/rtc.h | 2 ++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index e31fa0ad127e9545afac745a621d4ccbcd5fca28..67413600785d806fe4da441483ce1280357d8791 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -361,7 +361,7 @@ static void devm_rtc_release_device(void *res) put_device(&rtc->dev); } -struct rtc_device *devm_rtc_allocate_device(struct device *dev) +struct rtc_device *devm_rtc_allocate_device_priv(struct device *dev, void *priv) { struct rtc_device *rtc; int id, err; @@ -378,6 +378,7 @@ struct rtc_device *devm_rtc_allocate_device(struct device *dev) rtc->id = id; rtc->dev.parent = dev; + rtc->priv = priv; err = devm_add_action_or_reset(dev, devm_rtc_release_device, rtc); if (err) return ERR_PTR(err); @@ -388,6 +389,12 @@ struct rtc_device *devm_rtc_allocate_device(struct device *dev) return rtc; } +EXPORT_SYMBOL_GPL(devm_rtc_allocate_device_priv); + +struct rtc_device *devm_rtc_allocate_device(struct device *dev) +{ + return devm_rtc_allocate_device_priv(dev, NULL); +} EXPORT_SYMBOL_GPL(devm_rtc_allocate_device); int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c index c4a3ab53dcd4b7280a3a2981fe842729603a1feb..e0e1a488b795645d7c9453490d6cdba510cc5db5 100644 --- a/drivers/rtc/dev.c +++ b/drivers/rtc/dev.c @@ -410,7 +410,8 @@ static long rtc_dev_ioctl(struct file *file, } default: if (rtc->ops->param_get) - err = rtc->ops->param_get(rtc->dev.parent, ¶m); + err = rtc->ops->param_get(rtc->priv ? + &rtc->dev : rtc->dev.parent, ¶m); else err = -EINVAL; } @@ -440,7 +441,8 @@ static long rtc_dev_ioctl(struct file *file, default: if (rtc->ops->param_set) - err = rtc->ops->param_set(rtc->dev.parent, ¶m); + err = rtc->ops->param_set(rtc->priv ? + &rtc->dev : rtc->dev.parent, ¶m); else err = -EINVAL; } @@ -450,7 +452,7 @@ static long rtc_dev_ioctl(struct file *file, default: /* Finally try the driver's ioctl interface */ if (ops->ioctl) { - err = ops->ioctl(rtc->dev.parent, cmd, arg); + err = ops->ioctl(rtc->priv ? &rtc->dev : rtc->dev.parent, cmd, arg); if (err == -ENOIOCTLCMD) err = -ENOTTY; } else { diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index aaf76406cd7d7d2cfd5479fc1fc892fcb5efbb6b..06d51761900ee5d6cc3916d31d907505c193c6ad 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -91,7 +91,7 @@ static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) err = -EINVAL; } else { memset(tm, 0, sizeof(struct rtc_time)); - err = rtc->ops->read_time(rtc->dev.parent, tm); + err = rtc->ops->read_time(rtc->priv ? &rtc->dev : rtc->dev.parent, tm); if (err < 0) { dev_dbg(&rtc->dev, "read_time: fail to read: %d\n", err); @@ -155,7 +155,7 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) if (!rtc->ops) err = -ENODEV; else if (rtc->ops->set_time) - err = rtc->ops->set_time(rtc->dev.parent, tm); + err = rtc->ops->set_time(rtc->priv ? &rtc->dev : rtc->dev.parent, tm); else err = -EINVAL; @@ -200,7 +200,7 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc, alarm->time.tm_wday = -1; alarm->time.tm_yday = -1; alarm->time.tm_isdst = -1; - err = rtc->ops->read_alarm(rtc->dev.parent, alarm); + err = rtc->ops->read_alarm(rtc->priv ? &rtc->dev : rtc->dev.parent, alarm); } mutex_unlock(&rtc->ops_lock); @@ -441,7 +441,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) err = -EINVAL; else - err = rtc->ops->set_alarm(rtc->dev.parent, alarm); + err = rtc->ops->set_alarm(rtc->priv ? &rtc->dev : rtc->dev.parent, alarm); trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err); return err; @@ -545,7 +545,7 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable) err = -EINVAL; else - err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled); + err = rtc->ops->alarm_irq_enable(rtc->priv ? &rtc->dev : rtc->dev.parent, enabled); mutex_unlock(&rtc->ops_lock); @@ -847,7 +847,7 @@ static void rtc_alarm_disable(struct rtc_device *rtc) if (!rtc->ops || !test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->alarm_irq_enable) return; - rtc->ops->alarm_irq_enable(rtc->dev.parent, false); + rtc->ops->alarm_irq_enable(rtc->priv ? &rtc->dev : rtc->dev.parent, false); trace_rtc_alarm_irq_enable(0, 0); } @@ -1049,7 +1049,7 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset) return -EINVAL; mutex_lock(&rtc->ops_lock); - ret = rtc->ops->read_offset(rtc->dev.parent, offset); + ret = rtc->ops->read_offset(rtc->priv ? &rtc->dev : rtc->dev.parent, offset); mutex_unlock(&rtc->ops_lock); trace_rtc_read_offset(*offset, ret); @@ -1084,7 +1084,7 @@ int rtc_set_offset(struct rtc_device *rtc, long offset) return -EINVAL; mutex_lock(&rtc->ops_lock); - ret = rtc->ops->set_offset(rtc->dev.parent, offset); + ret = rtc->ops->set_offset(rtc->priv ? &rtc->dev : rtc->dev.parent, offset); mutex_unlock(&rtc->ops_lock); trace_rtc_set_offset(offset, ret); diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c index cbcdbb19d848e78e6674bd626833151a99773ef0..94cc4f9d62b7867018d876f7933468fbd1552ffc 100644 --- a/drivers/rtc/proc.c +++ b/drivers/rtc/proc.c @@ -73,7 +73,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) seq_printf(seq, "24hr\t\t: yes\n"); if (ops->proc) - ops->proc(rtc->dev.parent, seq); + ops->proc(rtc->priv ? &rtc->dev : rtc->dev.parent, seq); return 0; } diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 3f4d315aaec9e641e35c1c86a522f2879bec19ba..a6f3c86a08e1e214062b2a68d9a6a437afb186b3 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -110,6 +110,7 @@ struct rtc_device { struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */ int pie_enabled; struct work_struct irqwork; + void *priv; /* * This offset specifies the update timing of the RTC. @@ -182,6 +183,7 @@ extern struct rtc_device *devm_rtc_device_register(struct device *dev, const struct rtc_class_ops *ops, struct module *owner); struct rtc_device *devm_rtc_allocate_device(struct device *dev); +struct rtc_device *devm_rtc_allocate_device_priv(struct device *dev, void *priv); int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc); extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); From patchwork Mon Jan 20 02:25:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944691 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 9A69A1494C2 for ; Mon, 20 Jan 2025 02:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340005; cv=fail; b=WHJrzaP6NHXCIB1NmovJS7eA3K9IiCqWnpJqqLG1kJ49VEIkSicW8ia9SPVVx/LLDtu33pgmR2TGfTKYe8RL9gBc2RPho5OZX8Xgf2etAcsf9AXcsaA3JqvLU908wSGz5qLjgfg8JTCVNeN0gvMBv5IV274CbLjDXur6F0oGKv0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737340005; c=relaxed/simple; bh=Gkwmu72GW/T8BO4fFQuc9k2zZWr3upHH3QZnD9ouLP4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=DQQ8dvnOpvLllhkG70uW5NWzw0vNdP0Sw2jjEeJo1b3Xmu94TXnQnqgxEfDdbFEkgwNP3pSN5mVVzvHMnqPkW4TTOI2H+U5gKjJIXGJUzdvcpk++o4d7BnHwG1FZ7SXaI2nzEInweCL5jAHkbGHDxB5N3sHaP7GKbI7Hp2wBrLg= 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=hKMrbcf5; arc=fail smtp.client-ip=40.107.241.55 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="hKMrbcf5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EPYvAu+EtnxssWrwRuv3ZUoXwY65PfGoY+7jrhC63ODXDVznPaZ3CQ1k1UQ/YI+ZbsqWPZjdYgwe+ttxfJYqLmwZkZzbejFOmeQTti80PXJJbLUOlV3pswEyy6bgzQp6SbON3VefUba8VJRaftjgsrtbbO3onaWV8iyHwV6RVDvM8e+1yv9LX8RpGcNT6PkQ3923cGwI9fGdoEYYQMIxUQyWE9AUMy5afu+/VRSPC2k6jkhJi3EBwu6vM5HTp5ja87r9+NNC+JdN7WlTsheqPsXLnG5lDEfacZS372yyajr2l3841Qniw5r7BpUpvyz1/wbd3Y+/ELxFLap+npzr6w== 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=jl8nAGY/ZjoDzYb1Yak58SewtrQzOg8+j/EYm1sobVo=; b=c7gl+0hGGBjGF+YKRi0FXZXpbV7Ixq1aNpaxemjTaBnv29tA1Q6HmVmZa2RvDAQPm4mHZccVs9De0WHhoqPcxeeUcIhzXss1c9n7Lu6eeqN2Kt2uRJ6DS0jRykpM4HdSb2JUTRA93x4A0QeG8fvSD5gv4S3ld8uwdPc6Vq7EK6Hh754I4IVDQPeDiOZPDWhmjVIcjQtt0AOzDrGowouNX0LBtSzvquFvG4ezXYJ4dl4YA/PRVjJktGtfUtyy/gLuYlvtOKaJD1rsqm+jna6sARBrsz/reGFBtIZjefGF/mf12I6DMvqcfyuHBbnUJaImPJ2MH5YdB8dqU+auiapSPw== 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=jl8nAGY/ZjoDzYb1Yak58SewtrQzOg8+j/EYm1sobVo=; b=hKMrbcf532RNiBz1a/saqM+z7CeisO46Vwsg6La8X7PcW5SXFFb1eJVz1dqXXwNmvsrPCGiB+84sWauu9B6PiGclwJ7sTEERMNCNJlO9E2SSA/n26MRIna2W+hoOL+ZuZga3RELbYfHcLNeiouNt+PT1huTyANYrNJuyKx3JR2DjnQqXT2jZWPG7OFI23NLSmqOifRTWFxSm06iv9/6r3Rz0NxJotZWLlfkQjYP1pfvXxDGIaBUzWVrTMwyTJYSzCIPKPp/E5juWShLgjlrBswvvP6OBYbjl4J44oTe9C56o0ZDDhQFF+zzVrMI+1IJOLGzlDT/4IaylXr17ZkCdmg== 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 AS8PR04MB8690.eurprd04.prod.outlook.com (2603:10a6:20b:429::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 02:26:41 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 02:26:41 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 10:25:36 +0800 Subject: [PATCH 4/4] rtc: imx-sm-bbm: Support multiple RTCs Message-Id: <20250120-rtc-v1-4-08c50830bac9@nxp.com> References: <20250120-rtc-v1-0-08c50830bac9@nxp.com> In-Reply-To: <20250120-rtc-v1-0-08c50830bac9@nxp.com> To: Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexandre Belloni Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737339953; l=5574; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=iF6bDJjhb1QTl2LY4lI/hL+omPn4K8AgkYH5lkX3plk=; b=DG4qxX2zPOrPVsqm/bacn+JQDSZJol1U5HpUMP+2sMFsZeh8uJ+JyjQIkmvudRyPhmviz4duP CY1fjZZ/0WXB9jqOjFmvAuM+ldiD46k0m4kJNlbON2es7/cawLP8kxl X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::7) 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_|AS8PR04MB8690:EE_ X-MS-Office365-Filtering-Correlation-Id: 20befcec-14d9-466e-f6c7-08dd38f9dfe6 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|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?56jKp9YWhNMuDNZAYOHZowa/ZxBysgm?= =?utf-8?q?8Fc/VETWT/UNqN3osSehcPQ2G9EgRGCunmwfwweUPgu/OJKdAtSDZNdV7RwzSUBnH?= =?utf-8?q?I8+cxvQjP2auycINp9228qcQ3f8fOr4d/x82mHrEmeZyQzGMBKD6p5Cy0ojHYJgnf?= =?utf-8?q?1E+1y2sFcYkRcHZ5fT/b4y6UmIhn6oK6THe8knyGja/0mRRoAB89mJJ/sFRvjd2Va?= =?utf-8?q?LOyPL8NdjCGJZ5mEDVcEMMNRVY1Yf9tdSv8CSHtiNTd2xKkGHKRw+U7RlL86nLOQu?= =?utf-8?q?ae37I50GN75rtmcXQSli+EHeu4Fpgd9bMd1jMbrraJj/M2v9KAq6+0hdWmn0Mwb8F?= =?utf-8?q?37dGxIpEiHXHyrOxEvS93Zru3BwPN/nIYjvkMltQ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dVg6BFldboELNsWWIc0k?= =?utf-8?q?9cTzvOFKJz6uFgz3VCTrr3bZS+L/+I7PYK9AqxHnrI0F+lgFNYArgNEmhZusvoip5?= =?utf-8?q?Fna1Wc1UMKG+osk/HdwSa2pKXDhbuDcdCiquqiQW2LD8JNS/6GaDYTfA1fVEup/ga?= =?utf-8?q?crOu8eEVGQj?= 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)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3NSxGlSFPcSy8dzsW7ZtVFKEvgKH?= =?utf-8?q?YVFzPPlerNNS4vAhGOieXGy4hDzvNMtjlCXCYejv/XETVdSVN7rTN60lwHV42zQL+?= =?utf-8?q?z1e1Y9MRkl3EcEnAu6cw3UYtii1t7x/jbDkKdzWSTga/E+kOEQfsJvmJgEcxQB4VQ?= =?utf-8?q?1bQoILMw5AkJ49Zsc+bVjxi0vYAq+KZvLtqmpPglEiATdUdT0qQgmjwLhHtePcPz5?= =?utf-8?q?ihEZVGTYlwIyN/zmTddVEd/cE74PuhiYUUoW45GTfSHMhfjBxgwLFod12R77SAi6p?= =?utf-8?q?0Tm00tS3uyh4r+sXAxeg0d4+1u0TaQ3e74Ag20Kl/hLHmOJjqBvXq5GodH0TDOQtg?= =?utf-8?q?AZIPtwQehbvz8gon3aYludOlz1u6N/WCnH+hpFv3MgWB+tF4rs3YQDgBgGoB/7Wrh?= =?utf-8?q?yZxn58zi/8JDzcvV13YvNVRup0Hx555Nep7HUUktrrmdbcr+ae+/CEjZNhK8mEKhD?= =?utf-8?q?GKyh5/oKkqKiyhtfmccG1gnt2dWx5PLt5gDFpBR7Gif3FvFlDccP76tXsZvBVGkS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0xR/JSSjqKkck+pQYFWfDtRXxwoHZ2g8tqrPuwsDI7eBNcCVaBlQu3if?= =?utf-8?q?wFKAIh8hqUR122/Sd+qyIpO8Ywd0nxYD0PLNU5HbtTfdCTnAIkxlxS/WkK1S8eli4?= =?utf-8?q?5KQH6W5C71rx?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20befcec-14d9-466e-f6c7-08dd38f9dfe6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 02:26:41.1846 (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: D9S848fhkD2m4+eyC5EyCJl4p1xMTgyrGu6NBQh6IEd66ooj9mwphedY3hA6cp1refMMwB7f1IzvksQU+L6RBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8690 From: Peng Fan i.MX95 EVK has two RTCs exported by SCMI BBM protocol. Current driver only enables the 1st RTC inside BBNSM module, leaving the board RTC not used by Linux. To use the 2nd RTC, use 'bbm_info' to get the number of RTCs, register them all, and set 'bbnsm' as private info for rtc device to know which RTC it is when using rtc_class_ops to access rtc device. Signed-off-by: Peng Fan --- drivers/rtc/rtc-imx-sm-bbm.c | 69 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/drivers/rtc/rtc-imx-sm-bbm.c b/drivers/rtc/rtc-imx-sm-bbm.c index daa472be7c80697aa3cd3432eccef0c877e4c378..a29b30555d0c0581ecaa8b79760209dc780d2f0e 100644 --- a/drivers/rtc/rtc-imx-sm-bbm.c +++ b/drivers/rtc/rtc-imx-sm-bbm.c @@ -15,16 +15,18 @@ struct scmi_imx_bbm { struct rtc_device *rtc_dev; struct scmi_protocol_handle *ph; struct notifier_block nb; + u32 bbm_rtc_id; }; static int scmi_imx_bbm_read_time(struct device *dev, struct rtc_time *tm) { - struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct rtc_device *rtc = to_rtc_device(dev); + struct scmi_imx_bbm *bbnsm = rtc->priv; struct scmi_protocol_handle *ph = bbnsm->ph; u64 val; int ret; - ret = bbnsm->ops->rtc_time_get(ph, 0, &val); + ret = bbnsm->ops->rtc_time_get(ph, bbnsm->bbm_rtc_id, &val); if (ret) return ret; @@ -35,37 +37,40 @@ static int scmi_imx_bbm_read_time(struct device *dev, struct rtc_time *tm) static int scmi_imx_bbm_set_time(struct device *dev, struct rtc_time *tm) { - struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct rtc_device *rtc = to_rtc_device(dev); + struct scmi_imx_bbm *bbnsm = rtc->priv; struct scmi_protocol_handle *ph = bbnsm->ph; u64 val; val = rtc_tm_to_time64(tm); - return bbnsm->ops->rtc_time_set(ph, 0, val); + return bbnsm->ops->rtc_time_set(ph, bbnsm->bbm_rtc_id, val); } static int scmi_imx_bbm_alarm_irq_enable(struct device *dev, unsigned int enable) { - struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct rtc_device *rtc = to_rtc_device(dev); + struct scmi_imx_bbm *bbnsm = rtc->priv; struct scmi_protocol_handle *ph = bbnsm->ph; /* scmi_imx_bbm_set_alarm enables the irq, just handle disable here */ if (!enable) - return bbnsm->ops->rtc_alarm_set(ph, 0, false, 0); + return bbnsm->ops->rtc_alarm_set(ph, bbnsm->bbm_rtc_id, false, 0); return 0; } static int scmi_imx_bbm_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { - struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct rtc_device *rtc = to_rtc_device(dev); + struct scmi_imx_bbm *bbnsm = rtc->priv; struct scmi_protocol_handle *ph = bbnsm->ph; struct rtc_time *alrm_tm = &alrm->time; u64 val; val = rtc_tm_to_time64(alrm_tm); - return bbnsm->ops->rtc_alarm_set(ph, 0, true, val); + return bbnsm->ops->rtc_alarm_set(ph, bbnsm->bbm_rtc_id, true, val); } static const struct rtc_class_ops smci_imx_bbm_rtc_ops = { @@ -83,19 +88,18 @@ static int scmi_imx_bbm_rtc_notifier(struct notifier_block *nb, unsigned long ev if (r->is_rtc) rtc_update_irq(bbnsm->rtc_dev, 1, RTC_AF | RTC_IRQF); else - pr_err("Unexpected bbm event: %s\n", __func__); + pr_err("Unexpected bbm event: %s, bbm_rtc_id: %u\n", __func__, bbnsm->bbm_rtc_id); return 0; } -static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev) +static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev, struct scmi_imx_bbm *bbnsm) { const struct scmi_handle *handle = sdev->handle; struct device *dev = &sdev->dev; - struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); int ret; - bbnsm->rtc_dev = devm_rtc_allocate_device(dev); + bbnsm->rtc_dev = devm_rtc_allocate_device_priv(dev, bbnsm); if (IS_ERR(bbnsm->rtc_dev)) return PTR_ERR(bbnsm->rtc_dev); @@ -105,7 +109,7 @@ static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev) bbnsm->nb.notifier_call = &scmi_imx_bbm_rtc_notifier; ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, SCMI_EVENT_IMX_BBM_RTC, - NULL, &bbnsm->nb); + &bbnsm->bbm_rtc_id, &bbnsm->nb); if (ret) return ret; @@ -118,29 +122,42 @@ static int scmi_imx_bbm_rtc_probe(struct scmi_device *sdev) struct device *dev = &sdev->dev; struct scmi_protocol_handle *ph; struct scmi_imx_bbm *bbnsm; - int ret; + const struct scmi_imx_bbm_proto_ops *ops; + int ret, i; + u32 nr_rtc; if (!handle) return -ENODEV; - bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); - if (!bbnsm) - return -ENOMEM; + ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(ops)) + return PTR_ERR(ops); - bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); - if (IS_ERR(bbnsm->ops)) - return PTR_ERR(bbnsm->ops); - - bbnsm->ph = ph; + ret = ops->bbm_info(ph, &nr_rtc, NULL); + if (ret) + return ret; device_init_wakeup(dev, true); - dev_set_drvdata(dev, bbnsm); + for (i = 0; i < nr_rtc; i++) { + bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) { + ret = -ENOMEM; + goto fail; + } - ret = scmi_imx_bbm_rtc_init(sdev); - if (ret) - device_init_wakeup(dev, false); + bbnsm->ops = ops; + bbnsm->ph = ph; + bbnsm->bbm_rtc_id = i; + ret = scmi_imx_bbm_rtc_init(sdev, bbnsm); + if (ret) + goto fail; + } + + return 0; +fail: + device_init_wakeup(dev, false); return ret; }