1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __ASM_ARM_CPUIDLE_H
3*4882a593Smuzhiyun #define __ASM_ARM_CPUIDLE_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun #include <asm/proc-fns.h>
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #ifdef CONFIG_CPU_IDLE
8*4882a593Smuzhiyun extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
9*4882a593Smuzhiyun struct cpuidle_driver *drv, int index);
10*4882a593Smuzhiyun #define __cpuidle_method_section __used __section("__cpuidle_method_of_table")
11*4882a593Smuzhiyun #else
arm_cpuidle_simple_enter(struct cpuidle_device * dev,struct cpuidle_driver * drv,int index)12*4882a593Smuzhiyun static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
13*4882a593Smuzhiyun struct cpuidle_driver *drv, int index) { return -ENODEV; }
14*4882a593Smuzhiyun #define __cpuidle_method_section __maybe_unused /* drop silently */
15*4882a593Smuzhiyun #endif
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun /* Common ARM WFI state */
18*4882a593Smuzhiyun #define ARM_CPUIDLE_WFI_STATE_PWR(p) {\
19*4882a593Smuzhiyun .enter = arm_cpuidle_simple_enter,\
20*4882a593Smuzhiyun .exit_latency = 1,\
21*4882a593Smuzhiyun .target_residency = 1,\
22*4882a593Smuzhiyun .power_usage = p,\
23*4882a593Smuzhiyun .name = "WFI",\
24*4882a593Smuzhiyun .desc = "ARM WFI",\
25*4882a593Smuzhiyun }
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun * in case power_specified == 1, give a default WFI power value needed
29*4882a593Smuzhiyun * by some governors
30*4882a593Smuzhiyun */
31*4882a593Smuzhiyun #define ARM_CPUIDLE_WFI_STATE ARM_CPUIDLE_WFI_STATE_PWR(UINT_MAX)
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun struct device_node;
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun struct cpuidle_ops {
36*4882a593Smuzhiyun int (*suspend)(unsigned long arg);
37*4882a593Smuzhiyun int (*init)(struct device_node *, int cpu);
38*4882a593Smuzhiyun };
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun struct of_cpuidle_method {
41*4882a593Smuzhiyun const char *method;
42*4882a593Smuzhiyun const struct cpuidle_ops *ops;
43*4882a593Smuzhiyun };
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun #define CPUIDLE_METHOD_OF_DECLARE(name, _method, _ops) \
46*4882a593Smuzhiyun static const struct of_cpuidle_method __cpuidle_method_of_table_##name \
47*4882a593Smuzhiyun __cpuidle_method_section = { .method = _method, .ops = _ops }
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun extern int arm_cpuidle_suspend(int index);
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun extern int arm_cpuidle_init(int cpu);
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun #endif
54