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

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2018-2021 ARM Ltd.
11 #include <linux/clk-provider.h>
37 struct scmi_data *priv = policy->driver_data; in scmi_cpufreq_get_rate()
41 ret = perf_ops->freq_get(ph, priv->domain_id, &rate, false); in scmi_cpufreq_get_rate()
48 * perf_ops->freq_set is not a synchronous, the actual OPP change will
55 struct scmi_data *priv = policy->driver_data; in scmi_cpufreq_set_target()
56 u64 freq = policy->freq_table[index].frequency; in scmi_cpufreq_set_target()
58 return perf_ops->freq_set(ph, priv->domain_id, freq * 1000, false); in scmi_cpufreq_set_target()
64 struct scmi_data *priv = policy->driver_data; in scmi_cpufreq_fast_switch()
66 if (!perf_ops->freq_set(ph, priv->domain_id, in scmi_cpufreq_fast_switch()
79 domain = perf_ops->device_domain_id(cpu_dev); in scmi_get_sharing_cpus()
84 if (cpu == cpu_dev->id) in scmi_get_sharing_cpus()
91 tdomain = perf_ops->device_domain_id(tcpu_dev); in scmi_get_sharing_cpus()
103 enum scmi_power_scale power_scale = perf_ops->power_scale_get(ph); in scmi_get_cpu_power()
107 domain = perf_ops->device_domain_id(cpu_dev); in scmi_get_cpu_power()
113 ret = perf_ops->est_power_get(ph, domain, &Hz, power); in scmi_get_cpu_power()
135 cpu_dev = get_cpu_device(policy->cpu); in scmi_cpufreq_init()
137 pr_err("failed to get cpu%d device\n", policy->cpu); in scmi_cpufreq_init()
138 return -ENODEV; in scmi_cpufreq_init()
143 return -ENOMEM; in scmi_cpufreq_init()
145 if (!zalloc_cpumask_var(&priv->opp_shared_cpus, GFP_KERNEL)) { in scmi_cpufreq_init()
146 ret = -ENOMEM; in scmi_cpufreq_init()
151 ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus); in scmi_cpufreq_init()
159 * The OPP 'sharing cpus' info may come from DT through an empty opp in scmi_cpufreq_init()
160 * table and opp-shared. in scmi_cpufreq_init()
162 ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus); in scmi_cpufreq_init()
163 if (ret || cpumask_empty(priv->opp_shared_cpus)) { in scmi_cpufreq_init()
165 * Either opp-table is not set or no opp-shared was found. in scmi_cpufreq_init()
166 * Use the CPU mask from SCMI to designate CPUs sharing an OPP in scmi_cpufreq_init()
169 cpumask_copy(priv->opp_shared_cpus, policy->cpus); in scmi_cpufreq_init()
173 * A previous CPU may have marked OPPs as shared for a few CPUs, based on in scmi_cpufreq_init()
174 * what OPP core provided. If the current CPU is part of those few, then in scmi_cpufreq_init()
179 ret = perf_ops->device_opps_add(ph, cpu_dev); in scmi_cpufreq_init()
190 ret = -ENODEV; in scmi_cpufreq_init()
194 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, priv->opp_shared_cpus); in scmi_cpufreq_init()
196 dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", in scmi_cpufreq_init()
202 priv->nr_opp = nr_opp; in scmi_cpufreq_init()
211 priv->cpu_dev = cpu_dev; in scmi_cpufreq_init()
212 priv->domain_id = perf_ops->device_domain_id(cpu_dev); in scmi_cpufreq_init()
214 policy->driver_data = priv; in scmi_cpufreq_init()
215 policy->freq_table = freq_table; in scmi_cpufreq_init()
218 policy->dvfs_possible_from_any_cpu = true; in scmi_cpufreq_init()
220 latency = perf_ops->transition_latency_get(ph, cpu_dev); in scmi_cpufreq_init()
224 policy->cpuinfo.transition_latency = latency; in scmi_cpufreq_init()
226 policy->fast_switch_possible = in scmi_cpufreq_init()
227 perf_ops->fast_switch_possible(ph, cpu_dev); in scmi_cpufreq_init()
235 free_cpumask_var(priv->opp_shared_cpus); in scmi_cpufreq_init()
245 struct scmi_data *priv = policy->driver_data; in scmi_cpufreq_exit()
247 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); in scmi_cpufreq_exit()
248 dev_pm_opp_remove_all_dynamic(priv->cpu_dev); in scmi_cpufreq_exit()
249 free_cpumask_var(priv->opp_shared_cpus); in scmi_cpufreq_exit()
258 enum scmi_power_scale power_scale = perf_ops->power_scale_get(ph); in scmi_cpufreq_register_em()
259 struct scmi_data *priv = policy->driver_data; in scmi_cpufreq_register_em()
265 * policy, some CPUs may still share their perf-domains, and a CPU from in scmi_cpufreq_register_em()
269 if (!priv->nr_opp) in scmi_cpufreq_register_em()
276 em_dev_register_perf_domain(get_cpu_device(policy->cpu), priv->nr_opp, in scmi_cpufreq_register_em()
277 &em_cb, priv->opp_shared_cpus, in scmi_cpufreq_register_em()
299 struct device *dev = &sdev->dev; in scmi_cpufreq_probe()
302 handle = sdev->handle; in scmi_cpufreq_probe()
305 return -ENODEV; in scmi_cpufreq_probe()
307 perf_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PERF, &ph); in scmi_cpufreq_probe()
312 /* dummy clock provider as needed by OPP if clocks property is used */ in scmi_cpufreq_probe()
313 if (of_find_property(dev->of_node, "#clock-cells", NULL)) in scmi_cpufreq_probe()
338 .name = "scmi-cpufreq",