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

source code of linux/include/linux/cpu_pm.h