xref: /linux/drivers/cpuidle/cpuidle.h (revision b8d312aa075f33282565467662c4628dae0a2aff)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * cpuidle.h - The internal header file
4  */
5 
6 #ifndef __DRIVER_CPUIDLE_H
7 #define __DRIVER_CPUIDLE_H
8 
9 /* For internal use only */
10 extern char param_governor[];
11 extern struct cpuidle_governor *cpuidle_curr_governor;
12 extern struct list_head cpuidle_governors;
13 extern struct list_head cpuidle_detected_devices;
14 extern struct mutex cpuidle_lock;
15 extern spinlock_t cpuidle_driver_lock;
16 extern int cpuidle_disabled(void);
17 extern int cpuidle_enter_state(struct cpuidle_device *dev,
18 		struct cpuidle_driver *drv, int next_state);
19 
20 /* idle loop */
21 extern void cpuidle_install_idle_handler(void);
22 extern void cpuidle_uninstall_idle_handler(void);
23 
24 /* governors */
25 extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
26 
27 /* sysfs */
28 
29 struct device;
30 
31 extern int cpuidle_add_interface(struct device *dev);
32 extern void cpuidle_remove_interface(struct device *dev);
33 extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
34 extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
35 extern int cpuidle_add_sysfs(struct cpuidle_device *dev);
36 extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
37 
38 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
39 bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
40 int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
41 int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
42 		struct cpuidle_driver *drv, int next_state);
43 int cpuidle_coupled_register_device(struct cpuidle_device *dev);
44 void cpuidle_coupled_unregister_device(struct cpuidle_device *dev);
45 #else
46 static inline
47 bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
48 {
49 	return false;
50 }
51 
52 static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
53 {
54 	return 0;
55 }
56 
57 static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
58 		struct cpuidle_driver *drv, int next_state)
59 {
60 	return -1;
61 }
62 
63 static inline int cpuidle_coupled_register_device(struct cpuidle_device *dev)
64 {
65 	return 0;
66 }
67 
68 static inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev)
69 {
70 }
71 #endif
72 
73 #endif /* __DRIVER_CPUIDLE_H */
74