Lines Matching +full:opp +full:- +full:table

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Generic OPP helper interface for CPU device
5 * Copyright (C) 2009-2014 Texas Instruments Incorporated.
20 #include "opp.h"
25 * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device
27 * @table: Cpufreq table returned back to caller
29 * Generate a cpufreq table for a provided device- this assumes that the
30 * opp table is already initialized and ready for usage.
32 * This function allocates required memory for the cpufreq table. It is
34 * the table as required.
36 * Returns -EINVAL for bad pointers, -ENODEV if the device is not found, -ENOMEM
37 * if no memory available for the operation (table is not populated), returns 0
38 * if successful and table is populated.
41 * the table if any of the mentioned functions have been invoked in the interim.
46 struct dev_pm_opp *opp; in dev_pm_opp_init_cpufreq_table() local
53 return max_opps ? max_opps : -ENODATA; in dev_pm_opp_init_cpufreq_table()
57 return -ENOMEM; in dev_pm_opp_init_cpufreq_table()
61 opp = dev_pm_opp_find_freq_ceil(dev, &rate); in dev_pm_opp_init_cpufreq_table()
62 if (IS_ERR(opp)) { in dev_pm_opp_init_cpufreq_table()
63 ret = PTR_ERR(opp); in dev_pm_opp_init_cpufreq_table()
69 /* Is Boost/turbo opp ? */ in dev_pm_opp_init_cpufreq_table()
70 if (dev_pm_opp_is_turbo(opp)) in dev_pm_opp_init_cpufreq_table()
73 dev_pm_opp_put(opp); in dev_pm_opp_init_cpufreq_table()
90 * dev_pm_opp_free_cpufreq_table() - free the cpufreq table
92 * @table: table to free
94 * Free up the table allocated by dev_pm_opp_init_cpufreq_table
132 * dev_pm_opp_cpumask_remove_table() - Removes OPP table for @cpumask
133 * @cpumask: cpumask for which OPP table needs to be removed
135 * This removes the OPP tables for CPUs present in the @cpumask.
141 _dev_pm_opp_cpumask_remove_table(cpumask, -1); in dev_pm_opp_cpumask_remove_table()
146 * dev_pm_opp_set_sharing_cpus() - Mark OPP table as shared by few CPUs
148 * @cpumask: cpumask of the CPUs which share the OPP table with @cpu_dev
150 * This marks OPP table of the @cpu_dev as shared by the CPUs present in
153 * Returns -ENODEV if OPP table isn't already present.
168 if (cpu == cpu_dev->id) in dev_pm_opp_set_sharing_cpus()
180 dev_err(dev, "%s: failed to add opp-dev for cpu%d device\n", in dev_pm_opp_set_sharing_cpus()
185 /* Mark opp-table as multiple CPUs are sharing it now */ in dev_pm_opp_set_sharing_cpus()
186 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; in dev_pm_opp_set_sharing_cpus()
196 * dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev
202 * Returns -ENODEV if OPP table isn't already present and -EINVAL if the OPP
203 * table's status is access-unknown.
215 if (opp_table->shared_opp == OPP_TABLE_ACCESS_UNKNOWN) { in dev_pm_opp_get_sharing_cpus()
216 ret = -EINVAL; in dev_pm_opp_get_sharing_cpus()
222 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) { in dev_pm_opp_get_sharing_cpus()
223 mutex_lock(&opp_table->lock); in dev_pm_opp_get_sharing_cpus()
224 list_for_each_entry(opp_dev, &opp_table->dev_list, node) in dev_pm_opp_get_sharing_cpus()
225 cpumask_set_cpu(opp_dev->dev->id, cpumask); in dev_pm_opp_get_sharing_cpus()
226 mutex_unlock(&opp_table->lock); in dev_pm_opp_get_sharing_cpus()
228 cpumask_set_cpu(cpu_dev->id, cpumask); in dev_pm_opp_get_sharing_cpus()