]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: apple-soc: Allow per-SoC configuration of APPLE_DVFS_CMD_PS1
authorNick Chan <towinchenmi@gmail.com>
Wed, 18 Dec 2024 18:25:05 +0000 (02:25 +0800)
committerViresh Kumar <viresh.kumar@linaro.org>
Mon, 23 Dec 2024 10:56:46 +0000 (16:26 +0530)
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>
drivers/cpufreq/apple-soc-cpufreq.c

index ad6c7b8f290cacb8bf25a90faba02c00a5981465..90e34105b50bda9309ffb5e724e3b1f1102bb3f8 100644 (file)
@@ -27,6 +27,7 @@
 #define APPLE_DVFS_CMD_SET             BIT(25)
 #define APPLE_DVFS_CMD_PS2             GENMASK(15, 12)
 #define APPLE_DVFS_CMD_PS1             GENMASK(4, 0)
+#define APPLE_DVFS_CMD_PS1_SHIFT       0
 
 /* Same timebase as CPU counter (24MHz) */
 #define APPLE_DVFS_LAST_CHG_TIME       0x38
@@ -59,6 +60,8 @@ struct apple_soc_cpufreq_info {
        u64 max_pstate;
        u64 cur_pstate_mask;
        u64 cur_pstate_shift;
+       u64 ps1_mask;
+       u64 ps1_shift;
 };
 
 struct apple_cpu_priv {
@@ -74,6 +77,8 @@ static const struct apple_soc_cpufreq_info soc_t8103_info = {
        .max_pstate = 15,
        .cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8103,
        .cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8103,
+       .ps1_mask = APPLE_DVFS_CMD_PS1,
+       .ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
 };
 
 static const struct apple_soc_cpufreq_info soc_t8112_info = {
@@ -81,12 +86,16 @@ static const struct apple_soc_cpufreq_info soc_t8112_info = {
        .max_pstate = 31,
        .cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_T8112,
        .cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8112,
+       .ps1_mask = APPLE_DVFS_CMD_PS1,
+       .ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
 };
 
 static const struct apple_soc_cpufreq_info soc_default_info = {
        .has_ps2 = false,
        .max_pstate = 15,
        .cur_pstate_mask = 0, /* fallback */
+       .ps1_mask = APPLE_DVFS_CMD_PS1,
+       .ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT,
 };
 
 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,
                return -EIO;
        }
 
-       reg &= ~APPLE_DVFS_CMD_PS1;
-       reg |= FIELD_PREP(APPLE_DVFS_CMD_PS1, pstate);
+       reg &= ~priv->info->ps1_mask;
+       reg |= pstate << priv->info->ps1_shift;
        if (priv->info->has_ps2) {
                reg &= ~APPLE_DVFS_CMD_PS2;
                reg |= FIELD_PREP(APPLE_DVFS_CMD_PS2, pstate);