From: Konrad Dybcio <konrad.dybcio@linaro.org>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
Stephen Boyd <sboyd@kernel.org>, Niklas Cassel <nks@flawful.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: Robert Marko <robimarko@gmail.com>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
Jeffrey Hugo <quic_jhugo@quicinc.com>,
Marijn Suijten <marijn.suijten@somainline.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@somainline.org>
Subject: [PATCH v13 08/10] soc: qcom: cpr-common: Add threads support
Date: Wed, 02 Aug 2023 14:37:48 +0200 [thread overview]
Message-ID: <20230217-topic-cpr3h-v13-8-d01cff1c54cf@linaro.org> (raw)
In-Reply-To: <20230217-topic-cpr3h-v13-0-d01cff1c54cf@linaro.org>
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Add support for parsing per-CPR-thread data in preparation for introducing
CPR3+ support.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
[Konrad: separate this patch out of a bigger one]
Tested-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/genpd/qcom/cpr-common.c | 42 ++++++++++++++++++++++++-----------------
drivers/genpd/qcom/cpr-common.h | 8 ++++++--
drivers/genpd/qcom/cpr.c | 4 ++--
3 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/drivers/genpd/qcom/cpr-common.c b/drivers/genpd/qcom/cpr-common.c
index 3e3a4a61cfde..9001dccd4d95 100644
--- a/drivers/genpd/qcom/cpr-common.c
+++ b/drivers/genpd/qcom/cpr-common.c
@@ -73,35 +73,42 @@ static int cpr_read_fuse_uV(int init_v_width, int step_size_uV, int ref_uV,
return DIV_ROUND_UP(uV, step_volt) * step_volt;
}
-const struct cpr_fuse *cpr_get_fuses(struct device *dev,
+const struct cpr_fuse *cpr_get_fuses(struct device *dev, int tid,
unsigned int num_fuse_corners)
{
struct cpr_fuse *fuses;
- int i;
+ char cpr_name[11]; /* length of "cpr" + length of UINT_MAX (7) + \0 */
+ unsigned int i;
fuses = devm_kcalloc(dev, num_fuse_corners, sizeof(*fuses), GFP_KERNEL);
if (!fuses)
return ERR_PTR(-ENOMEM);
+ /* Support legacy bindings */
+ if (tid == UINT_MAX)
+ snprintf(cpr_name, sizeof(cpr_name), "cpr");
+ else
+ snprintf(cpr_name, sizeof(cpr_name), "cpr%d", tid);
+
for (i = 0; i < num_fuse_corners; i++) {
- char tbuf[32];
+ char tbuf[50];
- snprintf(tbuf, 32, "cpr_ring_osc%d", i + 1);
+ snprintf(tbuf, sizeof(tbuf), "%s_ring_osc%d", cpr_name, i + 1);
fuses[i].ring_osc = devm_kstrdup(dev, tbuf, GFP_KERNEL);
if (!fuses[i].ring_osc)
return ERR_PTR(-ENOMEM);
- snprintf(tbuf, 32, "cpr_init_voltage%d", i + 1);
+ snprintf(tbuf, sizeof(tbuf), "%s_init_voltage%d", cpr_name, i + 1);
fuses[i].init_voltage = devm_kstrdup(dev, tbuf, GFP_KERNEL);
if (!fuses[i].init_voltage)
return ERR_PTR(-ENOMEM);
- snprintf(tbuf, 32, "cpr_quotient%d", i + 1);
+ snprintf(tbuf, sizeof(tbuf), "%s_quotient%d", cpr_name, i + 1);
fuses[i].quotient = devm_kstrdup(dev, tbuf, GFP_KERNEL);
if (!fuses[i].quotient)
return ERR_PTR(-ENOMEM);
- snprintf(tbuf, 32, "cpr_quotient_offset%d", i + 1);
+ snprintf(tbuf, sizeof(tbuf), "%s_quotient_offset%d", cpr_name, i + 1);
fuses[i].quotient_offset = devm_kstrdup(dev, tbuf, GFP_KERNEL);
if (!fuses[i].quotient_offset)
return ERR_PTR(-ENOMEM);
@@ -202,15 +209,15 @@ int cpr_find_initial_corner(struct device *dev, struct clk *cpu_clk,
}
EXPORT_SYMBOL_GPL(cpr_find_initial_corner);
-unsigned int cpr_get_fuse_corner(struct dev_pm_opp *opp)
+unsigned int cpr_get_fuse_corner(struct dev_pm_opp *opp, u32 tid)
{
struct device_node *np;
unsigned int fuse_corner = 0;
np = dev_pm_opp_get_of_node(opp);
- if (of_property_read_u32(np, "qcom,opp-fuse-level", &fuse_corner))
- pr_err("%s: missing 'qcom,opp-fuse-level' property\n",
- __func__);
+ if (of_property_read_u32_index(np, "qcom,opp-fuse-level", tid, &fuse_corner))
+ pr_err("%s: missing 'qcom,opp-fuse-level[%u]' property\n",
+ __func__, tid);
of_node_put(np);
@@ -235,15 +242,16 @@ u64 cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
if (!ref_np)
goto out_ref;
- do {
- of_node_put(child_req_np);
- child_np = of_get_next_available_child(desc_np, child_np);
+ for_each_available_child_of_node(desc_np, child_np) {
child_req_np = of_parse_phandle(child_np, "required-opps", 0);
- } while (child_np && child_req_np != ref_np);
- if (child_np && child_req_np == ref_np)
- of_property_read_u64(child_np, "opp-hz", &rate);
+ if (child_np && child_req_np == ref_np) {
+ of_property_read_u64(child_np, "opp-hz", &rate);
+ goto out;
+ }
+ }
+out:
of_node_put(child_req_np);
of_node_put(child_np);
of_node_put(ref_np);
diff --git a/drivers/genpd/qcom/cpr-common.h b/drivers/genpd/qcom/cpr-common.h
index 1b2fa344eb09..2c5bb81ab713 100644
--- a/drivers/genpd/qcom/cpr-common.h
+++ b/drivers/genpd/qcom/cpr-common.h
@@ -22,6 +22,9 @@ struct fuse_corner_data {
int ref_uV;
int max_uV;
int min_uV;
+ int range_uV;
+ /* fuse volt: closed/open loop */
+ int volt_cloop_adjust;
int volt_oloop_adjust;
int max_volt_scale;
int max_quot_scale;
@@ -55,6 +58,7 @@ struct corner {
u32 save_ctl;
u32 save_irq;
u64 freq;
+ bool is_open_loop;
struct fuse_corner *fuse_corner;
};
@@ -81,7 +85,7 @@ int cpr_populate_ring_osc_idx(struct device *dev,
struct fuse_corner *fuse_corner,
const struct cpr_fuse *cpr_fuse,
int num_fuse_corners);
-const struct cpr_fuse *cpr_get_fuses(struct device *dev,
+const struct cpr_fuse *cpr_get_fuses(struct device *dev, int tid,
unsigned int num_fuse_corners);
int cpr_populate_fuse_common(struct device *dev,
struct fuse_corner_data *fdata,
@@ -91,7 +95,7 @@ int cpr_populate_fuse_common(struct device *dev,
int init_v_step);
int cpr_find_initial_corner(struct device *dev, struct clk *cpu_clk,
struct corner *corners, int num_corners);
-u32 cpr_get_fuse_corner(struct dev_pm_opp *opp);
+u32 cpr_get_fuse_corner(struct dev_pm_opp *opp, u32 tid);
u64 cpr_get_opp_hz_for_req(struct dev_pm_opp *ref, struct device *cpu_dev);
int cpr_calculate_scaling(struct device *dev,
const char *quot_offset,
diff --git a/drivers/genpd/qcom/cpr.c b/drivers/genpd/qcom/cpr.c
index bd0ac95e86e7..9fd26080481a 100644
--- a/drivers/genpd/qcom/cpr.c
+++ b/drivers/genpd/qcom/cpr.c
@@ -851,7 +851,7 @@ static int cpr_corner_init(struct cpr_drv *drv)
opp = dev_pm_opp_find_level_exact(&drv->pd.dev, level);
if (IS_ERR(opp))
return -EINVAL;
- fc = cpr_get_fuse_corner(opp);
+ fc = cpr_get_fuse_corner(opp, 0);
if (!fc) {
dev_pm_opp_put(opp);
return -EINVAL;
@@ -1325,7 +1325,7 @@ static int cpr_probe(struct platform_device *pdev)
if (ret)
return ret;
- drv->cpr_fuses = cpr_get_fuses(drv->dev, desc->num_fuse_corners);
+ drv->cpr_fuses = cpr_get_fuses(drv->dev, UINT_MAX, desc->num_fuse_corners);
if (IS_ERR(drv->cpr_fuses))
return PTR_ERR(drv->cpr_fuses);
--
2.41.0
next prev parent reply other threads:[~2023-08-02 12:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 12:37 [PATCH v13 00/10] Add support for Core Power Reduction v3, v4 and Hardened Konrad Dybcio
2023-08-02 12:37 ` [PATCH v13 01/10] cpufreq: blocklist MSM8998 in cpufreq-dt-platdev Konrad Dybcio
2023-08-02 12:58 ` Caleb Connolly
2023-08-03 5:49 ` Viresh Kumar
2023-08-02 12:37 ` [PATCH v13 02/10] MAINTAINERS: Add entry for Qualcomm CPRv3/v4/Hardened driver Konrad Dybcio
2023-08-02 12:37 ` [PATCH v13 03/10] dt-bindings: opp: v2-qcom-level: Document CPR3 open/closed loop volt adjustment Konrad Dybcio
2023-08-08 16:17 ` Krzysztof Kozlowski
2023-08-02 12:37 ` [PATCH v13 04/10] dt-bindings: soc: qcom: cpr3: Add bindings for CPR3 driver Konrad Dybcio
2023-08-08 16:20 ` Krzysztof Kozlowski
2023-08-02 12:37 ` [PATCH v13 05/10] soc: qcom: cpr: Move common functions to new file Konrad Dybcio
2023-08-02 12:37 ` [PATCH v13 06/10] soc: qcom: cpr-common: Add support for flat fuse adjustment Konrad Dybcio
2023-08-02 12:37 ` [PATCH v13 07/10] soc: qcom: cpr: Use u64 for frequency Konrad Dybcio
2023-08-02 12:37 ` Konrad Dybcio [this message]
2023-08-02 12:37 ` [PATCH v13 09/10] soc: qcom: Add support for Core Power Reduction v3, v4 and Hardened Konrad Dybcio
2023-08-02 12:37 ` [PATCH v13 10/10] arm64: dts: qcom: msm8998: Configure CPRh 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=20230217-topic-cpr3h-v13-8-d01cff1c54cf@linaro.org \
--to=konrad.dybcio@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=angelogioacchino.delregno@somainline.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=nks@flawful.org \
--cc=nm@ti.com \
--cc=quic_jhugo@quicinc.com \
--cc=rafael@kernel.org \
--cc=robh+dt@kernel.org \
--cc=robimarko@gmail.com \
--cc=sboyd@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=viresh.kumar@linaro.org \
--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
all inboxes | Powered by JetHome®