1 #ifndef _LINUX_PM_QOS_H
2 #define _LINUX_PM_QOS_H
3 /* interface for the pm_qos_power infrastructure of the linux kernel.
5 * Mark Gross <mgross@linux.intel.com>
7 #include <linux/plist.h>
8 #include <linux/notifier.h>
9 #include <linux/miscdevice.h>
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
16 #define PM_QOS_NUM_CLASSES 4
17 #define PM_QOS_DEFAULT_VALUE -1
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 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0
24 struct pm_qos_request {
25 struct plist_node node;
29 struct dev_pm_qos_request {
30 struct plist_node node;
36 PM_QOS_MAX, /* return the largest value */
37 PM_QOS_MIN /* return the smallest value */
41 * Note: The lockless read path depends on the CPU accessing
42 * target_value atomically. Atomic access is only guaranteed on all CPU
43 * types linux supports for 32 bit quantites
45 struct pm_qos_constraints {
46 struct plist_head list;
47 s32 target_value; /* Do not change to 64 bit */
49 enum pm_qos_type type;
50 struct blocking_notifier_head *notifiers;
53 /* Action requested to pm_qos_update_target */
54 enum pm_qos_req_action {
55 PM_QOS_ADD_REQ, /* Add a new request */
56 PM_QOS_UPDATE_REQ, /* Update an existing request */
57 PM_QOS_REMOVE_REQ /* Remove an existing request */
60 static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
66 int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
67 enum pm_qos_req_action action, int value);
68 void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
70 void pm_qos_update_request(struct pm_qos_request *req,
72 void pm_qos_remove_request(struct pm_qos_request *req);
74 int pm_qos_request(int pm_qos_class);
75 int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
76 int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
77 int pm_qos_request_active(struct pm_qos_request *req);
78 s32 pm_qos_read_value(struct pm_qos_constraints *c);
80 int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
82 int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
83 int dev_pm_qos_remove_request(struct dev_pm_qos_request *req);
84 int dev_pm_qos_add_notifier(struct device *dev,
85 struct notifier_block *notifier);
86 int dev_pm_qos_remove_notifier(struct device *dev,
87 struct notifier_block *notifier);
88 int dev_pm_qos_add_global_notifier(struct notifier_block *notifier);
89 int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
90 void dev_pm_qos_constraints_init(struct device *dev);
91 void dev_pm_qos_constraints_destroy(struct device *dev);
93 static inline int pm_qos_update_target(struct pm_qos_constraints *c,
94 struct plist_node *node,
95 enum pm_qos_req_action action,
98 static inline void pm_qos_add_request(struct pm_qos_request *req,
99 int pm_qos_class, s32 value)
101 static inline void pm_qos_update_request(struct pm_qos_request *req,
104 static inline void pm_qos_remove_request(struct pm_qos_request *req)
107 static inline int pm_qos_request(int pm_qos_class)
109 static inline int pm_qos_add_notifier(int pm_qos_class,
110 struct notifier_block *notifier)
112 static inline int pm_qos_remove_notifier(int pm_qos_class,
113 struct notifier_block *notifier)
115 static inline int pm_qos_request_active(struct pm_qos_request *req)
117 static inline s32 pm_qos_read_value(struct pm_qos_constraints *c)
120 static inline int dev_pm_qos_add_request(struct device *dev,
121 struct dev_pm_qos_request *req,
124 static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
127 static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
129 static inline int dev_pm_qos_add_notifier(struct device *dev,
130 struct notifier_block *notifier)
132 static inline int dev_pm_qos_remove_notifier(struct device *dev,
133 struct notifier_block *notifier)
135 static inline int dev_pm_qos_add_global_notifier(
136 struct notifier_block *notifier)
138 static inline int dev_pm_qos_remove_global_notifier(
139 struct notifier_block *notifier)
141 static inline void dev_pm_qos_constraints_init(struct device *dev)
143 static inline void dev_pm_qos_constraints_destroy(struct device *dev)