Lines Matching +full:cluster +full:- +full:cpufreq

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Apple SoC CPU cluster performance state driver
7 * Based on scpi-cpufreq.c
13 #include <linux/cpufreq.h>
90 .compatible = "apple,t8103-cluster-cpufreq",
94 .compatible = "apple,t8112-cluster-cpufreq",
98 .compatible = "apple,cluster-cpufreq",
107 struct apple_cpu_priv *priv = policy->driver_data; in apple_soc_cpufreq_get_rate()
111 if (priv->info->cur_pstate_mask) { in apple_soc_cpufreq_get_rate()
112 u64 reg = readq_relaxed(priv->reg_base + APPLE_DVFS_STATUS); in apple_soc_cpufreq_get_rate()
114 pstate = (reg & priv->info->cur_pstate_mask) >> priv->info->cur_pstate_shift; in apple_soc_cpufreq_get_rate()
120 u64 reg = readq_relaxed(priv->reg_base + APPLE_DVFS_CMD); in apple_soc_cpufreq_get_rate()
125 cpufreq_for_each_valid_entry(p, policy->freq_table) in apple_soc_cpufreq_get_rate()
126 if (p->driver_data == pstate) in apple_soc_cpufreq_get_rate()
127 return p->frequency; in apple_soc_cpufreq_get_rate()
129 dev_err(priv->cpu_dev, "could not find frequency for pstate %d\n", in apple_soc_cpufreq_get_rate()
137 struct apple_cpu_priv *priv = policy->driver_data; in apple_soc_cpufreq_set_target()
138 unsigned int pstate = policy->freq_table[index].driver_data; in apple_soc_cpufreq_set_target()
142 if (index > priv->info->max_pstate) in apple_soc_cpufreq_set_target()
143 index = priv->info->max_pstate; in apple_soc_cpufreq_set_target()
145 if (readq_poll_timeout_atomic(priv->reg_base + APPLE_DVFS_CMD, reg, in apple_soc_cpufreq_set_target()
148 return -EIO; in apple_soc_cpufreq_set_target()
156 writeq_relaxed(reg, priv->reg_base + APPLE_DVFS_CMD); in apple_soc_cpufreq_set_target()
164 if (apple_soc_cpufreq_set_target(policy, policy->cached_resolved_idx) < 0) in apple_soc_cpufreq_fast_switch()
167 return policy->freq_table[policy->cached_resolved_idx].frequency; in apple_soc_cpufreq_fast_switch()
178 ret = of_perf_domain_get_sharing_cpumask(policy->cpu, "performance-domains", in apple_soc_cpufreq_find_cluster()
179 "#performance-domain-cells", in apple_soc_cpufreq_find_cluster()
180 policy->cpus, &args); in apple_soc_cpufreq_find_cluster()
187 return -ENODEV; in apple_soc_cpufreq_find_cluster()
189 *info = match->data; in apple_soc_cpufreq_find_cluster()
193 return -ENOMEM; in apple_soc_cpufreq_find_cluster()
214 cpu_dev = get_cpu_device(policy->cpu); in apple_soc_cpufreq_init()
216 pr_err("failed to get cpu%d device\n", policy->cpu); in apple_soc_cpufreq_init()
217 return -ENODEV; in apple_soc_cpufreq_init()
228 dev_err(cpu_dev, "%s: failed to get cluster info: %d\n", __func__, ret); in apple_soc_cpufreq_init()
232 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); in apple_soc_cpufreq_init()
241 ret = -EPROBE_DEFER; in apple_soc_cpufreq_init()
247 ret = -ENOMEM; in apple_soc_cpufreq_init()
253 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret); in apple_soc_cpufreq_init()
257 /* Get OPP levels (p-state indexes) and stash them in driver_data */ in apple_soc_cpufreq_init()
270 priv->cpu_dev = cpu_dev; in apple_soc_cpufreq_init()
271 priv->reg_base = reg_base; in apple_soc_cpufreq_init()
272 priv->info = info; in apple_soc_cpufreq_init()
273 policy->driver_data = priv; in apple_soc_cpufreq_init()
274 policy->freq_table = freq_table; in apple_soc_cpufreq_init()
280 policy->cpuinfo.transition_latency = transition_latency; in apple_soc_cpufreq_init()
281 policy->dvfs_possible_from_any_cpu = true; in apple_soc_cpufreq_init()
282 policy->fast_switch_possible = true; in apple_soc_cpufreq_init()
283 policy->suspend_freq = freq_table[0].frequency; in apple_soc_cpufreq_init()
310 struct apple_cpu_priv *priv = policy->driver_data; in apple_soc_cpufreq_exit()
312 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); in apple_soc_cpufreq_exit()
313 dev_pm_opp_remove_all_dynamic(priv->cpu_dev); in apple_soc_cpufreq_exit()
314 iounmap(priv->reg_base); in apple_soc_cpufreq_exit()
319 .name = "apple-cpufreq",
335 if (!of_machine_is_compatible("apple,arm-platform")) in apple_soc_cpufreq_module_init()
336 return -ENODEV; in apple_soc_cpufreq_module_init()
350 MODULE_DESCRIPTION("Apple SoC CPU cluster DVFS driver");