Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2011 Google, Inc.
0004  *
0005  * Author:
0006  *  Colin Cross <ccross@android.com>
0007  */
0008 
0009 #ifndef _LINUX_CPU_PM_H
0010 #define _LINUX_CPU_PM_H
0011 
0012 #include <linux/kernel.h>
0013 #include <linux/notifier.h>
0014 
0015 /*
0016  * When a CPU goes to a low power state that turns off power to the CPU's
0017  * power domain, the contents of some blocks (floating point coprocessors,
0018  * interrupt controllers, caches, timers) in the same power domain can
0019  * be lost.  The cpm_pm notifiers provide a method for platform idle, suspend,
0020  * and hotplug implementations to notify the drivers for these blocks that
0021  * they may be reset.
0022  *
0023  * All cpu_pm notifications must be called with interrupts disabled.
0024  *
0025  * The notifications are split into two classes: CPU notifications and CPU
0026  * cluster notifications.
0027  *
0028  * CPU notifications apply to a single CPU and must be called on the affected
0029  * CPU.  They are used to save per-cpu context for affected blocks.
0030  *
0031  * CPU cluster notifications apply to all CPUs in a single power domain. They
0032  * are used to save any global context for affected blocks, and must be called
0033  * after all the CPUs in the power domain have been notified of the low power
0034  * state.
0035  */
0036 
0037 /*
0038  * Event codes passed as unsigned long val to notifier calls
0039  */
0040 enum cpu_pm_event {
0041     /* A single cpu is entering a low power state */
0042     CPU_PM_ENTER,
0043 
0044     /* A single cpu failed to enter a low power state */
0045     CPU_PM_ENTER_FAILED,
0046 
0047     /* A single cpu is exiting a low power state */
0048     CPU_PM_EXIT,
0049 
0050     /* A cpu power domain is entering a low power state */
0051     CPU_CLUSTER_PM_ENTER,
0052 
0053     /* A cpu power domain failed to enter a low power state */
0054     CPU_CLUSTER_PM_ENTER_FAILED,
0055 
0056     /* A cpu power domain is exiting a low power state */
0057     CPU_CLUSTER_PM_EXIT,
0058 };
0059 
0060 #ifdef CONFIG_CPU_PM
0061 int cpu_pm_register_notifier(struct notifier_block *nb);
0062 int cpu_pm_unregister_notifier(struct notifier_block *nb);
0063 int cpu_pm_enter(void);
0064 int cpu_pm_exit(void);
0065 int cpu_cluster_pm_enter(void);
0066 int cpu_cluster_pm_exit(void);
0067 
0068 #else
0069 
0070 static inline int cpu_pm_register_notifier(struct notifier_block *nb)
0071 {
0072     return 0;
0073 }
0074 
0075 static inline int cpu_pm_unregister_notifier(struct notifier_block *nb)
0076 {
0077     return 0;
0078 }
0079 
0080 static inline int cpu_pm_enter(void)
0081 {
0082     return 0;
0083 }
0084 
0085 static inline int cpu_pm_exit(void)
0086 {
0087     return 0;
0088 }
0089 
0090 static inline int cpu_cluster_pm_enter(void)
0091 {
0092     return 0;
0093 }
0094 
0095 static inline int cpu_cluster_pm_exit(void)
0096 {
0097     return 0;
0098 }
0099 #endif
0100 #endif