Lines Matching +full:max +full:- +full:frequency
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2002 - 2003 Dominik Brodowski
14 * FREQUENCY TABLE HELPERS *
19 struct cpufreq_frequency_table *pos, *table = policy->freq_table; in policy_has_boost_freq()
25 if (pos->flags & CPUFREQ_BOOST_FREQ) in policy_has_boost_freq()
41 freq = pos->frequency; in cpufreq_frequency_table_cpuinfo()
43 if ((!cpufreq_boost_enabled() || !policy->boost_enabled) in cpufreq_frequency_table_cpuinfo()
44 && (pos->flags & CPUFREQ_BOOST_FREQ)) in cpufreq_frequency_table_cpuinfo()
47 pr_debug("table entry %u: %u kHz\n", (int)(pos - table), freq); in cpufreq_frequency_table_cpuinfo()
54 policy->min = policy->cpuinfo.min_freq = min_freq; in cpufreq_frequency_table_cpuinfo()
55 policy->max = max_freq; in cpufreq_frequency_table_cpuinfo()
60 if (policy->cpuinfo.max_freq < max_freq) in cpufreq_frequency_table_cpuinfo()
61 policy->max = policy->cpuinfo.max_freq = max_freq; in cpufreq_frequency_table_cpuinfo()
63 if (policy->min == ~0) in cpufreq_frequency_table_cpuinfo()
64 return -EINVAL; in cpufreq_frequency_table_cpuinfo()
76 pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", in cpufreq_frequency_table_verify()
77 policy->min, policy->max, policy->cpu); in cpufreq_frequency_table_verify()
82 freq = pos->frequency; in cpufreq_frequency_table_verify()
84 if ((freq >= policy->min) && (freq <= policy->max)) { in cpufreq_frequency_table_verify()
89 if ((prev_smaller < freq) && (freq <= policy->max)) in cpufreq_frequency_table_verify()
94 policy->max = prev_smaller; in cpufreq_frequency_table_verify()
98 pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", in cpufreq_frequency_table_verify()
99 policy->min, policy->max, policy->cpu); in cpufreq_frequency_table_verify()
106 * Generic routine to verify policy & frequency table, requires driver to set
107 * policy->freq_table prior to it.
111 if (!policy->freq_table) in cpufreq_generic_frequency_table_verify()
112 return -ENODEV; in cpufreq_generic_frequency_table_verify()
114 return cpufreq_frequency_table_verify(policy, policy->freq_table); in cpufreq_generic_frequency_table_verify()
124 .frequency = 0, in cpufreq_table_index_unsorted()
128 .frequency = 0, in cpufreq_table_index_unsorted()
131 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_index_unsorted()
136 target_freq, relation, policy->cpu); in cpufreq_table_index_unsorted()
140 suboptimal.frequency = ~0; in cpufreq_table_index_unsorted()
144 optimal.frequency = ~0; in cpufreq_table_index_unsorted()
149 freq = pos->frequency; in cpufreq_table_index_unsorted()
151 if ((freq < policy->min) || (freq > policy->max)) in cpufreq_table_index_unsorted()
160 if (freq >= optimal.frequency) { in cpufreq_table_index_unsorted()
161 optimal.frequency = freq; in cpufreq_table_index_unsorted()
165 if (freq <= suboptimal.frequency) { in cpufreq_table_index_unsorted()
166 suboptimal.frequency = freq; in cpufreq_table_index_unsorted()
173 if (freq <= optimal.frequency) { in cpufreq_table_index_unsorted()
174 optimal.frequency = freq; in cpufreq_table_index_unsorted()
178 if (freq >= suboptimal.frequency) { in cpufreq_table_index_unsorted()
179 suboptimal.frequency = freq; in cpufreq_table_index_unsorted()
185 diff = abs(freq - target_freq); in cpufreq_table_index_unsorted()
186 if (diff < optimal.frequency || in cpufreq_table_index_unsorted()
187 (diff == optimal.frequency && in cpufreq_table_index_unsorted()
188 freq > table[optimal.driver_data].frequency)) { in cpufreq_table_index_unsorted()
189 optimal.frequency = diff; in cpufreq_table_index_unsorted()
197 WARN(1, "Invalid frequency table: %u\n", policy->cpu); in cpufreq_table_index_unsorted()
206 table[index].frequency); in cpufreq_table_index_unsorted()
214 struct cpufreq_frequency_table *pos, *table = policy->freq_table; in cpufreq_frequency_table_get_index()
218 pr_debug("%s: Unable to find frequency table\n", __func__); in cpufreq_frequency_table_get_index()
219 return -ENOENT; in cpufreq_frequency_table_get_index()
223 if (pos->frequency == freq) in cpufreq_frequency_table_get_index()
226 return -EINVAL; in cpufreq_frequency_table_get_index()
231 * show_available_freqs - show available frequencies for the specified CPU
237 struct cpufreq_frequency_table *pos, *table = policy->freq_table; in show_available_freqs()
240 return -ENODEV; in show_available_freqs()
249 * continue - do not display anything in show_available_freqs()
254 if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ)) in show_available_freqs()
257 count += sprintf(&buf[count], "%u ", pos->frequency); in show_available_freqs()
270 * scaling_available_frequencies_show - show available normal frequencies for
282 * scaling_boost_frequencies_show - show available boost frequencies for
301 struct cpufreq_frequency_table *pos, *table = policy->freq_table; in set_freq_table_sorted()
305 policy->freq_table_sorted = CPUFREQ_TABLE_UNSORTED; in set_freq_table_sorted()
313 if (pos->frequency == prev->frequency) { in set_freq_table_sorted()
314 pr_warn("Duplicate freq-table entries: %u\n", in set_freq_table_sorted()
315 pos->frequency); in set_freq_table_sorted()
316 return -EINVAL; in set_freq_table_sorted()
319 /* Frequency increased from prev to pos */ in set_freq_table_sorted()
320 if (pos->frequency > prev->frequency) { in set_freq_table_sorted()
321 /* But frequency was decreasing earlier */ in set_freq_table_sorted()
329 /* Frequency decreased from prev to pos */ in set_freq_table_sorted()
331 /* But frequency was increasing earlier */ in set_freq_table_sorted()
337 ascending--; in set_freq_table_sorted()
344 policy->freq_table_sorted = CPUFREQ_TABLE_SORTED_ASCENDING; in set_freq_table_sorted()
346 policy->freq_table_sorted = CPUFREQ_TABLE_SORTED_DESCENDING; in set_freq_table_sorted()
358 if (!policy->freq_table) { in cpufreq_table_validate_and_sort()
361 return -EINVAL; in cpufreq_table_validate_and_sort()
366 ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); in cpufreq_table_validate_and_sort()
374 MODULE_DESCRIPTION("CPUfreq frequency table helpers");