Skip to content

Commit f84ccad

Browse files
Vladimir Zapolskiyvireshk
authored andcommitted
cpufreq: qcom-cpufreq-hw: Fix throttle frequency value on EPSS platforms
On QCOM platforms with EPSS flavour of cpufreq IP a throttled frequency is obtained from another register REG_DOMAIN_STATE, thus the helper function qcom_lmh_get_throttle_freq() should be modified accordingly, as for now it returns gibberish since .reg_current_vote is unset for EPSS hardware. To exclude a hardcoded magic number 19200 it is replaced by "xo" clock rate in KHz. Fixes: 275157b ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support") Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Vladimir Zapolskiy <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent a1eb080 commit f84ccad

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
struct qcom_cpufreq_soc_data {
3030
u32 reg_enable;
31+
u32 reg_domain_state;
3132
u32 reg_dcvs_ctrl;
3233
u32 reg_freq_lut;
3334
u32 reg_volt_lut;
@@ -280,11 +281,16 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)
280281
}
281282
}
282283

283-
static unsigned int qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
284+
static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data)
284285
{
285-
unsigned int val = readl_relaxed(data->base + data->soc_data->reg_current_vote);
286+
unsigned int lval;
286287

287-
return (val & 0x3FF) * 19200;
288+
if (data->soc_data->reg_current_vote)
289+
lval = readl_relaxed(data->base + data->soc_data->reg_current_vote) & 0x3ff;
290+
else
291+
lval = readl_relaxed(data->base + data->soc_data->reg_domain_state) & 0xff;
292+
293+
return lval * xo_rate;
288294
}
289295

290296
static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
@@ -294,14 +300,12 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
294300
struct device *dev = get_cpu_device(cpu);
295301
unsigned long freq_hz, throttled_freq;
296302
struct dev_pm_opp *opp;
297-
unsigned int freq;
298303

299304
/*
300305
* Get the h/w throttled frequency, normalize it using the
301306
* registered opp table and use it to calculate thermal pressure.
302307
*/
303-
freq = qcom_lmh_get_throttle_freq(data);
304-
freq_hz = freq * HZ_PER_KHZ;
308+
freq_hz = qcom_lmh_get_throttle_freq(data);
305309

306310
opp = dev_pm_opp_find_freq_floor(dev, &freq_hz);
307311
if (IS_ERR(opp) && PTR_ERR(opp) == -ERANGE)
@@ -371,6 +375,7 @@ static const struct qcom_cpufreq_soc_data qcom_soc_data = {
371375

372376
static const struct qcom_cpufreq_soc_data epss_soc_data = {
373377
.reg_enable = 0x0,
378+
.reg_domain_state = 0x20,
374379
.reg_dcvs_ctrl = 0xb0,
375380
.reg_freq_lut = 0x100,
376381
.reg_volt_lut = 0x200,

0 commit comments

Comments
 (0)