Skip to content

Commit 0755a93

Browse files
asdfugilvireshk
authored andcommitted
cpufreq: apple-soc: Allow per-SoC configuration of APPLE_DVFS_CMD_PS1
Support for SoC that has a different APPLE_DVFS_CMD_PS1 will be added soon, so modify the driver first to allow it to be configured per-SoC. Signed-off-by: Nick Chan <towinchenmi@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 4a06c25 commit 0755a93

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/cpufreq/apple-soc-cpufreq.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define APPLE_DVFS_CMD_SET BIT(25)
2828
#define APPLE_DVFS_CMD_PS2 GENMASK(15, 12)
2929
#define APPLE_DVFS_CMD_PS1 GENMASK(4, 0)
30+
#define APPLE_DVFS_CMD_PS1_SHIFT 0
3031

3132
/* Same timebase as CPU counter (24MHz) */
3233
#define APPLE_DVFS_LAST_CHG_TIME 0x38
@@ -59,6 +60,8 @@ struct apple_soc_cpufreq_info {
5960
u64 max_pstate;
6061
u64 cur_pstate_mask;
6162
u64 cur_pstate_shift;
63+
u64 ps1_mask;
64+
u64 ps1_shift;
6265
};
6366

6467
struct apple_cpu_priv {
@@ -74,19 +77,25 @@ static const struct apple_soc_cpufreq_info soc_t8103_info = {
7477
.max_pstate = 15,
7578
.cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8103,
7679
.cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8103,
80+
.ps1_mask = APPLE_DVFS_CMD_PS1,
81+
.ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
7782
};
7883

7984
static const struct apple_soc_cpufreq_info soc_t8112_info = {
8085
.has_ps2 = false,
8186
.max_pstate = 31,
8287
.cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8112,
8388
.cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8112,
89+
.ps1_mask = APPLE_DVFS_CMD_PS1,
90+
.ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
8491
};
8592

8693
static const struct apple_soc_cpufreq_info soc_default_info = {
8794
.has_ps2 = false,
8895
.max_pstate = 15,
8996
.cur_pstate_mask = 0, /* fallback */
97+
.ps1_mask = APPLE_DVFS_CMD_PS1,
98+
.ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
9099
};
91100

92101
static const struct of_device_id apple_soc_cpufreq_of_match[] __maybe_unused = {
@@ -152,8 +161,8 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy,
152161
return -EIO;
153162
}
154163

155-
reg &= ~APPLE_DVFS_CMD_PS1;
156-
reg |= FIELD_PREP(APPLE_DVFS_CMD_PS1, pstate);
164+
reg &= ~priv->info->ps1_mask;
165+
reg |= pstate << priv->info->ps1_shift;
157166
if (priv->info->has_ps2) {
158167
reg &= ~APPLE_DVFS_CMD_PS2;
159168
reg |= FIELD_PREP(APPLE_DVFS_CMD_PS2, pstate);

0 commit comments

Comments
 (0)