#ifndef _LINUX_CPUFREQ_H
#define _LINUX_CPUFREQ_H
#include <linux/clk.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/completion.h>
#include <linux/kobject.h>
#include <linux/notifier.h>
#include <linux/of.h>
#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
#include <linux/minmax.h>
#define CPUFREQ_ETERNAL …
#define CPUFREQ_NAME_LEN …
#define CPUFREQ_NAME_PLEN …
struct cpufreq_governor;
enum cpufreq_table_sorting { … };
struct cpufreq_cpuinfo { … };
struct cpufreq_policy { … };
struct cpufreq_policy_data { … };
struct cpufreq_freqs { … };
#define CPUFREQ_SHARED_TYPE_NONE …
#define CPUFREQ_SHARED_TYPE_HW …
#define CPUFREQ_SHARED_TYPE_ALL …
#define CPUFREQ_SHARED_TYPE_ANY …
#ifdef CONFIG_CPU_FREQ
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
void cpufreq_cpu_put(struct cpufreq_policy *policy);
#else
static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
{
return NULL;
}
static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
{
return NULL;
}
static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { }
#endif
static inline bool policy_is_inactive(struct cpufreq_policy *policy)
{ … }
static inline bool policy_is_shared(struct cpufreq_policy *policy)
{ … }
#ifdef CONFIG_CPU_FREQ
unsigned int cpufreq_get(unsigned int cpu);
unsigned int cpufreq_quick_get(unsigned int cpu);
unsigned int cpufreq_quick_get_max(unsigned int cpu);
unsigned int cpufreq_get_hw_max_freq(unsigned int cpu);
void disable_cpufreq(void);
u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
struct cpufreq_policy *cpufreq_cpu_acquire(unsigned int cpu);
void cpufreq_cpu_release(struct cpufreq_policy *policy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
void refresh_frequency_limits(struct cpufreq_policy *policy);
void cpufreq_update_policy(unsigned int cpu);
void cpufreq_update_limits(unsigned int cpu);
bool have_governor_per_policy(void);
bool cpufreq_supports_freq_invariance(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
bool has_target_index(void);
DECLARE_PER_CPU(unsigned long, cpufreq_pressure);
static inline unsigned long cpufreq_get_pressure(int cpu)
{ … }
#else
static inline unsigned int cpufreq_get(unsigned int cpu)
{
return 0;
}
static inline unsigned int cpufreq_quick_get(unsigned int cpu)
{
return 0;
}
static inline unsigned int cpufreq_quick_get_max(unsigned int cpu)
{
return 0;
}
static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu)
{
return 0;
}
static inline bool cpufreq_supports_freq_invariance(void)
{
return false;
}
static inline void disable_cpufreq(void) { }
static inline void cpufreq_update_limits(unsigned int cpu) { }
static inline unsigned long cpufreq_get_pressure(int cpu)
{
return 0;
}
#endif
#ifdef CONFIG_CPU_FREQ_STAT
void cpufreq_stats_create_table(struct cpufreq_policy *policy);
void cpufreq_stats_free_table(struct cpufreq_policy *policy);
void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
unsigned int new_freq);
#else
static inline void cpufreq_stats_create_table(struct cpufreq_policy *policy) { }
static inline void cpufreq_stats_free_table(struct cpufreq_policy *policy) { }
static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
unsigned int new_freq) { }
#endif
#define CPUFREQ_RELATION_L …
#define CPUFREQ_RELATION_H …
#define CPUFREQ_RELATION_C …
#define CPUFREQ_RELATION_E …
#define CPUFREQ_RELATION_LE …
#define CPUFREQ_RELATION_HE …
#define CPUFREQ_RELATION_CE …
struct freq_attr { … };
#define cpufreq_freq_attr_ro(_name) …
#define cpufreq_freq_attr_ro_perm(_name, _perm) …
#define cpufreq_freq_attr_rw(_name) …
#define cpufreq_freq_attr_wo(_name) …
#define define_one_global_ro(_name) …
#define define_one_global_rw(_name) …
struct cpufreq_driver { … };
#define CPUFREQ_NEED_UPDATE_LIMITS …
#define CPUFREQ_CONST_LOOPS …
#define CPUFREQ_IS_COOLING_DEV …
#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY …
#define CPUFREQ_ASYNC_NOTIFICATION …
#define CPUFREQ_NEED_INITIAL_FREQ_CHECK …
#define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING …
int cpufreq_register_driver(struct cpufreq_driver *driver_data);
void cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
bool cpufreq_driver_test_flags(u16 flags);
const char *cpufreq_get_current_driver(void);
void *cpufreq_get_driver_data(void);
static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv)
{ … }
static inline void cpufreq_verify_within_limits(struct cpufreq_policy_data *policy,
unsigned int min,
unsigned int max)
{ … }
static inline void
cpufreq_verify_within_cpu_limits(struct cpufreq_policy_data *policy)
{ … }
#ifdef CONFIG_CPU_FREQ
void cpufreq_suspend(void);
void cpufreq_resume(void);
int cpufreq_generic_suspend(struct cpufreq_policy *policy);
#else
static inline void cpufreq_suspend(void) {}
static inline void cpufreq_resume(void) {}
#endif
#define CPUFREQ_TRANSITION_NOTIFIER …
#define CPUFREQ_POLICY_NOTIFIER …
#define CPUFREQ_PRECHANGE …
#define CPUFREQ_POSTCHANGE …
#define CPUFREQ_CREATE_POLICY …
#define CPUFREQ_REMOVE_POLICY …
#ifdef CONFIG_CPU_FREQ
int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
void cpufreq_freq_transition_begin(struct cpufreq_policy *policy,
struct cpufreq_freqs *freqs);
void cpufreq_freq_transition_end(struct cpufreq_policy *policy,
struct cpufreq_freqs *freqs, int transition_failed);
#else
static inline int cpufreq_register_notifier(struct notifier_block *nb,
unsigned int list)
{
return 0;
}
static inline int cpufreq_unregister_notifier(struct notifier_block *nb,
unsigned int list)
{
return 0;
}
#endif
static inline unsigned long cpufreq_scale(unsigned long old, u_int div,
u_int mult)
{ … }
#define CPUFREQ_POLICY_UNKNOWN …
#define CPUFREQ_POLICY_POWERSAVE …
#define CPUFREQ_POLICY_PERFORMANCE …
struct cpufreq_governor { … };
#define CPUFREQ_GOV_DYNAMIC_SWITCHING …
#define CPUFREQ_GOV_STRICT_TARGET …
unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq);
void cpufreq_driver_adjust_perf(unsigned int cpu,
unsigned long min_perf,
unsigned long target_perf,
unsigned long capacity);
bool cpufreq_driver_has_adjust_perf(void);
int cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
unsigned int target_freq);
unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy);
int cpufreq_register_governor(struct cpufreq_governor *governor);
void cpufreq_unregister_governor(struct cpufreq_governor *governor);
int cpufreq_start_governor(struct cpufreq_policy *policy);
void cpufreq_stop_governor(struct cpufreq_policy *policy);
#define cpufreq_governor_init(__governor) …
#define cpufreq_governor_exit(__governor) …
struct cpufreq_governor *cpufreq_default_governor(void);
struct cpufreq_governor *cpufreq_fallback_governor(void);
static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
{ … }
struct gov_attr_set { … };
extern const struct sysfs_ops governor_sysfs_ops;
static inline struct gov_attr_set *to_gov_attr_set(struct kobject *kobj)
{ … }
void gov_attr_set_init(struct gov_attr_set *attr_set, struct list_head *list_node);
void gov_attr_set_get(struct gov_attr_set *attr_set, struct list_head *list_node);
unsigned int gov_attr_set_put(struct gov_attr_set *attr_set, struct list_head *list_node);
struct governor_attr { … };
#define CPUFREQ_ENTRY_INVALID …
#define CPUFREQ_TABLE_END …
#define CPUFREQ_BOOST_FREQ …
#define CPUFREQ_INEFFICIENT_FREQ …
struct cpufreq_frequency_table { … };
#define cpufreq_for_each_entry(pos, table) …
#define cpufreq_for_each_entry_idx(pos, table, idx) …
#define cpufreq_for_each_valid_entry(pos, table) …
#define cpufreq_for_each_valid_entry_idx(pos, table, idx) …
#define cpufreq_for_each_efficient_entry_idx(pos, table, idx, efficiencies) …
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table);
int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
struct cpufreq_frequency_table *table);
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy);
int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
unsigned int freq);
ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
#ifdef CONFIG_CPU_FREQ
int cpufreq_boost_trigger_state(int state);
bool cpufreq_boost_enabled(void);
int cpufreq_enable_boost_support(void);
bool policy_has_boost_freq(struct cpufreq_policy *policy);
static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_l(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_ah(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_h(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_ac(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline int cpufreq_table_find_index_c(struct cpufreq_policy *policy,
unsigned int target_freq,
bool efficiencies)
{ … }
static inline bool cpufreq_is_in_limits(struct cpufreq_policy *policy, int idx)
{ … }
static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{ … }
static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy *policy)
{ … }
static inline int
cpufreq_table_set_inefficient(struct cpufreq_policy *policy,
unsigned int frequency)
{ … }
static inline int parse_perf_domain(int cpu, const char *list_name,
const char *cell_name,
struct of_phandle_args *args)
{ … }
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
const char *cell_name, struct cpumask *cpumask,
struct of_phandle_args *pargs)
{ … }
#else
static inline int cpufreq_boost_trigger_state(int state)
{
return 0;
}
static inline bool cpufreq_boost_enabled(void)
{
return false;
}
static inline int cpufreq_enable_boost_support(void)
{
return -EINVAL;
}
static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
{
return false;
}
static inline int
cpufreq_table_set_inefficient(struct cpufreq_policy *policy,
unsigned int frequency)
{
return -EINVAL;
}
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
const char *cell_name, struct cpumask *cpumask,
struct of_phandle_args *pargs)
{
return -EOPNOTSUPP;
}
#endif
extern unsigned int arch_freq_get_on_cpu(int cpu);
#ifndef arch_set_freq_scale
static __always_inline
void arch_set_freq_scale(const struct cpumask *cpus,
unsigned long cur_freq,
unsigned long max_freq)
{ … }
#endif
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
extern struct freq_attr *cpufreq_generic_attr[];
int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy);
unsigned int cpufreq_generic_get(unsigned int cpu);
void cpufreq_generic_init(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table,
unsigned int transition_latency);
static inline void cpufreq_register_em_with_opp(struct cpufreq_policy *policy)
{ … }
#endif