Lines Matching +full:max +full:- +full:by +full:- +full:define
1 /* SPDX-License-Identifier: GPL-2.0-only */
6 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
9 #define _LINUX_CPUFREQ_H
26 * Maximum transition latency is in nanoseconds - if it's unknown,
30 #define CPUFREQ_ETERNAL (-1)
31 #define CPUFREQ_NAME_LEN 16
33 #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)
47 /* in 10^(-9) s = nanoseconds */
65 unsigned int max; /* in kHz */ member
68 unsigned int restore_freq; /* = policy->cur before transition */
93 * - Any routine that wants to read from the policy structure will
95 * - Any routine that will write to the policy structure and/or may take away
103 * - fast_switch_possible should be set by the driver if it can
106 * - fast_switch_enabled is to be set by governors that support fast
120 * the driver to set the frequency for this policy. To be set by the
144 /* cpufreq-stats */
158 * Used for passing new cpufreq policy data to the cpufreq driver's ->verify()
160 * and max values, if necessary, and specifically it must not update the
168 unsigned int max; /* in kHz */ member
179 #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
180 #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
181 #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
182 #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
202 return cpumask_empty(policy->cpus); in policy_is_inactive()
207 return cpumask_weight(policy->cpus) > 1; in policy_is_shared()
270 #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
271 #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
272 #define CPUFREQ_RELATION_C 2 /* closest frequency to target */
280 #define cpufreq_freq_attr_ro(_name) \
284 #define cpufreq_freq_attr_ro_perm(_name, _perm) \
288 #define cpufreq_freq_attr_rw(_name) \
292 #define cpufreq_freq_attr_wo(_name) \
296 #define define_one_global_ro(_name) \
300 #define define_one_global_rw(_name) \
310 /* needed by all drivers */
314 /* define one out of two */
318 * On failure, should always restore frequency to policy->restore_freq
330 * Caches and returns the lowest driver-supported frequency greater than
351 * In that case core will directly call ->target_index().
386 /* driver isn't removed even if all ->init() calls failed */
387 #define CPUFREQ_STICKY BIT(0)
389 /* loops_per_jiffy or other kernel "constants" aren't affected by frequency transitions */
390 #define CPUFREQ_CONST_LOOPS BIT(1)
393 #define CPUFREQ_PM_NO_WARN BIT(2)
396 * This should be set by platforms having multiple clock-domains, i.e.
401 #define CPUFREQ_HAVE_GOVERNOR_PER_POLICY BIT(3)
404 * Driver will do POSTCHANGE notifications from outside of their ->target()
405 * routine and so must set cpufreq_driver->flags with this flag, so that core
408 #define CPUFREQ_ASYNC_NOTIFICATION BIT(4)
411 * Set by drivers which want cpufreq core to check if CPU is running at a
412 * frequency present in freq-table exposed by the driver. For these drivers if
414 * from the table. And if that fails, we will stop further boot process by
417 #define CPUFREQ_NEED_INITIAL_FREQ_CHECK BIT(5)
420 * Set by drivers to disallow use of governors with "dynamic_switching" flag
423 #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING BIT(6)
426 * Set by drivers that want the core to automatically register the cpufreq
429 #define CPUFREQ_IS_COOLING_DEV BIT(7)
432 * Set by drivers that need to update internale upper and lower boundaries along
434 * the diver if the target frequency does not change, but the policy min or max
437 #define CPUFREQ_NEED_UPDATE_LIMITS BIT(8)
449 (drv->flags & CPUFREQ_IS_COOLING_DEV); in cpufreq_thermal_control_enabled()
454 unsigned int max) in cpufreq_verify_within_limits() argument
456 if (policy->min < min) in cpufreq_verify_within_limits()
457 policy->min = min; in cpufreq_verify_within_limits()
458 if (policy->max < min) in cpufreq_verify_within_limits()
459 policy->max = min; in cpufreq_verify_within_limits()
460 if (policy->min > max) in cpufreq_verify_within_limits()
461 policy->min = max; in cpufreq_verify_within_limits()
462 if (policy->max > max) in cpufreq_verify_within_limits()
463 policy->max = max; in cpufreq_verify_within_limits()
464 if (policy->min > policy->max) in cpufreq_verify_within_limits()
465 policy->min = policy->max; in cpufreq_verify_within_limits()
472 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, in cpufreq_verify_within_cpu_limits()
473 policy->cpuinfo.max_freq); in cpufreq_verify_within_cpu_limits()
489 #define CPUFREQ_TRANSITION_NOTIFIER (0)
490 #define CPUFREQ_POLICY_NOTIFIER (1)
493 #define CPUFREQ_PRECHANGE (0)
494 #define CPUFREQ_POSTCHANGE (1)
497 #define CPUFREQ_CREATE_POLICY (0)
498 #define CPUFREQ_REMOVE_POLICY (1)
523 * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch
551 #define CPUFREQ_POLICY_UNKNOWN (0)
553 * If (cpufreq_driver->target) exists, the ->governor decides what frequency
554 * within the limits is used. If (cpufreq_driver->setpolicy> exists, these
557 #define CPUFREQ_POLICY_POWERSAVE (1)
558 #define CPUFREQ_POLICY_PERFORMANCE (2)
566 #define LATENCY_MULTIPLIER (1000)
586 /* For governors which change frequency dynamically by themselves */
587 #define CPUFREQ_GOV_DYNAMIC_SWITCHING BIT(0)
590 #define CPUFREQ_GOV_STRICT_TARGET BIT(1)
610 #define cpufreq_governor_init(__governor) \
617 #define cpufreq_governor_exit(__governor) \
629 if (policy->max < policy->cur) in cpufreq_policy_apply_limits()
630 __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); in cpufreq_policy_apply_limits()
631 else if (policy->min > policy->cur) in cpufreq_policy_apply_limits()
632 __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); in cpufreq_policy_apply_limits()
663 #define CPUFREQ_ENTRY_INVALID ~0u
664 #define CPUFREQ_TABLE_END ~1u
666 #define CPUFREQ_BOOST_FREQ (1 << 0)
670 unsigned int driver_data; /* driver specific data, not used by core */
671 unsigned int frequency; /* kHz - doesn't need to be in ascending
685 return -EINVAL; in dev_pm_opp_init_cpufreq_table()
696 * cpufreq_for_each_entry - iterate over a cpufreq_frequency_table
701 #define cpufreq_for_each_entry(pos, table) \
702 for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)
705 * cpufreq_for_each_entry_idx - iterate over a cpufreq_frequency_table
712 #define cpufreq_for_each_entry_idx(pos, table, idx) \
713 for (pos = table, idx = 0; pos->frequency != CPUFREQ_TABLE_END; \
717 * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table
723 #define cpufreq_for_each_valid_entry(pos, table) \
724 for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) \
725 if (pos->frequency == CPUFREQ_ENTRY_INVALID) \
730 * cpufreq_for_each_valid_entry_idx - iterate with index over a cpufreq
737 #define cpufreq_for_each_valid_entry_idx(pos, table, idx) \
739 if (pos->frequency == CPUFREQ_ENTRY_INVALID) \
769 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_al()
772 int idx, best = -1; in cpufreq_table_find_index_al()
775 freq = pos->frequency; in cpufreq_table_find_index_al()
790 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_dl()
793 int idx, best = -1; in cpufreq_table_find_index_dl()
796 freq = pos->frequency; in cpufreq_table_find_index_dl()
807 if (best == -1) in cpufreq_table_find_index_dl()
816 /* Works only on sorted freq-tables */
820 target_freq = clamp_val(target_freq, policy->min, policy->max); in cpufreq_table_find_index_l()
822 if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING) in cpufreq_table_find_index_l()
832 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_ah()
835 int idx, best = -1; in cpufreq_table_find_index_ah()
838 freq = pos->frequency; in cpufreq_table_find_index_ah()
849 if (best == -1) in cpufreq_table_find_index_ah()
862 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_dh()
865 int idx, best = -1; in cpufreq_table_find_index_dh()
868 freq = pos->frequency; in cpufreq_table_find_index_dh()
879 /* Works only on sorted freq-tables */
883 target_freq = clamp_val(target_freq, policy->min, policy->max); in cpufreq_table_find_index_h()
885 if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING) in cpufreq_table_find_index_h()
895 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_ac()
898 int idx, best = -1; in cpufreq_table_find_index_ac()
901 freq = pos->frequency; in cpufreq_table_find_index_ac()
912 if (best == -1) in cpufreq_table_find_index_ac()
916 if (target_freq - table[best].frequency > freq - target_freq) in cpufreq_table_find_index_ac()
929 struct cpufreq_frequency_table *table = policy->freq_table; in cpufreq_table_find_index_dc()
932 int idx, best = -1; in cpufreq_table_find_index_dc()
935 freq = pos->frequency; in cpufreq_table_find_index_dc()
946 if (best == -1) in cpufreq_table_find_index_dc()
950 if (table[best].frequency - target_freq > target_freq - freq) in cpufreq_table_find_index_dc()
959 /* Works only on sorted freq-tables */
963 target_freq = clamp_val(target_freq, policy->min, policy->max); in cpufreq_table_find_index_c()
965 if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING) in cpufreq_table_find_index_c()
975 if (unlikely(policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED)) in cpufreq_frequency_table_target()
997 if (unlikely(!policy->freq_table)) in cpufreq_table_count_valid_entries()
1000 cpufreq_for_each_valid_entry(pos, policy->freq_table) in cpufreq_table_count_valid_entries()
1017 return -EINVAL; in cpufreq_enable_boost_support()