blob: 9f336af17fa6038abe7b939b6c4718fd6965c540 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Len Brown4f86d3a2007-10-03 18:58:00 -04002/*
3 * cpuidle.h - The internal header file
4 */
5
6#ifndef __DRIVER_CPUIDLE_H
7#define __DRIVER_CPUIDLE_H
8
Len Brown4f86d3a2007-10-03 18:58:00 -04009/* For internal use only */
Rafael J. Wysocki61cb5752018-12-05 23:45:34 +010010extern char param_governor[];
Len Brown4f86d3a2007-10-03 18:58:00 -040011extern struct cpuidle_governor *cpuidle_curr_governor;
Joao Martinscb5d8c42019-09-08 00:45:21 +010012extern struct cpuidle_governor *cpuidle_prev_governor;
Len Brown4f86d3a2007-10-03 18:58:00 -040013extern struct list_head cpuidle_governors;
14extern struct list_head cpuidle_detected_devices;
15extern struct mutex cpuidle_lock;
16extern spinlock_t cpuidle_driver_lock;
Len Brown62027ae2011-04-01 18:13:10 -040017extern int cpuidle_disabled(void);
Colin Cross56cfbf72012-05-07 17:57:39 -070018extern int cpuidle_enter_state(struct cpuidle_device *dev,
19 struct cpuidle_driver *drv, int next_state);
Len Brown4f86d3a2007-10-03 18:58:00 -040020
21/* idle loop */
22extern void cpuidle_install_idle_handler(void);
23extern void cpuidle_uninstall_idle_handler(void);
24
25/* governors */
Joao Martinscb5d8c42019-09-08 00:45:21 +010026extern struct cpuidle_governor *cpuidle_find_governor(const char *str);
Len Brown4f86d3a2007-10-03 18:58:00 -040027extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
28
29/* sysfs */
Daniel Lezcano8f3e9952012-10-31 01:09:02 +010030
31struct device;
32
Kay Sievers8a25a2f2011-12-21 14:29:42 -080033extern int cpuidle_add_interface(struct device *dev);
34extern void cpuidle_remove_interface(struct device *dev);
Daniel Lezcanobf4d1b52012-10-31 16:44:48 +000035extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
36extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
Daniel Lezcano1aef40e2012-10-26 12:26:24 +020037extern int cpuidle_add_sysfs(struct cpuidle_device *dev);
38extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
Len Brown4f86d3a2007-10-03 18:58:00 -040039
Colin Cross4126c012012-05-07 17:57:41 -070040#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
Xunlei Pang4c1ed5a2015-08-04 13:48:56 +080041bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state);
Xunlei Pangabceaa92015-08-31 11:34:05 +080042int cpuidle_coupled_state_verify(struct cpuidle_driver *drv);
Colin Cross4126c012012-05-07 17:57:41 -070043int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
44 struct cpuidle_driver *drv, int next_state);
45int cpuidle_coupled_register_device(struct cpuidle_device *dev);
46void cpuidle_coupled_unregister_device(struct cpuidle_device *dev);
47#else
Xunlei Pang4c1ed5a2015-08-04 13:48:56 +080048static inline
49bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state)
Colin Cross4126c012012-05-07 17:57:41 -070050{
51 return false;
52}
53
Xunlei Pangabceaa92015-08-31 11:34:05 +080054static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv)
55{
56 return 0;
57}
58
Colin Cross4126c012012-05-07 17:57:41 -070059static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
60 struct cpuidle_driver *drv, int next_state)
61{
62 return -1;
63}
64
65static inline int cpuidle_coupled_register_device(struct cpuidle_device *dev)
66{
67 return 0;
68}
69
70static inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev)
71{
72}
73#endif
74
Len Brown4f86d3a2007-10-03 18:58:00 -040075#endif /* __DRIVER_CPUIDLE_H */