governor.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * governor.h - internal header for devfreq governors.
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * MyungJoo Ham <myungjoo.ham@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This header is for devfreq governors in drivers/devfreq/
  12. */
  13. #ifndef _GOVERNOR_H
  14. #define _GOVERNOR_H
  15. #include <linux/devfreq.h>
  16. #define to_devfreq(DEV) container_of((DEV), struct devfreq, dev)
  17. /* Devfreq events */
  18. #define DEVFREQ_GOV_START 0x1
  19. #define DEVFREQ_GOV_STOP 0x2
  20. #define DEVFREQ_GOV_INTERVAL 0x3
  21. #define DEVFREQ_GOV_SUSPEND 0x4
  22. #define DEVFREQ_GOV_RESUME 0x5
  23. /**
  24. * struct devfreq_governor - Devfreq policy governor
  25. * @node: list node - contains registered devfreq governors
  26. * @name: Governor's name
  27. * @immutable: Immutable flag for governor. If the value is 1,
  28. * this govenror is never changeable to other governor.
  29. * @get_target_freq: Returns desired operating frequency for the device.
  30. * Basically, get_target_freq will run
  31. * devfreq_dev_profile.get_dev_status() to get the
  32. * status of the device (load = busy_time / total_time).
  33. * If no_central_polling is set, this callback is called
  34. * only with update_devfreq() notified by OPP.
  35. * @event_handler: Callback for devfreq core framework to notify events
  36. * to governors. Events include per device governor
  37. * init and exit, opp changes out of devfreq, suspend
  38. * and resume of per device devfreq during device idle.
  39. *
  40. * Note that the callbacks are called with devfreq->lock locked by devfreq.
  41. */
  42. struct devfreq_governor {
  43. struct list_head node;
  44. const char name[DEVFREQ_NAME_LEN];
  45. const unsigned int immutable;
  46. int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
  47. int (*event_handler)(struct devfreq *devfreq,
  48. unsigned int event, void *data);
  49. };
  50. /* Caution: devfreq->lock must be locked before calling update_devfreq */
  51. extern int update_devfreq(struct devfreq *devfreq);
  52. extern void devfreq_monitor_start(struct devfreq *devfreq);
  53. extern void devfreq_monitor_stop(struct devfreq *devfreq);
  54. extern void devfreq_monitor_suspend(struct devfreq *devfreq);
  55. extern void devfreq_monitor_resume(struct devfreq *devfreq);
  56. extern void devfreq_interval_update(struct devfreq *devfreq,
  57. unsigned int *delay);
  58. extern int devfreq_add_governor(struct devfreq_governor *governor);
  59. extern int devfreq_remove_governor(struct devfreq_governor *governor);
  60. extern int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
  61. static inline int devfreq_update_stats(struct devfreq *df)
  62. {
  63. return df->profile->get_dev_status(df->dev.parent, &df->last_status);
  64. }
  65. #endif /* _GOVERNOR_H */