governor.h 2.6 KB

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