Skip to content

Commit 4a06c25

Browse files
marcanvireshk
authored andcommitted
cpufreq: apple-soc: Drop setting the PS2 field on M2+
Newer device do not use this. It is not known what this field does, but change the behavior to be same as macOS to be safe. Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Nick Chan <towinchenmi@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent a248d90 commit 4a06c25

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/cpufreq/apple-soc-cpufreq.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define APPLE_DVFS_CMD 0x20
2626
#define APPLE_DVFS_CMD_BUSY BIT(31)
2727
#define APPLE_DVFS_CMD_SET BIT(25)
28-
#define APPLE_DVFS_CMD_PS2 GENMASK(16, 12)
28+
#define APPLE_DVFS_CMD_PS2 GENMASK(15, 12)
2929
#define APPLE_DVFS_CMD_PS1 GENMASK(4, 0)
3030

3131
/* Same timebase as CPU counter (24MHz) */
@@ -55,6 +55,7 @@
5555
#define APPLE_DVFS_TRANSITION_TIMEOUT 100
5656

5757
struct apple_soc_cpufreq_info {
58+
bool has_ps2;
5859
u64 max_pstate;
5960
u64 cur_pstate_mask;
6061
u64 cur_pstate_shift;
@@ -69,18 +70,21 @@ struct apple_cpu_priv {
6970
static struct cpufreq_driver apple_soc_cpufreq_driver;
7071

7172
static const struct apple_soc_cpufreq_info soc_t8103_info = {
73+
.has_ps2 = true,
7274
.max_pstate = 15,
7375
.cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8103,
7476
.cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8103,
7577
};
7678

7779
static const struct apple_soc_cpufreq_info soc_t8112_info = {
80+
.has_ps2 = false,
7881
.max_pstate = 31,
7982
.cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8112,
8083
.cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8112,
8184
};
8285

8386
static const struct apple_soc_cpufreq_info soc_default_info = {
87+
.has_ps2 = false,
8488
.max_pstate = 15,
8589
.cur_pstate_mask = 0, /* fallback */
8690
};
@@ -148,9 +152,12 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy,
148152
return -EIO;
149153
}
150154

151-
reg &= ~(APPLE_DVFS_CMD_PS1 | APPLE_DVFS_CMD_PS2);
155+
reg &= ~APPLE_DVFS_CMD_PS1;
152156
reg |= FIELD_PREP(APPLE_DVFS_CMD_PS1, pstate);
153-
reg |= FIELD_PREP(APPLE_DVFS_CMD_PS2, pstate);
157+
if (priv->info->has_ps2) {
158+
reg &= ~APPLE_DVFS_CMD_PS2;
159+
reg |= FIELD_PREP(APPLE_DVFS_CMD_PS2, pstate);
160+
}
154161
reg |= APPLE_DVFS_CMD_SET;
155162

156163
writeq_relaxed(reg, priv->reg_base + APPLE_DVFS_CMD);

0 commit comments

Comments
 (0)