Colin Cross | 06e8572 | 2011-11-09 16:39:19 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Google, Inc. |
| 3 | * |
| 4 | * Author: |
| 5 | * Colin Cross <ccross <at> android.com> |
| 6 | * |
| 7 | * This software is licensed under the terms of the GNU General Public |
| 8 | * License version 2, as published by the Free Software Foundation, and |
| 9 | * may be copied, distributed, and modified under those terms. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #ifndef _LINUX_CPU_PM_H |
| 19 | #define _LINUX_CPU_PM_H |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/notifier.h> |
| 23 | |
| 24 | /* |
| 25 | * When a CPU goes to a low power state that turns off power to the CPU's |
| 26 | * power domain, the contents of some blocks (floating point coprocessors, |
| 27 | * interrutp controllers, caches, timers) in the same power domain can |
| 28 | * be lost. The cpm_pm notifiers provide a method for platform idle, suspend, |
| 29 | * and hotplug implementations to notify the drivers for these blocks that |
| 30 | * they may be reset. |
| 31 | * |
| 32 | * All cpu_pm notifications must be called with interrupts disabled. |
| 33 | * |
| 34 | * The notifications are split into two classes, CPU notifications and CPU |
| 35 | * cluster notifications. |
| 36 | * |
| 37 | * CPU notifications apply to a single CPU, and must be called on the affected |
| 38 | * CPU. They are used to save per-cpu context for affected blocks. |
| 39 | * |
| 40 | * CPU cluster notifications apply to all CPUs in a single power domain. They |
| 41 | * are used to save any global context for affected blocks, and must be called |
| 42 | * after all the CPUs in the power domain have been notified of the low power |
| 43 | * state. |
| 44 | * |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | * Event codes passed as unsigned long val to notifier calls |
| 49 | */ |
| 50 | enum cpu_pm_event { |
| 51 | /* A single cpu is entering a low power state */ |
| 52 | CPU_PM_ENTER, |
| 53 | |
| 54 | /* A single cpu failed to enter a low power state */ |
| 55 | CPU_PM_ENTER_FAILED, |
| 56 | |
| 57 | /* A single cpu is exiting a low power state */ |
| 58 | CPU_PM_EXIT, |
| 59 | |
| 60 | /* A cpu power domain is entering a low power state */ |
| 61 | CPU_CLUSTER_PM_ENTER, |
| 62 | |
| 63 | /* A cpu power domain failed to enter a low power state */ |
| 64 | CPU_CLUSTER_PM_ENTER_FAILED, |
| 65 | |
| 66 | /* A cpu power domain is exiting a low power state */ |
| 67 | CPU_CLUSTER_PM_EXIT, |
| 68 | }; |
| 69 | |
Taniya Das | a75b3df | 2011-12-02 17:04:40 +0530 | [diff] [blame] | 70 | #ifdef CONFIG_CPU_PM |
Colin Cross | 06e8572 | 2011-11-09 16:39:19 -0500 | [diff] [blame] | 71 | int cpu_pm_register_notifier(struct notifier_block *nb); |
Taniya Das | a75b3df | 2011-12-02 17:04:40 +0530 | [diff] [blame] | 72 | #else |
| 73 | static inline int cpu_pm_register_notifier(struct notifier_block *nb) |
| 74 | { return 0; } |
| 75 | #endif |
| 76 | |
Colin Cross | 06e8572 | 2011-11-09 16:39:19 -0500 | [diff] [blame] | 77 | int cpu_pm_unregister_notifier(struct notifier_block *nb); |
| 78 | |
| 79 | /* |
| 80 | * cpm_pm_enter |
| 81 | * |
| 82 | * Notifies listeners that a single cpu is entering a low power state that may |
| 83 | * cause some blocks in the same power domain as the cpu to reset. |
| 84 | * |
| 85 | * Must be called on the affected cpu with interrupts disabled. Platform is |
| 86 | * responsible for ensuring that cpu_pm_enter is not called twice on the same |
| 87 | * cpu before cpu_pm_exit is called. |
| 88 | */ |
| 89 | int cpu_pm_enter(void); |
| 90 | |
| 91 | /* |
| 92 | * cpm_pm_exit |
| 93 | * |
| 94 | * Notifies listeners that a single cpu is exiting a low power state that may |
| 95 | * have caused some blocks in the same power domain as the cpu to reset. |
| 96 | * |
| 97 | * Must be called on the affected cpu with interrupts disabled. |
| 98 | */ |
| 99 | int cpu_pm_exit(void); |
| 100 | |
| 101 | /* |
| 102 | * cpm_cluster_pm_enter |
| 103 | * |
| 104 | * Notifies listeners that all cpus in a power domain are entering a low power |
| 105 | * state that may cause some blocks in the same power domain to reset. |
| 106 | * |
| 107 | * Must be called after cpu_pm_enter has been called on all cpus in the power |
| 108 | * domain, and before cpu_pm_exit has been called on any cpu in the power |
| 109 | * domain. |
| 110 | * |
| 111 | * Must be called with interrupts disabled. |
| 112 | */ |
| 113 | int cpu_cluster_pm_enter(void); |
| 114 | |
| 115 | /* |
| 116 | * cpm_pm_enter |
| 117 | * |
| 118 | * Notifies listeners that a single cpu is entering a low power state that may |
| 119 | * cause some blocks in the same power domain as the cpu to reset. |
| 120 | * |
| 121 | * Must be called after cpu_pm_enter has been called on all cpus in the power |
| 122 | * domain, and before cpu_pm_exit has been called on any cpu in the power |
| 123 | * domain. |
| 124 | * |
| 125 | * Must be called with interrupts disabled. |
| 126 | */ |
| 127 | int cpu_cluster_pm_exit(void); |
| 128 | |
| 129 | #endif |