Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1545110rdb; Sat, 26 Aug 2023 07:03:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEaEe4RElYzdTxtHgeNFlsik6Djf1Lyi/q51M8qNMkNHmE1HUalTUcAImFazJB5YB13BBi X-Received: by 2002:a05:6a20:548f:b0:133:c12a:4d6 with SMTP id i15-20020a056a20548f00b00133c12a04d6mr22561517pzk.1.1693058618466; Sat, 26 Aug 2023 07:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693058618; cv=none; d=google.com; s=arc-20160816; b=CJUYXCjI9vbeyfZtmU2OOAYN8Ta6HL2RdrFWFXVd9P32lmXeRKPdOIhd96zA8wutEG PTi0cRAe0z5Xwx2ogJQqhUX21DJPS6EJ4nXl2o0AsDeSqf73lL5Voj0XqblhOzSGJhmK TMN/ieKR8jdfzx+HPseR/xDeCFnWYNAA6AuMYZNWg2cdpM9Rw9bG00HVbFmmjjw31gAC UfhSF5lZVLPaCdengq8pIojNhxGeeBdwbMGoWNmNGRflKZq9aVcWFoFXRRVftsbp+E0z dPd6y6EejVNcInNcxqsql+ied2FynGd2GXKYEmCcfrXkyk+BkkCFNDed0LHLMfOaFpSK 7x3A== 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=7m6g3WPL7iPUaGQKdUIec9J5sEjTaSvV7tOjO2zxBPU=; fh=IGCjTpZfwSg+cKezC718uKBfQhRIEPbQRgSSkQG1ikQ=; b=RzwV8CDSg3Uda22+4IqenHiSiz8kfNWK7osrI9iAkeu5ipWjrl8EfNzgAW+kXpshVJ Tn3D589/j8PTNBgXqeL+v/5sboh/km6TwkmaOlocukjm3kAHSJmc6o87X5u9AoGxUFwY dBWMvhxm7dxBOwwAN59m9NuuSkZgK74EQckN/kTl7n8u4mzBpyY4YREKmlmcX50BOqO+ eMQUvxoADa2RfrkYMaQPRH7OYIJNXPr3GYmCEWvpFOpCNYtgjZJDlbdcL2nxyTAm+nIC r+XW0xiOapO6pE7mXP/7sZ/gHrP6NFantrTJf4FNfRB3CxBCSKfCiyatVPtIXt+MxRF4 Xk/g== 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 r20-20020a6560d4000000b00564a1716ebbsi3909111pgv.697.2023.08.26.07.03.14; Sat, 26 Aug 2023 07:03:38 -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 S232461AbjHZMyS (ORCPT + 99 others); Sat, 26 Aug 2023 08:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjHZMxz (ORCPT ); Sat, 26 Aug 2023 08:53:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 83C0919AE; Sat, 26 Aug 2023 05:53:53 -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 99A5F1FB; Sat, 26 Aug 2023 05:54:33 -0700 (PDT) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 431503F64C; Sat, 26 Aug 2023 05:53:51 -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@foss.st.com, 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 v2 5/6] clk: scmi: Add support for .is_enabled clk_ops Date: Sat, 26 Aug 2023 13:53:07 +0100 Message-ID: <20230826125308.462328-6-cristian.marussi@arm.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230826125308.462328-1-cristian.marussi@arm.com> References: <20230826125308.462328-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 --- v1 --> v2 - use more descriptive defines --- 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 b7a180b3443e..2e1337b511eb 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -20,6 +20,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; @@ -105,10 +106,24 @@ static void scmi_clk_atomic_disable(struct clk_hw *hw) scmi_proto_clk_ops->disable(clk->ph, clk->id, ATOMIC); } +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, ATOMIC); + 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 @@ -132,6 +147,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, @@ -221,6 +237,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.42.0