xref: /openbmc/linux/drivers/cpuidle/cpuidle.h (revision b2441318)
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 */
104f86d3a8SLen Brown extern struct cpuidle_governor *cpuidle_curr_governor;
114f86d3a8SLen Brown extern struct list_head cpuidle_governors;
124f86d3a8SLen Brown extern struct list_head cpuidle_detected_devices;
134f86d3a8SLen Brown extern struct mutex cpuidle_lock;
144f86d3a8SLen Brown extern spinlock_t cpuidle_driver_lock;
1562027aeaSLen Brown extern int cpuidle_disabled(void);
1656cfbf74SColin Cross extern int cpuidle_enter_state(struct cpuidle_device *dev,
1756cfbf74SColin Cross 		struct cpuidle_driver *drv, int next_state);
184f86d3a8SLen Brown 
194f86d3a8SLen Brown /* idle loop */
204f86d3a8SLen Brown extern void cpuidle_install_idle_handler(void);
214f86d3a8SLen Brown extern void cpuidle_uninstall_idle_handler(void);
224f86d3a8SLen Brown 
234f86d3a8SLen Brown /* governors */
244f86d3a8SLen Brown extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
254f86d3a8SLen Brown 
264f86d3a8SLen Brown /* sysfs */
278f3e9953SDaniel Lezcano 
288f3e9953SDaniel Lezcano struct device;
298f3e9953SDaniel Lezcano 
308a25a2fdSKay Sievers extern int cpuidle_add_interface(struct device *dev);
318a25a2fdSKay Sievers extern void cpuidle_remove_interface(struct device *dev);
32bf4d1b5dSDaniel Lezcano extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
33bf4d1b5dSDaniel Lezcano extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
341aef40e2SDaniel Lezcano extern int cpuidle_add_sysfs(struct cpuidle_device *dev);
351aef40e2SDaniel Lezcano extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
364f86d3a8SLen Brown 
374126c019SColin Cross #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
384c1ed5a6SXunlei Pang bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
39abceaa9cSXunlei Pang int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
404126c019SColin Cross int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
414126c019SColin Cross 		struct cpuidle_driver *drv, int next_state);
424126c019SColin Cross int cpuidle_coupled_register_device(struct cpuidle_device *dev);
434126c019SColin Cross void cpuidle_coupled_unregister_device(struct cpuidle_device *dev);
444126c019SColin Cross #else
454c1ed5a6SXunlei Pang static inline
464c1ed5a6SXunlei Pang bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
474126c019SColin Cross {
484126c019SColin Cross 	return false;
494126c019SColin Cross }
504126c019SColin Cross 
51abceaa9cSXunlei Pang static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
52abceaa9cSXunlei Pang {
53abceaa9cSXunlei Pang 	return 0;
54abceaa9cSXunlei Pang }
55abceaa9cSXunlei Pang 
564126c019SColin Cross static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
574126c019SColin Cross 		struct cpuidle_driver *drv, int next_state)
584126c019SColin Cross {
594126c019SColin Cross 	return -1;
604126c019SColin Cross }
614126c019SColin Cross 
624126c019SColin Cross static inline int cpuidle_coupled_register_device(struct cpuidle_device *dev)
634126c019SColin Cross {
644126c019SColin Cross 	return 0;
654126c019SColin Cross }
664126c019SColin Cross 
674126c019SColin Cross static inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev)
684126c019SColin Cross {
694126c019SColin Cross }
704126c019SColin Cross #endif
714126c019SColin Cross 
724f86d3a8SLen Brown #endif /* __DRIVER_CPUIDLE_H */
73