]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: apple-soc: Add Apple A7-A8X SoC cpufreq support
authorNick Chan <towinchenmi@gmail.com>
Wed, 18 Dec 2024 18:25:09 +0000 (02:25 +0800)
committerViresh Kumar <viresh.kumar@linaro.org>
Mon, 23 Dec 2024 10:56:48 +0000 (16:26 +0530)
These SoCs only use 3 bits for p-states, and have a different
APPLE_DVFS_CMD_PS1 mask value.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/apple-soc-cpufreq.c

index 879ddec9e557d00d96eb1250fb04ccfb7d1b8966..269b18c62d040297df9832c7b3ccc6e1c096a01e 100644 (file)
 #include <linux/pm_opp.h>
 #include <linux/slab.h>
 
-#define APPLE_DVFS_CMD                 0x20
-#define APPLE_DVFS_CMD_BUSY            BIT(31)
-#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
+#define APPLE_DVFS_CMD                         0x20
+#define APPLE_DVFS_CMD_BUSY                    BIT(31)
+#define APPLE_DVFS_CMD_SET                     BIT(25)
+#define APPLE_DVFS_CMD_PS1_S5L8960X            GENMASK(24, 22)
+#define APPLE_DVFS_CMD_PS1_S5L8960X_SHIFT      22
+#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
@@ -36,6 +38,9 @@
  * Apple ran out of bits and had to shift this in T8112...
  */
 #define APPLE_DVFS_STATUS                      0x50
+#define APPLE_DVFS_STATUS_CUR_PS_S5L8960X      GENMASK(5, 3)
+#define APPLE_DVFS_STATUS_CUR_PS_SHIFT_S5L8960X        3
+#define APPLE_DVFS_STATUS_TGT_PS_S5L8960X      GENMASK(2, 0)
 #define APPLE_DVFS_STATUS_CUR_PS_T8103         GENMASK(7, 4)
 #define APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8103   4
 #define APPLE_DVFS_STATUS_TGT_PS_T8103         GENMASK(3, 0)
@@ -72,6 +77,15 @@ struct apple_cpu_priv {
 
 static struct cpufreq_driver apple_soc_cpufreq_driver;
 
+static const struct apple_soc_cpufreq_info soc_s5l8960x_info = {
+       .has_ps2 = false,
+       .max_pstate = 7,
+       .cur_pstate_mask = APPLE_DVFS_STATUS_CUR_PS_S5L8960X,
+       .cur_pstate_shift = APPLE_DVFS_STATUS_CUR_PS_SHIFT_S5L8960X,
+       .ps1_mask = APPLE_DVFS_CMD_PS1_S5L8960X,
+       .ps1_shift = APPLE_DVFS_CMD_PS1_S5L8960X_SHIFT,
+};
+
 static const struct apple_soc_cpufreq_info soc_t8103_info = {
        .has_ps2 = true,
        .max_pstate = 15,
@@ -99,6 +113,10 @@ static const struct apple_soc_cpufreq_info soc_default_info = {
 };
 
 static const struct of_device_id apple_soc_cpufreq_of_match[] __maybe_unused = {
+       {
+               .compatible = "apple,s5l8960x-cluster-cpufreq",
+               .data = &soc_s5l8960x_info,
+       },
        {
                .compatible = "apple,t8103-cluster-cpufreq",
                .data = &soc_t8103_info,