Lines Matching +full:opp +full:- +full:shared

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.
73 int cpu = dev->id; in find_supply_name()
76 np = of_node_get(dev->of_node); in find_supply_name()
84 pp = of_find_property(np, "cpu0-supply", NULL); in find_supply_name()
91 pp = of_find_property(np, "cpu-supply", NULL); in find_supply_name()
111 priv = cpufreq_dt_find_data(policy->cpu); in cpufreq_init()
113 pr_err("failed to find data for cpu%d\n", policy->cpu); in cpufreq_init()
114 return -ENODEV; in cpufreq_init()
116 cpu_dev = priv->cpu_dev; in cpufreq_init()
129 cpumask_copy(policy->cpus, priv->cpus); in cpufreq_init()
130 policy->driver_data = priv; in cpufreq_init()
131 policy->clk = cpu_clk; in cpufreq_init()
132 policy->freq_table = priv->freq_table; in cpufreq_init()
133 policy->suspend_freq = dev_pm_opp_get_suspend_opp_freq(cpu_dev) / 1000; in cpufreq_init()
134 policy->cpuinfo.transition_latency = transition_latency; in cpufreq_init()
135 policy->dvfs_possible_from_any_cpu = true; in cpufreq_init()
156 /* We did light-weight tear down earlier, nothing to do here */ in cpufreq_online()
163 * Preserve policy->driver_data and don't free resources on light-weight in cpufreq_offline()
171 clk_put(policy->clk); in cpufreq_exit()
186 .name = "cpufreq-dt",
205 return -EPROBE_DEFER; in dt_cpufreq_early_init()
209 return -ENOMEM; in dt_cpufreq_early_init()
211 if (!alloc_cpumask_var(&priv->cpus, GFP_KERNEL)) in dt_cpufreq_early_init()
212 return -ENOMEM; in dt_cpufreq_early_init()
214 cpumask_set_cpu(cpu, priv->cpus); in dt_cpufreq_early_init()
215 priv->cpu_dev = cpu_dev; in dt_cpufreq_early_init()
218 * OPP layer will be taking care of regulators now, but it needs to know in dt_cpufreq_early_init()
223 priv->opp_token = dev_pm_opp_set_regulators(cpu_dev, reg_name); in dt_cpufreq_early_init()
224 if (priv->opp_token < 0) { in dt_cpufreq_early_init()
225 ret = dev_err_probe(cpu_dev, priv->opp_token, in dt_cpufreq_early_init()
231 /* Get OPP-sharing information from "operating-points-v2" bindings */ in dt_cpufreq_early_init()
232 ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->cpus); in dt_cpufreq_early_init()
234 if (ret != -ENOENT) in dt_cpufreq_early_init()
238 * operating-points-v2 not supported, fallback to all CPUs share in dt_cpufreq_early_init()
239 * OPP for backward compatibility if the platform hasn't set in dt_cpufreq_early_init()
242 if (dev_pm_opp_get_sharing_cpus(cpu_dev, priv->cpus)) in dt_cpufreq_early_init()
247 * Initialize OPP tables for all priv->cpus. They will be shared by in dt_cpufreq_early_init()
248 * all CPUs which have marked their CPUs shared with OPP bindings. in dt_cpufreq_early_init()
250 * For platforms not using operating-points-v2 bindings, we do this in dt_cpufreq_early_init()
251 * before updating priv->cpus. Otherwise, we will end up creating in dt_cpufreq_early_init()
255 * it is -EPROBE_DEFER. in dt_cpufreq_early_init()
257 ret = dev_pm_opp_of_cpumask_add_table(priv->cpus); in dt_cpufreq_early_init()
259 priv->have_static_opps = true; in dt_cpufreq_early_init()
260 } else if (ret == -EPROBE_DEFER) { in dt_cpufreq_early_init()
265 * The OPP table must be initialized, statically or dynamically, by this in dt_cpufreq_early_init()
270 dev_err(cpu_dev, "OPP table can't be empty\n"); in dt_cpufreq_early_init()
271 ret = -ENODEV; in dt_cpufreq_early_init()
276 cpumask_setall(priv->cpus); in dt_cpufreq_early_init()
277 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, priv->cpus); in dt_cpufreq_early_init()
279 dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", in dt_cpufreq_early_init()
283 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &priv->freq_table); in dt_cpufreq_early_init()
289 list_add(&priv->node, &priv_list); in dt_cpufreq_early_init()
293 if (priv->have_static_opps) in dt_cpufreq_early_init()
294 dev_pm_opp_of_cpumask_remove_table(priv->cpus); in dt_cpufreq_early_init()
295 dev_pm_opp_put_regulators(priv->opp_token); in dt_cpufreq_early_init()
297 free_cpumask_var(priv->cpus); in dt_cpufreq_early_init()
306 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &priv->freq_table); in dt_cpufreq_release()
307 if (priv->have_static_opps) in dt_cpufreq_release()
308 dev_pm_opp_of_cpumask_remove_table(priv->cpus); in dt_cpufreq_release()
309 dev_pm_opp_put_regulators(priv->opp_token); in dt_cpufreq_release()
310 free_cpumask_var(priv->cpus); in dt_cpufreq_release()
311 list_del(&priv->node); in dt_cpufreq_release()
317 struct cpufreq_dt_platform_data *data = dev_get_platdata(&pdev->dev); in dt_cpufreq_probe()
320 /* Request resources early so we can return in case of -EPROBE_DEFER */ in dt_cpufreq_probe()
322 ret = dt_cpufreq_early_init(&pdev->dev, cpu); in dt_cpufreq_probe()
328 if (data->have_governor_per_policy) in dt_cpufreq_probe()
331 dt_cpufreq_driver.resume = data->resume; in dt_cpufreq_probe()
332 if (data->suspend) in dt_cpufreq_probe()
333 dt_cpufreq_driver.suspend = data->suspend; in dt_cpufreq_probe()
334 if (data->get_intermediate) { in dt_cpufreq_probe()
335 dt_cpufreq_driver.target_intermediate = data->target_intermediate; in dt_cpufreq_probe()
336 dt_cpufreq_driver.get_intermediate = data->get_intermediate; in dt_cpufreq_probe()
342 dev_err(&pdev->dev, "failed register driver: %d\n", ret); in dt_cpufreq_probe()
361 .name = "cpufreq-dt",
368 MODULE_ALIAS("platform:cpufreq-dt");