From: Robert Marko <robimarko@gmail.com>
To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
andersson@kernel.org, konradybcio@kernel.org,
abelvesa@kernel.org, ilia.lin@kernel.org, rafael@kernel.org,
viresh.kumar@linaro.org, ulfh@kernel.org, lgirdwood@gmail.com,
broonie@kernel.org, angelogioacchino.delregno@somainline.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Cc: Robert Marko <robimarko@gmail.com>
Subject: [PATCH 3/7] pmdomain: qcom: cpr4: add IPQ8074 APSS support
Date: Tue, 1 Dec 2026 22:34:16 +0100 [thread overview]
Message-ID: <20261201213534.343361-4-robimarko@gmail.com> (raw)
In-Reply-To: <20261201213534.343361-1-robimarko@gmail.com>
Add IPQ8074 APSS fuse corner data, ring oscillator scaling factors,
and voltage limits to the CPRv4 driver. Select AC or HK CPU OPPs from
the SoC ID and provide the IPQ8074 array power mux operations needed
when the supply crosses its voltage threshold.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
drivers/pmdomain/qcom/Kconfig | 5 +-
drivers/pmdomain/qcom/cpr4.c | 120 ++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/qcom/Kconfig b/drivers/pmdomain/qcom/Kconfig
index 7a38fca694e6..37cb042add1d 100644
--- a/drivers/pmdomain/qcom/Kconfig
+++ b/drivers/pmdomain/qcom/Kconfig
@@ -25,12 +25,13 @@ config QCOM_CPR4
depends on PM
depends on NVMEM
depends on REGULATOR
+ depends on QCOM_SMEM
select REGMAP
select PM_OPP
select PM_GENERIC_DOMAINS
help
- Say Y here to enable CPRv4 voltage control on supported
- Qualcomm SoCs. The controller uses ring oscillator measurements to
+ Say Y here to enable CPRv4 voltage control on Qualcomm IPQ8074
+ SoCs. The controller uses ring oscillator measurements to
adjust the CPU supply voltage within the limits of each operating
point. The driver reads calibration fuses and exposes voltage levels
as power domain performance states for CPU frequency scaling.
diff --git a/drivers/pmdomain/qcom/cpr4.c b/drivers/pmdomain/qcom/cpr4.c
index 27f6bf2ed132..a8128d536646 100644
--- a/drivers/pmdomain/qcom/cpr4.c
+++ b/drivers/pmdomain/qcom/cpr4.c
@@ -25,9 +25,11 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
+#include <linux/soc/qcom/smem.h>
#include <linux/string.h>
#include <linux/workqueue.h>
+#include <dt-bindings/arm/qcom,ids.h>
enum voltage_change_dir {
NO_CHANGE,
@@ -88,6 +90,11 @@ struct corner_data {
#define CPR4_RO_COUNT 16
#define CPR4_RO_MASK GENMASK(CPR4_RO_COUNT - 1, 0)
+#define IPQ8074_APM_MODE 0x2a8
+#define IPQ8074_APM_DELAY 0x2ac
+#define IPQ8074_APM_STATUS 0x2b0
+#define IPQ8074_APM_STATUS_MASK GENMASK(4, 0)
+
/* CPR register offsets shared with earlier controller revisions */
#define CPR4_REG_CPR_CTL 0x4
#define CPR4_CPR_CTL_LOOP_EN_MASK BIT(0)
@@ -819,6 +826,31 @@ static void cpr_corner_restore(struct cpr_thread *thread,
corner->last_uV = corner->uV;
}
+static int ipq8074_apm_init(struct cpr_drv *drv)
+{
+ return regmap_write(drv->apm, IPQ8074_APM_DELAY, 0x02111001);
+}
+
+static int ipq8074_apm_switch(struct cpr_drv *drv, bool to_apcc)
+{
+ unsigned int status;
+ int ret;
+
+ ret = regmap_write(drv->apm, IPQ8074_APM_MODE, to_apcc ? 2 : 0);
+ if (ret)
+ return ret;
+
+ ret = regmap_read_poll_timeout(drv->apm, IPQ8074_APM_STATUS,
+ status,
+ (status & IPQ8074_APM_STATUS_MASK) ==
+ (to_apcc ? 3 : 0), 1, 500);
+ if (ret)
+ dev_err(drv->dev, "APM switch to %s timed out: %#x\n",
+ to_apcc ? "APCC" : "MX", status);
+
+ return ret;
+}
+
/**
* cpr_commit_state() - Set the newly requested voltage
* @thread: Structure holding CPR thread-specific parameters
@@ -2027,6 +2059,31 @@ static int cpr4_resources_init(struct platform_device *pdev,
return 0;
}
+static int ipq8074_cpr_get_supported_hw(struct cpr_drv *drv)
+{
+ u32 soc_id;
+ int ret;
+
+ ret = qcom_smem_get_soc_id(&soc_id);
+ if (ret)
+ return ret;
+
+ switch (soc_id) {
+ case QCOM_ID_IPQ8072A:
+ case QCOM_ID_IPQ8074A:
+ case QCOM_ID_IPQ8076A:
+ case QCOM_ID_IPQ8078A:
+ drv->supported_hw = BIT(0);
+ break;
+ default:
+ /* AC and unknown variants use the lower frequency range. */
+ drv->supported_hw = BIT(1);
+ break;
+ }
+
+ return 0;
+}
+
static int cpr_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2175,7 +2232,70 @@ static void cpr_remove(struct platform_device *pdev)
debugfs_remove_recursive(drv->debugfs);
}
+/* IPQ8074 APSS uses CPR4 with one thread and four fuse corners. */
+static const int ipq8074_ro_scaling[][CPR4_RO_COUNT] = {
+ {
+ 3970, 4150, 0, 2280, 2520, 2470, 2250, 2280,
+ 2390, 2330, 2530, 2500, 850, 2900, 2510, 2170,
+ },
+};
+
+static struct fuse_corner_data ipq8074_fuse_corners[] = {
+ { .ref_uV = 720000, .min_uV = 592000, .max_uV = 840000,
+ .range_uV = 40000, .quot_scale = 1 },
+ { .ref_uV = 864000, .min_uV = 648000, .max_uV = 944000,
+ .range_uV = 40000, .quot_scale = 1, .quot_offset_scale = 5 },
+ { .ref_uV = 992000, .min_uV = 744000, .max_uV = 992000,
+ .range_uV = 40000, .quot_scale = 1, .quot_offset_scale = 5 },
+ { .ref_uV = 1064000, .min_uV = 848000, .max_uV = 1064000,
+ .range_uV = 40000, .quot_scale = 1, .quot_offset_scale = 5 },
+};
+
+static const u32 ipq8074_corner_max_uV[] = {
+ 840000, 904000, 944000, 984000, 992000, 1064000,
+};
+
+static const struct cpr_thread_desc ipq8074_thread = {
+ .controller_id = 0,
+ .hw_tid = 0,
+ .ro_scaling_factor = ipq8074_ro_scaling,
+ .ro_scaling_factor_common = true,
+ .init_voltage_step = 8000,
+ .init_voltage_width = 6,
+ .sensor_range_start = 0,
+ .sensor_range_end = 6,
+ .step_quot_init_min = 12,
+ .step_quot_init_max = 14,
+ .num_fuse_corners = ARRAY_SIZE(ipq8074_fuse_corners),
+ .fuse_corner_data = ipq8074_fuse_corners,
+};
+
+static const struct cpr_desc ipq8074_cpr_desc = {
+ .num_threads = 1,
+ .timer_delay_us = 5000,
+ .timer_cons_up = 0,
+ .timer_cons_down = 0,
+ .up_threshold = 4,
+ .down_threshold = 1,
+ .idle_clocks = 15,
+ .count_mode = CPR4_CPR_CTL_COUNT_MODE_ALL_AT_ONCE_MIN,
+ .count_repeat = 14,
+ .gcnt_us = 1,
+ .vreg_step_fixed = 8000,
+ .vreg_step_up_limit = 1,
+ .vreg_step_down_limit = 1,
+ .apm_threshold = 848000,
+ .cpr_base_voltage = 592000,
+ .cpr_max_voltage = 1064000,
+ .corner_max_uV = ipq8074_corner_max_uV,
+ .get_supported_hw = ipq8074_cpr_get_supported_hw,
+ .apm_init = ipq8074_apm_init,
+ .apm_switch = ipq8074_apm_switch,
+ .threads = (const struct cpr_thread_desc *[]) { &ipq8074_thread },
+};
+
static const struct of_device_id cpr4_match_table[] = {
+ { .compatible = "qcom,ipq8074-cpr4", .data = &ipq8074_cpr_desc },
{ }
};
MODULE_DEVICE_TABLE(of, cpr4_match_table);
--
2.56.1
next prev parent reply other threads:[~2026-12-01 21:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 21:34 [PATCH 0/7] Add APSS CPRv4 support for IPQ8074 Robert Marko
2026-12-01 21:34 ` [PATCH 1/7] dt-bindings: power: document Qualcomm CPRv4 Robert Marko
2026-12-01 21:34 ` [PATCH 2/7] pmdomain: qcom: add CPRv4 power domain driver Robert Marko
2026-12-01 21:34 ` Robert Marko [this message]
2026-12-01 21:34 ` [PATCH 4/7] cpufreq: qcom: attach IPQ8074 CPUs to CPRv4 domain Robert Marko
2026-12-01 21:34 ` [PATCH 5/7] arm64: dts: qcom: ipq8074: describe APSS CPRv4 fuses Robert Marko
2026-12-01 21:34 ` [PATCH 6/7] arm64: dts: qcom: ipq8074: add APSS CPRv4 and OPPs Robert Marko
2026-12-01 21:34 ` [PATCH 7/7] arm64: dts: qcom: ipq8074-hk10: include PMP8074 PMIC Robert Marko
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=20261201213534.343361-4-robimarko@gmail.com \
--to=robimarko@gmail.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@somainline.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ilia.lin@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.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=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=ulfh@kernel.org \
--cc=viresh.kumar@linaro.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