Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 2 | /* |
| 3 | * cpuidle.h - The internal header file |
| 4 | */ |
| 5 | |
| 6 | #ifndef __DRIVER_CPUIDLE_H |
| 7 | #define __DRIVER_CPUIDLE_H |
| 8 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 9 | /* For internal use only */ |
Rafael J. Wysocki | 61cb575 | 2018-12-05 23:45:34 +0100 | [diff] [blame] | 10 | extern char param_governor[]; |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 11 | extern struct cpuidle_governor *cpuidle_curr_governor; |
Joao Martins | cb5d8c4 | 2019-09-08 00:45:21 +0100 | [diff] [blame] | 12 | extern struct cpuidle_governor *cpuidle_prev_governor; |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 13 | extern struct list_head cpuidle_governors; |
| 14 | extern struct list_head cpuidle_detected_devices; |
| 15 | extern struct mutex cpuidle_lock; |
| 16 | extern spinlock_t cpuidle_driver_lock; |
Len Brown | 62027ae | 2011-04-01 18:13:10 -0400 | [diff] [blame] | 17 | extern int cpuidle_disabled(void); |
Colin Cross | 56cfbf7 | 2012-05-07 17:57:39 -0700 | [diff] [blame] | 18 | extern int cpuidle_enter_state(struct cpuidle_device *dev, |
| 19 | struct cpuidle_driver *drv, int next_state); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 20 | |
| 21 | /* idle loop */ |
| 22 | extern void cpuidle_install_idle_handler(void); |
| 23 | extern void cpuidle_uninstall_idle_handler(void); |
| 24 | |
| 25 | /* governors */ |
Joao Martins | cb5d8c4 | 2019-09-08 00:45:21 +0100 | [diff] [blame] | 26 | extern struct cpuidle_governor *cpuidle_find_governor(const char *str); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 27 | extern int cpuidle_switch_governor(struct cpuidle_governor *gov); |
| 28 | |
| 29 | /* sysfs */ |
Daniel Lezcano | 8f3e995 | 2012-10-31 01:09:02 +0100 | [diff] [blame] | 30 | |
| 31 | struct device; |
| 32 | |
Kay Sievers | 8a25a2f | 2011-12-21 14:29:42 -0800 | [diff] [blame] | 33 | extern int cpuidle_add_interface(struct device *dev); |
| 34 | extern void cpuidle_remove_interface(struct device *dev); |
Daniel Lezcano | bf4d1b5 | 2012-10-31 16:44:48 +0000 | [diff] [blame] | 35 | extern int cpuidle_add_device_sysfs(struct cpuidle_device *device); |
| 36 | extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device); |
Daniel Lezcano | 1aef40e | 2012-10-26 12:26:24 +0200 | [diff] [blame] | 37 | extern int cpuidle_add_sysfs(struct cpuidle_device *dev); |
| 38 | extern void cpuidle_remove_sysfs(struct cpuidle_device *dev); |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 39 | |
Colin Cross | 4126c01 | 2012-05-07 17:57:41 -0700 | [diff] [blame] | 40 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED |
Xunlei Pang | 4c1ed5a | 2015-08-04 13:48:56 +0800 | [diff] [blame] | 41 | bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state); |
Xunlei Pang | abceaa9 | 2015-08-31 11:34:05 +0800 | [diff] [blame] | 42 | int cpuidle_coupled_state_verify(struct cpuidle_driver *drv); |
Colin Cross | 4126c01 | 2012-05-07 17:57:41 -0700 | [diff] [blame] | 43 | int cpuidle_enter_state_coupled(struct cpuidle_device *dev, |
| 44 | struct cpuidle_driver *drv, int next_state); |
| 45 | int cpuidle_coupled_register_device(struct cpuidle_device *dev); |
| 46 | void cpuidle_coupled_unregister_device(struct cpuidle_device *dev); |
| 47 | #else |
Xunlei Pang | 4c1ed5a | 2015-08-04 13:48:56 +0800 | [diff] [blame] | 48 | static inline |
| 49 | bool cpuidle_state_is_coupled(struct cpuidle_driver *drv, int state) |
Colin Cross | 4126c01 | 2012-05-07 17:57:41 -0700 | [diff] [blame] | 50 | { |
| 51 | return false; |
| 52 | } |
| 53 | |
Xunlei Pang | abceaa9 | 2015-08-31 11:34:05 +0800 | [diff] [blame] | 54 | static inline int cpuidle_coupled_state_verify(struct cpuidle_driver *drv) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | |
Colin Cross | 4126c01 | 2012-05-07 17:57:41 -0700 | [diff] [blame] | 59 | static inline int cpuidle_enter_state_coupled(struct cpuidle_device *dev, |
| 60 | struct cpuidle_driver *drv, int next_state) |
| 61 | { |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | static inline int cpuidle_coupled_register_device(struct cpuidle_device *dev) |
| 66 | { |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | static inline void cpuidle_coupled_unregister_device(struct cpuidle_device *dev) |
| 71 | { |
| 72 | } |
| 73 | #endif |
| 74 | |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 75 | #endif /* __DRIVER_CPUIDLE_H */ |