aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/devfreq.h238
-rw-r--r--include/linux/device.h5
-rw-r--r--include/linux/freezer.h4
-rw-r--r--include/linux/netdevice.h4
-rw-r--r--include/linux/opp.h12
-rw-r--r--include/linux/pm.h26
-rw-r--r--include/linux/pm_clock.h71
-rw-r--r--include/linux/pm_domain.h26
-rw-r--r--include/linux/pm_qos.h155
-rw-r--r--include/linux/pm_qos_params.h38
-rw-r--r--include/linux/pm_runtime.h42
-rw-r--r--include/linux/suspend.h95
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
22struct 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 */
39struct 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 */
65struct 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 */
97struct 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 */
136struct 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)
155extern struct devfreq *devfreq_add_device(struct device *dev,
156 struct devfreq_dev_profile *profile,
157 const struct devfreq_governor *governor,
158 void *data);
159extern int devfreq_remove_device(struct devfreq *devfreq);
160
161/* Helper functions for devfreq user device driver with OPP. */
162extern struct opp *devfreq_recommended_opp(struct device *dev,
163 unsigned long *freq);
164extern int devfreq_register_opp_notifier(struct device *dev,
165 struct devfreq *devfreq);
166extern int devfreq_unregister_opp_notifier(struct device *dev,
167 struct devfreq *devfreq);
168
169#ifdef CONFIG_DEVFREQ_GOV_POWERSAVE
170extern const struct devfreq_governor devfreq_powersave;
171#endif
172#ifdef CONFIG_DEVFREQ_GOV_PERFORMANCE
173extern const struct devfreq_governor devfreq_performance;
174#endif
175#ifdef CONFIG_DEVFREQ_GOV_USERSPACE
176extern const struct devfreq_governor devfreq_userspace;
177#endif
178#ifdef CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND
179extern 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 */
193struct devfreq_simple_ondemand_data {
194 unsigned int upthreshold;
195 unsigned int downdifferential;
196};
197#endif
198
199#else /* !CONFIG_PM_DEVFREQ */
200static 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
208static int devfreq_remove_device(struct devfreq *devfreq);
209{
210 return 0;
211}
212
213static struct opp *devfreq_recommended_opp(struct device *dev,
214 unsigned long *freq)
215{
216 return -EINVAL;
217}
218
219static int devfreq_register_opp_notifier(struct device *dev,
220 struct devfreq *devfreq)
221{
222 return -EINVAL;
223}
224
225static 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
641static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
642{
643 return dev ? dev->power.subsys_data : NULL;
644}
645
641static inline unsigned int dev_get_uevent_suppress(const struct device *dev) 646static 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
50extern void refrigerator(void); 50extern void refrigerator(void);
51extern int freeze_processes(void); 51extern int freeze_processes(void);
52extern int freeze_kernel_threads(void);
52extern void thaw_processes(void); 53extern void thaw_processes(void);
53 54
54static inline int try_to_freeze(void) 55static inline int try_to_freeze(void)
@@ -171,7 +172,8 @@ static inline void clear_freeze_flag(struct task_struct *p) {}
171static inline int thaw_process(struct task_struct *p) { return 1; } 172static inline int thaw_process(struct task_struct *p) { return 1; }
172 173
173static inline void refrigerator(void) {} 174static inline void refrigerator(void) {}
174static inline int freeze_processes(void) { BUG(); return 0; } 175static inline int freeze_processes(void) { return -ENOSYS; }
176static inline int freeze_kernel_threads(void) { return -ENOSYS; }
175static inline void thaw_processes(void) {} 177static inline void thaw_processes(void) {}
176 178
177static inline int try_to_freeze(void) { return 0; } 179static 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
20struct opp; 21struct opp;
21 22
23enum 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
24unsigned long opp_get_voltage(struct opp *opp); 29unsigned long opp_get_voltage(struct opp *opp);
@@ -40,6 +45,8 @@ int opp_enable(struct device *dev, unsigned long freq);
40 45
41int opp_disable(struct device *dev, unsigned long freq); 46int opp_disable(struct device *dev, unsigned long freq);
42 47
48struct srcu_notifier_head *opp_get_notifier(struct device *dev);
49
43#else 50#else
44static inline unsigned long opp_get_voltage(struct opp *opp) 51static 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
100struct 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
422struct wakeup_source; 426struct wakeup_source;
423 427
428struct pm_domain_data {
429 struct list_head list_node;
430 struct device *dev;
431};
432
433struct 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
424struct dev_pm_info { 444struct 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
468extern void update_pm_runtime_accounting(struct device *dev); 490extern void update_pm_runtime_accounting(struct device *dev);
491extern int dev_pm_get_subsys_data(struct device *dev);
492extern 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
15struct 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
22static 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
28extern void pm_clk_init(struct device *dev);
29extern int pm_clk_create(struct device *dev);
30extern void pm_clk_destroy(struct device *dev);
31extern int pm_clk_add(struct device *dev, const char *con_id);
32extern void pm_clk_remove(struct device *dev, const char *con_id);
33extern int pm_clk_suspend(struct device *dev);
34extern int pm_clk_resume(struct device *dev);
35#else
36static inline bool pm_clk_no_clocks(struct device *dev)
37{
38 return true;
39}
40static inline void pm_clk_init(struct device *dev)
41{
42}
43static inline int pm_clk_create(struct device *dev)
44{
45 return -EINVAL;
46}
47static inline void pm_clk_destroy(struct device *dev)
48{
49}
50static inline int pm_clk_add(struct device *dev, const char *con_id)
51{
52 return -EINVAL;
53}
54static 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
62extern void pm_clk_add_notifier(struct bus_type *bus,
63 struct pm_clk_notifier_block *clknb);
64#else
65static 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
14enum gpd_status { 14enum 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 {
25struct generic_pm_domain { 26struct 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
57struct dev_list_entry { 58struct 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
65struct generic_pm_domain_data {
66 struct pm_domain_data base;
60 bool need_restore; 67 bool need_restore;
61}; 68};
62 69
70static 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
64extern int pm_genpd_add_device(struct generic_pm_domain *genpd, 76extern 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
25struct pm_qos_request {
26 struct plist_node node;
27 int pm_qos_class;
28};
29
30struct dev_pm_qos_request {
31 struct plist_node node;
32 struct device *dev;
33};
34
35enum 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 */
46struct 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 */
55enum 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
61static 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
67int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
68 enum pm_qos_req_action action, int value);
69void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
70 s32 value);
71void pm_qos_update_request(struct pm_qos_request *req,
72 s32 new_value);
73void pm_qos_remove_request(struct pm_qos_request *req);
74
75int pm_qos_request(int pm_qos_class);
76int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
77int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
78int pm_qos_request_active(struct pm_qos_request *req);
79s32 pm_qos_read_value(struct pm_qos_constraints *c);
80
81s32 dev_pm_qos_read_value(struct device *dev);
82int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
83 s32 value);
84int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
85int dev_pm_qos_remove_request(struct dev_pm_qos_request *req);
86int dev_pm_qos_add_notifier(struct device *dev,
87 struct notifier_block *notifier);
88int dev_pm_qos_remove_notifier(struct device *dev,
89 struct notifier_block *notifier);
90int dev_pm_qos_add_global_notifier(struct notifier_block *notifier);
91int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
92void dev_pm_qos_constraints_init(struct device *dev);
93void dev_pm_qos_constraints_destroy(struct device *dev);
94#else
95static 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; }
100static inline void pm_qos_add_request(struct pm_qos_request *req,
101 int pm_qos_class, s32 value)
102 { return; }
103static inline void pm_qos_update_request(struct pm_qos_request *req,
104 s32 new_value)
105 { return; }
106static inline void pm_qos_remove_request(struct pm_qos_request *req)
107 { return; }
108
109static inline int pm_qos_request(int pm_qos_class)
110 { return 0; }
111static inline int pm_qos_add_notifier(int pm_qos_class,
112 struct notifier_block *notifier)
113 { return 0; }
114static inline int pm_qos_remove_notifier(int pm_qos_class,
115 struct notifier_block *notifier)
116 { return 0; }
117static inline int pm_qos_request_active(struct pm_qos_request *req)
118 { return 0; }
119static inline s32 pm_qos_read_value(struct pm_qos_constraints *c)
120 { return 0; }
121
122static inline s32 dev_pm_qos_read_value(struct device *dev)
123 { return 0; }
124static inline int dev_pm_qos_add_request(struct device *dev,
125 struct dev_pm_qos_request *req,
126 s32 value)
127 { return 0; }
128static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
129 s32 new_value)
130 { return 0; }
131static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
132 { return 0; }
133static inline int dev_pm_qos_add_notifier(struct device *dev,
134 struct notifier_block *notifier)
135 { return 0; }
136static inline int dev_pm_qos_remove_notifier(struct device *dev,
137 struct notifier_block *notifier)
138 { return 0; }
139static inline int dev_pm_qos_add_global_notifier(
140 struct notifier_block *notifier)
141 { return 0; }
142static inline int dev_pm_qos_remove_global_notifier(
143 struct notifier_block *notifier)
144 { return 0; }
145static inline void dev_pm_qos_constraints_init(struct device *dev)
146{
147 dev->power.power_state = PMSG_ON;
148}
149static 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
23struct pm_qos_request_list {
24 struct plist_node list;
25 int pm_qos_class;
26};
27
28void pm_qos_add_request(struct pm_qos_request_list *l, int pm_qos_class, s32 value);
29void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
30 s32 new_value);
31void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req);
32
33int pm_qos_request(int pm_qos_class);
34int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
35int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
36int 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
254struct 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
261extern int pm_clk_init(struct device *dev);
262extern void pm_clk_destroy(struct device *dev);
263extern int pm_clk_add(struct device *dev, const char *con_id);
264extern void pm_clk_remove(struct device *dev, const char *con_id);
265extern int pm_clk_suspend(struct device *dev);
266extern int pm_clk_resume(struct device *dev);
267#else
268static inline int pm_clk_init(struct device *dev)
269{
270 return -EINVAL;
271}
272static inline void pm_clk_destroy(struct device *dev)
273{
274}
275static inline int pm_clk_add(struct device *dev, const char *con_id)
276{
277 return -EINVAL;
278}
279static 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
287extern void pm_clk_add_notifier(struct bus_type *bus,
288 struct pm_clk_notifier_block *clknb);
289#else
290static 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
12extern void pm_set_vt_switch(int); 12extern void pm_set_vt_switch(int);
13extern int pm_prepare_console(void);
14extern void pm_restore_console(void);
15#else 13#else
16static inline void pm_set_vt_switch(int do_switch) 14static inline void pm_set_vt_switch(int do_switch)
17{ 15{
18} 16}
17#endif
19 18
19#ifdef CONFIG_VT_CONSOLE_SLEEP
20extern int pm_prepare_console(void);
21extern void pm_restore_console(void);
22#else
20static inline int pm_prepare_console(void) 23static 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
40enum 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
49struct 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
67extern struct suspend_stats suspend_stats;
68
69static 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
78static 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
85static 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 */
400unsigned long page_key_additional_pages(unsigned long pages);
401int page_key_alloc(unsigned long pages);
402void page_key_free(void);
403void page_key_read(unsigned long *pfn);
404void page_key_memorize(unsigned long *pfn);
405void page_key_write(void *address);
406
407#else /* !CONFIG_ARCH_SAVE_PAGE_KEYS */
408
409static inline unsigned long page_key_additional_pages(unsigned long pages)
410{
411 return 0;
412}
413
414static inline int page_key_alloc(unsigned long pages)
415{
416 return 0;
417}
418
419static inline void page_key_free(void) {}
420static inline void page_key_read(unsigned long *pfn) {}
421static inline void page_key_memorize(unsigned long *pfn) {}
422static 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 */