diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/devfreq.h | 238 | ||||
| -rw-r--r-- | include/linux/device.h | 5 | ||||
| -rw-r--r-- | include/linux/freezer.h | 4 | ||||
| -rw-r--r-- | include/linux/netdevice.h | 4 | ||||
| -rw-r--r-- | include/linux/opp.h | 12 | ||||
| -rw-r--r-- | include/linux/pm.h | 26 | ||||
| -rw-r--r-- | include/linux/pm_clock.h | 71 | ||||
| -rw-r--r-- | include/linux/pm_domain.h | 26 | ||||
| -rw-r--r-- | include/linux/pm_qos.h | 155 | ||||
| -rw-r--r-- | include/linux/pm_qos_params.h | 38 | ||||
| -rw-r--r-- | include/linux/pm_runtime.h | 42 | ||||
| -rw-r--r-- | include/linux/suspend.h | 95 |
12 files changed, 622 insertions, 94 deletions
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h new file mode 100644 index 000000000000..afb94583960c --- /dev/null +++ b/include/linux/devfreq.h | |||
| @@ -0,0 +1,238 @@ | |||
| 1 | /* | ||
| 2 | * devfreq: Generic Dynamic Voltage and Frequency Scaling (DVFS) Framework | ||
| 3 | * for Non-CPU Devices. | ||
| 4 | * | ||
| 5 | * Copyright (C) 2011 Samsung Electronics | ||
| 6 | * MyungJoo Ham <myungjoo.ham@samsung.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef __LINUX_DEVFREQ_H__ | ||
| 14 | #define __LINUX_DEVFREQ_H__ | ||
| 15 | |||
| 16 | #include <linux/device.h> | ||
| 17 | #include <linux/notifier.h> | ||
| 18 | #include <linux/opp.h> | ||
| 19 | |||
| 20 | #define DEVFREQ_NAME_LEN 16 | ||
| 21 | |||
| 22 | struct devfreq; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * struct devfreq_dev_status - Data given from devfreq user device to | ||
| 26 | * governors. Represents the performance | ||
| 27 | * statistics. | ||
| 28 | * @total_time The total time represented by this instance of | ||
| 29 | * devfreq_dev_status | ||
| 30 | * @busy_time The time that the device was working among the | ||
| 31 | * total_time. | ||
| 32 | * @current_frequency The operating frequency. | ||
| 33 | * @private_data An entry not specified by the devfreq framework. | ||
| 34 | * A device and a specific governor may have their | ||
| 35 | * own protocol with private_data. However, because | ||
| 36 | * this is governor-specific, a governor using this | ||
| 37 | * will be only compatible with devices aware of it. | ||
| 38 | */ | ||
| 39 | struct devfreq_dev_status { | ||
| 40 | /* both since the last measure */ | ||
| 41 | unsigned long total_time; | ||
| 42 | unsigned long busy_time; | ||
| 43 | unsigned long current_frequency; | ||
| 44 | void *private_date; | ||
| 45 | }; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * struct devfreq_dev_profile - Devfreq's user device profile | ||
| 49 | * @initial_freq The operating frequency when devfreq_add_device() is | ||
| 50 | * called. | ||
| 51 | * @polling_ms The polling interval in ms. 0 disables polling. | ||
| 52 | * @target The device should set its operating frequency at | ||
| 53 | * freq or lowest-upper-than-freq value. If freq is | ||
| 54 | * higher than any operable frequency, set maximum. | ||
| 55 | * Before returning, target function should set | ||
| 56 | * freq at the current frequency. | ||
| 57 | * @get_dev_status The device should provide the current performance | ||
| 58 | * status to devfreq, which is used by governors. | ||
| 59 | * @exit An optional callback that is called when devfreq | ||
| 60 | * is removing the devfreq object due to error or | ||
| 61 | * from devfreq_remove_device() call. If the user | ||
| 62 | * has registered devfreq->nb at a notifier-head, | ||
| 63 | * this is the time to unregister it. | ||
| 64 | */ | ||
| 65 | struct devfreq_dev_profile { | ||
| 66 | unsigned long initial_freq; | ||
| 67 | unsigned int polling_ms; | ||
| 68 | |||
| 69 | int (*target)(struct device *dev, unsigned long *freq); | ||
| 70 | int (*get_dev_status)(struct device *dev, | ||
| 71 | struct devfreq_dev_status *stat); | ||
| 72 | void (*exit)(struct device *dev); | ||
| 73 | }; | ||
| 74 | |||
| 75 | /** | ||
| 76 | * struct devfreq_governor - Devfreq policy governor | ||
| 77 | * @name Governor's name | ||
| 78 | * @get_target_freq Returns desired operating frequency for the device. | ||
| 79 | * Basically, get_target_freq will run | ||
| 80 | * devfreq_dev_profile.get_dev_status() to get the | ||
| 81 | * status of the device (load = busy_time / total_time). | ||
| 82 | * If no_central_polling is set, this callback is called | ||
| 83 | * only with update_devfreq() notified by OPP. | ||
| 84 | * @init Called when the devfreq is being attached to a device | ||
| 85 | * @exit Called when the devfreq is being removed from a | ||
| 86 | * device. Governor should stop any internal routines | ||
| 87 | * before return because related data may be | ||
| 88 | * freed after exit(). | ||
| 89 | * @no_central_polling Do not use devfreq's central polling mechanism. | ||
| 90 | * When this is set, devfreq will not call | ||
| 91 | * get_target_freq with devfreq_monitor(). However, | ||
| 92 | * devfreq will call get_target_freq with | ||
| 93 | * devfreq_update() notified by OPP framework. | ||
| 94 | * | ||
| 95 | * Note that the callbacks are called with devfreq->lock locked by devfreq. | ||
| 96 | */ | ||
| 97 | struct devfreq_governor { | ||
| 98 | const char name[DEVFREQ_NAME_LEN]; | ||
| 99 | int (*get_target_freq)(struct devfreq *this, unsigned long *freq); | ||
| 100 | int (*init)(struct devfreq *this); | ||
| 101 | void (*exit)(struct devfreq *this); | ||
| 102 | const bool no_central_polling; | ||
| 103 | }; | ||
| 104 | |||
| 105 | /** | ||
| 106 | * struct devfreq - Device devfreq structure | ||
| 107 | * @node list node - contains the devices with devfreq that have been | ||
| 108 | * registered. | ||
| 109 | * @lock a mutex to protect accessing devfreq. | ||
| 110 | * @dev device registered by devfreq class. dev.parent is the device | ||
| 111 | * using devfreq. | ||
| 112 | * @profile device-specific devfreq profile | ||
| 113 | * @governor method how to choose frequency based on the usage. | ||
| 114 | * @nb notifier block used to notify devfreq object that it should | ||
| 115 | * reevaluate operable frequencies. Devfreq users may use | ||
| 116 | * devfreq.nb to the corresponding register notifier call chain. | ||
| 117 | * @polling_jiffies interval in jiffies. | ||
| 118 | * @previous_freq previously configured frequency value. | ||
| 119 | * @next_polling the number of remaining jiffies to poll with | ||
| 120 | * "devfreq_monitor" executions to reevaluate | ||
| 121 | * frequency/voltage of the device. Set by | ||
| 122 | * profile's polling_ms interval. | ||
| 123 | * @data Private data of the governor. The devfreq framework does not | ||
| 124 | * touch this. | ||
| 125 | * @being_removed a flag to mark that this object is being removed in | ||
| 126 | * order to prevent trying to remove the object multiple times. | ||
| 127 | * | ||
| 128 | * This structure stores the devfreq information for a give device. | ||
| 129 | * | ||
| 130 | * Note that when a governor accesses entries in struct devfreq in its | ||
| 131 | * functions except for the context of callbacks defined in struct | ||
| 132 | * devfreq_governor, the governor should protect its access with the | ||
| 133 | * struct mutex lock in struct devfreq. A governor may use this mutex | ||
| 134 | * to protect its own private data in void *data as well. | ||
| 135 | */ | ||
| 136 | struct devfreq { | ||
| 137 | struct list_head node; | ||
| 138 | |||
| 139 | struct mutex lock; | ||
| 140 | struct device dev; | ||
| 141 | struct devfreq_dev_profile *profile; | ||
| 142 | const struct devfreq_governor *governor; | ||
| 143 | struct notifier_block nb; | ||
| 144 | |||
| 145 | unsigned long polling_jiffies; | ||
| 146 | unsigned long previous_freq; | ||
| 147 | unsigned int next_polling; | ||
| 148 | |||
| 149 | void *data; /* private data for governors */ | ||
| 150 | |||
| 151 | bool being_removed; | ||
| 152 | }; | ||
| 153 | |||
| 154 | #if defined(CONFIG_PM_DEVFREQ) | ||
| 155 | extern struct devfreq *devfreq_add_device(struct device *dev, | ||
| 156 | struct devfreq_dev_profile *profile, | ||
| 157 | const struct devfreq_governor *governor, | ||
| 158 | void *data); | ||
| 159 | extern int devfreq_remove_device(struct devfreq *devfreq); | ||
| 160 | |||
| 161 | /* Helper functions for devfreq user device driver with OPP. */ | ||
| 162 | extern struct opp *devfreq_recommended_opp(struct device *dev, | ||
| 163 | unsigned long *freq); | ||
| 164 | extern int devfreq_register_opp_notifier(struct device *dev, | ||
| 165 | struct devfreq *devfreq); | ||
| 166 | extern int devfreq_unregister_opp_notifier(struct device *dev, | ||
| 167 | struct devfreq *devfreq); | ||
| 168 | |||
| 169 | #ifdef CONFIG_DEVFREQ_GOV_POWERSAVE | ||
| 170 | extern const struct devfreq_governor devfreq_powersave; | ||
| 171 | #endif | ||
| 172 | #ifdef CONFIG_DEVFREQ_GOV_PERFORMANCE | ||
| 173 | extern const struct devfreq_governor devfreq_performance; | ||
| 174 | #endif | ||
| 175 | #ifdef CONFIG_DEVFREQ_GOV_USERSPACE | ||
| 176 | extern const struct devfreq_governor devfreq_userspace; | ||
| 177 | #endif | ||
| 178 | #ifdef CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND | ||
| 179 | extern const struct devfreq_governor devfreq_simple_ondemand; | ||
| 180 | /** | ||
| 181 | * struct devfreq_simple_ondemand_data - void *data fed to struct devfreq | ||
| 182 | * and devfreq_add_device | ||
| 183 | * @ upthreshold If the load is over this value, the frequency jumps. | ||
| 184 | * Specify 0 to use the default. Valid value = 0 to 100. | ||
| 185 | * @ downdifferential If the load is under upthreshold - downdifferential, | ||
| 186 | * the governor may consider slowing the frequency down. | ||
| 187 | * Specify 0 to use the default. Valid value = 0 to 100. | ||
| 188 | * downdifferential < upthreshold must hold. | ||
| 189 | * | ||
| 190 | * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor, | ||
| 191 | * the governor uses the default values. | ||
| 192 | */ | ||
| 193 | struct devfreq_simple_ondemand_data { | ||
| 194 | unsigned int upthreshold; | ||
| 195 | unsigned int downdifferential; | ||
| 196 | }; | ||
| 197 | #endif | ||
| 198 | |||
| 199 | #else /* !CONFIG_PM_DEVFREQ */ | ||
| 200 | static struct devfreq *devfreq_add_device(struct device *dev, | ||
| 201 | struct devfreq_dev_profile *profile, | ||
| 202 | struct devfreq_governor *governor, | ||
| 203 | void *data); | ||
| 204 | { | ||
| 205 | return NULL; | ||
| 206 | } | ||
| 207 | |||
| 208 | static int devfreq_remove_device(struct devfreq *devfreq); | ||
| 209 | { | ||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | static struct opp *devfreq_recommended_opp(struct device *dev, | ||
| 214 | unsigned long *freq) | ||
| 215 | { | ||
| 216 | return -EINVAL; | ||
| 217 | } | ||
| 218 | |||
| 219 | static int devfreq_register_opp_notifier(struct device *dev, | ||
| 220 | struct devfreq *devfreq) | ||
| 221 | { | ||
| 222 | return -EINVAL; | ||
| 223 | } | ||
| 224 | |||
| 225 | static int devfreq_unregister_opp_notifier(struct device *dev, | ||
| 226 | struct devfreq *devfreq) | ||
| 227 | { | ||
| 228 | return -EINVAL; | ||
| 229 | } | ||
| 230 | |||
| 231 | #define devfreq_powersave NULL | ||
| 232 | #define devfreq_performance NULL | ||
| 233 | #define devfreq_userspace NULL | ||
| 234 | #define devfreq_simple_ondemand NULL | ||
| 235 | |||
| 236 | #endif /* CONFIG_PM_DEVFREQ */ | ||
| 237 | |||
| 238 | #endif /* __LINUX_DEVFREQ_H__ */ | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 46751bdb71da..bdcf361ca938 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -638,6 +638,11 @@ static inline void set_dev_node(struct device *dev, int node) | |||
| 638 | } | 638 | } |
| 639 | #endif | 639 | #endif |
| 640 | 640 | ||
| 641 | static inline struct pm_subsys_data *dev_to_psd(struct device *dev) | ||
| 642 | { | ||
| 643 | return dev ? dev->power.subsys_data : NULL; | ||
| 644 | } | ||
| 645 | |||
| 641 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) | 646 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) |
| 642 | { | 647 | { |
| 643 | return dev->kobj.uevent_suppress; | 648 | return dev->kobj.uevent_suppress; |
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 1effc8b56b4e..aa56cf31f7ff 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
| @@ -49,6 +49,7 @@ extern int thaw_process(struct task_struct *p); | |||
| 49 | 49 | ||
| 50 | extern void refrigerator(void); | 50 | extern void refrigerator(void); |
| 51 | extern int freeze_processes(void); | 51 | extern int freeze_processes(void); |
| 52 | extern int freeze_kernel_threads(void); | ||
| 52 | extern void thaw_processes(void); | 53 | extern void thaw_processes(void); |
| 53 | 54 | ||
| 54 | static inline int try_to_freeze(void) | 55 | static inline int try_to_freeze(void) |
| @@ -171,7 +172,8 @@ static inline void clear_freeze_flag(struct task_struct *p) {} | |||
| 171 | static inline int thaw_process(struct task_struct *p) { return 1; } | 172 | static inline int thaw_process(struct task_struct *p) { return 1; } |
| 172 | 173 | ||
| 173 | static inline void refrigerator(void) {} | 174 | static inline void refrigerator(void) {} |
| 174 | static inline int freeze_processes(void) { BUG(); return 0; } | 175 | static inline int freeze_processes(void) { return -ENOSYS; } |
| 176 | static inline int freeze_kernel_threads(void) { return -ENOSYS; } | ||
| 175 | static inline void thaw_processes(void) {} | 177 | static inline void thaw_processes(void) {} |
| 176 | 178 | ||
| 177 | static inline int try_to_freeze(void) { return 0; } | 179 | static inline int try_to_freeze(void) { return 0; } |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index c8615cd0b2f6..df1c836e6948 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #include <linux/if_link.h> | 31 | #include <linux/if_link.h> |
| 32 | 32 | ||
| 33 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
| 34 | #include <linux/pm_qos_params.h> | 34 | #include <linux/pm_qos.h> |
| 35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
| 36 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
| 37 | #include <linux/atomic.h> | 37 | #include <linux/atomic.h> |
| @@ -969,7 +969,7 @@ struct net_device { | |||
| 969 | */ | 969 | */ |
| 970 | char name[IFNAMSIZ]; | 970 | char name[IFNAMSIZ]; |
| 971 | 971 | ||
| 972 | struct pm_qos_request_list pm_qos_req; | 972 | struct pm_qos_request pm_qos_req; |
| 973 | 973 | ||
| 974 | /* device name hash chain */ | 974 | /* device name hash chain */ |
| 975 | struct hlist_node name_hlist; | 975 | struct hlist_node name_hlist; |
diff --git a/include/linux/opp.h b/include/linux/opp.h index 7020e9736fc5..87a9208f8aec 100644 --- a/include/linux/opp.h +++ b/include/linux/opp.h | |||
| @@ -16,9 +16,14 @@ | |||
| 16 | 16 | ||
| 17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 18 | #include <linux/cpufreq.h> | 18 | #include <linux/cpufreq.h> |
| 19 | #include <linux/notifier.h> | ||
| 19 | 20 | ||
| 20 | struct opp; | 21 | struct opp; |
| 21 | 22 | ||
| 23 | enum opp_event { | ||
| 24 | OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, | ||
| 25 | }; | ||
| 26 | |||
| 22 | #if defined(CONFIG_PM_OPP) | 27 | #if defined(CONFIG_PM_OPP) |
| 23 | 28 | ||
| 24 | unsigned long opp_get_voltage(struct opp *opp); | 29 | unsigned long opp_get_voltage(struct opp *opp); |
| @@ -40,6 +45,8 @@ int opp_enable(struct device *dev, unsigned long freq); | |||
| 40 | 45 | ||
| 41 | int opp_disable(struct device *dev, unsigned long freq); | 46 | int opp_disable(struct device *dev, unsigned long freq); |
| 42 | 47 | ||
| 48 | struct srcu_notifier_head *opp_get_notifier(struct device *dev); | ||
| 49 | |||
| 43 | #else | 50 | #else |
| 44 | static inline unsigned long opp_get_voltage(struct opp *opp) | 51 | static inline unsigned long opp_get_voltage(struct opp *opp) |
| 45 | { | 52 | { |
| @@ -89,6 +96,11 @@ static inline int opp_disable(struct device *dev, unsigned long freq) | |||
| 89 | { | 96 | { |
| 90 | return 0; | 97 | return 0; |
| 91 | } | 98 | } |
| 99 | |||
| 100 | struct srcu_notifier_head *opp_get_notifier(struct device *dev) | ||
| 101 | { | ||
| 102 | return ERR_PTR(-EINVAL); | ||
| 103 | } | ||
| 92 | #endif /* CONFIG_PM */ | 104 | #endif /* CONFIG_PM */ |
| 93 | 105 | ||
| 94 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) | 106 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) |
diff --git a/include/linux/pm.h b/include/linux/pm.h index f7c84c9abd30..f15acb646813 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
| @@ -326,6 +326,7 @@ extern struct dev_pm_ops generic_subsys_pm_ops; | |||
| 326 | * requested by a driver. | 326 | * requested by a driver. |
| 327 | */ | 327 | */ |
| 328 | 328 | ||
| 329 | #define PM_EVENT_INVALID (-1) | ||
| 329 | #define PM_EVENT_ON 0x0000 | 330 | #define PM_EVENT_ON 0x0000 |
| 330 | #define PM_EVENT_FREEZE 0x0001 | 331 | #define PM_EVENT_FREEZE 0x0001 |
| 331 | #define PM_EVENT_SUSPEND 0x0002 | 332 | #define PM_EVENT_SUSPEND 0x0002 |
| @@ -346,6 +347,7 @@ extern struct dev_pm_ops generic_subsys_pm_ops; | |||
| 346 | #define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND) | 347 | #define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND) |
| 347 | #define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME) | 348 | #define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME) |
| 348 | 349 | ||
| 350 | #define PMSG_INVALID ((struct pm_message){ .event = PM_EVENT_INVALID, }) | ||
| 349 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | 351 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) |
| 350 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | 352 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) |
| 351 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) | 353 | #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) |
| @@ -366,6 +368,8 @@ extern struct dev_pm_ops generic_subsys_pm_ops; | |||
| 366 | #define PMSG_AUTO_RESUME ((struct pm_message) \ | 368 | #define PMSG_AUTO_RESUME ((struct pm_message) \ |
| 367 | { .event = PM_EVENT_AUTO_RESUME, }) | 369 | { .event = PM_EVENT_AUTO_RESUME, }) |
| 368 | 370 | ||
| 371 | #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) | ||
| 372 | |||
| 369 | /** | 373 | /** |
| 370 | * Device run-time power management status. | 374 | * Device run-time power management status. |
| 371 | * | 375 | * |
| @@ -421,6 +425,22 @@ enum rpm_request { | |||
| 421 | 425 | ||
| 422 | struct wakeup_source; | 426 | struct wakeup_source; |
| 423 | 427 | ||
| 428 | struct pm_domain_data { | ||
| 429 | struct list_head list_node; | ||
| 430 | struct device *dev; | ||
| 431 | }; | ||
| 432 | |||
| 433 | struct pm_subsys_data { | ||
| 434 | spinlock_t lock; | ||
| 435 | unsigned int refcount; | ||
| 436 | #ifdef CONFIG_PM_CLK | ||
| 437 | struct list_head clock_list; | ||
| 438 | #endif | ||
| 439 | #ifdef CONFIG_PM_GENERIC_DOMAINS | ||
| 440 | struct pm_domain_data *domain_data; | ||
| 441 | #endif | ||
| 442 | }; | ||
| 443 | |||
| 424 | struct dev_pm_info { | 444 | struct dev_pm_info { |
| 425 | pm_message_t power_state; | 445 | pm_message_t power_state; |
| 426 | unsigned int can_wakeup:1; | 446 | unsigned int can_wakeup:1; |
| @@ -432,6 +452,7 @@ struct dev_pm_info { | |||
| 432 | struct list_head entry; | 452 | struct list_head entry; |
| 433 | struct completion completion; | 453 | struct completion completion; |
| 434 | struct wakeup_source *wakeup; | 454 | struct wakeup_source *wakeup; |
| 455 | bool wakeup_path:1; | ||
| 435 | #else | 456 | #else |
| 436 | unsigned int should_wakeup:1; | 457 | unsigned int should_wakeup:1; |
| 437 | #endif | 458 | #endif |
| @@ -462,10 +483,13 @@ struct dev_pm_info { | |||
| 462 | unsigned long suspended_jiffies; | 483 | unsigned long suspended_jiffies; |
| 463 | unsigned long accounting_timestamp; | 484 | unsigned long accounting_timestamp; |
| 464 | #endif | 485 | #endif |
| 465 | void *subsys_data; /* Owned by the subsystem. */ | 486 | struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ |
| 487 | struct pm_qos_constraints *constraints; | ||
| 466 | }; | 488 | }; |
| 467 | 489 | ||
| 468 | extern void update_pm_runtime_accounting(struct device *dev); | 490 | extern void update_pm_runtime_accounting(struct device *dev); |
| 491 | extern int dev_pm_get_subsys_data(struct device *dev); | ||
| 492 | extern int dev_pm_put_subsys_data(struct device *dev); | ||
| 469 | 493 | ||
| 470 | /* | 494 | /* |
| 471 | * Power domains provide callbacks that are executed during system suspend, | 495 | * Power domains provide callbacks that are executed during system suspend, |
diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h new file mode 100644 index 000000000000..8348866e7b05 --- /dev/null +++ b/include/linux/pm_clock.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | /* | ||
| 2 | * pm_clock.h - Definitions and headers related to device clocks. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp. | ||
| 5 | * | ||
| 6 | * This file is released under the GPLv2. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef _LINUX_PM_CLOCK_H | ||
| 10 | #define _LINUX_PM_CLOCK_H | ||
| 11 | |||
| 12 | #include <linux/device.h> | ||
| 13 | #include <linux/notifier.h> | ||
| 14 | |||
| 15 | struct pm_clk_notifier_block { | ||
| 16 | struct notifier_block nb; | ||
| 17 | struct dev_pm_domain *pm_domain; | ||
| 18 | char *con_ids[]; | ||
| 19 | }; | ||
| 20 | |||
| 21 | #ifdef CONFIG_PM_CLK | ||
| 22 | static inline bool pm_clk_no_clocks(struct device *dev) | ||
| 23 | { | ||
| 24 | return dev && dev->power.subsys_data | ||
| 25 | && list_empty(&dev->power.subsys_data->clock_list); | ||
| 26 | } | ||
| 27 | |||
| 28 | extern void pm_clk_init(struct device *dev); | ||
| 29 | extern int pm_clk_create(struct device *dev); | ||
| 30 | extern void pm_clk_destroy(struct device *dev); | ||
| 31 | extern int pm_clk_add(struct device *dev, const char *con_id); | ||
| 32 | extern void pm_clk_remove(struct device *dev, const char *con_id); | ||
| 33 | extern int pm_clk_suspend(struct device *dev); | ||
| 34 | extern int pm_clk_resume(struct device *dev); | ||
| 35 | #else | ||
| 36 | static inline bool pm_clk_no_clocks(struct device *dev) | ||
| 37 | { | ||
| 38 | return true; | ||
| 39 | } | ||
| 40 | static inline void pm_clk_init(struct device *dev) | ||
| 41 | { | ||
| 42 | } | ||
| 43 | static inline int pm_clk_create(struct device *dev) | ||
| 44 | { | ||
| 45 | return -EINVAL; | ||
| 46 | } | ||
| 47 | static inline void pm_clk_destroy(struct device *dev) | ||
| 48 | { | ||
| 49 | } | ||
| 50 | static inline int pm_clk_add(struct device *dev, const char *con_id) | ||
| 51 | { | ||
| 52 | return -EINVAL; | ||
| 53 | } | ||
| 54 | static inline void pm_clk_remove(struct device *dev, const char *con_id) | ||
| 55 | { | ||
| 56 | } | ||
| 57 | #define pm_clk_suspend NULL | ||
| 58 | #define pm_clk_resume NULL | ||
| 59 | #endif | ||
| 60 | |||
| 61 | #ifdef CONFIG_HAVE_CLK | ||
| 62 | extern void pm_clk_add_notifier(struct bus_type *bus, | ||
| 63 | struct pm_clk_notifier_block *clknb); | ||
| 64 | #else | ||
| 65 | static inline void pm_clk_add_notifier(struct bus_type *bus, | ||
| 66 | struct pm_clk_notifier_block *clknb) | ||
| 67 | { | ||
| 68 | } | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #endif | ||
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f9ec1736a116..65633e5a2bc0 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | enum gpd_status { | 14 | enum gpd_status { |
| 15 | GPD_STATE_ACTIVE = 0, /* PM domain is active */ | 15 | GPD_STATE_ACTIVE = 0, /* PM domain is active */ |
| 16 | GPD_STATE_WAIT_MASTER, /* PM domain's master is being waited for */ | ||
| 16 | GPD_STATE_BUSY, /* Something is happening to the PM domain */ | 17 | GPD_STATE_BUSY, /* Something is happening to the PM domain */ |
| 17 | GPD_STATE_REPEAT, /* Power off in progress, to be repeated */ | 18 | GPD_STATE_REPEAT, /* Power off in progress, to be repeated */ |
| 18 | GPD_STATE_POWER_OFF, /* PM domain is off */ | 19 | GPD_STATE_POWER_OFF, /* PM domain is off */ |
| @@ -25,15 +26,14 @@ struct dev_power_governor { | |||
| 25 | struct generic_pm_domain { | 26 | struct generic_pm_domain { |
| 26 | struct dev_pm_domain domain; /* PM domain operations */ | 27 | struct dev_pm_domain domain; /* PM domain operations */ |
| 27 | struct list_head gpd_list_node; /* Node in the global PM domains list */ | 28 | struct list_head gpd_list_node; /* Node in the global PM domains list */ |
| 28 | struct list_head sd_node; /* Node in the parent's subdomain list */ | 29 | struct list_head master_links; /* Links with PM domain as a master */ |
| 29 | struct generic_pm_domain *parent; /* Parent PM domain */ | 30 | struct list_head slave_links; /* Links with PM domain as a slave */ |
| 30 | struct list_head sd_list; /* List of dubdomains */ | ||
| 31 | struct list_head dev_list; /* List of devices */ | 31 | struct list_head dev_list; /* List of devices */ |
| 32 | struct mutex lock; | 32 | struct mutex lock; |
| 33 | struct dev_power_governor *gov; | 33 | struct dev_power_governor *gov; |
| 34 | struct work_struct power_off_work; | 34 | struct work_struct power_off_work; |
| 35 | unsigned int in_progress; /* Number of devices being suspended now */ | 35 | unsigned int in_progress; /* Number of devices being suspended now */ |
| 36 | unsigned int sd_count; /* Number of subdomains with power "on" */ | 36 | atomic_t sd_count; /* Number of subdomains with power "on" */ |
| 37 | enum gpd_status status; /* Current state of the domain */ | 37 | enum gpd_status status; /* Current state of the domain */ |
| 38 | wait_queue_head_t status_wait_queue; | 38 | wait_queue_head_t status_wait_queue; |
| 39 | struct task_struct *poweroff_task; /* Powering off task */ | 39 | struct task_struct *poweroff_task; /* Powering off task */ |
| @@ -42,6 +42,7 @@ struct generic_pm_domain { | |||
| 42 | unsigned int suspended_count; /* System suspend device counter */ | 42 | unsigned int suspended_count; /* System suspend device counter */ |
| 43 | unsigned int prepared_count; /* Suspend counter of prepared devices */ | 43 | unsigned int prepared_count; /* Suspend counter of prepared devices */ |
| 44 | bool suspend_power_off; /* Power status before system suspend */ | 44 | bool suspend_power_off; /* Power status before system suspend */ |
| 45 | bool dev_irq_safe; /* Device callbacks are IRQ-safe */ | ||
| 45 | int (*power_off)(struct generic_pm_domain *domain); | 46 | int (*power_off)(struct generic_pm_domain *domain); |
| 46 | int (*power_on)(struct generic_pm_domain *domain); | 47 | int (*power_on)(struct generic_pm_domain *domain); |
| 47 | int (*start_device)(struct device *dev); | 48 | int (*start_device)(struct device *dev); |
| @@ -54,12 +55,23 @@ static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) | |||
| 54 | return container_of(pd, struct generic_pm_domain, domain); | 55 | return container_of(pd, struct generic_pm_domain, domain); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | struct dev_list_entry { | 58 | struct gpd_link { |
| 58 | struct list_head node; | 59 | struct generic_pm_domain *master; |
| 59 | struct device *dev; | 60 | struct list_head master_node; |
| 61 | struct generic_pm_domain *slave; | ||
| 62 | struct list_head slave_node; | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct generic_pm_domain_data { | ||
| 66 | struct pm_domain_data base; | ||
| 60 | bool need_restore; | 67 | bool need_restore; |
| 61 | }; | 68 | }; |
| 62 | 69 | ||
| 70 | static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd) | ||
| 71 | { | ||
| 72 | return container_of(pdd, struct generic_pm_domain_data, base); | ||
| 73 | } | ||
| 74 | |||
| 63 | #ifdef CONFIG_PM_GENERIC_DOMAINS | 75 | #ifdef CONFIG_PM_GENERIC_DOMAINS |
| 64 | extern int pm_genpd_add_device(struct generic_pm_domain *genpd, | 76 | extern int pm_genpd_add_device(struct generic_pm_domain *genpd, |
| 65 | struct device *dev); | 77 | struct device *dev); |
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h new file mode 100644 index 000000000000..83b0ea302a80 --- /dev/null +++ b/include/linux/pm_qos.h | |||
| @@ -0,0 +1,155 @@ | |||
| 1 | #ifndef _LINUX_PM_QOS_H | ||
| 2 | #define _LINUX_PM_QOS_H | ||
| 3 | /* interface for the pm_qos_power infrastructure of the linux kernel. | ||
| 4 | * | ||
| 5 | * Mark Gross <mgross@linux.intel.com> | ||
| 6 | */ | ||
| 7 | #include <linux/plist.h> | ||
| 8 | #include <linux/notifier.h> | ||
| 9 | #include <linux/miscdevice.h> | ||
| 10 | #include <linux/device.h> | ||
| 11 | |||
| 12 | #define PM_QOS_RESERVED 0 | ||
| 13 | #define PM_QOS_CPU_DMA_LATENCY 1 | ||
| 14 | #define PM_QOS_NETWORK_LATENCY 2 | ||
| 15 | #define PM_QOS_NETWORK_THROUGHPUT 3 | ||
| 16 | |||
| 17 | #define PM_QOS_NUM_CLASSES 4 | ||
| 18 | #define PM_QOS_DEFAULT_VALUE -1 | ||
| 19 | |||
| 20 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
| 21 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
| 22 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 | ||
| 23 | #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 | ||
| 24 | |||
| 25 | struct pm_qos_request { | ||
| 26 | struct plist_node node; | ||
| 27 | int pm_qos_class; | ||
| 28 | }; | ||
| 29 | |||
| 30 | struct dev_pm_qos_request { | ||
| 31 | struct plist_node node; | ||
| 32 | struct device *dev; | ||
| 33 | }; | ||
| 34 | |||
| 35 | enum pm_qos_type { | ||
| 36 | PM_QOS_UNITIALIZED, | ||
| 37 | PM_QOS_MAX, /* return the largest value */ | ||
| 38 | PM_QOS_MIN /* return the smallest value */ | ||
| 39 | }; | ||
| 40 | |||
| 41 | /* | ||
| 42 | * Note: The lockless read path depends on the CPU accessing | ||
| 43 | * target_value atomically. Atomic access is only guaranteed on all CPU | ||
| 44 | * types linux supports for 32 bit quantites | ||
| 45 | */ | ||
| 46 | struct pm_qos_constraints { | ||
| 47 | struct plist_head list; | ||
| 48 | s32 target_value; /* Do not change to 64 bit */ | ||
| 49 | s32 default_value; | ||
| 50 | enum pm_qos_type type; | ||
| 51 | struct blocking_notifier_head *notifiers; | ||
| 52 | }; | ||
| 53 | |||
| 54 | /* Action requested to pm_qos_update_target */ | ||
| 55 | enum pm_qos_req_action { | ||
| 56 | PM_QOS_ADD_REQ, /* Add a new request */ | ||
| 57 | PM_QOS_UPDATE_REQ, /* Update an existing request */ | ||
| 58 | PM_QOS_REMOVE_REQ /* Remove an existing request */ | ||
| 59 | }; | ||
| 60 | |||
| 61 | static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req) | ||
| 62 | { | ||
| 63 | return req->dev != 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | #ifdef CONFIG_PM | ||
| 67 | int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, | ||
| 68 | enum pm_qos_req_action action, int value); | ||
| 69 | void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, | ||
| 70 | s32 value); | ||
| 71 | void pm_qos_update_request(struct pm_qos_request *req, | ||
| 72 | s32 new_value); | ||
| 73 | void pm_qos_remove_request(struct pm_qos_request *req); | ||
| 74 | |||
| 75 | int pm_qos_request(int pm_qos_class); | ||
| 76 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
| 77 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
| 78 | int pm_qos_request_active(struct pm_qos_request *req); | ||
| 79 | s32 pm_qos_read_value(struct pm_qos_constraints *c); | ||
| 80 | |||
| 81 | s32 dev_pm_qos_read_value(struct device *dev); | ||
| 82 | int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, | ||
| 83 | s32 value); | ||
| 84 | int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); | ||
| 85 | int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); | ||
| 86 | int dev_pm_qos_add_notifier(struct device *dev, | ||
| 87 | struct notifier_block *notifier); | ||
| 88 | int dev_pm_qos_remove_notifier(struct device *dev, | ||
| 89 | struct notifier_block *notifier); | ||
| 90 | int dev_pm_qos_add_global_notifier(struct notifier_block *notifier); | ||
| 91 | int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier); | ||
| 92 | void dev_pm_qos_constraints_init(struct device *dev); | ||
| 93 | void dev_pm_qos_constraints_destroy(struct device *dev); | ||
| 94 | #else | ||
| 95 | static inline int pm_qos_update_target(struct pm_qos_constraints *c, | ||
| 96 | struct plist_node *node, | ||
| 97 | enum pm_qos_req_action action, | ||
| 98 | int value) | ||
| 99 | { return 0; } | ||
| 100 | static inline void pm_qos_add_request(struct pm_qos_request *req, | ||
| 101 | int pm_qos_class, s32 value) | ||
| 102 | { return; } | ||
| 103 | static inline void pm_qos_update_request(struct pm_qos_request *req, | ||
| 104 | s32 new_value) | ||
| 105 | { return; } | ||
| 106 | static inline void pm_qos_remove_request(struct pm_qos_request *req) | ||
| 107 | { return; } | ||
| 108 | |||
| 109 | static inline int pm_qos_request(int pm_qos_class) | ||
| 110 | { return 0; } | ||
| 111 | static inline int pm_qos_add_notifier(int pm_qos_class, | ||
| 112 | struct notifier_block *notifier) | ||
| 113 | { return 0; } | ||
| 114 | static inline int pm_qos_remove_notifier(int pm_qos_class, | ||
| 115 | struct notifier_block *notifier) | ||
| 116 | { return 0; } | ||
| 117 | static inline int pm_qos_request_active(struct pm_qos_request *req) | ||
| 118 | { return 0; } | ||
| 119 | static inline s32 pm_qos_read_value(struct pm_qos_constraints *c) | ||
| 120 | { return 0; } | ||
| 121 | |||
| 122 | static inline s32 dev_pm_qos_read_value(struct device *dev) | ||
| 123 | { return 0; } | ||
| 124 | static inline int dev_pm_qos_add_request(struct device *dev, | ||
| 125 | struct dev_pm_qos_request *req, | ||
| 126 | s32 value) | ||
| 127 | { return 0; } | ||
| 128 | static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req, | ||
| 129 | s32 new_value) | ||
| 130 | { return 0; } | ||
| 131 | static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) | ||
| 132 | { return 0; } | ||
| 133 | static inline int dev_pm_qos_add_notifier(struct device *dev, | ||
| 134 | struct notifier_block *notifier) | ||
| 135 | { return 0; } | ||
| 136 | static inline int dev_pm_qos_remove_notifier(struct device *dev, | ||
| 137 | struct notifier_block *notifier) | ||
| 138 | { return 0; } | ||
| 139 | static inline int dev_pm_qos_add_global_notifier( | ||
| 140 | struct notifier_block *notifier) | ||
| 141 | { return 0; } | ||
| 142 | static inline int dev_pm_qos_remove_global_notifier( | ||
| 143 | struct notifier_block *notifier) | ||
| 144 | { return 0; } | ||
| 145 | static inline void dev_pm_qos_constraints_init(struct device *dev) | ||
| 146 | { | ||
| 147 | dev->power.power_state = PMSG_ON; | ||
| 148 | } | ||
| 149 | static inline void dev_pm_qos_constraints_destroy(struct device *dev) | ||
| 150 | { | ||
| 151 | dev->power.power_state = PMSG_INVALID; | ||
| 152 | } | ||
| 153 | #endif | ||
| 154 | |||
| 155 | #endif | ||
diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h deleted file mode 100644 index a7d87f911cab..000000000000 --- a/include/linux/pm_qos_params.h +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | #ifndef _LINUX_PM_QOS_PARAMS_H | ||
| 2 | #define _LINUX_PM_QOS_PARAMS_H | ||
| 3 | /* interface for the pm_qos_power infrastructure of the linux kernel. | ||
| 4 | * | ||
| 5 | * Mark Gross <mgross@linux.intel.com> | ||
| 6 | */ | ||
| 7 | #include <linux/plist.h> | ||
| 8 | #include <linux/notifier.h> | ||
| 9 | #include <linux/miscdevice.h> | ||
| 10 | |||
| 11 | #define PM_QOS_RESERVED 0 | ||
| 12 | #define PM_QOS_CPU_DMA_LATENCY 1 | ||
| 13 | #define PM_QOS_NETWORK_LATENCY 2 | ||
| 14 | #define PM_QOS_NETWORK_THROUGHPUT 3 | ||
| 15 | |||
| 16 | #define PM_QOS_NUM_CLASSES 4 | ||
| 17 | #define PM_QOS_DEFAULT_VALUE -1 | ||
| 18 | |||
| 19 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
| 20 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | ||
| 21 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 | ||
| 22 | |||
| 23 | struct pm_qos_request_list { | ||
| 24 | struct plist_node list; | ||
| 25 | int pm_qos_class; | ||
| 26 | }; | ||
| 27 | |||
| 28 | void pm_qos_add_request(struct pm_qos_request_list *l, int pm_qos_class, s32 value); | ||
| 29 | void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req, | ||
| 30 | s32 new_value); | ||
| 31 | void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req); | ||
| 32 | |||
| 33 | int pm_qos_request(int pm_qos_class); | ||
| 34 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
| 35 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); | ||
| 36 | int pm_qos_request_active(struct pm_qos_request_list *req); | ||
| 37 | |||
| 38 | #endif | ||
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index daac05d751b2..70b284024d9e 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h | |||
| @@ -251,46 +251,4 @@ static inline void pm_runtime_dont_use_autosuspend(struct device *dev) | |||
| 251 | __pm_runtime_use_autosuspend(dev, false); | 251 | __pm_runtime_use_autosuspend(dev, false); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | struct pm_clk_notifier_block { | ||
| 255 | struct notifier_block nb; | ||
| 256 | struct dev_pm_domain *pm_domain; | ||
| 257 | char *con_ids[]; | ||
| 258 | }; | ||
| 259 | |||
| 260 | #ifdef CONFIG_PM_CLK | ||
| 261 | extern int pm_clk_init(struct device *dev); | ||
| 262 | extern void pm_clk_destroy(struct device *dev); | ||
| 263 | extern int pm_clk_add(struct device *dev, const char *con_id); | ||
| 264 | extern void pm_clk_remove(struct device *dev, const char *con_id); | ||
| 265 | extern int pm_clk_suspend(struct device *dev); | ||
| 266 | extern int pm_clk_resume(struct device *dev); | ||
| 267 | #else | ||
| 268 | static inline int pm_clk_init(struct device *dev) | ||
| 269 | { | ||
| 270 | return -EINVAL; | ||
| 271 | } | ||
| 272 | static inline void pm_clk_destroy(struct device *dev) | ||
| 273 | { | ||
| 274 | } | ||
| 275 | static inline int pm_clk_add(struct device *dev, const char *con_id) | ||
| 276 | { | ||
| 277 | return -EINVAL; | ||
| 278 | } | ||
| 279 | static inline void pm_clk_remove(struct device *dev, const char *con_id) | ||
| 280 | { | ||
| 281 | } | ||
| 282 | #define pm_clk_suspend NULL | ||
| 283 | #define pm_clk_resume NULL | ||
| 284 | #endif | ||
| 285 | |||
| 286 | #ifdef CONFIG_HAVE_CLK | ||
| 287 | extern void pm_clk_add_notifier(struct bus_type *bus, | ||
| 288 | struct pm_clk_notifier_block *clknb); | ||
| 289 | #else | ||
| 290 | static inline void pm_clk_add_notifier(struct bus_type *bus, | ||
| 291 | struct pm_clk_notifier_block *clknb) | ||
| 292 | { | ||
| 293 | } | ||
| 294 | #endif | ||
| 295 | |||
| 296 | #endif | 254 | #endif |
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 6bbcef22e105..57a692432f8a 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -8,15 +8,18 @@ | |||
| 8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
| 9 | #include <asm/errno.h> | 9 | #include <asm/errno.h> |
| 10 | 10 | ||
| 11 | #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) | 11 | #ifdef CONFIG_VT |
| 12 | extern void pm_set_vt_switch(int); | 12 | extern void pm_set_vt_switch(int); |
| 13 | extern int pm_prepare_console(void); | ||
| 14 | extern void pm_restore_console(void); | ||
| 15 | #else | 13 | #else |
| 16 | static inline void pm_set_vt_switch(int do_switch) | 14 | static inline void pm_set_vt_switch(int do_switch) |
| 17 | { | 15 | { |
| 18 | } | 16 | } |
| 17 | #endif | ||
| 19 | 18 | ||
| 19 | #ifdef CONFIG_VT_CONSOLE_SLEEP | ||
| 20 | extern int pm_prepare_console(void); | ||
| 21 | extern void pm_restore_console(void); | ||
| 22 | #else | ||
| 20 | static inline int pm_prepare_console(void) | 23 | static inline int pm_prepare_console(void) |
| 21 | { | 24 | { |
| 22 | return 0; | 25 | return 0; |
| @@ -34,6 +37,58 @@ typedef int __bitwise suspend_state_t; | |||
| 34 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) | 37 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) |
| 35 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 4) | 38 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 4) |
| 36 | 39 | ||
| 40 | enum suspend_stat_step { | ||
| 41 | SUSPEND_FREEZE = 1, | ||
| 42 | SUSPEND_PREPARE, | ||
| 43 | SUSPEND_SUSPEND, | ||
| 44 | SUSPEND_SUSPEND_NOIRQ, | ||
| 45 | SUSPEND_RESUME_NOIRQ, | ||
| 46 | SUSPEND_RESUME | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct suspend_stats { | ||
| 50 | int success; | ||
| 51 | int fail; | ||
| 52 | int failed_freeze; | ||
| 53 | int failed_prepare; | ||
| 54 | int failed_suspend; | ||
| 55 | int failed_suspend_noirq; | ||
| 56 | int failed_resume; | ||
| 57 | int failed_resume_noirq; | ||
| 58 | #define REC_FAILED_NUM 2 | ||
| 59 | int last_failed_dev; | ||
| 60 | char failed_devs[REC_FAILED_NUM][40]; | ||
| 61 | int last_failed_errno; | ||
| 62 | int errno[REC_FAILED_NUM]; | ||
| 63 | int last_failed_step; | ||
| 64 | enum suspend_stat_step failed_steps[REC_FAILED_NUM]; | ||
| 65 | }; | ||
| 66 | |||
| 67 | extern struct suspend_stats suspend_stats; | ||
| 68 | |||
| 69 | static inline void dpm_save_failed_dev(const char *name) | ||
| 70 | { | ||
| 71 | strlcpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev], | ||
| 72 | name, | ||
| 73 | sizeof(suspend_stats.failed_devs[0])); | ||
| 74 | suspend_stats.last_failed_dev++; | ||
| 75 | suspend_stats.last_failed_dev %= REC_FAILED_NUM; | ||
| 76 | } | ||
| 77 | |||
| 78 | static inline void dpm_save_failed_errno(int err) | ||
| 79 | { | ||
| 80 | suspend_stats.errno[suspend_stats.last_failed_errno] = err; | ||
| 81 | suspend_stats.last_failed_errno++; | ||
| 82 | suspend_stats.last_failed_errno %= REC_FAILED_NUM; | ||
| 83 | } | ||
| 84 | |||
| 85 | static inline void dpm_save_failed_step(enum suspend_stat_step step) | ||
| 86 | { | ||
| 87 | suspend_stats.failed_steps[suspend_stats.last_failed_step] = step; | ||
| 88 | suspend_stats.last_failed_step++; | ||
| 89 | suspend_stats.last_failed_step %= REC_FAILED_NUM; | ||
| 90 | } | ||
| 91 | |||
| 37 | /** | 92 | /** |
| 38 | * struct platform_suspend_ops - Callbacks for managing platform dependent | 93 | * struct platform_suspend_ops - Callbacks for managing platform dependent |
| 39 | * system sleep states. | 94 | * system sleep states. |
| @@ -334,4 +389,38 @@ static inline void unlock_system_sleep(void) | |||
| 334 | } | 389 | } |
| 335 | #endif | 390 | #endif |
| 336 | 391 | ||
| 392 | #ifdef CONFIG_ARCH_SAVE_PAGE_KEYS | ||
| 393 | /* | ||
| 394 | * The ARCH_SAVE_PAGE_KEYS functions can be used by an architecture | ||
| 395 | * to save/restore additional information to/from the array of page | ||
| 396 | * frame numbers in the hibernation image. For s390 this is used to | ||
| 397 | * save and restore the storage key for each page that is included | ||
| 398 | * in the hibernation image. | ||
| 399 | */ | ||
| 400 | unsigned long page_key_additional_pages(unsigned long pages); | ||
| 401 | int page_key_alloc(unsigned long pages); | ||
| 402 | void page_key_free(void); | ||
| 403 | void page_key_read(unsigned long *pfn); | ||
| 404 | void page_key_memorize(unsigned long *pfn); | ||
| 405 | void page_key_write(void *address); | ||
| 406 | |||
| 407 | #else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */ | ||
| 408 | |||
| 409 | static inline unsigned long page_key_additional_pages(unsigned long pages) | ||
| 410 | { | ||
| 411 | return 0; | ||
| 412 | } | ||
| 413 | |||
| 414 | static inline int page_key_alloc(unsigned long pages) | ||
| 415 | { | ||
| 416 | return 0; | ||
| 417 | } | ||
| 418 | |||
| 419 | static inline void page_key_free(void) {} | ||
| 420 | static inline void page_key_read(unsigned long *pfn) {} | ||
| 421 | static inline void page_key_memorize(unsigned long *pfn) {} | ||
| 422 | static inline void page_key_write(void *address) {} | ||
| 423 | |||
| 424 | #endif /* !CONFIG_ARCH_SAVE_PAGE_KEYS */ | ||
| 425 | |||
| 337 | #endif /* _LINUX_SUSPEND_H */ | 426 | #endif /* _LINUX_SUSPEND_H */ |
