1139826Simp/* SPDX-License-Identifier: GPL-2.0-only */
253541Sshin/*
353541Sshin * Copyright (C) 2011 Google, Inc.
453541Sshin *
553541Sshin * Author:
653541Sshin *	Colin Cross <ccross@android.com>
753541Sshin */
853541Sshin
953541Sshin#ifndef _LINUX_CPU_PM_H
1053541Sshin#define _LINUX_CPU_PM_H
1153541Sshin
1253541Sshin#include <linux/kernel.h>
1353541Sshin#include <linux/notifier.h>
1453541Sshin
1553541Sshin/*
1653541Sshin * When a CPU goes to a low power state that turns off power to the CPU's
1753541Sshin * power domain, the contents of some blocks (floating point coprocessors,
1853541Sshin * interrupt controllers, caches, timers) in the same power domain can
1953541Sshin * be lost.  The cpm_pm notifiers provide a method for platform idle, suspend,
2053541Sshin * and hotplug implementations to notify the drivers for these blocks that
2153541Sshin * they may be reset.
2253541Sshin *
2353541Sshin * All cpu_pm notifications must be called with interrupts disabled.
2453541Sshin *
2553541Sshin * The notifications are split into two classes: CPU notifications and CPU
2653541Sshin * cluster notifications.
2753541Sshin *
28174510Sobrien * CPU notifications apply to a single CPU and must be called on the affected
29174510Sobrien * CPU.  They are used to save per-cpu context for affected blocks.
3053541Sshin *
3153541Sshin * CPU cluster notifications apply to all CPUs in a single power domain. They
32174510Sobrien * are used to save any global context for affected blocks, and must be called
33174510Sobrien * after all the CPUs in the power domain have been notified of the low power
34174510Sobrien * state.
3553541Sshin */
3653541Sshin
3753541Sshin/*
3853541Sshin * Event codes passed as unsigned long val to notifier calls
3953541Sshin */
4053541Sshinenum cpu_pm_event {
4153541Sshin	/* A single cpu is entering a low power state */
4253541Sshin	CPU_PM_ENTER,
4353541Sshin
4453541Sshin	/* A single cpu failed to enter a low power state */
4553541Sshin	CPU_PM_ENTER_FAILED,
4653541Sshin
4753541Sshin	/* A single cpu is exiting a low power state */
4853541Sshin	CPU_PM_EXIT,
49195699Srwatson
5053541Sshin	/* A cpu power domain is entering a low power state */
5153541Sshin	CPU_CLUSTER_PM_ENTER,
5253541Sshin
5362587Sitojun	/* A cpu power domain failed to enter a low power state */
5453541Sshin	CPU_CLUSTER_PM_ENTER_FAILED,
5562587Sitojun
56121684Sume	/* A cpu power domain is exiting a low power state */
57121684Sume	CPU_CLUSTER_PM_EXIT,
5853541Sshin};
59184307Srwatson
60184307Srwatson#ifdef CONFIG_CPU_PM
6153541Sshinint cpu_pm_register_notifier(struct notifier_block *nb);
6253541Sshinint cpu_pm_unregister_notifier(struct notifier_block *nb);
6353541Sshinint cpu_pm_enter(void);
6453541Sshinint cpu_pm_exit(void);
6553541Sshinint cpu_cluster_pm_enter(void);
6662587Sitojunint cpu_cluster_pm_exit(void);
6753541Sshin
68175162Sobrien#else
69175162Sobrien
70175162Sobrienstatic inline int cpu_pm_register_notifier(struct notifier_block *nb)
71175162Sobrien{
72175162Sobrien	return 0;
7353541Sshin}
74121346Sume
75121346Sumestatic inline int cpu_pm_unregister_notifier(struct notifier_block *nb)
76121346Sume{
77121346Sume	return 0;
78215701Sdim}
79215701Sdim
80215701Sdimstatic inline int cpu_pm_enter(void)
8153541Sshin{
82195727Srwatson	return 0;
83195727Srwatson}
84195727Srwatson
85195699Srwatsonstatic inline int cpu_pm_exit(void)
86121346Sume{
87121346Sume	return 0;
88121346Sume}
89121355Sume
90121346Sumestatic inline int cpu_cluster_pm_enter(void)
91121345Sume{
9269774Sphk	return 0;
9362587Sitojun}
9453541Sshin
9553541Sshinstatic inline int cpu_cluster_pm_exit(void)
9653541Sshin{
97157927Sps	return 0;
98157927Sps}
99157927Sps#endif
100157927Sps#endif
101181803Sbz