18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * cpuidle.h - The internal header file 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __DRIVER_CPUIDLE_H 78c2ecf20Sopenharmony_ci#define __DRIVER_CPUIDLE_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* For internal use only */ 108c2ecf20Sopenharmony_ciextern char param_governor[]; 118c2ecf20Sopenharmony_ciextern struct cpuidle_governor *cpuidle_curr_governor; 128c2ecf20Sopenharmony_ciextern struct cpuidle_governor *cpuidle_prev_governor; 138c2ecf20Sopenharmony_ciextern struct list_head cpuidle_governors; 148c2ecf20Sopenharmony_ciextern struct list_head cpuidle_detected_devices; 158c2ecf20Sopenharmony_ciextern struct mutex cpuidle_lock; 168c2ecf20Sopenharmony_ciextern spinlock_t cpuidle_driver_lock; 178c2ecf20Sopenharmony_ciextern int cpuidle_disabled(void); 188c2ecf20Sopenharmony_ciextern int cpuidle_enter_state(struct cpuidle_device *dev, 198c2ecf20Sopenharmony_ci struct cpuidle_driver *drv, int next_state); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* idle loop */ 228c2ecf20Sopenharmony_ciextern void cpuidle_install_idle_handler(void); 238c2ecf20Sopenharmony_ciextern void cpuidle_uninstall_idle_handler(void); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* governors */ 268c2ecf20Sopenharmony_ciextern struct cpuidle_governor *cpuidle_find_governor(const char *str); 278c2ecf20Sopenharmony_ciextern int cpuidle_switch_governor(struct cpuidle_governor *gov); 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* sysfs */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistruct device; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciextern int cpuidle_add_interface(struct device *dev); 348c2ecf20Sopenharmony_ciextern void cpuidle_remove_interface(struct device *dev); 358c2ecf20Sopenharmony_ciextern int cpuidle_add_device_sysfs(struct cpuidle_device *device); 368c2ecf20Sopenharmony_ciextern void cpuidle_remove_device_sysfs(struct cpuidle_device *device); 378c2ecf20Sopenharmony_ciextern int cpuidle_add_sysfs(struct cpuidle_device *dev); 388c2ecf20Sopenharmony_ciextern void cpuidle_remove_sysfs(struct cpuidle_device *dev); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED 418c2ecf20Sopenharmony_cibool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state); 428c2ecf20Sopenharmony_ciint cpuidle_coupled_state_verify(struct cpuidle_driver *drv); 438c2ecf20Sopenharmony_ciint cpuidle_enter_state_coupled(struct cpuidle_device *dev, 448c2ecf20Sopenharmony_ci struct cpuidle_driver *drv, int next_state); 458c2ecf20Sopenharmony_ciint cpuidle_coupled_register_device(struct cpuidle_device *dev); 468c2ecf20Sopenharmony_civoid cpuidle_coupled_unregister_device(struct cpuidle_device *dev); 478c2ecf20Sopenharmony_ci#else 488c2ecf20Sopenharmony_cistatic inline 498c2ecf20Sopenharmony_cibool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state) 508c2ecf20Sopenharmony_ci{ 518c2ecf20Sopenharmony_ci return false; 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci return 0; 578c2ecf20Sopenharmony_ci} 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev, 608c2ecf20Sopenharmony_ci struct cpuidle_driver *drv, int next_state) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci return -1; 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic inline int cpuidle_coupled_register_device(struct cpuidle_device *dev) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci return 0; 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci#endif 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#endif /* __DRIVER_CPUIDLE_H */ 76