idle_stats_device.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __ARCH_ARM_MACH_MSM_IDLE_STATS_DEVICE_H
  2. #define __ARCH_ARM_MACH_MSM_IDLE_STATS_DEVICE_H
  3. #include <linux/types.h>
  4. #include <linux/ioctl.h>
  5. #define MSM_IDLE_STATS_EVENT_NONE 0
  6. #define MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED 1
  7. #define MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED_RESET 2
  8. #define MSM_IDLE_STATS_EVENT_COLLECTION_NEARLY_FULL 4
  9. #define MSM_IDLE_STATS_EVENT_COLLECTION_FULL 8
  10. #define MSM_IDLE_STATS_EVENT_IDLE_TIMER_EXPIRED 16
  11. /*
  12. * All time, timer, and time interval values are in units of
  13. * microseconds unless stated otherwise.
  14. */
  15. #define MSM_IDLE_STATS_NR_MAX_INTERVALS 200
  16. struct msm_idle_pulse {
  17. __s64 busy_start_time;
  18. __u32 busy_interval;
  19. __u32 wait_interval;
  20. };
  21. struct msm_idle_read_stats {
  22. __u32 event;
  23. __s64 return_timestamp;
  24. __u32 busy_timer_remaining;
  25. __u32 nr_collected;
  26. struct msm_idle_pulse pulse_chain[MSM_IDLE_STATS_NR_MAX_INTERVALS];
  27. };
  28. struct msm_idle_write_stats {
  29. __u32 busy_timer;
  30. __u32 next_busy_timer;
  31. __u32 max_samples;
  32. };
  33. #define MSM_IDLE_STATS_IOC_MAGIC 0xD8
  34. #define MSM_IDLE_STATS_IOC_READ_STATS \
  35. _IOWR(MSM_IDLE_STATS_IOC_MAGIC, 1, struct msm_idle_read_stats)
  36. #define MSM_IDLE_STATS_IOC_WRITE_STATS \
  37. _IOWR(MSM_IDLE_STATS_IOC_MAGIC, 2, struct msm_idle_write_stats)
  38. #ifdef __KERNEL__
  39. #include <linux/hrtimer.h>
  40. #include <linux/mutex.h>
  41. #include <linux/miscdevice.h>
  42. struct msm_idle_stats_device {
  43. const char *name;
  44. void (*get_sample)(struct msm_idle_stats_device *device,
  45. struct msm_idle_pulse *pulse);
  46. struct miscdevice miscdev;
  47. spinlock_t lock;
  48. wait_queue_head_t wait;
  49. struct list_head list;
  50. struct hrtimer busy_timer;
  51. ktime_t busy_timer_interval;
  52. ktime_t idle_start;
  53. ktime_t remaining_time;
  54. __u32 max_samples;
  55. struct msm_idle_read_stats *stats;
  56. struct msm_idle_read_stats stats_vector[2];
  57. };
  58. int msm_idle_stats_register_device(struct msm_idle_stats_device *device);
  59. int msm_idle_stats_deregister_device(struct msm_idle_stats_device *device);
  60. void msm_idle_stats_prepare_idle_start(struct msm_idle_stats_device *device);
  61. void msm_idle_stats_abort_idle_start(struct msm_idle_stats_device *device);
  62. void msm_idle_stats_idle_start(struct msm_idle_stats_device *device);
  63. void msm_idle_stats_idle_end(struct msm_idle_stats_device *device,
  64. struct msm_idle_pulse *pulse);
  65. void msm_idle_stats_update_event(struct msm_idle_stats_device *device,
  66. __u32 event);
  67. #endif
  68. #endif /* __ARCH_ARM_MACH_MSM_IDLE_STATS_DEVICE_H */