From nobody Tue Apr 28 11:19:02 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F9CFC433EF for ; Fri, 1 Jul 2022 08:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235990AbiGAIfM (ORCPT ); Fri, 1 Jul 2022 04:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234894AbiGAIfH (ORCPT ); Fri, 1 Jul 2022 04:35:07 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1073E70E50 for ; Fri, 1 Jul 2022 01:35:05 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id k14so1744492plh.4 for ; Fri, 01 Jul 2022 01:35:05 -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=+2Ef2YvOVbBd7DXhKAJTt40bhH4p1+0X7KiKVGhn8xc=; b=Cutz2882kef7/XZceTtXwkbS9R9cGf3o2gsVG+D0XcqYOxJ+dENYkHfHgDd/PcCDhp yEgFCDrUS9fQpfBFPokIJTMo1d3hmnaoQPNg0wDMhXwAWhCL/KLrInCXPn0CA6DTqPTm MKhCgz1YqItbg0r+skhyWZbi+qrQGteGxK7RidsAAhWpK/fhrX1FjGuLg/JPFOZRekzv Z0JI6PirJtxV9yPHD8gVE1h3CRlBUJmw7OxeEWlL0geT7ra7D7+sqXOcTEhcohHQKogz EIIUAVTJRnk2eCWHMkjMCs0F3Ldf3QFWKbZKWmvUFnnydwdmVJA8Q3AbZ/PZ6KrtQLk4 +mTw== 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=+2Ef2YvOVbBd7DXhKAJTt40bhH4p1+0X7KiKVGhn8xc=; b=PZSf4fyq5kyaqv2yQnFM1H4PD1HrJDK0wfHgh48GjZ3bRw/597PpCYwfczGnaM0Z85 bHkKRIfNHEKcoL/uwu88mxzPwZK0Yj4erK0MWy+cLgJBOcqTdhmG2oaIO+ktAt2t0z0w zrRlRqCsaaFC0b2N8gi49k1lHyLfeNMmtfHP7m169+XN07mCmZXTgyxHGeBGkZf+Yxm9 ywCrtCk1qxtXvEIVKcvHrS/+co9/89a+opWHw51l7JbRH1XIc17ly1HwxMhH7nAmmNwz NWfUGzzffb3j8T+jDD5jYTMxE5rhu8MXD+21mzDNGwHdO4kg0Jn4pHLnNJPnSKAeGpw7 d/zA== X-Gm-Message-State: AJIora/cd37NiVfq7B0j7xgedrc7nfsZ2v//ps8WOOKeVqW3Hn4CubMT BxoGwZtVwUoNDORozK1rK4Gx+A== X-Google-Smtp-Source: AGRyM1tzmld+DWdaIe+aRx3rzjz6qqUei+ry37MD8LCIVKSWpEKf4HajzoISjcGr1l3jfltAf1ab1A== X-Received: by 2002:a17:902:a503:b0:167:93c0:c602 with SMTP id s3-20020a170902a50300b0016793c0c602mr19546883plq.39.1656664504530; Fri, 01 Jul 2022 01:35:04 -0700 (PDT) Received: from localhost ([122.172.201.58]) by smtp.gmail.com with ESMTPSA id h5-20020a170902f54500b0016bc2e752eesm283312plf.159.2022.07.01.01.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 01:35:04 -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 , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 1/5] OPP: Add support for config_regulators() helper Date: Fri, 1 Jul 2022 14:04:51 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Extend the dev_pm_opp_set_config() interface to allow adding config_regulators() helpers. This helper will be called to set the voltages of the regulators from the regular path in _set_opp(), while we are trying to change the OPP. This will eventually replace the custom set_opp() helper. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 68 +++++++++++++++++++++++++++++++++++++++++- drivers/opp/opp.h | 2 ++ include/linux/pm_opp.h | 6 ++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 75bb570d30e4..d5e1ae6f5ea1 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1185,6 +1185,17 @@ static int _set_opp(struct device *dev, struct opp_t= able *opp_table, dev_err(dev, "Failed to set bw: %d\n", ret); return ret; } + + if (opp_table->config_regulators) { + ret =3D opp_table->config_regulators(dev, old_opp, opp, + opp_table->regulators, + opp_table->regulator_count); + if (ret) { + dev_err(dev, "Failed to set regulator voltages: %d\n", + ret); + return ret; + } + } } =20 if (opp_table->set_opp) { @@ -1202,6 +1213,17 @@ static int _set_opp(struct device *dev, struct opp_t= able *opp_table, =20 /* Scaling down? Configure required OPPs after frequency */ if (scaling_down) { + if (opp_table->config_regulators) { + ret =3D opp_table->config_regulators(dev, old_opp, opp, + opp_table->regulators, + opp_table->regulator_count); + if (ret) { + dev_err(dev, "Failed to set regulator voltages: %d\n", + ret); + return ret; + } + } + ret =3D _set_opp_bw(opp_table, opp, dev); if (ret) { dev_err(dev, "Failed to set bw: %d\n", ret); @@ -2246,6 +2268,38 @@ static void _opp_unregister_set_opp_helper(struct op= p_table *opp_table) } } =20 +/** + * _opp_set_config_regulators_helper() - Register custom set regulator hel= per. + * @dev: Device for which the helper is getting registered. + * @config_regulators: Custom set regulator helper. + * + * This is useful to support platforms with multiple regulators per device. + * + * This must be called before any OPPs are initialized for the device. + */ +static int _opp_set_config_regulators_helper(struct opp_table *opp_table, + struct device *dev, config_regulators_t config_regulators) +{ + /* Another CPU that shares the OPP table has set the helper ? */ + if (!opp_table->config_regulators) + opp_table->config_regulators =3D config_regulators; + + return 0; +} + +/** + * _opp_put_config_regulators_helper() - Releases resources blocked for + * config_regulators helper. + * @opp_table: OPP table returned from _opp_set_config_regulators_helper(). + * + * Release resources blocked for platform specific config_regulators helpe= r. + */ +static void _opp_put_config_regulators_helper(struct opp_table *opp_table) +{ + if (opp_table->config_regulators) + opp_table->config_regulators =3D NULL; +} + static void _detach_genpd(struct opp_table *opp_table) { int index; @@ -2372,8 +2426,10 @@ static void _opp_clear_config(struct opp_config_data= *data) _opp_put_regulators(data->opp_table); if (data->flags & OPP_CONFIG_SUPPORTED_HW) _opp_put_supported_hw(data->opp_table); - if (data->flags & OPP_CONFIG_REGULATOR_HELPER) + if (data->flags & OPP_CONFIG_REGULATOR_HELPER) { + _opp_put_config_regulators_helper(data->opp_table); _opp_unregister_set_opp_helper(data->opp_table); + } if (data->flags & OPP_CONFIG_PROP_NAME) _opp_put_prop_name(data->opp_table); if (data->flags & OPP_CONFIG_CLK) @@ -2455,6 +2511,16 @@ int dev_pm_opp_set_config(struct device *dev, struct= dev_pm_opp_config *config) data->flags |=3D OPP_CONFIG_REGULATOR_HELPER; } =20 + /* Configure config_regulators helper */ + if (config->config_regulators) { + ret =3D _opp_set_config_regulators_helper(opp_table, dev, + config->config_regulators); + if (ret) + goto err; + + data->flags |=3D OPP_CONFIG_REGULATOR_HELPER; + } + /* Configure supported hardware */ if (config->supported_hw) { ret =3D _opp_set_supported_hw(opp_table, config->supported_hw, diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index d652f0cc84f1..45fd40737159 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -172,6 +172,7 @@ enum opp_table_access { * @prop_name: A name to postfix to many DT properties, while parsing them. * @clk_configured: Clock name is configured by the platform. * @clk: Device's clock handle + * @config_regulators: Platform specific config_regulators() callback. * @regulators: Supply regulators * @regulator_count: Number of power supply regulators. Its value can be -1 * (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt @@ -224,6 +225,7 @@ struct opp_table { const char *prop_name; bool clk_configured; struct clk *clk; + config_regulators_t config_regulators; struct regulator **regulators; int regulator_count; struct icc_path **paths; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 26653be21dc0..721aa02bcaaf 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -90,12 +90,17 @@ struct dev_pm_set_opp_data { struct device *dev; }; =20 +typedef int (*config_regulators_t)(struct device *dev, + struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, + struct regulator **regulators, unsigned int count); + /** * struct dev_pm_opp_config - Device OPP configuration values * @clk_names: Clk name. * @clk_count: Number of clocks, max 1 for now. * @prop_name: Name to postfix to properties. * @set_opp: Custom set OPP helper. + * @config_regulators: Custom set regulator helper. * @supported_hw: Array of hierarchy of versions to match. * @supported_hw_count: Number of elements in the array. * @regulator_names: Array of pointers to the names of the regulator. @@ -111,6 +116,7 @@ struct dev_pm_opp_config { unsigned int clk_count; const char *prop_name; int (*set_opp)(struct dev_pm_set_opp_data *data); + config_regulators_t config_regulators; unsigned int *supported_hw; unsigned int supported_hw_count; const char * const *regulator_names; --=20 2.31.1.272.g89b43f80a514 From nobody Tue Apr 28 11:19:02 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5C65C43334 for ; Fri, 1 Jul 2022 08:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236584AbiGAIfV (ORCPT ); Fri, 1 Jul 2022 04:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235086AbiGAIfK (ORCPT ); Fri, 1 Jul 2022 04:35:10 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A483671240 for ; Fri, 1 Jul 2022 01:35:07 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id o18so1752655plg.2 for ; Fri, 01 Jul 2022 01:35:07 -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=lRM1PjazghlAlPXD7tv2+SDz7O4GVNObgvkudXkk8IM=; b=dQcvYUX3d0Hc0/3/lPi3x4cea9DpxT15pkG7XJcV/dRQwLiCxhr2Xy2LgqoLzItyej zzKQPqreKgGzKukt5sLNtRRhy3aFjlf5ekppgoSU04aLj0/JlX5XcRByJ9d9nRmIFCo4 rc7FLitPNQPGO/3DrtFeyB5VoGynlR/kV8HnUbUPoMq1zupRxXfbRlk5wx9AJohtE7vV sakRnduEheX83YXsAudn/QPLOuPTh08lUjMVGflTR6LRRb0endklvEI7oyZYIDtuLcgH I3ziaBt2snD7ovzFYLq8MJBSiKQszyoRkM2D+fxEWbHk6CScZ/29a+wBeEcTvaFqv3fB FgLQ== 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=lRM1PjazghlAlPXD7tv2+SDz7O4GVNObgvkudXkk8IM=; b=AIpBIMhyU6+cb/b8cQGb96N4mrr9I45eNpJG6s6cMg2jsL+jRKMPF/r8Xo/EIfX7aQ DKTUm7tzJr3yL3RYLf7Udl6ykM5J4CsO9Pfp3WXjEAF7Loh50ObBzQwr3dDOTBOBo+OT FOFNC7jFCRgHfBmPyqlN+erks+UYPlPLjV2g2rK1xRZ3RmQzt9zfkb9vtwhtWmepSklp q29cZh2gPitjVt/Z/isi3h+gOA6JreQxafQSxqm/jFCoaY2wDtSUZOhyLMdahXsdzuQy prgdiIPpmsq9bis2xw/qLqmeOSdugsYzee+FvFllmu5WTYfLBw7pAfwHWgQvuArepcP3 tjbg== X-Gm-Message-State: AJIora9K3SKww7jvC1MpLHYPaqoirey2Q1rx77Zf7MqmeK4aMz59QpUj wmYRhcPvkryORNtmr1Ap4FqgrA== X-Google-Smtp-Source: AGRyM1vWS4XhZQ2vX+0HfYDGexiYN0ySk/slaYykTQoF5+866XV74mzfPyfUvGl17A9dviN85hDFtg== X-Received: by 2002:a17:90b:895:b0:1ec:827c:ef0f with SMTP id bj21-20020a17090b089500b001ec827cef0fmr16875092pjb.10.1656664507206; Fri, 01 Jul 2022 01:35:07 -0700 (PDT) Received: from localhost ([122.172.201.58]) by smtp.gmail.com with ESMTPSA id d63-20020a621d42000000b0052532d9cb18sm14864102pfd.183.2022.07.01.01.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 01:35:06 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 2/5] OPP: Make _generic_set_opp_regulator() a config_regulators() interface Date: Fri, 1 Jul 2022 14:04:52 +0530 Message-Id: <2d9786a0e2460d3c4ac94a147a8b7ff77d36f696.1656664183.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In order to reuse the same code path, i.e. clk_set_rate() from _set_opp(), migrate _generic_set_opp_regulator() to implement a config_regulators() interface. It is renamed to _opp_config_regulator_single() and is set as the preferred config_regulators() interface whenever we have a single regulator available. Note that this also drops code responsible for restoring the voltage/freq in case of errors. We aren't handling that properly currently, restoring only some of the resources while leaving others out (like bandwidth and required OPPs). It is better to drop all of it instead of partial restoration. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 51 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index d5e1ae6f5ea1..df0135f2cfec 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -896,62 +896,34 @@ static inline int _generic_set_opp_clk_only(struct de= vice *dev, struct clk *clk, return ret; } =20 -static int _generic_set_opp_regulator(struct opp_table *opp_table, - struct device *dev, - struct dev_pm_opp *opp, - unsigned long freq, - int scaling_down) +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) { - struct regulator *reg =3D opp_table->regulators[0]; - struct dev_pm_opp *old_opp =3D opp_table->current_opp; + struct regulator *reg =3D regulators[0]; int ret; =20 /* This function only supports single regulator per device */ - if (WARN_ON(opp_table->regulator_count > 1)) { + if (WARN_ON(count > 1)) { dev_err(dev, "multiple regulators are not supported\n"); return -EINVAL; } =20 - /* Scaling up? Scale voltage before frequency */ - if (!scaling_down) { - ret =3D _set_opp_voltage(dev, reg, opp->supplies); - if (ret) - goto restore_voltage; - } - - /* Change frequency */ - ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, freq); + ret =3D _set_opp_voltage(dev, reg, new_opp->supplies); if (ret) - goto restore_voltage; - - /* Scaling down? Scale voltage after frequency */ - if (scaling_down) { - ret =3D _set_opp_voltage(dev, reg, opp->supplies); - if (ret) - goto restore_freq; - } + return ret; =20 /* * Enable the regulator after setting its voltages, otherwise it breaks * some boot-enabled regulators. */ - if (unlikely(!opp_table->enabled)) { + if (unlikely(!new_opp->opp_table->enabled)) { ret =3D regulator_enable(reg); if (ret < 0) dev_warn(dev, "Failed to enable regulator: %d", ret); } =20 return 0; - -restore_freq: - if (_generic_set_opp_clk_only(dev, opp_table->clk, old_opp->rate)) - dev_err(dev, "%s: failed to restore old-freq (%lu Hz)\n", - __func__, old_opp->rate); -restore_voltage: - /* This shouldn't harm even if the voltages weren't updated earlier */ - _set_opp_voltage(dev, reg, old_opp->supplies); - - return ret; } =20 static int _set_opp_bw(const struct opp_table *opp_table, @@ -1200,9 +1172,6 @@ static int _set_opp(struct device *dev, struct opp_ta= ble *opp_table, =20 if (opp_table->set_opp) { ret =3D _set_opp_custom(opp_table, dev, opp, freq); - } else if (opp_table->regulators) { - ret =3D _generic_set_opp_regulator(opp_table, dev, opp, freq, - scaling_down); } else { /* Only frequency scaling */ ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, freq); @@ -2113,6 +2082,10 @@ static int _opp_set_regulators(struct opp_table *opp= _table, struct device *dev, } mutex_unlock(&opp_table->lock); =20 + /* Set generic config_regulators() for single regulators here */ + if (count =3D=3D 1) + opp_table->config_regulators =3D _opp_config_regulator_single; + return 0; =20 free_regulators: --=20 2.31.1.272.g89b43f80a514 From nobody Tue Apr 28 11:19:02 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86AB3C433EF for ; Fri, 1 Jul 2022 08:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236549AbiGAIfZ (ORCPT ); Fri, 1 Jul 2022 04:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236254AbiGAIfO (ORCPT ); Fri, 1 Jul 2022 04:35:14 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F2671255 for ; Fri, 1 Jul 2022 01:35:10 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id jh14so1759493plb.1 for ; Fri, 01 Jul 2022 01:35:10 -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=gf1z1i4Q1Q3vJR21rVGny9xQ3EfEJ5IGT6qjZgIHsA4=; b=IXDx8gCse9Dbez57gdpSuPhRjJlqmAZI+GdQmH1KAmICiEVRSI/O5+Nq/kTU02U7hs LBIYe71Gh0gNX8obI/NLPCQhq3SychtbXt/MFQWM0O+Y6Mycfh6fb8Qz7p5HKJceFDo2 e8pZkr6GbKrNAE1WlImQhlmZ3qNuZ6F9rLjvItxpnhddyMPBWgZdL9s1822xMoF9nB4j ZZh9KaOBqrXBAZRjsMU7VHtyrAU2P5k9I/Ayz+zcje4Wjqtlw9pR7w650AUq2GdfbyBg VJNSADYhtqHpGbaX+nshdY/u1T51eM5OJEExmERQNYqDEUEl5qxBNOr6FavomcVWRY3/ Yk9g== 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=gf1z1i4Q1Q3vJR21rVGny9xQ3EfEJ5IGT6qjZgIHsA4=; b=Nc6mN26rLIuAGX9VxW6YM1Y0dfLKkeJwcHxhzjtB/5Q7u9PqJLHGPuwfNlBGBYIetV sOd/tizvZ3d8MV9xgfR4CqUs98sZx0ZcQ3AosBvuMhrE/OPI2eZq9jp4CPXXNs0grey/ rB/z9Bd5a2qD6QtPueW0A7BmmvMwVj7rvUYjEGcH/g7xUQT6y7EvZ8l0mGnawIztQuEh FRePGFL5RYToSGIe5+nBiviqZCR2g/nEweMsmekyWTa2a3k7IXHZi0bNcB0lOZ9YgZ2N GHKXg1VxYGXSJzpsiPAyTgyyFNzGG/zNHFaj6UfXDPhibX8StBOaIHE0CpDsqIjKx54w jgdQ== X-Gm-Message-State: AJIora/8WwXZVD72XybvVYqcvUElj/eEBEDwwPQHMEAuHw+vczd81aT8 VsMjV7yYHuIVtnOeaQFsSgKUlQ== X-Google-Smtp-Source: AGRyM1sVTkXdZm2N3xY+g4CzUVsxzz+8bjiH/v9tie3OzOBVHFHidbrtl6ZvsivohEm7kEn3+KaYJw== X-Received: by 2002:a17:90a:6809:b0:1ec:c213:56c8 with SMTP id p9-20020a17090a680900b001ecc21356c8mr16973975pjj.82.1656664509946; Fri, 01 Jul 2022 01:35:09 -0700 (PDT) Received: from localhost ([122.172.201.58]) by smtp.gmail.com with ESMTPSA id y41-20020a056a001ca900b00518d06efbc8sm15129130pfw.98.2022.07.01.01.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 01:35:09 -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 , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 3/5] OPP: Add dev_pm_opp_get_supplies() Date: Fri, 1 Jul 2022 14:04:53 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We already have an API for getting voltage information for a single regulator, dev_pm_opp_get_voltage(), but there is nothing available for multiple regulator case. This patch adds a new API, dev_pm_opp_get_supplies(), to get all information related to the supplies for an OPP. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 25 +++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index df0135f2cfec..ee842a3d27a6 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -117,6 +117,31 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp= *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage); =20 +/** + * dev_pm_opp_get_supplies() - Gets the supply information corresponding t= o an opp + * @opp: opp for which voltage has to be returned for + * @supplies: Placeholder for copying the supply information. + * + * Return: negative error number on failure, 0 otherwise on success after + * setting @supplies. + * + * This can be used for devices with any number of power supplies. The cal= ler + * must ensure the @supplies array must contain space for each regulator. + */ +int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, + struct dev_pm_opp_supply *supplies) +{ + if (IS_ERR_OR_NULL(opp) || !supplies) { + pr_err("%s: Invalid parameters\n", __func__); + return -EINVAL; + } + + memcpy(supplies, opp->supplies, + sizeof(*supplies) * opp->opp_table->regulator_count); + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_supplies); + /** * dev_pm_opp_get_power() - Gets the power corresponding to an opp * @opp: opp for which power has to be returned for diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 721aa02bcaaf..4c1cce06a61c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -132,6 +132,8 @@ void dev_pm_opp_put_opp_table(struct opp_table *opp_tab= le); =20 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); =20 +int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supp= ly *supplies); + unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); =20 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); @@ -220,6 +222,11 @@ static inline unsigned long dev_pm_opp_get_voltage(str= uct dev_pm_opp *opp) return 0; } =20 +static inline int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct d= ev_pm_opp_supply *supplies) +{ + return -EOPNOTSUPP; +} + static inline unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) { return 0; --=20 2.31.1.272.g89b43f80a514 From nobody Tue Apr 28 11:19:02 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB3FCC433EF for ; Fri, 1 Jul 2022 08:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231745AbiGAIf3 (ORCPT ); Fri, 1 Jul 2022 04:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236494AbiGAIfP (ORCPT ); Fri, 1 Jul 2022 04:35:15 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A4071252 for ; Fri, 1 Jul 2022 01:35:13 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id g7so1969925pjj.2 for ; Fri, 01 Jul 2022 01:35:13 -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=/J/oGF74cDu8WRXcmEUoVqkWg7/dM3ieJV6SNHK5u2g=; b=wJ4YMZ6WLBdrditEkE5xr2++AgUlYr19Lh44vM2dqHRINpwTsz9a5gI65oTVGYkGb1 8LvT2VXuTws67upE08yWCsQhkV6JOw2/2ssORzbt2Ct5kDeyZpG5U6uiJigpF/bOWCr/ ZT9/u25NSfTCYll2z6hDsspxphpNLvoxBoUpZOhtfY9ZyspvXxfs3JZ2XEmxuHIRhdKp NjF4K1FG+mHrkTcRSZliV1Nwa6P8jSwp9ct9GP0rkV7b81VGaCGEcUOn0T231qrwPU45 JT84zDwuiSytd8Y8T5Omnj07CFYYTQ4EMqryDTgWIeAGtjI2RwdMiOIqNc3rJUz5A+cd e7Hw== 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=/J/oGF74cDu8WRXcmEUoVqkWg7/dM3ieJV6SNHK5u2g=; b=GPQ3cMN8C/N+HhjoS5jQWer0420wKJJUEwCI0lzz/EafSxk2gYTlIy8CwzUNVXEfS1 jmirhTDIdrWYwXSL1vwwerGhY89v5xDjAm7b9lrdI69b3ah5qchHyPCig/W3yjKrQtoR vnoXq0iUh9Eegwn4tcUC/alg5/p3rvAM+sFtz3RbNWdrSp0GMvSKi741Gbl/h2uu9tlf 8c2lUsAGZHV4waO9GfCNpj5Kyp2JS4l0WAQyLPt/xFU4mL142ntUKv25gMrgGJ6JXEaV qOoDa+ax2Xr3ej9yI8V1BuQ/0xH/vwTHmAH/v8jvmclYX0O2sgvfwo5Ac8ljQUnpoBRg XP/Q== X-Gm-Message-State: AJIora/lcAl/fmVxj0jODwImYYfblCsiUtSdVwsODpSHAMcVOgdY0V4X wDnEpCx6Ig06/D/iSgGoj4gp9w== X-Google-Smtp-Source: AGRyM1txuauuk+cj9pXaDTeqhWJALiBbIWHadKxSv+B6yXyhdhDAYGmVhHoteZsZIJRf8Xo3VM5MHQ== X-Received: by 2002:a17:902:6b8b:b0:14d:66c4:f704 with SMTP id p11-20020a1709026b8b00b0014d66c4f704mr20022449plk.53.1656664512730; Fri, 01 Jul 2022 01:35:12 -0700 (PDT) Received: from localhost ([122.172.201.58]) by smtp.gmail.com with ESMTPSA id t2-20020a1709027fc200b0016a581f9ac2sm14768963plb.234.2022.07.01.01.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 01:35:12 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V2 4/5] OPP: ti: Migrate to config_regulators() Date: Fri, 1 Jul 2022 14:04:54 +0530 Message-Id: <5ca08d546dd7e03e290256b4530ab4e6266da72e.1656664183.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The OPP core now provides config_regulators() interface, which needs the platforms to just set the OPP voltages instead of both clk and voltage. The clock is set by the OPP core instead and hence reduces code redundancy. Migrate the only user of the custom set_opp() interface to config_regulators(). Signed-off-by: Viresh Kumar --- drivers/opp/ti-opp-supply.c | 74 +++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/drivers/opp/ti-opp-supply.c b/drivers/opp/ti-opp-supply.c index 26e929377ebd..f1f881140fa2 100644 --- a/drivers/opp/ti-opp-supply.c +++ b/drivers/opp/ti-opp-supply.c @@ -36,11 +36,15 @@ struct ti_opp_supply_optimum_voltage_table { * @vdd_table: Optimized voltage mapping table * @num_vdd_table: number of entries in vdd_table * @vdd_absolute_max_voltage_uv: absolute maximum voltage in UV for the su= pply + * @old_supplies: Placeholder for supplies information for old OPP. + * @new_supplies: Placeholder for supplies information for new OPP. */ struct ti_opp_supply_data { struct ti_opp_supply_optimum_voltage_table *vdd_table; u32 num_vdd_table; u32 vdd_absolute_max_voltage_uv; + struct dev_pm_opp_supply old_supplies[2]; + struct dev_pm_opp_supply new_supplies[2]; }; =20 static struct ti_opp_supply_data opp_data; @@ -266,27 +270,32 @@ static int _opp_set_voltage(struct device *dev, return 0; } =20 -/** - * ti_opp_supply_set_opp() - do the opp supply transition - * @data: information on regulators and new and old opps provided by - * opp core to use in transition - * - * Return: If successful, 0, else appropriate error value. - */ -static int ti_opp_supply_set_opp(struct dev_pm_set_opp_data *data) +/* Do the opp supply transition */ +static int ti_opp_config_regulators(struct device *dev, + struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, + struct regulator **regulators, unsigned int count) { - struct dev_pm_opp_supply *old_supply_vdd =3D &data->old_opp.supplies[0]; - struct dev_pm_opp_supply *old_supply_vbb =3D &data->old_opp.supplies[1]; - struct dev_pm_opp_supply *new_supply_vdd =3D &data->new_opp.supplies[0]; - struct dev_pm_opp_supply *new_supply_vbb =3D &data->new_opp.supplies[1]; - struct device *dev =3D data->dev; - unsigned long old_freq =3D data->old_opp.rate, freq =3D data->new_opp.rat= e; - struct clk *clk =3D data->clk; - struct regulator *vdd_reg =3D data->regulators[0]; - struct regulator *vbb_reg =3D data->regulators[1]; + struct dev_pm_opp_supply *old_supply_vdd =3D &opp_data.old_supplies[0]; + struct dev_pm_opp_supply *old_supply_vbb =3D &opp_data.old_supplies[1]; + struct dev_pm_opp_supply *new_supply_vdd =3D &opp_data.new_supplies[0]; + struct dev_pm_opp_supply *new_supply_vbb =3D &opp_data.new_supplies[1]; + struct regulator *vdd_reg =3D regulators[0]; + struct regulator *vbb_reg =3D regulators[1]; + unsigned long old_freq, freq; int vdd_uv; int ret; =20 + /* We must have two regulators here */ + WARN_ON(count !=3D 2); + + /* Fetch supplies and freq information from OPP core */ + ret =3D dev_pm_opp_get_supplies(new_opp, opp_data.new_supplies); + WARN_ON(ret); + + old_freq =3D dev_pm_opp_get_freq(old_opp); + freq =3D dev_pm_opp_get_freq(new_opp); + WARN_ON(!old_freq || !freq); + vdd_uv =3D _get_optimal_vdd_voltage(dev, &opp_data, new_supply_vdd->u_volt); =20 @@ -303,39 +312,24 @@ static int ti_opp_supply_set_opp(struct dev_pm_set_op= p_data *data) ret =3D _opp_set_voltage(dev, new_supply_vbb, 0, vbb_reg, "vbb"); if (ret) goto restore_voltage; - } - - /* Change frequency */ - dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", - __func__, old_freq, freq); - - ret =3D clk_set_rate(clk, freq); - if (ret) { - dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, - ret); - goto restore_voltage; - } - - /* Scaling down? Scale voltage after frequency */ - if (freq < old_freq) { + } else { ret =3D _opp_set_voltage(dev, new_supply_vbb, 0, vbb_reg, "vbb"); if (ret) - goto restore_freq; + goto restore_voltage; =20 ret =3D _opp_set_voltage(dev, new_supply_vdd, vdd_uv, vdd_reg, "vdd"); if (ret) - goto restore_freq; + goto restore_voltage; } =20 return 0; =20 -restore_freq: - ret =3D clk_set_rate(clk, old_freq); - if (ret) - dev_err(dev, "%s: failed to restore old-freq (%lu Hz)\n", - __func__, old_freq); restore_voltage: + /* Fetch old supplies information only if required */ + ret =3D dev_pm_opp_get_supplies(old_opp, opp_data.old_supplies); + WARN_ON(ret); + /* This shouldn't harm even if the voltages weren't updated earlier */ if (old_supply_vdd->u_volt) { ret =3D _opp_set_voltage(dev, old_supply_vbb, 0, vbb_reg, "vbb"); @@ -383,7 +377,7 @@ static int ti_opp_supply_probe(struct platform_device *= pdev) const struct ti_opp_supply_of_data *of_data; int ret =3D 0; struct dev_pm_opp_config config =3D { - .set_opp =3D ti_opp_supply_set_opp, + .config_regulators =3D ti_opp_config_regulators, }; =20 match =3D of_match_device(ti_opp_supply_of_match, dev); --=20 2.31.1.272.g89b43f80a514 From nobody Tue Apr 28 11:19:02 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D3ACC433EF for ; Fri, 1 Jul 2022 08:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236691AbiGAIfg (ORCPT ); Fri, 1 Jul 2022 04:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236556AbiGAIfS (ORCPT ); Fri, 1 Jul 2022 04:35:18 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3104F7126C for ; Fri, 1 Jul 2022 01:35:16 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id v126so1771527pgv.11 for ; Fri, 01 Jul 2022 01:35:16 -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=bbGaxrRF9z3JzTpjw2cMWBIlZoYiw5+dq8IseSMnzvE=; b=egz3392MrBcS9XCUFKQppWh4bpC9pjna6ebMSdmLTG+1FhbZT2bYZBh5oXx2fK7+G/ V2+x1mj+M9zfOGWQLQoLqPuWkxIiiMoZVoBtF+0rRl0hOFF3SwkoSO2GcFTGz5JRfRFp L3cmSHlKVgEj2BPv9qFDSQvDgap2gi8Acg4aislMyhPiL4VfYSmoTYTQtMMOSNsxErH1 fXW3qz+dinMPddg9KO9rJu9f0JtQIgq/qmUn8e/X4TkV3r0cwIg2JBNVbYtuDC13frYz Pp/Hpj9AS68ksdPaXabZmdv4nZfs4Gy1xC9EjdejplJ2q4aQ/z4ANSmp5ZROi5ohuCRd 05dg== 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=bbGaxrRF9z3JzTpjw2cMWBIlZoYiw5+dq8IseSMnzvE=; b=giGo6ZhNP6IUS+025QUMH23FcztSZgsukmbj1TRzR1t9/itkh3LEW73gCCnrpv0Dtg +f2ceZHrovEMAN+Z5n5QGc7KvQs7DdvttMRRscJxwWJco3CGVL7HJwyRvuZCvOsIcxp+ Ou2LJ5QSaCarOUzLDsbzEvPOJnGtqjp9R1zEMbNiw53D2dHExXABi4Eo5oqo+9IgOhxS SK2OhEUpZlcjDUFy0umasPeTZrxRyhdQHUoFjq9zZL9QpcAIdJVkWNuYKOnhINEDevHE hF6cYX/jOvolNjK3mUtjYNBpH79YZB3zgu0ZlZx7GL4A4CLfMpFaaodILYxsk5nLyQ9S UQEQ== X-Gm-Message-State: AJIora9YMEl7Vj/H0lP/EQ/06vT++EMo/t6JcD1UiOH8WdBGOwB4DM2l mjhr1tx9M7DMh5mr8SZ93hw6UQ== X-Google-Smtp-Source: AGRyM1uJdfJJ02T/o5Ayf6i77jpCMazt3aujpCIl7UXPDwv/QnXbcV8QdAOBgzMhEhyqPSBevsq1uw== X-Received: by 2002:a63:6c81:0:b0:3fd:4be3:8ee9 with SMTP id h123-20020a636c81000000b003fd4be38ee9mr11045731pgc.188.1656664515626; Fri, 01 Jul 2022 01:35:15 -0700 (PDT) Received: from localhost ([122.172.201.58]) by smtp.gmail.com with ESMTPSA id jf17-20020a17090b175100b001ec86a0490csm5769560pjb.32.2022.07.01.01.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 01:35:15 -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 , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 5/5] OPP: Remove custom OPP helper support Date: Fri, 1 Jul 2022 14:04:55 +0530 Message-Id: <370493d46e406c1d52541f0060edff8f9f116b85.1656664183.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The only user of the custom helper is migrated to use config_regulators() interface. Remove the now unused custom OPP helper support. This cleans up _set_opp() and leaves a single code path to be used by all users. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 132 +---------------------------------------- drivers/opp/opp.h | 7 --- include/linux/pm_opp.h | 35 ----------- 3 files changed, 2 insertions(+), 172 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index ee842a3d27a6..024a9106b6d2 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -979,36 +979,6 @@ static int _set_opp_bw(const struct opp_table *opp_tab= le, return 0; } =20 -static int _set_opp_custom(const struct opp_table *opp_table, - struct device *dev, struct dev_pm_opp *opp, - unsigned long freq) -{ - struct dev_pm_set_opp_data *data =3D opp_table->set_opp_data; - struct dev_pm_opp *old_opp =3D opp_table->current_opp; - int size; - - /* - * We support this only if dev_pm_opp_set_config() was called - * earlier to set regulators. - */ - if (opp_table->sod_supplies) { - size =3D sizeof(*old_opp->supplies) * opp_table->regulator_count; - memcpy(data->old_opp.supplies, old_opp->supplies, size); - memcpy(data->new_opp.supplies, opp->supplies, size); - data->regulator_count =3D opp_table->regulator_count; - } else { - data->regulator_count =3D 0; - } - - data->regulators =3D opp_table->regulators; - data->clk =3D opp_table->clk; - data->dev =3D dev; - data->old_opp.rate =3D old_opp->rate; - data->new_opp.rate =3D freq; - - return opp_table->set_opp(data); -} - static int _set_required_opp(struct device *dev, struct device *pd_dev, struct dev_pm_opp *opp, int i) { @@ -1195,13 +1165,7 @@ static int _set_opp(struct device *dev, struct opp_t= able *opp_table, } } =20 - if (opp_table->set_opp) { - ret =3D _set_opp_custom(opp_table, dev, opp, freq); - } else { - /* Only frequency scaling */ - ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, freq); - } - + ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, freq); if (ret) return ret; =20 @@ -2065,7 +2029,6 @@ static void _opp_put_prop_name(struct opp_table *opp_= table) static int _opp_set_regulators(struct opp_table *opp_table, struct device = *dev, const char * const names[], unsigned int count) { - struct dev_pm_opp_supply *supplies; struct regulator *reg; int ret, i; =20 @@ -2093,20 +2056,6 @@ static int _opp_set_regulators(struct opp_table *opp= _table, struct device *dev, =20 opp_table->regulator_count =3D count; =20 - supplies =3D kmalloc_array(count * 2, sizeof(*supplies), GFP_KERNEL); - if (!supplies) { - ret =3D -ENOMEM; - goto free_regulators; - } - - mutex_lock(&opp_table->lock); - opp_table->sod_supplies =3D supplies; - if (opp_table->set_opp_data) { - opp_table->set_opp_data->old_opp.supplies =3D supplies; - opp_table->set_opp_data->new_opp.supplies =3D supplies + count; - } - mutex_unlock(&opp_table->lock); - /* Set generic config_regulators() for single regulators here */ if (count =3D=3D 1) opp_table->config_regulators =3D _opp_config_regulator_single; @@ -2143,16 +2092,6 @@ static void _opp_put_regulators(struct opp_table *op= p_table) for (i =3D opp_table->regulator_count - 1; i >=3D 0; i--) regulator_put(opp_table->regulators[i]); =20 - mutex_lock(&opp_table->lock); - if (opp_table->set_opp_data) { - opp_table->set_opp_data->old_opp.supplies =3D NULL; - opp_table->set_opp_data->new_opp.supplies =3D NULL; - } - - kfree(opp_table->sod_supplies); - opp_table->sod_supplies =3D NULL; - mutex_unlock(&opp_table->lock); - kfree(opp_table->regulators); opp_table->regulators =3D NULL; opp_table->regulator_count =3D -1; @@ -2211,61 +2150,6 @@ static void _opp_put_clknames(struct opp_table *opp_= table) } } =20 -/** - * _opp_register_set_opp_helper() - Register custom set OPP helper - * @dev: Device for which the helper is getting registered. - * @set_opp: Custom set OPP helper. - * - * This is useful to support complex platforms (like platforms with multip= le - * regulators per device), instead of the generic OPP set rate helper. - * - * This must be called before any OPPs are initialized for the device. - */ -static int _opp_register_set_opp_helper(struct opp_table *opp_table, - struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)) -{ - struct dev_pm_set_opp_data *data; - - /* Another CPU that shares the OPP table has set the helper ? */ - if (opp_table->set_opp) - return 0; - - data =3D kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - mutex_lock(&opp_table->lock); - opp_table->set_opp_data =3D data; - if (opp_table->sod_supplies) { - data->old_opp.supplies =3D opp_table->sod_supplies; - data->new_opp.supplies =3D opp_table->sod_supplies + - opp_table->regulator_count; - } - mutex_unlock(&opp_table->lock); - - opp_table->set_opp =3D set_opp; - - return 0; -} - -/** - * _opp_unregister_set_opp_helper() - Releases resources blocked for set_o= pp helper - * @opp_table: OPP table returned from _opp_register_set_opp_helper(). - * - * Release resources blocked for platform specific set_opp helper. - */ -static void _opp_unregister_set_opp_helper(struct opp_table *opp_table) -{ - if (opp_table->set_opp) { - opp_table->set_opp =3D NULL; - - mutex_lock(&opp_table->lock); - kfree(opp_table->set_opp_data); - opp_table->set_opp_data =3D NULL; - mutex_unlock(&opp_table->lock); - } -} - /** * _opp_set_config_regulators_helper() - Register custom set regulator hel= per. * @dev: Device for which the helper is getting registered. @@ -2424,10 +2308,8 @@ static void _opp_clear_config(struct opp_config_data= *data) _opp_put_regulators(data->opp_table); if (data->flags & OPP_CONFIG_SUPPORTED_HW) _opp_put_supported_hw(data->opp_table); - if (data->flags & OPP_CONFIG_REGULATOR_HELPER) { + if (data->flags & OPP_CONFIG_REGULATOR_HELPER) _opp_put_config_regulators_helper(data->opp_table); - _opp_unregister_set_opp_helper(data->opp_table); - } if (data->flags & OPP_CONFIG_PROP_NAME) _opp_put_prop_name(data->opp_table); if (data->flags & OPP_CONFIG_CLK) @@ -2499,16 +2381,6 @@ int dev_pm_opp_set_config(struct device *dev, struct= dev_pm_opp_config *config) data->flags |=3D OPP_CONFIG_PROP_NAME; } =20 - /* Configure opp helper */ - if (config->set_opp) { - ret =3D _opp_register_set_opp_helper(opp_table, dev, - config->set_opp); - if (ret) - goto err; - - data->flags |=3D OPP_CONFIG_REGULATOR_HELPER; - } - /* Configure config_regulators helper */ if (config->config_regulators) { ret =3D _opp_set_config_regulators_helper(opp_table, dev, diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 45fd40737159..13abe991e811 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -182,9 +182,6 @@ enum opp_table_access { * @enabled: Set to true if the device's resources are enabled/configured. * @genpd_performance_state: Device's power domain support performance sta= te. * @is_genpd: Marks if the OPP table belongs to a genpd. - * @set_opp: Platform specific set_opp callback - * @sod_supplies: Set opp data supplies - * @set_opp_data: Data to be passed to set_opp callback * @dentry: debugfs dentry pointer of the real device directory (not links= ). * @dentry_name: Name of the real dentry. * @@ -234,10 +231,6 @@ struct opp_table { bool genpd_performance_state; bool is_genpd; =20 - int (*set_opp)(struct dev_pm_set_opp_data *data); - struct dev_pm_opp_supply *sod_supplies; - struct dev_pm_set_opp_data *set_opp_data; - #ifdef CONFIG_DEBUG_FS struct dentry *dentry; char dentry_name[NAME_MAX]; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 4c1cce06a61c..25a1e15cb7fe 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -57,39 +57,6 @@ struct dev_pm_opp_icc_bw { u32 peak; }; =20 -/** - * struct dev_pm_opp_info - OPP freq/voltage/current values - * @rate: Target clk rate in hz - * @supplies: Array of voltage/current values for all power supplies - * - * This structure stores the freq/voltage/current values for a single OPP. - */ -struct dev_pm_opp_info { - unsigned long rate; - struct dev_pm_opp_supply *supplies; -}; - -/** - * struct dev_pm_set_opp_data - Set OPP data - * @old_opp: Old OPP info - * @new_opp: New OPP info - * @regulators: Array of regulator pointers - * @regulator_count: Number of regulators - * @clk: Pointer to clk - * @dev: Pointer to the struct device - * - * This structure contains all information required for setting an OPP. - */ -struct dev_pm_set_opp_data { - struct dev_pm_opp_info old_opp; - struct dev_pm_opp_info new_opp; - - struct regulator **regulators; - unsigned int regulator_count; - struct clk *clk; - struct device *dev; -}; - typedef int (*config_regulators_t)(struct device *dev, struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, struct regulator **regulators, unsigned int count); @@ -99,7 +66,6 @@ typedef int (*config_regulators_t)(struct device *dev, * @clk_names: Clk name. * @clk_count: Number of clocks, max 1 for now. * @prop_name: Name to postfix to properties. - * @set_opp: Custom set OPP helper. * @config_regulators: Custom set regulator helper. * @supported_hw: Array of hierarchy of versions to match. * @supported_hw_count: Number of elements in the array. @@ -115,7 +81,6 @@ struct dev_pm_opp_config { const char * const *clk_names; unsigned int clk_count; const char *prop_name; - int (*set_opp)(struct dev_pm_set_opp_data *data); config_regulators_t config_regulators; unsigned int *supported_hw; unsigned int supported_hw_count; --=20 2.31.1.272.g89b43f80a514