From patchwork Thu Jul 25 09:07:41 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: 13741653 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013038.outbound.protection.outlook.com [52.101.67.38]) (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 8B384196D8E; Thu, 25 Jul 2024 08:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721897935; cv=fail; b=M+NOGYfxGQ2bXRyJC2ien5JHtURBANw3hQ06Y3itZbGuhgK+4gF3KI5+xwKdy4zhBPwMGmGNIpv5t6TpvVJ7tpY41y7NhgDFpyMTrt9K/s5Pgpj+FsU4QFnzNYeomYpzIb6nPZ/4NqiBeHydys0pcyqMfdJe18gQZxrvl/W/xMM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721897935; c=relaxed/simple; bh=Qyl7RMFebsj4IEx7FgxQEhHZGkcsSEZsFkFD9AhCnwg=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=b//rC6IHAnRWHj49BjSD4lVw2DeN9VGxWsAR0gw4nS2KPLKuE1qcguWkDnOS5JS83x0dVrdpYtdtB7CpXUoBEiGUiJSZiu6IVCXZYMKUnhq3P6jYtA/yFI52CZa+WVTUl/WEXI9bG29s/yZyo9XIzqgbO2crSoA6hMgI8/lmFpY= 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=WUoUezUn; arc=fail smtp.client-ip=52.101.67.38 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="WUoUezUn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QWQwRWT529+A02VOPEE3b6fUzUbB6oeBVjjrOJUjmRv7je+WyfS09DeT8r7uj+gFqQJVWrbiajeCWmto7aKn+vRMhpGA1U6AX766mKJhw1sBDTbtLwbM1gJtJ2j3qm33TV6A5AjNdSP+ShtpVYaAvRwWs613ls82gBBAzOrAxaPzI9cov1lSIryRet8DlM5U0r4fZziF7zyQSzN9GALD4ZfHkOcHJ558hVDx3GpneIECugl/kYy6qNMguo1pHFKn7TINlzURCMNF/M/6RSV7BGreSYHx08t17ZS2SbmXN8BK7GSqbd8707AEznHLl+SZyanLt1Sje/zfrbZnhPu5wA== 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=Prx8q3Luk+2gWBiDRsHl11DCO6EizaYEn5wo2kmuQPE=; b=dmnnhiR6AdnwtdbRLzMEqQlDQfgXNfijKcfgMuUlPeUDwrGpAUKHD3tOVMUtEqHcveTQcVg2Z+j0IJPlEiS1zQ540JOJ+Rzhi69PVzm5BBRiVXrdYjxkzMb7s8J2Dm1fwY9uwcf4yIazbMwC4jrChEHjH8omQP4NB7nE4E+58pVazdiEb/kqgiZJW+hUmKXPiKJBDXhAtsOpBy49qC2uLaGZiPVh2mqdakHKV2lppE7AU0zNLc/A82xn6FDsMm8c6zywLmrfPd0W/j4EQay5EsUI53/GNBsdmQSyYwI4z4bEJk6BcYQ6EpFUdZe+pN42yTojOK7fEPN9d2tKxGWi8g== 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=Prx8q3Luk+2gWBiDRsHl11DCO6EizaYEn5wo2kmuQPE=; b=WUoUezUndmjh+xu6FkAjkjHTaAOmJAzmHRLOpHTYUu77SGoMPgeiB1DH4vSwTNxWJHY/cm5WwC82RszEp81aiIAfICWhbKUbU8s01a1i0dvBufq6ZlrIATAiSebsR11Skr5Rc2Jl0pG4YzgTUA8vfJemfOsi28ih/IgCMpmjyGNh6P32Xq4+cdk+xoszAanMeb9nJYXXqInXeSzPP7e/3JF3AGOdRypVg7byEaGuHoNBJWrZfo1MVfCPROpxZQzKVTdzbLy5XcuMZSrNCCt+2ADyswFG60p4dwHsvgp/7tmDi0V+tGDv3NvYYMR7VDHWAthpP+GJQ2oB+ydGyKa5Qg== 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 PAXPR04MB9124.eurprd04.prod.outlook.com (2603:10a6:102:22f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.28; Thu, 25 Jul 2024 08:58:50 +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, 25 Jul 2024 08:58:50 +0000 From: "Peng Fan (OSS)" To: sudeep.holla@arm.com, cristian.marussi@arm.com, mturquette@baylibre.com, sboyd@kernel.org, linux-clk@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, Peng Fan Subject: [PATCH] clk: scmi: add is_prepared hook Date: Thu, 25 Jul 2024 17:07:41 +0800 Message-Id: <20240725090741.1039642-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SI2PR01CA0022.apcprd01.prod.exchangelabs.com (2603:1096:4:192::14) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-clk@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_|PAXPR04MB9124:EE_ X-MS-Office365-Filtering-Correlation-Id: c8baf258-681a-474b-db16-08dcac880016 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|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: DGbZXD4OjSxV+0kSUepU+gTrvCMBubfMrM2J7y2sCzv596B6fwKEyyjf0kJKVAmu3rIK0XlhnEjiv2qQg/a0dNhXIv9YTdhoHsWZChgNk6KH7wVfADy9U7uwf/pbHoqtyeZSoV4Hs3xQsC5rS/Qh2RokS+czEIUiWy8tEYVk+kzkRItLJ2QNZV+TKnen2xFJh0RmPvTHrco0UIUMdMKaM6c9/LRJalyGvQP1w0VTfEq4yd63Ie4YKy9+VnkpWkshoex/suhbWA0VodKMzfPIFEDURbOf+8k0RF/SW2kOYgodBfKq+A6OjaHE5kb2jW0DebJBJKJrallBzHy3Yc6gGniPkkl/H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-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)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: txqCbMCeKp2qJJSykeepQhxcj5Ls7WRJSwHH/eOiRolZrcstehrRMNuvlvniZ/Zx1q7/bbDZmVdDIDTuTnRkoqpgEPqES7ELslDIEmQMTic60Nq8fSTlUnIdsx/ytwIC+GmoW1WcQXkc1vD2etqvpnnTfV87E1OsnNcXYIYDxATtUbPfC771UDLI9AuTANM253dIXjD9KmteeHw30iVO5rwGJ24uTzadhiHomiRlNPygKKaINZRxYf8MNeGEiFWO8UV4Gu5+pJ8VefMqLmQqkakPf43siSc1t0fqsl3MQjp9r6R8eEjDCG/UQRgFlCDl5x35Qu19wuA23OkwFiovKFn/auotjsH2Cxtc8zfVDo9ulNmq8hsz37qOhBbmJUqdQ96IcqeS/+qd+Zlv8A5EYLq2wXmyR7xgDjCja8C53hCLPzJQ3WtuDYFXRkB9rZ/Pv75tB1ZiicI/JrBEeWPK9pFh0e+8rIntr2aH4ATeJLLdW8q6KoxINTWWWjBPa/JerAPqIqgBNLRFEyIySI4ZxU7nr5rcsOsb258NsVVcdOfLqohITr53Ft3oC0rNG8+9tLXXOPWYBdF/ymsHJeEIhDOcfBf8NgUs9djdAbE2Lc3PqriOkw+2E9tVfH0EKpdsBKlIGpbUyoj/Xm2WWyYghBAk7cbOZCW/DVQhfexXkin00vMQa87thfwYOSEPVO0GrOBR4QbIbH4yVpSv1bxAj0SwhtUUmMuokoB1wgqCNFeKJrdt0rsgdeFHwg3hPABs82YKt1r+yvGkyOEKUW02DF1pJ42OisTvoeI9IQZNwQAvP1uWiRfruyADhIEKk+9Et8NOogkJSvO8VuukGl2Pzsg3FhLIs7EPGnngeoI7JM1hu8NEd9Xb2Im/9Uu9eQRkOh7wrA8HbUW7UMe4/zuXcLVsihegCw55aHF4idlVPZkEcIThn0QBmCp/cpKGqCIXoPYOL63nk44i6senvCZcGEvAz+M9RNdI4f/bAgvc8kPiqMGV7ikMkBizXtb8miSXzf4QMpv8qJZuHanDtB7Mdc2/PYJhs70e33MNkQnY0rs3dT6ytjbgOpTsQOsnC3zmpDDC7Yp5fDtKEfgIpGACg9+p+s3VPCv2vdLQtzOaQKt5Zj1jt0jHl0vLBDxc3aZE4fQjrR9vaMNzZaPClnySq4sxke23OlOvrQtd50a6ucCet82rygEy+ufBvbQnL/svA04HoA86xOweV1uU0r8tLWBs8OPFOkWp+iEgsUEKii3RFFBB4QegCAoRxFC/NtQ8jTTnOUImi5pr5rahgBjEQcN6nM4vOE8OI0XmHpHQixL55uANsQ/oGPqYUZKZcnuoR0vaXXHhBPMAMcXxJ2dGeOh8n/rx0j5ay5ceQJ+N2L7dWeaK64tz5W+Q/dmiPYGQcQCkPZqCjXy6087N4dboA5Ue5mGV1JnUn2ZfljYl7ThdVogvw+syiCxtxejN7Vmy1uMAL6spnFv7t0bqzYFCNO+0SYvHivSoqdXp2EL/gZ3OkgkZZ1KWGqt5LXdMjy/Dikp8pl3s8RQ0uLp8q/aZL9EuRdp/xYpTNNFeB4EMQvZN/G5T+fjOkgd0/m9EYgHu X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8baf258-681a-474b-db16-08dcac880016 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2024 08:58:49.9942 (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: QQlquTWNTbnr2NpPEwOfUNSmL9tCUWKjiKqBTR4nIHvQnwqK5LKCFWtsZqJv/HjoEuVSqTv/JwqXZ+DzIqHfuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9124 From: Peng Fan Some clks maybe default enabled by hardware, so add is_prepared hook to get the status of the clk. Then when disabling unused clks, those unused clks but default hardware on clks could be in off state to save power. Signed-off-by: Peng Fan Reviewed-by: Dhruva Gole --- drivers/clk/clk-scmi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index d86a02563f6c..d2d370337ba5 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -142,6 +142,20 @@ static void scmi_clk_disable(struct clk_hw *hw) scmi_proto_clk_ops->disable(clk->ph, clk->id, NOT_ATOMIC); } +static int scmi_clk_is_enabled(struct clk_hw *hw) +{ + int ret; + bool enabled = false; + struct scmi_clk *clk = to_scmi_clk(hw); + + ret = scmi_proto_clk_ops->state_get(clk->ph, clk->id, &enabled, NOT_ATOMIC); + if (ret) + dev_warn(clk->dev, + "Failed to get state for clock ID %d\n", clk->id); + + return !!enabled; +} + static int scmi_clk_atomic_enable(struct clk_hw *hw) { struct scmi_clk *clk = to_scmi_clk(hw); @@ -280,6 +294,7 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key) } else { ops->prepare = scmi_clk_enable; ops->unprepare = scmi_clk_disable; + ops->is_prepared = scmi_clk_is_enabled; } }