Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp927608imw; Tue, 5 Jul 2022 00:12:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sCWThKnXOoQAVLCcXN18VEVAYDy2i/zey4ELkl5J1fXZ/HYwF+rlHNUhhzujYbE7tNQboC X-Received: by 2002:a17:903:2347:b0:16a:33cd:5308 with SMTP id c7-20020a170903234700b0016a33cd5308mr39073062plh.122.1657005153637; Tue, 05 Jul 2022 00:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657005153; cv=none; d=google.com; s=arc-20160816; b=mHt6Fc7Jmf6jwNelckadZQtVIWp711k8CEqK1WBvwQy12RJ2gQCwXZend47lcnA2KA Hrghz4vREyogkJOR2IAIedY7Ts/s0dPsjiriwKSQo+z/ynKzCJASZGLdkilwFzZvXssi BsrhwzZdtGhXhBnhcXXcIUQztA2TNnevg/+lUM7ksNJO7P3SqJvpWN4+wacITz4OSVEC dXgvAXxP0QlU6GPMKKvo7OftBb5PhDcSY+0X6zZtS1Q3wfHl7z9CjJcmt+tiOUSUHMun cmC4xed60olrRJM9dyGuxsh/UhxKt7tjGV1/WnmwR5Pv5LjFF7j27o6qfXD5WGjWaZ+7 u6Gw== 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 :dkim-signature; bh=vLm3xPD9OxbHjcm/3fn6+SA6JSr3RLuVTRqSmxurVMY=; b=j2BKpb4mdqIRbH4MfVzYNkUtOlFMomfcxFCnsYo8uCeFLbqJ0pVXfpxFNO9J7MoETu u0RkYF4e9lrwuTGbHf2vLqnUuq00D3XbmdO4v2Lr5Uz0y1Ar/oATMLKoD7aSuJK4It/F tDir5fkEPyL8dWhP0wPAbILIqBp8y5xeyne2Zy2tXn1qjJcgpERYb76X/TWmSS+T42Km RVGwXaxcWhWK4D5QC0PfiIFwg7R9AMYDZbJmke9rdeiwgIr42KN4CwphSXmenKfRJY0z AlMzpdLihGkojC2VECBQHqioPf24zaDjGiDPl8PwhIolf8ZkLFu439PUGx6NOLCJSaym J3Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gKr6TFO1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 78-20020a630151000000b004019bf283d2si16188525pgb.554.2022.07.05.00.12.17; Tue, 05 Jul 2022 00:12:33 -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; dkim=pass header.i=@linaro.org header.s=google header.b=gKr6TFO1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbiGEHBX (ORCPT + 99 others); Tue, 5 Jul 2022 03:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbiGEHBC (ORCPT ); Tue, 5 Jul 2022 03:01:02 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125F1101C6 for ; Tue, 5 Jul 2022 00:01:01 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o31-20020a17090a0a2200b001ef7bd037bbso6333920pjo.0 for ; Tue, 05 Jul 2022 00:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vLm3xPD9OxbHjcm/3fn6+SA6JSr3RLuVTRqSmxurVMY=; b=gKr6TFO1o5rV/BJddvsaeHxIruLKA4Z2tP5sqRSoBNOYHrukCuOEPGVo7e0FTYEgcl JPs+oG85x6SFfg1vEvtXP/lQAQshrSfhiZOrw0EvjkPoldint3hsdATSOECt1ld+kral 1/fwMfJjCAslWGLERTlFONibnZ2X/aI+FyQheqN49D0SODJRUq9YvPe4bETtuDUx7lhn O+DgQG7qTltlnJSl6LpWP/hbMr85OFfSWtaXD2E472mS/yPchzfIXGR5RE6AgJums6Yp aZePjB4t17iRU707AGz931Cy7UL5f6O6XOmW21x0CWOznju7ZLKjwk5pBiGkT88ykqro SrPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vLm3xPD9OxbHjcm/3fn6+SA6JSr3RLuVTRqSmxurVMY=; b=tgiMdhXOz3pC3SM7QfuYM76ugBputQg80p90HpCKsm0HKv/37+k2jDIIAPAB95sPiT v2sEJNQt5QEc5SX28SXXda16PnIVPJxajRs+aF9hqwclbEsTK0eoCO4AM2eOm77NwZtL PuUEgG4X1mgmkocFVsyrCyERWebKXqzC3dDuCi5sw3da2wJX/RB8sCjQO4y0d3qAEgNb QR87m9N19VEuiXoPqOqDhpMwYj82eBf0rpPm4ZczX1k1yqjRGepKdUyE+M39t9YPnwez ZWyfrdOg/jKxMiJQj/NUxmPTD6IVeBiOFqjKHGA03VpW+MBULu/QicoiTmZHhzpCOOZv ubTA== X-Gm-Message-State: AJIora9CTUm8ieOuz3mAQc/gy3624E/pC4rHbhH2W6qdRM3lMK1X0b4x DTMFO5+BXbNdT6eoK4zMYqWa4Q== X-Received: by 2002:a17:903:1246:b0:16b:a568:4f74 with SMTP id u6-20020a170903124600b0016ba5684f74mr31761798plh.0.1657004460632; Tue, 05 Jul 2022 00:01:00 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id b8-20020a170902650800b0016bee668a62sm1513972plk.108.2022.07.05.00.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:01:00 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 10/13] OPP: Provide a simple implementation to configure multiple clocks Date: Tue, 5 Jul 2022 12:30:13 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 This provides a simple implementation to configure multiple clocks for a device. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5b3542557f72..597f7df3e375 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -843,6 +843,40 @@ _opp_config_clk_single(struct device *dev, struct opp_table *opp_table, return ret; } +/* + * Simple implementation for configuring multiple clocks. Configure clocks in + * the order in which they are present in the array while scaling up. + */ +int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down) +{ + int ret, i; + + if (scaling_down) { + for (i = opp_table->clk_count - 1; i >= 0; i--) { + ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); + if (ret) { + dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, + ret); + return ret; + } + } + } else { + for (i = 0; i < opp_table->clk_count; i++) { + ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); + if (ret) { + dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, + ret); + return ret; + } + } + } + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_config_clks_simple); + static int _opp_config_regulator_single(struct device *dev, struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, struct regulator **regulators, unsigned int count) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 104151dfe46c..683e6baf9618 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -159,6 +159,9 @@ int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); void dev_pm_opp_clear_config(int token); +int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down); struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); @@ -342,6 +345,13 @@ static inline int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_c static inline void dev_pm_opp_clear_config(int token) {} +static inline int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down) +{ + return -EOPNOTSUPP; +} + static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp) { -- 2.31.1.272.g89b43f80a514