xref: /openbmc/linux/drivers/cpuidle/cpuidle.h (revision 61cb5758d3c46bc1ba87694fefc0d9653613ce6b)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
24f86d3a8SLen Brown /*
34f86d3a8SLen Brown  * cpuidle.h - The internal header file
44f86d3a8SLen Brown  */
54f86d3a8SLen Brown 
64f86d3a8SLen Brown #ifndef __DRIVER_CPUIDLE_H
74f86d3a8SLen Brown #define __DRIVER_CPUIDLE_H
84f86d3a8SLen Brown 
94f86d3a8SLen Brown /* For internal use only */
10*61cb5758SRafael J. Wysocki extern char param_governor[];
114f86d3a8SLen Brown extern struct cpuidle_governor *cpuidle_curr_governor;
124f86d3a8SLen Brown extern struct list_head cpuidle_governors;
134f86d3a8SLen Brown extern struct list_head cpuidle_detected_devices;
144f86d3a8SLen Brown extern struct mutex cpuidle_lock;
154f86d3a8SLen Brown extern spinlock_t cpuidle_driver_lock;
1662027aeaSLen Brown extern int cpuidle_disabled(void);
1756cfbf74SColin Cross extern int cpuidle_enter_state(struct cpuidle_device *dev,
1856cfbf74SColin Cross 		struct cpuidle_driver *drv, int next_state);
194f86d3a8SLen Brown 
204f86d3a8SLen Brown /* idle loop */
214f86d3a8SLen Brown extern void cpuidle_install_idle_handler(void);
224f86d3a8SLen Brown extern void cpuidle_uninstall_idle_handler(void);
234f86d3a8SLen Brown 
244f86d3a8SLen Brown /* governors */
254f86d3a8SLen Brown extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
264f86d3a8SLen Brown 
274f86d3a8SLen Brown /* sysfs */
288f3e9953SDaniel Lezcano 
298f3e9953SDaniel Lezcano struct device;
308f3e9953SDaniel Lezcano 
318a25a2fdSKay Sievers extern int cpuidle_add_interface(struct device *dev);
328a25a2fdSKay Sievers extern void cpuidle_remove_interface(struct device *dev);
33bf4d1b5dSDaniel Lezcano extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
34bf4d1b5dSDaniel Lezcano extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
351aef40e2SDaniel Lezcano extern int cpuidle_add_sysfs(struct cpuidle_device *dev);
361aef40e2SDaniel Lezcano extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
374f86d3a8SLen Brown 
384126c019SColin Cross #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
394c1ed5a6SXunlei Pang bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
40abceaa9cSXunlei Pang int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
414126c019SColin Cross int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
424126c019SColin Cross 		struct cpuidle_driver *drv, int next_state);
434126c019SColin Cross int cpuidle_coupled_register_device(struct cpuidle_device *dev);
444126c019SColin Cross void cpuidle_coupled_unregister_device(struct cpuidle_device *dev);
454126c019SColin Cross #else
464c1ed5a6SXunlei Pang static inline
474c1ed5a6SXunlei Pang bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
484126c019SColin Cross {
494126c019SColin Cross 	return false;
504126c019SColin Cross }
514126c019SColin Cross 
52abceaa9cSXunlei Pang static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
53abceaa9cSXunlei Pang {
54abceaa9cSXunlei Pang 	return 0;
55abceaa9cSXunlei Pang }
56abceaa9cSXunlei Pang 
574126c019SColin Cross static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
584126c019SColin Cross 		struct cpuidle_driver *drv, int next_state)
594126c019SColin Cross {
604126c019SColin Cross 	return -1;
614126c019SColin Cross }
624126c019SColin Cross 
634126c019SColin Cross static inline int cpuidle_coupled_register_device(struct cpuidle_device *dev)
644126c019SColin Cross {
654126c019SColin Cross 	return 0;
664126c019SColin Cross }
674126c019SColin Cross 
684126c019SColin Cross static inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev)
694126c019SColin Cross {
704126c019SColin Cross }
714126c019SColin Cross #endif
724126c019SColin Cross 
734f86d3a8SLen Brown #endif /* __DRIVER_CPUIDLE_H */
74