]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/pm_opp.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Generic OPP Interface
5 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
11 #ifndef __LINUX_OPP_H__
12 #define __LINUX_OPP_H__
14 #include <linux/err.h>
15 #include <linux/notifier.h>
23 enum dev_pm_opp_event
{
24 OPP_EVENT_ADD
, OPP_EVENT_REMOVE
, OPP_EVENT_ENABLE
, OPP_EVENT_DISABLE
,
28 * struct dev_pm_opp_supply - Power supply voltage/current values
29 * @u_volt: Target voltage in microvolts corresponding to this OPP
30 * @u_volt_min: Minimum voltage in microvolts corresponding to this OPP
31 * @u_volt_max: Maximum voltage in microvolts corresponding to this OPP
32 * @u_amp: Maximum current drawn by the device in microamperes
34 * This structure stores the voltage/current values for a single power supply.
36 struct dev_pm_opp_supply
{
38 unsigned long u_volt_min
;
39 unsigned long u_volt_max
;
44 * struct dev_pm_opp_info - OPP freq/voltage/current values
45 * @rate: Target clk rate in hz
46 * @supplies: Array of voltage/current values for all power supplies
48 * This structure stores the freq/voltage/current values for a single OPP.
50 struct dev_pm_opp_info
{
52 struct dev_pm_opp_supply
*supplies
;
56 * struct dev_pm_set_opp_data - Set OPP data
57 * @old_opp: Old OPP info
58 * @new_opp: New OPP info
59 * @regulators: Array of regulator pointers
60 * @regulator_count: Number of regulators
61 * @clk: Pointer to clk
62 * @dev: Pointer to the struct device
64 * This structure contains all information required for setting an OPP.
66 struct dev_pm_set_opp_data
{
67 struct dev_pm_opp_info old_opp
;
68 struct dev_pm_opp_info new_opp
;
70 struct regulator
**regulators
;
71 unsigned int regulator_count
;
76 #if defined(CONFIG_PM_OPP)
78 struct opp_table
*dev_pm_opp_get_opp_table(struct device
*dev
);
79 struct opp_table
*dev_pm_opp_get_opp_table_indexed(struct device
*dev
, int index
);
80 void dev_pm_opp_put_opp_table(struct opp_table
*opp_table
);
82 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp
*opp
);
84 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp
*opp
);
86 unsigned int dev_pm_opp_get_level(struct dev_pm_opp
*opp
);
88 bool dev_pm_opp_is_turbo(struct dev_pm_opp
*opp
);
90 int dev_pm_opp_get_opp_count(struct device
*dev
);
91 unsigned long dev_pm_opp_get_max_clock_latency(struct device
*dev
);
92 unsigned long dev_pm_opp_get_max_volt_latency(struct device
*dev
);
93 unsigned long dev_pm_opp_get_max_transition_latency(struct device
*dev
);
94 unsigned long dev_pm_opp_get_suspend_opp_freq(struct device
*dev
);
96 struct dev_pm_opp
*dev_pm_opp_find_freq_exact(struct device
*dev
,
100 struct dev_pm_opp
*dev_pm_opp_find_freq_floor(struct device
*dev
,
101 unsigned long *freq
);
102 struct dev_pm_opp
*dev_pm_opp_find_freq_ceil_by_volt(struct device
*dev
,
103 unsigned long u_volt
);
105 struct dev_pm_opp
*dev_pm_opp_find_freq_ceil(struct device
*dev
,
106 unsigned long *freq
);
107 void dev_pm_opp_put(struct dev_pm_opp
*opp
);
109 int dev_pm_opp_add(struct device
*dev
, unsigned long freq
,
110 unsigned long u_volt
);
111 void dev_pm_opp_remove(struct device
*dev
, unsigned long freq
);
112 void dev_pm_opp_remove_all_dynamic(struct device
*dev
);
114 int dev_pm_opp_enable(struct device
*dev
, unsigned long freq
);
116 int dev_pm_opp_disable(struct device
*dev
, unsigned long freq
);
118 int dev_pm_opp_register_notifier(struct device
*dev
, struct notifier_block
*nb
);
119 int dev_pm_opp_unregister_notifier(struct device
*dev
, struct notifier_block
*nb
);
121 struct opp_table
*dev_pm_opp_set_supported_hw(struct device
*dev
, const u32
*versions
, unsigned int count
);
122 void dev_pm_opp_put_supported_hw(struct opp_table
*opp_table
);
123 struct opp_table
*dev_pm_opp_set_prop_name(struct device
*dev
, const char *name
);
124 void dev_pm_opp_put_prop_name(struct opp_table
*opp_table
);
125 struct opp_table
*dev_pm_opp_set_regulators(struct device
*dev
, const char * const names
[], unsigned int count
);
126 void dev_pm_opp_put_regulators(struct opp_table
*opp_table
);
127 struct opp_table
*dev_pm_opp_set_clkname(struct device
*dev
, const char * name
);
128 void dev_pm_opp_put_clkname(struct opp_table
*opp_table
);
129 struct opp_table
*dev_pm_opp_register_set_opp_helper(struct device
*dev
, int (*set_opp
)(struct dev_pm_set_opp_data
*data
));
130 void dev_pm_opp_unregister_set_opp_helper(struct opp_table
*opp_table
);
131 struct opp_table
*dev_pm_opp_set_genpd_virt_dev(struct device
*dev
, struct device
*virt_dev
, int index
);
132 void dev_pm_opp_put_genpd_virt_dev(struct opp_table
*opp_table
, struct device
*virt_dev
);
133 int dev_pm_opp_xlate_performance_state(struct opp_table
*src_table
, struct opp_table
*dst_table
, unsigned int pstate
);
134 int dev_pm_opp_set_rate(struct device
*dev
, unsigned long target_freq
);
135 int dev_pm_opp_set_sharing_cpus(struct device
*cpu_dev
, const struct cpumask
*cpumask
);
136 int dev_pm_opp_get_sharing_cpus(struct device
*cpu_dev
, struct cpumask
*cpumask
);
137 void dev_pm_opp_remove_table(struct device
*dev
);
138 void dev_pm_opp_cpumask_remove_table(const struct cpumask
*cpumask
);
140 static inline struct opp_table
*dev_pm_opp_get_opp_table(struct device
*dev
)
142 return ERR_PTR(-ENOTSUPP
);
145 static inline struct opp_table
*dev_pm_opp_get_opp_table_indexed(struct device
*dev
, int index
)
147 return ERR_PTR(-ENOTSUPP
);
150 static inline void dev_pm_opp_put_opp_table(struct opp_table
*opp_table
) {}
152 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp
*opp
)
157 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp
*opp
)
162 static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp
*opp
)
167 static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp
*opp
)
172 static inline int dev_pm_opp_get_opp_count(struct device
*dev
)
177 static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device
*dev
)
182 static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device
*dev
)
187 static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device
*dev
)
192 static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device
*dev
)
197 static inline struct dev_pm_opp
*dev_pm_opp_find_freq_exact(struct device
*dev
,
198 unsigned long freq
, bool available
)
200 return ERR_PTR(-ENOTSUPP
);
203 static inline struct dev_pm_opp
*dev_pm_opp_find_freq_floor(struct device
*dev
,
206 return ERR_PTR(-ENOTSUPP
);
209 static inline struct dev_pm_opp
*dev_pm_opp_find_freq_ceil_by_volt(struct device
*dev
,
210 unsigned long u_volt
)
212 return ERR_PTR(-ENOTSUPP
);
215 static inline struct dev_pm_opp
*dev_pm_opp_find_freq_ceil(struct device
*dev
,
218 return ERR_PTR(-ENOTSUPP
);
221 static inline void dev_pm_opp_put(struct dev_pm_opp
*opp
) {}
223 static inline int dev_pm_opp_add(struct device
*dev
, unsigned long freq
,
224 unsigned long u_volt
)
229 static inline void dev_pm_opp_remove(struct device
*dev
, unsigned long freq
)
233 static inline void dev_pm_opp_remove_all_dynamic(struct device
*dev
)
237 static inline int dev_pm_opp_enable(struct device
*dev
, unsigned long freq
)
242 static inline int dev_pm_opp_disable(struct device
*dev
, unsigned long freq
)
247 static inline int dev_pm_opp_register_notifier(struct device
*dev
, struct notifier_block
*nb
)
252 static inline int dev_pm_opp_unregister_notifier(struct device
*dev
, struct notifier_block
*nb
)
257 static inline struct opp_table
*dev_pm_opp_set_supported_hw(struct device
*dev
,
261 return ERR_PTR(-ENOTSUPP
);
264 static inline void dev_pm_opp_put_supported_hw(struct opp_table
*opp_table
) {}
266 static inline struct opp_table
*dev_pm_opp_register_set_opp_helper(struct device
*dev
,
267 int (*set_opp
)(struct dev_pm_set_opp_data
*data
))
269 return ERR_PTR(-ENOTSUPP
);
272 static inline void dev_pm_opp_unregister_set_opp_helper(struct opp_table
*opp_table
) {}
274 static inline struct opp_table
*dev_pm_opp_set_prop_name(struct device
*dev
, const char *name
)
276 return ERR_PTR(-ENOTSUPP
);
279 static inline void dev_pm_opp_put_prop_name(struct opp_table
*opp_table
) {}
281 static inline struct opp_table
*dev_pm_opp_set_regulators(struct device
*dev
, const char * const names
[], unsigned int count
)
283 return ERR_PTR(-ENOTSUPP
);
286 static inline void dev_pm_opp_put_regulators(struct opp_table
*opp_table
) {}
288 static inline struct opp_table
*dev_pm_opp_set_clkname(struct device
*dev
, const char * name
)
290 return ERR_PTR(-ENOTSUPP
);
293 static inline void dev_pm_opp_put_clkname(struct opp_table
*opp_table
) {}
295 static inline struct opp_table
*dev_pm_opp_set_genpd_virt_dev(struct device
*dev
, struct device
*virt_dev
, int index
)
297 return ERR_PTR(-ENOTSUPP
);
300 static inline void dev_pm_opp_put_genpd_virt_dev(struct opp_table
*opp_table
, struct device
*virt_dev
) {}
302 static inline int dev_pm_opp_xlate_performance_state(struct opp_table
*src_table
, struct opp_table
*dst_table
, unsigned int pstate
)
307 static inline int dev_pm_opp_set_rate(struct device
*dev
, unsigned long target_freq
)
312 static inline int dev_pm_opp_set_sharing_cpus(struct device
*cpu_dev
, const struct cpumask
*cpumask
)
317 static inline int dev_pm_opp_get_sharing_cpus(struct device
*cpu_dev
, struct cpumask
*cpumask
)
322 static inline void dev_pm_opp_remove_table(struct device
*dev
)
326 static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask
*cpumask
)
330 #endif /* CONFIG_PM_OPP */
332 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
333 int dev_pm_opp_of_add_table(struct device
*dev
);
334 int dev_pm_opp_of_add_table_indexed(struct device
*dev
, int index
);
335 void dev_pm_opp_of_remove_table(struct device
*dev
);
336 int dev_pm_opp_of_cpumask_add_table(const struct cpumask
*cpumask
);
337 void dev_pm_opp_of_cpumask_remove_table(const struct cpumask
*cpumask
);
338 int dev_pm_opp_of_get_sharing_cpus(struct device
*cpu_dev
, struct cpumask
*cpumask
);
339 struct device_node
*dev_pm_opp_of_get_opp_desc_node(struct device
*dev
);
340 struct device_node
*dev_pm_opp_get_of_node(struct dev_pm_opp
*opp
);
341 int of_get_required_opp_performance_state(struct device_node
*np
, int index
);
342 void dev_pm_opp_of_register_em(struct cpumask
*cpus
);
344 static inline int dev_pm_opp_of_add_table(struct device
*dev
)
349 static inline int dev_pm_opp_of_add_table_indexed(struct device
*dev
, int index
)
354 static inline void dev_pm_opp_of_remove_table(struct device
*dev
)
358 static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask
*cpumask
)
363 static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask
*cpumask
)
367 static inline int dev_pm_opp_of_get_sharing_cpus(struct device
*cpu_dev
, struct cpumask
*cpumask
)
372 static inline struct device_node
*dev_pm_opp_of_get_opp_desc_node(struct device
*dev
)
377 static inline struct device_node
*dev_pm_opp_get_of_node(struct dev_pm_opp
*opp
)
382 static inline void dev_pm_opp_of_register_em(struct cpumask
*cpus
)
386 static inline int of_get_required_opp_performance_state(struct device_node
*np
, int index
)
392 #endif /* __LINUX_OPP_H__ */