From nobody Thu Apr 30 13:59:11 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 12450C433EF for ; Tue, 31 May 2022 10:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245491AbiEaKKb (ORCPT ); Tue, 31 May 2022 06:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245461AbiEaKKV (ORCPT ); Tue, 31 May 2022 06:10:21 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31669996B0 for ; Tue, 31 May 2022 03:10:20 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id y187so634851pgd.3 for ; Tue, 31 May 2022 03:10:20 -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=coONZgGzVl+ts87B3n9/T4bQl890pWmuXnplgV/C9Qg=; b=Qa7hl/jpCBUOw+kvcg30HuQhWAvp/zpkTKCuIfskarK5euPwihSjNOzWf7CUYn2IdY rbc+MXsZfPguvuAqzrjjCEYrnwsguKIv7EyMruUjtkyhQShfM4XMQHt0nGyf1utKruqZ ObQnT3hw1xetdBZfuY1C7nVpN6vaUaKnrZdnU3J1VQ2zaphGuqvjMxn3YcVcGGtJylbv Fc5cymUqI1pOCcY9IfiOvNsSN+ucRtxqOcCV3ynkkdCJ0lwo4CKHfpybyfvlKepjaqK2 P3SlPLG8mv4pA8DU3htg91lg3E1o80C7VkX/eeHgQrByz0fSUkECg0cDrf6FVt/fdSG8 c7ag== 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=coONZgGzVl+ts87B3n9/T4bQl890pWmuXnplgV/C9Qg=; b=aJRjySYBb3yxD9Ck+HtdJ+n+viuO4++2y05P81ZtA6KwnGl0CS2byXSpTzinpZeW85 vHbKtZXXy6Ysj7Zy7hGi1X+PJ9UR2chttA9F+0gsjA7KkiG/l+r68TrxiFfZoasSbXVr LMUvwtJiJ8RZJIfhdgAhu7QVALBCYRbSJ0tltdyinOIqXyiNM+tJIiC4ZepL8k5pZxPU 4VGeJdwoY0BVZy4Dme8qVg8XxomIcdBVrQShT7pfjMRtofEqoEA7gKLdvdIGVyPE3qw9 f8GxTCUZCAcw4zf1YXvEStLYl8gUiQE84oguFlsEJKMnp5zsay0/RytEyunFO0PjiuTt POWA== X-Gm-Message-State: AOAM530xiyw7AayhULrOWGfvfZFW7uR0ydgXXic5PCYxEnV7mjZ/px3M OBFRRoYvW3QmTWq61cRKweOUdi11eqKTKg== X-Google-Smtp-Source: ABdhPJyBkBo9gqfY3r46DA7I2O+W5n1W3xh3U7PbVLcmjOmAEVH68r2SqZtJjTU+hxUdFInwHElEUA== X-Received: by 2002:a65:5886:0:b0:3fb:a6ea:b741 with SMTP id d6-20020a655886000000b003fba6eab741mr17416708pgu.502.1653991819634; Tue, 31 May 2022 03:10:19 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id g13-20020aa7874d000000b0050dc762816fsm10267850pfo.73.2022.05.31.03.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:10:19 -0700 (PDT) From: Viresh Kumar To: Keerthy , Dave Gerlach , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] OPP: Add support for config_regulators() helper Date: Tue, 31 May 2022 15:40:00 +0530 Message-Id: <17e3f49303a738605b0b6e2b835578c55f3fe82c.1653991004.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" 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. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 63 ++++++++++++++++++++++++++++++++++++++++++ drivers/opp/opp.h | 2 ++ include/linux/pm_opp.h | 5 ++++ 3 files changed, 70 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 62c5d4308e01..bac91d078cbb 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1181,6 +1181,15 @@ 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->regu= lators, + 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) { @@ -1198,6 +1207,15 @@ 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->regu= lators, + 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); @@ -2237,6 +2255,43 @@ 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) { + mutex_lock(&opp_table->lock); + opp_table->config_regulators =3D config_regulators; + mutex_unlock(&opp_table->lock); + } + + return 0; +} + +/** + * _opp_put_config_regulators_helper() - Releases resources blocked for co= nfig_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) { + mutex_lock(&opp_table->lock); + opp_table->config_regulators =3D NULL; + mutex_unlock(&opp_table->lock); + } +} + static void _detach_genpd(struct opp_table *opp_table) { int index; @@ -2404,6 +2459,13 @@ struct opp_table *dev_pm_opp_set_config(struct devic= e *dev, goto err; } =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; + } + /* Configure supported hardware */ if (config->supported_hw) { ret =3D _opp_set_supported_hw(opp_table, config->supported_hw, @@ -2458,6 +2520,7 @@ void dev_pm_opp_clear_config(struct opp_table *opp_ta= ble) _opp_detach_genpd(opp_table); _opp_put_regulators(opp_table); _opp_put_supported_hw(opp_table); + _opp_put_config_regulators_helper(opp_table); _opp_unregister_set_opp_helper(opp_table); _opp_put_prop_name(opp_table); _opp_put_clkname(opp_table); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 9e1cfcb0ea98..4695d315e7f9 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -151,6 +151,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 @@ -203,6 +204,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 6cf1bbc71ed2..7e7986106274 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -90,11 +90,15 @@ 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_name: Clk name. * @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. @@ -108,6 +112,7 @@ struct dev_pm_opp_config { const char *clk_name; 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 Thu Apr 30 13:59:11 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 1C348C433EF for ; Tue, 31 May 2022 10:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245550AbiEaKKg (ORCPT ); Tue, 31 May 2022 06:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245554AbiEaKKZ (ORCPT ); Tue, 31 May 2022 06:10:25 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 051B599804 for ; Tue, 31 May 2022 03:10:23 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id s14so12413458plk.8 for ; Tue, 31 May 2022 03:10:23 -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=YyUyg3polV3O3U+GfR+R8JOfYv9TQjwFgBv3/tKFoOo=; b=Sr3ItoKPRjamyvCKHzR9XNPAHzYYBZieCF+M0MW4T0/N/fo1Fk5nZ6n/ZLQ0M+uIZW LyTAQXP+Rw4vstbqTLz2yjp2TgdUkhXrynJTqeLpPYazaQzgWYwrVg70LcL+Mq1xqV0E JR+7DPTA6MgZiyfLM4N1/4ElqKJBMuY+31qWY5PwZWggWJKkrjMH24uiYgLAKK3fm51C HWY9XuJ5jjQZwuEExFvMysJTGoxRJlbrGIlag3IOrTzeLxuRdiWJi6FjMjph/KxDPwPl sxPvUkIztZ0/DTHR+s+l8FKpLrVtQZTFzL4/KFUOPGOZ7SbGd+SN6XQzaSou3XvaNn9M YWZA== 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=YyUyg3polV3O3U+GfR+R8JOfYv9TQjwFgBv3/tKFoOo=; b=fPq49oqfW6PUnJOVeoAKsteDwm2Nl+O2XL/8uVNFkffc1gdNV1e9UOzdN7tM8dCoey BvqYbOWiq72JI5iVgxF1tNKbOQK88EW8RzLaZ/ZfE8KC/5+mveup27wSTVuSfy0E3NiN FOIAI+LJUNd+c1Uf3LDCv8yKTZNHJLH4xZne86ZTnCBu5wrTOz4oe0wAnkGdmiUqJuDd av5qa3z2WD6DiqzxcYJ0/pEgEGd+2R3kYo7BA5m2zoZWiNsMuiakNizXera4TSSOv3Lo SBYTu2B3yxWu/WKtDaJSvoNa1YQ3LPNjLtCfIwd7CQ13ZDVgPNlMwHo/hZuuiz5531OY KdLw== X-Gm-Message-State: AOAM532hOE5WEAHKf0iHn9lqoT5PAAs9xu5ai50a5bDfQdQKrqHlqhW5 GfkPuCmdA83H3GabIA0Q1vvMWg== X-Google-Smtp-Source: ABdhPJw8TkORQQRhDtHEl2r0rvyG1TzTesdGYRyFPHaSYsY70jPU0SdKG2Sc63FedMuwtLWqfugVuA== X-Received: by 2002:a17:90a:4417:b0:1ca:a861:3fbf with SMTP id s23-20020a17090a441700b001caa8613fbfmr28142580pjg.80.1653991822433; Tue, 31 May 2022 03:10:22 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id ch12-20020a056a00288c00b004fa743ba3f9sm10217427pfb.2.2022.05.31.03.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:10:22 -0700 (PDT) From: Viresh Kumar To: Keerthy , Dave Gerlach , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] OPP: Make _generic_set_opp_regulator() a config_regulators() interface Date: Tue, 31 May 2022 15:40:01 +0530 Message-Id: <3720e177d6cb3924a2ea111cf1787898a2c743d1.1653991004.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. 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 bac91d078cbb..2f76442845be 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -892,62 +892,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, @@ -1194,9 +1166,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); @@ -2103,6 +2072,10 @@ static int _opp_set_regulators(struct opp_table *opp= _table, struct device *dev, opp_table->set_opp_data->old_opp.supplies =3D supplies; opp_table->set_opp_data->new_opp.supplies =3D supplies + count; } + + /* Set generic config_regulators() for single regulators here */ + if (count =3D=3D 1) + opp_table->config_regulators =3D _opp_config_regulator_single; mutex_unlock(&opp_table->lock); =20 return 0; --=20 2.31.1.272.g89b43f80a514 From nobody Thu Apr 30 13:59:11 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 12670C433F5 for ; Tue, 31 May 2022 10:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245565AbiEaKKo (ORCPT ); Tue, 31 May 2022 06:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245547AbiEaKKc (ORCPT ); Tue, 31 May 2022 06:10:32 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC3E5996B0 for ; Tue, 31 May 2022 03:10:25 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id 187so1205148pfu.9 for ; Tue, 31 May 2022 03:10:25 -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=t251UuYRX9Gpk6ss004lGbBIWKYfWc6ZdKzVbibvYPg=; b=fwlYso4ODGThWvb7mm55FvL2//jUk5biuuuIfzJ/5OIu19ucpglm2wXgyXpwwaAhiR SLNuPQIkSu1uXrlOPqHCRxVYEUVnSCnskiGNigQIAmlJ2Radzqn/hcu+/+XMtjWMZHt0 cYnel2tgevynwXsSFmQSdjz3/4GJo0o3oxV0XRnR1TBozSkbCxDNyzxlZhUE8uVrUhHP eKf/E3qDpjGcTmeuSkn6Y9PDqNs1HhVfDn91YkVKiOD7WSisXVcvFjp8gSR+HJzjIbwT B5FEvws6wKGtZs5niQ7AfVzIUa1Blma2HIJPlb8IBhXffvt/h0SucIzG6pItPg9yenV4 KuJw== 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=t251UuYRX9Gpk6ss004lGbBIWKYfWc6ZdKzVbibvYPg=; b=1yN5ECTEHWBbeqfhOscbTxUpNsYabCVz6ppzPmrZFSJwJ6oP4cLgfgavBcMYY2M+CQ X7VkvJp2FB3ZeqJzyfKL8E7pzgRgsRIWTWogxTuoV2ab53GmsAm2UURnO3kQwL+y1pct W82Kl3af46fTGn65u5jiLk5rB+JTmdTggI4HE11C5XThm54Iig0delh8ZLLJboyYRALu L98vQ0iORU11ixo5Wsh8FUC70H3XeodzO6GcSYWlbRAg237vuOzrYs1MiqGVhVeOQphh 8+LfRlqUdUhW8x0veC4tIQB2L5zh9OEpHGEcFlBROTarREkCNKHwuFNWvseROS1vNSY4 I3VA== X-Gm-Message-State: AOAM533nIQmd2uORgbvAJG9MjyxhQTsSaa1ldjT0QrkxCyEtUqfAA0kY kMghMpCPCzc2h3wMUcEP3WGv2g== X-Google-Smtp-Source: ABdhPJzIj5N40D2+o6BjW/xwenMeZo+JSTMOCaseQ/RzunmkKENQLPvLgBAKbqXCR91riXsFu5HLoQ== X-Received: by 2002:a05:6a00:b41:b0:50d:35fa:476d with SMTP id p1-20020a056a000b4100b0050d35fa476dmr61199182pfo.33.1653991825325; Tue, 31 May 2022 03:10:25 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id f3-20020aa79d83000000b0050dc76281f0sm10341595pfq.202.2022.05.31.03.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:10:25 -0700 (PDT) From: Viresh Kumar To: Keerthy , Dave Gerlach , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] OPP: Add dev_pm_opp_get_supplies() Date: Tue, 31 May 2022 15:40:02 +0530 Message-Id: <20838d8f1f883c6484ecd40db23097fbc727b55d.1653991004.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" 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. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 2f76442845be..58ce1240e808 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -113,6 +113,28 @@ 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_supp= ly *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->regul= ator_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 7e7986106274..185503aab64d 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -128,6 +128,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); @@ -216,6 +218,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 Thu Apr 30 13:59:11 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 A1E1FC433EF for ; Tue, 31 May 2022 10:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245596AbiEaKKw (ORCPT ); Tue, 31 May 2022 06:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245597AbiEaKKd (ORCPT ); Tue, 31 May 2022 06:10:33 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E1A9A990 for ; Tue, 31 May 2022 03:10:28 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id s12so37909plp.0 for ; Tue, 31 May 2022 03:10:28 -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=841lChJS+wM9jNwwGNIhEP39YB5JqkFPrtXZuFk54ZE=; b=wsVUZDBwbwJUD2AB5HlQVmhzbHK1IExWV+c19cH6hRQ4ggbGuqoH+/SviPapk+UlP+ GovfI79gVH10UBXFXfmTlzsthLjkOA1835nlQttp3GoFkWxIC4661qZxSOfIiheO8Jyw aJF9fFoEdU6QbLPEmfh0HxVzDsBEKdgLMoInHDuIZQ9QyYsYfdgF3Dpoaa7WeI4bOvdm pqaXYir/RYh5smiEISje8EncY1SXUyW4g40HmCOsALNm9ET1E9roOEzH3Y2qIIJuU3uC XESf+PGPGVZ454UhBrQzSmVQ84pdaWc8BChcLIAO5vQznh4ONZ1jsw3BIP5Wsn8Bpf1T o5aw== 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=841lChJS+wM9jNwwGNIhEP39YB5JqkFPrtXZuFk54ZE=; b=AFCeI6uRNQBBBTDW++stmaMNZ+gYYyEwtDzjg1BSId4O+sADSC3TciDGJxNAj8pxc6 TQ+e7Zn76aPRRkwj7HuDAJTMfG3UqwDQcr5JJnONS5c+gWomIELpuQVLmgSUCBSrBjyG rY6xOhBnHgFaJvMv6ZuFKx+dNQBEVKbVKnJrQFk6rvlaY43h1s0AISsLNAPMg2j84/76 wvDiSeY+4QkMdZizWPHM3xvtshratzw1RYe/YrggG69AYBk3Sm1hYTYEveTFhH1HipSI 5lKP7meEdAsYGURZrkCSeVF35teozMC0flTcQsPxfSQKWDDxhKyCfwrIIqTP1kzovBsB YRBA== X-Gm-Message-State: AOAM53054WvO63FqmiX9G6WO/f2cTVd8Cj50GkorPFIguEThfP3PNy3E /nKLKPkwNtdGMHtNsiDdrIV9+A== X-Google-Smtp-Source: ABdhPJyykrDTXjJH194BNbajlW0qZVaKHHLjVigQyygVAMr38BqXMuyG1t704aSR+1M4CfeL+rYRSg== X-Received: by 2002:a17:90b:33cd:b0:1e2:a03c:a4b1 with SMTP id lk13-20020a17090b33cd00b001e2a03ca4b1mr17806391pjb.49.1653991828146; Tue, 31 May 2022 03:10:28 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id l7-20020a17090a150700b001e2f3831102sm1509234pja.17.2022.05.31.03.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:10:27 -0700 (PDT) From: Viresh Kumar To: Keerthy , Dave Gerlach , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] OPP: ti: Migrate to config_regulators() Date: Tue, 31 May 2022 15:40:03 +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" 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 a30825dc30cf..2aeb084fc379 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 Thu Apr 30 13:59:11 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 1C55FC433F5 for ; Tue, 31 May 2022 10:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245581AbiEaKLD (ORCPT ); Tue, 31 May 2022 06:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245560AbiEaKKe (ORCPT ); Tue, 31 May 2022 06:10:34 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922E899802 for ; Tue, 31 May 2022 03:10:32 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id e66so12391503pgc.8 for ; Tue, 31 May 2022 03:10:32 -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=TN0HoEKkinrYkohW6UQvZ/lz2gE/8xkyne4fFymVx20=; b=qVpOPoUenZlAfHwl8ri4mvJTPSRYl9PaJaIgL9nvLtwI9os8z4+x9/ZmnuJYRdWVzg 4XqnB8lW1zW+R035zJI7I4gpCxvxm19gY3Vxo1QpCyUJBh7/t28NlF/Iam9WCCHu0Nip 1BTtwPqlJn/7vgXvh+sPAgfKqtQk0xz/uu+EU1c6PDSnU8IUsxeGZ8gIpUlDDONFbsqA jqLmenm0SHDm8l51zxev74zvRcrQqvCTB0qoKky24wnWMpBcjk0N9cGPX2b++a++XjRT juzhOd4V21J7TEle6eXAN/kyh9Hkwu97xd4b9jBOMa3MVDfHbp9Y+0yaasP2rrWpZ8Z8 g8qQ== 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=TN0HoEKkinrYkohW6UQvZ/lz2gE/8xkyne4fFymVx20=; b=sbrvNUK/o0G1rk/n8weKp21LGrFNg+WC4SPbPhcidar6MbVsnlMGMm8L1mvA5pGuXJ twYn2KNmOGUqwlOhZRvCpoLhIqAvITA4OjK//DY/pTWZblIYHFM/xjwHnJcpOV+BriKg pLc9JtUsijb4yiBeMUlpx6JUt6licGwQRlRUUwGXmeUAPLz58Mes6p2kIDiOjExWGHgE Zh1dHU2nzCnaZ+WX7u+73VoeRB4k94LGX9RO+m+j4kShA0+o2A18fQm/TleXzcdoz8E7 TIMMVCa+rrziYSboOkRi7qGBFb6H9xMYLcA7Y8l0nIa7B4KXtyWi54ygTdpJqvQy5re0 EUxw== X-Gm-Message-State: AOAM532fNqa9xRkGsAf8D6QHacOdUIuYXACDF4W2ztMSdF8xxHaUWuoR gH3OkBancaGhDeTVNE1hrZpGdA== X-Google-Smtp-Source: ABdhPJwIWu6PLEIkbJFNmL7qXX5rIyYf2/9kJll8601WTPGr8WXwODprLaju2Q1iPAn/lp0Qgmo7Bw== X-Received: by 2002:a63:81c6:0:b0:3fc:818e:8621 with SMTP id t189-20020a6381c6000000b003fc818e8621mr315581pgd.173.1653991831718; Tue, 31 May 2022 03:10:31 -0700 (PDT) Received: from localhost ([122.162.234.2]) by smtp.gmail.com with ESMTPSA id h17-20020a170902f71100b0016168e90f2csm10867861plo.208.2022.05.31.03.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:10:31 -0700 (PDT) From: Viresh Kumar To: Keerthy , Dave Gerlach , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] OPP: Remove custom OPP helper support Date: Tue, 31 May 2022 15:40:04 +0530 Message-Id: <2e6ee73dbc8a231377547a8e9497561cadb38166.1653991004.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. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 126 +---------------------------------------- drivers/opp/opp.h | 7 --- include/linux/pm_opp.h | 35 ------------ 3 files changed, 2 insertions(+), 166 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 58ce1240e808..554a043bc225 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -972,36 +972,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) { @@ -1186,13 +1156,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 @@ -2054,7 +2018,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 @@ -2082,20 +2045,8 @@ 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; - } - /* Set generic config_regulators() for single regulators here */ + mutex_lock(&opp_table->lock); if (count =3D=3D 1) opp_table->config_regulators =3D _opp_config_regulator_single; mutex_unlock(&opp_table->lock); @@ -2132,16 +2083,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; @@ -2195,61 +2136,6 @@ static void _opp_put_clkname(struct opp_table *opp_t= able) } } =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. @@ -2447,13 +2333,6 @@ struct opp_table *dev_pm_opp_set_config(struct devic= e *dev, goto err; } =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; - } - /* Configure config_regulators helper */ if (config->config_regulators) { ret =3D _opp_set_config_regulators_helper(opp_table, dev, config->config= _regulators); @@ -2516,7 +2395,6 @@ void dev_pm_opp_clear_config(struct opp_table *opp_ta= ble) _opp_put_regulators(opp_table); _opp_put_supported_hw(opp_table); _opp_put_config_regulators_helper(opp_table); - _opp_unregister_set_opp_helper(opp_table); _opp_put_prop_name(opp_table); _opp_put_clkname(opp_table); =20 diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 4695d315e7f9..407eee9f10ab 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -161,9 +161,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. * @@ -213,10 +210,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 185503aab64d..c6d8f01ef9fd 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); @@ -97,7 +64,6 @@ typedef int (*config_regulators_t)(struct device *dev, st= ruct dev_pm_opp *old_op * struct dev_pm_opp_config - Device OPP configuration values * @clk_name: Clk name. * @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. @@ -111,7 +77,6 @@ typedef int (*config_regulators_t)(struct device *dev, s= truct dev_pm_opp *old_op struct dev_pm_opp_config { const char *clk_name; 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