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: 13741652 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 E7156C3DA5D for ; Thu, 25 Jul 2024 08:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Prx8q3Luk+2gWBiDRsHl11DCO6EizaYEn5wo2kmuQPE=; b=RofgMwyjnd1aio6RnjP3TQ2wWo H1+7lPrduzaJJxPZn8TPvyQzOGJZAhIRaGxH2q6pqe3wuSddSeT3vHXt7iUzn4z5Hclin097VFpGp li/isZlu3eH6m1qcXG9AKBKLO1+Kna7dOOD3hfO4tfoGs9bxC1keIQ2YbuW4p6vduMH8KXmWoJM2I uBkS907CtRhuoMNxJ8UskHhxaRtEOWCwMiaRTw89gWz6KBUaSfpACae1m1takRR1+4Foto5s7Xhwv s5UsJY5psC/R4OngIAZKYq4WSLbv134r0wdE0FlIlnRdy1l4NftAkJ2L+UQcpPsjk9GaHO5KlmOGU eIhSbahw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWuJl-00000000Ozv-0Ihh; Thu, 25 Jul 2024 08:59:21 +0000 Received: from mail-northeuropeazlp170110001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWuJM-00000000Ovv-0Q2h for linux-arm-kernel@lists.infradead.org; Thu, 25 Jul 2024 08:58:57 +0000 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) 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/HsE5QG56MjTfs38AwST9AIwbNTCKcMly81jmRTnnWDLkRE2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V: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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240725_015856_174429_F41123B6 X-CRM114-Status: GOOD ( 10.61 ) 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 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; } }