]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/base/power/power.h
Merge branches 'pm-cpu', 'pm-cpuidle' and 'pm-domains'
[mirror_ubuntu-zesty-kernel.git] / drivers / base / power / power.h
CommitLineData
1a9a9152
RW
1#include <linux/pm_qos.h>
2
e91c11b1
RW
3static inline void device_pm_init_common(struct device *dev)
4{
bed2b42d
RW
5 if (!dev->power.early_init) {
6 spin_lock_init(&dev->power.lock);
37530f2b 7 dev->power.qos = NULL;
bed2b42d
RW
8 dev->power.early_init = true;
9 }
e91c11b1
RW
10}
11
d30d819d 12#ifdef CONFIG_PM
5e928f77 13
bed2b42d
RW
14static inline void pm_runtime_early_init(struct device *dev)
15{
16 dev->power.disable_depth = 1;
17 device_pm_init_common(dev);
18}
19
5e928f77
RW
20extern void pm_runtime_init(struct device *dev);
21extern void pm_runtime_remove(struct device *dev);
22
4990d4fe
TL
23struct wake_irq {
24 struct device *dev;
25 int irq;
26 bool dedicated_irq:1;
27};
28
29extern void dev_pm_arm_wake_irq(struct wake_irq *wirq);
30extern void dev_pm_disarm_wake_irq(struct wake_irq *wirq);
31
32#ifdef CONFIG_PM_SLEEP
33
34extern int device_wakeup_attach_irq(struct device *dev,
35 struct wake_irq *wakeirq);
36extern void device_wakeup_detach_irq(struct device *dev);
37extern void device_wakeup_arm_wake_irqs(void);
38extern void device_wakeup_disarm_wake_irqs(void);
39
40#else
41
42static inline int
43device_wakeup_attach_irq(struct device *dev,
44 struct wake_irq *wakeirq)
45{
46 return 0;
47}
48
49static inline void device_wakeup_detach_irq(struct device *dev)
50{
51}
52
53static inline void device_wakeup_arm_wake_irqs(void)
54{
55}
56
57static inline void device_wakeup_disarm_wake_irqs(void)
58{
59}
60
61#endif /* CONFIG_PM_SLEEP */
62
d30d819d
RW
63/*
64 * sysfs.c
65 */
66
67extern int dpm_sysfs_add(struct device *dev);
68extern void dpm_sysfs_remove(struct device *dev);
69extern void rpm_sysfs_remove(struct device *dev);
70extern int wakeup_sysfs_add(struct device *dev);
71extern void wakeup_sysfs_remove(struct device *dev);
72extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
73extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
74extern int pm_qos_sysfs_add_flags(struct device *dev);
75extern void pm_qos_sysfs_remove_flags(struct device *dev);
13b2c4a0
MW
76extern int pm_qos_sysfs_add_latency_tolerance(struct device *dev);
77extern void pm_qos_sysfs_remove_latency_tolerance(struct device *dev);
d30d819d
RW
78
79#else /* CONFIG_PM */
5e928f77 80
bed2b42d
RW
81static inline void pm_runtime_early_init(struct device *dev)
82{
83 device_pm_init_common(dev);
84}
85
5e928f77
RW
86static inline void pm_runtime_init(struct device *dev) {}
87static inline void pm_runtime_remove(struct device *dev) {}
88
d30d819d
RW
89static inline int dpm_sysfs_add(struct device *dev) { return 0; }
90static inline void dpm_sysfs_remove(struct device *dev) {}
91static inline void rpm_sysfs_remove(struct device *dev) {}
92static inline int wakeup_sysfs_add(struct device *dev) { return 0; }
93static inline void wakeup_sysfs_remove(struct device *dev) {}
94static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
95static inline void pm_qos_sysfs_remove(struct device *dev) {}
96
4990d4fe
TL
97static inline void dev_pm_arm_wake_irq(struct wake_irq *wirq)
98{
99}
100
101static inline void dev_pm_disarm_wake_irq(struct wake_irq *wirq)
102{
103}
104
d30d819d 105#endif
3b98aeaf 106
296699de 107#ifdef CONFIG_PM_SLEEP
1da177e4 108
0e06b4a8
RW
109/* kernel/power/main.c */
110extern int pm_async_enabled;
1da177e4 111
0e06b4a8 112/* drivers/base/power/main.c */
1eede070 113extern struct list_head dpm_list; /* The active device list */
1da177e4 114
dec13c15 115static inline struct device *to_device(struct list_head *entry)
1da177e4 116{
cd59abfc 117 return container_of(entry, struct device, power.entry);
1da177e4
LT
118}
119
e91c11b1 120extern void device_pm_sleep_init(struct device *dev);
3b98aeaf 121extern void device_pm_add(struct device *);
1da177e4 122extern void device_pm_remove(struct device *);
ffa6a705
CH
123extern void device_pm_move_before(struct device *, struct device *);
124extern void device_pm_move_after(struct device *, struct device *);
125extern void device_pm_move_last(struct device *);
1da177e4 126
5e928f77
RW
127#else /* !CONFIG_PM_SLEEP */
128
e91c11b1 129static inline void device_pm_sleep_init(struct device *dev) {}
5e928f77 130
37530f2b 131static inline void device_pm_add(struct device *dev) {}
1a9a9152 132
5e928f77
RW
133static inline void device_pm_remove(struct device *dev)
134{
135 pm_runtime_remove(dev);
136}
dec13c15 137
ffa6a705
CH
138static inline void device_pm_move_before(struct device *deva,
139 struct device *devb) {}
140static inline void device_pm_move_after(struct device *deva,
141 struct device *devb) {}
142static inline void device_pm_move_last(struct device *dev) {}
775b64d2 143
5e928f77 144#endif /* !CONFIG_PM_SLEEP */
dec13c15 145
e91c11b1
RW
146static inline void device_pm_init(struct device *dev)
147{
148 device_pm_init_common(dev);
149 device_pm_sleep_init(dev);
150 pm_runtime_init(dev);
151}