Lines Matching +full:opp +full:- +full:suspend

1 // SPDX-License-Identifier: GPL-2.0-only
25 #include "cpufreq-dt.h"
41 NULL, /* Extra space for boost-attr if required */
50 if (cpumask_test_cpu(cpu, priv->cpus)) in cpufreq_dt_find_data()
59 struct private_data *priv = policy->driver_data; in set_target()
60 unsigned long freq = policy->freq_table[index].frequency; in set_target()
62 return dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000); in set_target()
66 * An earlier version of opp-v1 bindings used to name the regulator
67 * "cpu0-supply", we still need to handle that for backwards compatibility.
71 struct device_node *np __free(device_node) = of_node_get(dev->of_node); in find_supply_name()
72 int cpu = dev->id; in find_supply_name()
79 if (!cpu && of_property_present(np, "cpu0-supply")) in find_supply_name()
82 if (of_property_present(np, "cpu-supply")) in find_supply_name()
97 priv = cpufreq_dt_find_data(policy->cpu); in cpufreq_init()
99 pr_err("failed to find data for cpu%d\n", policy->cpu); in cpufreq_init()
100 return -ENODEV; in cpufreq_init()
102 cpu_dev = priv->cpu_dev; in cpufreq_init()
115 cpumask_copy(policy->cpus, priv->cpus); in cpufreq_init()
116 policy->driver_data = priv; in cpufreq_init()
117 policy->clk = cpu_clk; in cpufreq_init()
118 policy->freq_table = priv->freq_table; in cpufreq_init()
119 policy->suspend_freq = dev_pm_opp_get_suspend_opp_freq(cpu_dev) / 1000; in cpufreq_init()
120 policy->cpuinfo.transition_latency = transition_latency; in cpufreq_init()
121 policy->dvfs_possible_from_any_cpu = true; in cpufreq_init()
142 /* We did light-weight tear down earlier, nothing to do here */ in cpufreq_online()
149 * Preserve policy->driver_data and don't free resources on light-weight in cpufreq_offline()
157 clk_put(policy->clk); in cpufreq_exit()
171 .name = "cpufreq-dt",
173 .suspend = cpufreq_generic_suspend,
190 return -EPROBE_DEFER; in dt_cpufreq_early_init()
194 return -ENOMEM; in dt_cpufreq_early_init()
196 if (!zalloc_cpumask_var(&priv->cpus, GFP_KERNEL)) in dt_cpufreq_early_init()
197 return -ENOMEM; in dt_cpufreq_early_init()
199 cpumask_set_cpu(cpu, priv->cpus); in dt_cpufreq_early_init()
200 priv->cpu_dev = cpu_dev; in dt_cpufreq_early_init()
203 * OPP layer will be taking care of regulators now, but it needs to know in dt_cpufreq_early_init()
208 priv->opp_token = dev_pm_opp_set_regulators(cpu_dev, reg_name); in dt_cpufreq_early_init()
209 if (priv->opp_token < 0) { in dt_cpufreq_early_init()
210 ret = dev_err_probe(cpu_dev, priv->opp_token, in dt_cpufreq_early_init()
216 /* Get OPP-sharing information from "operating-points-v2" bindings */ in dt_cpufreq_early_init()
217 ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->cpus); in dt_cpufreq_early_init()
219 if (ret != -ENOENT) in dt_cpufreq_early_init()
223 * operating-points-v2 not supported, fallback to all CPUs share in dt_cpufreq_early_init()
224 * OPP for backward compatibility if the platform hasn't set in dt_cpufreq_early_init()
227 if (dev_pm_opp_get_sharing_cpus(cpu_dev, priv->cpus)) in dt_cpufreq_early_init()
232 * Initialize OPP tables for all priv->cpus. They will be shared by in dt_cpufreq_early_init()
233 * all CPUs which have marked their CPUs shared with OPP bindings. in dt_cpufreq_early_init()
235 * For platforms not using operating-points-v2 bindings, we do this in dt_cpufreq_early_init()
236 * before updating priv->cpus. Otherwise, we will end up creating in dt_cpufreq_early_init()
240 * it is -EPROBE_DEFER. in dt_cpufreq_early_init()
242 ret = dev_pm_opp_of_cpumask_add_table(priv->cpus); in dt_cpufreq_early_init()
244 priv->have_static_opps = true; in dt_cpufreq_early_init()
245 } else if (ret == -EPROBE_DEFER) { in dt_cpufreq_early_init()
250 * The OPP table must be initialized, statically or dynamically, by this in dt_cpufreq_early_init()
255 dev_err(cpu_dev, "OPP table can't be empty\n"); in dt_cpufreq_early_init()
256 ret = -ENODEV; in dt_cpufreq_early_init()
261 cpumask_setall(priv->cpus); in dt_cpufreq_early_init()
262 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, priv->cpus); in dt_cpufreq_early_init()
268 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &priv->freq_table); in dt_cpufreq_early_init()
274 list_add(&priv->node, &priv_list); in dt_cpufreq_early_init()
278 if (priv->have_static_opps) in dt_cpufreq_early_init()
279 dev_pm_opp_of_cpumask_remove_table(priv->cpus); in dt_cpufreq_early_init()
280 dev_pm_opp_put_regulators(priv->opp_token); in dt_cpufreq_early_init()
282 free_cpumask_var(priv->cpus); in dt_cpufreq_early_init()
291 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &priv->freq_table); in dt_cpufreq_release()
292 if (priv->have_static_opps) in dt_cpufreq_release()
293 dev_pm_opp_of_cpumask_remove_table(priv->cpus); in dt_cpufreq_release()
294 dev_pm_opp_put_regulators(priv->opp_token); in dt_cpufreq_release()
295 free_cpumask_var(priv->cpus); in dt_cpufreq_release()
296 list_del(&priv->node); in dt_cpufreq_release()
302 struct cpufreq_dt_platform_data *data = dev_get_platdata(&pdev->dev); in dt_cpufreq_probe()
305 /* Request resources early so we can return in case of -EPROBE_DEFER */ in dt_cpufreq_probe()
307 ret = dt_cpufreq_early_init(&pdev->dev, cpu); in dt_cpufreq_probe()
313 if (data->have_governor_per_policy) in dt_cpufreq_probe()
316 dt_cpufreq_driver.resume = data->resume; in dt_cpufreq_probe()
317 if (data->suspend) in dt_cpufreq_probe()
318 dt_cpufreq_driver.suspend = data->suspend; in dt_cpufreq_probe()
319 if (data->get_intermediate) { in dt_cpufreq_probe()
320 dt_cpufreq_driver.target_intermediate = data->target_intermediate; in dt_cpufreq_probe()
321 dt_cpufreq_driver.get_intermediate = data->get_intermediate; in dt_cpufreq_probe()
327 dev_err(&pdev->dev, "failed register driver: %d\n", ret); in dt_cpufreq_probe()
345 .name = "cpufreq-dt",
352 MODULE_ALIAS("platform:cpufreq-dt");