Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1099489rdg; Fri, 11 Aug 2023 09:38:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxfG9cLQ4+0GsecwI2BMiBVqHqserBoplaqcwhCgatl3BnW/en3q397CDELDoPv2EKHp6m X-Received: by 2002:a17:90a:a46:b0:268:977d:5253 with SMTP id o64-20020a17090a0a4600b00268977d5253mr2012396pjo.8.1691771924752; Fri, 11 Aug 2023 09:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771924; cv=none; d=google.com; s=arc-20160816; b=wRa0e8lR+sdbiase9/LPE/T5ymfFfjZG7MZywht0vXt19ZJp5zrtbVhFtkNKjOnI12 TcXDnm2gm/kPHytGXYzxj1pBJt1e5gRIxZHkAjcMOEctzDDJF9AnbryKtHPmcKggLwYb hhOtssP/hHYj/yFNXOmhIdFaQGeBMHWC78k0FcUn7NcE3SKCzFBbWVoiyM4hnxvI3y1U xkOtn7GKmz75xgF8qhUGk+0mFcJN37SfciOGlNi4LEUDt+JQ6OvsII9xeFfuaNkPUlMT l3CBqzabwEhB8jEHI4sQAI9nZh4W14xaGZAkwVoganr1T3sPQIzSxSSCLN5hWGzl0oLm w8BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zyf6Vy2/Q+MPoiuR3BOK5bqwhmUoklaGctag7NKy+LU=; fh=S+pyV4uNeYv17K2EadaTrxZRaJH55XFTUj83MlxgjWo=; b=DUH5dTQg3QvmE1k2Y1c/aAPzbBVBEOYn8es59US/xjdawxpcFm75oSAr7X2jEcaair u8WRm+8j9TQOIfBWIfAc9jQXUWlQGamQh/EM6Xg+vzaSXsHmIZr9vbAvn91XGfmGD7Ka zm0Zgs2psdEKue+IsI9/1OXXMigamToSmGnuVpH4TdMz6WaqDYL6cG+MuV6xjyCu9Uve Zsx1KS9NAJZTWK2Yt79yjFyiU4ZKrKBY1QdUemwY1t8cPeslhBA/YAP02TjEIsVTwXhD vpiULigugTVTWVIsVHyCoragUG/tnCludd8brulAI8zMCWr3a0IQer6H/rAVULMlsZSF vljg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a17090a951200b00267ed8359e2si3593582pjo.55.2023.08.11.09.38.32; Fri, 11 Aug 2023 09:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235857AbjHKQQL (ORCPT + 99 others); Fri, 11 Aug 2023 12:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbjHKQQG (ORCPT ); Fri, 11 Aug 2023 12:16:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 610C4271E; Fri, 11 Aug 2023 09:16:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E8FF113E; Fri, 11 Aug 2023 09:16:47 -0700 (PDT) Received: from pluto.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E4763F64C; Fri, 11 Aug 2023 09:16:02 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, etienne.carriere@linaro.org, peng.fan@oss.nxp.com, chuck.cannon@nxp.com, souvik.chakravarty@arm.com, nicola.mazzucato@arm.com, Cristian Marussi , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org Subject: [PATCH 5/6] clk: scmi: Add support for .is_enabled clk_ops Date: Fri, 11 Aug 2023 17:14:45 +0100 Message-ID: <20230811161446.636253-6-cristian.marussi@arm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230811161446.636253-1-cristian.marussi@arm.com> References: <20230811161446.636253-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for .is_enabled atomic clk_ops using the related SCMI Clock operation in atomic mode, if available. Note that the .is_enabled callback will be supported by this SCMI Clock driver only if the configured underlying SCMI transport does support atomic operations. CC: Michael Turquette CC: Stephen Boyd CC: linux-clk@vger.kernel.org Signed-off-by: Cristian Marussi --- drivers/clk/clk-scmi.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index ff003083e592..3770b58cc882 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -17,6 +17,7 @@ static const struct scmi_clk_proto_ops *scmi_proto_clk_ops; struct scmi_clk { u32 id; + struct device *dev; struct clk_hw hw; const struct scmi_clock_info *info; const struct scmi_protocol_handle *ph; @@ -102,10 +103,24 @@ static void scmi_clk_atomic_disable(struct clk_hw *hw) scmi_proto_clk_ops->disable(clk->ph, clk->id, true); } +static int scmi_clk_atomic_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, true); + if (ret) + dev_warn(clk->dev, + "Failed to get state for clock ID %d\n", clk->id); + + return !!enabled; +} + /* - * We can provide enable/disable atomic callbacks only if the underlying SCMI - * transport for an SCMI instance is configured to handle SCMI commands in an - * atomic manner. + * We can provide enable/disable/is_enabled atomic callbacks only if the + * underlying SCMI transport for an SCMI instance is configured to handle + * SCMI commands in an atomic manner. * * When no SCMI atomic transport support is available we instead provide only * the prepare/unprepare API, as allowed by the clock framework when atomic @@ -129,6 +144,7 @@ static const struct clk_ops scmi_atomic_clk_ops = { .set_rate = scmi_clk_set_rate, .enable = scmi_clk_atomic_enable, .disable = scmi_clk_atomic_disable, + .is_enabled = scmi_clk_atomic_is_enabled, }; static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk, @@ -218,6 +234,7 @@ static int scmi_clocks_probe(struct scmi_device *sdev) sclk->id = idx; sclk->ph = ph; + sclk->dev = dev; /* * Note that when transport is atomic but SCMI protocol did not -- 2.41.0