1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright (C) 2011 Google, Inc.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Author:
6*4882a593Smuzhiyun * Colin Cross <ccross@android.com>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #ifndef _LINUX_CPU_PM_H
10*4882a593Smuzhiyun #define _LINUX_CPU_PM_H
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun #include <linux/kernel.h>
13*4882a593Smuzhiyun #include <linux/notifier.h>
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun /*
16*4882a593Smuzhiyun * When a CPU goes to a low power state that turns off power to the CPU's
17*4882a593Smuzhiyun * power domain, the contents of some blocks (floating point coprocessors,
18*4882a593Smuzhiyun * interrupt controllers, caches, timers) in the same power domain can
19*4882a593Smuzhiyun * be lost. The cpm_pm notifiers provide a method for platform idle, suspend,
20*4882a593Smuzhiyun * and hotplug implementations to notify the drivers for these blocks that
21*4882a593Smuzhiyun * they may be reset.
22*4882a593Smuzhiyun *
23*4882a593Smuzhiyun * All cpu_pm notifications must be called with interrupts disabled.
24*4882a593Smuzhiyun *
25*4882a593Smuzhiyun * The notifications are split into two classes: CPU notifications and CPU
26*4882a593Smuzhiyun * cluster notifications.
27*4882a593Smuzhiyun *
28*4882a593Smuzhiyun * CPU notifications apply to a single CPU and must be called on the affected
29*4882a593Smuzhiyun * CPU. They are used to save per-cpu context for affected blocks.
30*4882a593Smuzhiyun *
31*4882a593Smuzhiyun * CPU cluster notifications apply to all CPUs in a single power domain. They
32*4882a593Smuzhiyun * are used to save any global context for affected blocks, and must be called
33*4882a593Smuzhiyun * after all the CPUs in the power domain have been notified of the low power
34*4882a593Smuzhiyun * state.
35*4882a593Smuzhiyun */
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun /*
38*4882a593Smuzhiyun * Event codes passed as unsigned long val to notifier calls
39*4882a593Smuzhiyun */
40*4882a593Smuzhiyun enum cpu_pm_event {
41*4882a593Smuzhiyun /* A single cpu is entering a low power state */
42*4882a593Smuzhiyun CPU_PM_ENTER,
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun /* A single cpu failed to enter a low power state */
45*4882a593Smuzhiyun CPU_PM_ENTER_FAILED,
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun /* A single cpu is exiting a low power state */
48*4882a593Smuzhiyun CPU_PM_EXIT,
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun /* A cpu power domain is entering a low power state */
51*4882a593Smuzhiyun CPU_CLUSTER_PM_ENTER,
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun /* A cpu power domain failed to enter a low power state */
54*4882a593Smuzhiyun CPU_CLUSTER_PM_ENTER_FAILED,
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun /* A cpu power domain is exiting a low power state */
57*4882a593Smuzhiyun CPU_CLUSTER_PM_EXIT,
58*4882a593Smuzhiyun };
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun #ifdef CONFIG_CPU_PM
61*4882a593Smuzhiyun int cpu_pm_register_notifier(struct notifier_block *nb);
62*4882a593Smuzhiyun int cpu_pm_unregister_notifier(struct notifier_block *nb);
63*4882a593Smuzhiyun int cpu_pm_enter(void);
64*4882a593Smuzhiyun int cpu_pm_exit(void);
65*4882a593Smuzhiyun int cpu_cluster_pm_enter(void);
66*4882a593Smuzhiyun int cpu_cluster_pm_exit(void);
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun #else
69*4882a593Smuzhiyun
cpu_pm_register_notifier(struct notifier_block * nb)70*4882a593Smuzhiyun static inline int cpu_pm_register_notifier(struct notifier_block *nb)
71*4882a593Smuzhiyun {
72*4882a593Smuzhiyun return 0;
73*4882a593Smuzhiyun }
74*4882a593Smuzhiyun
cpu_pm_unregister_notifier(struct notifier_block * nb)75*4882a593Smuzhiyun static inline int cpu_pm_unregister_notifier(struct notifier_block *nb)
76*4882a593Smuzhiyun {
77*4882a593Smuzhiyun return 0;
78*4882a593Smuzhiyun }
79*4882a593Smuzhiyun
cpu_pm_enter(void)80*4882a593Smuzhiyun static inline int cpu_pm_enter(void)
81*4882a593Smuzhiyun {
82*4882a593Smuzhiyun return 0;
83*4882a593Smuzhiyun }
84*4882a593Smuzhiyun
cpu_pm_exit(void)85*4882a593Smuzhiyun static inline int cpu_pm_exit(void)
86*4882a593Smuzhiyun {
87*4882a593Smuzhiyun return 0;
88*4882a593Smuzhiyun }
89*4882a593Smuzhiyun
cpu_cluster_pm_enter(void)90*4882a593Smuzhiyun static inline int cpu_cluster_pm_enter(void)
91*4882a593Smuzhiyun {
92*4882a593Smuzhiyun return 0;
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun
cpu_cluster_pm_exit(void)95*4882a593Smuzhiyun static inline int cpu_cluster_pm_exit(void)
96*4882a593Smuzhiyun {
97*4882a593Smuzhiyun return 0;
98*4882a593Smuzhiyun }
99*4882a593Smuzhiyun #endif
100*4882a593Smuzhiyun #endif
101