Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 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 | |
| 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 | |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 23 | struct pm_qos_request { |
| 24 | struct plist_node node; |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 25 | int pm_qos_class; |
| 26 | }; |
| 27 | |
Jean Pihet | 4e1779b | 2011-08-25 15:35:27 +0200 | [diff] [blame^] | 28 | enum pm_qos_type { |
| 29 | PM_QOS_UNITIALIZED, |
| 30 | PM_QOS_MAX, /* return the largest value */ |
| 31 | PM_QOS_MIN /* return the smallest value */ |
| 32 | }; |
| 33 | |
| 34 | /* |
| 35 | * Note: The lockless read path depends on the CPU accessing |
| 36 | * target_value atomically. Atomic access is only guaranteed on all CPU |
| 37 | * types linux supports for 32 bit quantites |
| 38 | */ |
| 39 | struct pm_qos_constraints { |
| 40 | struct plist_head list; |
| 41 | s32 target_value; /* Do not change to 64 bit */ |
| 42 | s32 default_value; |
| 43 | enum pm_qos_type type; |
| 44 | struct blocking_notifier_head *notifiers; |
| 45 | }; |
| 46 | |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 47 | #ifdef CONFIG_PM |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 48 | void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, |
| 49 | s32 value); |
| 50 | void pm_qos_update_request(struct pm_qos_request *req, |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 51 | s32 new_value); |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 52 | void pm_qos_remove_request(struct pm_qos_request *req); |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 53 | |
| 54 | int pm_qos_request(int pm_qos_class); |
| 55 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); |
| 56 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 57 | int pm_qos_request_active(struct pm_qos_request *req); |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 58 | #else |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 59 | static inline void pm_qos_add_request(struct pm_qos_request *req, |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 60 | int pm_qos_class, s32 value) |
| 61 | { return; } |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 62 | static inline void pm_qos_update_request(struct pm_qos_request *req, |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 63 | s32 new_value) |
| 64 | { return; } |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 65 | static inline void pm_qos_remove_request(struct pm_qos_request *req) |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 66 | { return; } |
| 67 | |
| 68 | static inline int pm_qos_request(int pm_qos_class) |
| 69 | { return 0; } |
| 70 | static inline int pm_qos_add_notifier(int pm_qos_class, |
| 71 | struct notifier_block *notifier) |
| 72 | { return 0; } |
| 73 | static inline int pm_qos_remove_notifier(int pm_qos_class, |
| 74 | struct notifier_block *notifier) |
| 75 | { return 0; } |
Jean Pihet | cc74998 | 2011-08-25 15:35:12 +0200 | [diff] [blame] | 76 | static inline int pm_qos_request_active(struct pm_qos_request *req) |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 77 | { return 0; } |
| 78 | #endif |
| 79 | |
| 80 | #endif |