From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Ilia Lin <ilia.lin@kernel.org>, Viresh Kumar <vireshk@kernel.org>,
Nishanth Menon <nm@ti.com>, Stephen Boyd <sboyd@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Georgi Djakov <djakov@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-pm@vger.kernel.org, linux-clk@vger.kernel.org,
Christian Marangi <ansuelsmth@gmail.com>,
Stephan Gerhold <stephan@gerhold.net>
Subject: [RFC PATCH 3/8] cpufreq: qcom-nvmem: provide vmin constraint for early Kraits
Date: Sun, 2 Jul 2023 20:50:40 +0300 [thread overview]
Message-ID: <20230702175045.122041-4-dmitry.baryshkov@linaro.org> (raw)
In-Reply-To: <20230702175045.122041-1-dmitry.baryshkov@linaro.org>
Early Krait CPUs required that core voltage was not below 1.15 V.
Implement this requirement by adding separate config_regulators
callback.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 67 +++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
index 113f35668048..9312c8ab62a8 100644
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -30,6 +30,8 @@
#include <linux/slab.h>
#include <linux/soc/qcom/smem.h>
+#include <asm/cputype.h>
+
#include <dt-bindings/arm/qcom,ids.h>
struct qcom_cpufreq_drv;
@@ -257,6 +259,66 @@ static const struct qcom_cpufreq_match_data match_data_apq8064 = {
.regulator_names = apq8064_regulator_names,
};
+static const int krait_needs_vmin(void)
+{
+ switch (read_cpuid_id()) {
+ case 0x511F04D0: /* KR28M2A20 */
+ case 0x511F04D1: /* KR28M2A21 */
+ case 0x510F06F0: /* KR28M4A10 */
+ return 1;
+ default:
+ return 0;
+ };
+}
+
+#define KRAIT_VMIN 1150000
+#define KRAIT_VMIN_MAX (KRAIT_VMIN + 25000)
+static int krait_config_regulator_vmin(struct device *dev,
+ struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp,
+ struct regulator **regulators, unsigned int count)
+{
+ struct regulator *reg = regulators[0];
+ struct dev_pm_opp_supply supply;
+ int ret;
+
+ /* This function only supports single regulator per device */
+ if (WARN_ON(count > 1)) {
+ dev_err(dev, "multiple regulators are not supported\n");
+ return -EINVAL;
+ }
+
+ if (IS_ERR(reg)) {
+ dev_dbg(dev, "%s: regulator not available: %ld\n", __func__,
+ PTR_ERR(reg));
+ return 0;
+ }
+
+ ret = dev_pm_opp_get_supplies(new_opp, &supply);
+ if (WARN_ON(ret))
+ return ret;
+
+ if (supply.u_volt_min < KRAIT_VMIN) {
+ supply.u_volt_min = KRAIT_VMIN;
+ supply.u_volt = KRAIT_VMIN;
+ supply.u_volt_max = KRAIT_VMIN_MAX;
+ }
+
+ dev_dbg(dev, "%s: voltages (mV): %lu %lu %lu\n", __func__,
+ supply.u_volt_min, supply.u_volt, supply.u_volt_max);
+
+ ret = regulator_set_voltage_triplet(reg,
+ supply.u_volt_min,
+ supply.u_volt,
+ supply.u_volt_max);
+ if (ret)
+ dev_err(dev, "%s: failed to set voltage (%lu %lu %lu mV): %d\n",
+ __func__, supply.u_volt_min, supply.u_volt,
+ supply.u_volt_max, ret);
+
+ return ret;
+}
+
+
static int qcom_cpufreq_probe(struct platform_device *pdev)
{
struct qcom_cpufreq_drv *drv;
@@ -344,8 +406,11 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
config.virt_devs = NULL;
}
- if (drv->data->regulator_names)
+ if (drv->data->regulator_names) {
config.regulator_names = drv->data->regulator_names;
+ if (krait_needs_vmin())
+ config.config_regulators = krait_config_regulator_vmin;
+ }
if (config.supported_hw ||
config.genpd_names ||
--
2.39.2
next prev parent reply other threads:[~2023-07-02 17:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 17:50 [RFC PATCH 0/8] ARM: qcom: msm8960: support CPU frequency scaling Dmitry Baryshkov
2023-07-02 17:50 ` [RFC PATCH 1/8] dt-bindings: nvmem: qfprom: add compatible for MSM8960 Dmitry Baryshkov
2023-07-03 16:38 ` Conor Dooley
2023-07-02 17:50 ` [RFC PATCH 2/8] cpufreq: qcom-nvmem: enable core voltage scaling " Dmitry Baryshkov
2023-07-02 17:50 ` Dmitry Baryshkov [this message]
2023-07-03 11:38 ` [RFC PATCH 3/8] cpufreq: qcom-nvmem: provide vmin constraint for early Kraits Konrad Dybcio
2023-07-02 17:50 ` [RFC PATCH 4/8] ARM: dts: qcom: msm8960-cdp: constraint cpufreq regulators Dmitry Baryshkov
2023-07-04 13:03 ` Konrad Dybcio
2023-07-04 13:34 ` Dmitry Baryshkov
2023-07-04 13:50 ` Konrad Dybcio
2023-07-02 17:50 ` [RFC PATCH 5/8] ARM: dts: qcom: msm8960-samsung-expressatt: " Dmitry Baryshkov
2023-07-02 17:50 ` [RFC PATCH 6/8] ARM: dts: qcom: msm8960: add Krait clock controller Dmitry Baryshkov
2023-07-02 17:50 ` [RFC PATCH 7/8] ARM: dts: qcom: msm8960: add L2 cache scaling Dmitry Baryshkov
2023-07-02 17:50 ` [RFC PATCH 8/8] ARM: dts: qcom: apq8064: add simple CPUFreq support Dmitry Baryshkov
2023-07-04 13:05 ` Konrad Dybcio
2023-07-04 13:44 ` Dmitry Baryshkov
2023-07-04 13:49 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230702175045.122041-4-dmitry.baryshkov@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djakov@kernel.org \
--cc=ilia.lin@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nm@ti.com \
--cc=rafael@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=stephan@gerhold.net \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox