governor_performance.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * linux/drivers/devfreq/governor_performance.c
  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. #include <linux/devfreq.h>
  12. #include <linux/module.h>
  13. #include "governor.h"
  14. static int devfreq_performance_func(struct devfreq *df,
  15. unsigned long *freq,
  16. u32 *flag)
  17. {
  18. /*
  19. * target callback should be able to get floor value as
  20. * said in devfreq.h
  21. */
  22. if (!df->max_freq)
  23. *freq = UINT_MAX;
  24. else
  25. *freq = df->max_freq;
  26. return 0;
  27. }
  28. static int devfreq_performance_handler(struct devfreq *devfreq,
  29. unsigned int event, void *data)
  30. {
  31. int ret = 0;
  32. unsigned long freq;
  33. mutex_lock(&devfreq->lock);
  34. freq = devfreq->previous_freq;
  35. switch (event) {
  36. case DEVFREQ_GOV_START:
  37. devfreq->profile->target(devfreq->dev.parent,
  38. &freq,
  39. DEVFREQ_FLAG_WAKEUP_MAXFREQ);
  40. /* fall through */
  41. case DEVFREQ_GOV_RESUME:
  42. ret = update_devfreq(devfreq);
  43. break;
  44. case DEVFREQ_GOV_SUSPEND:
  45. devfreq->profile->target(devfreq->dev.parent,
  46. &freq,
  47. DEVFREQ_FLAG_WAKEUP_MAXFREQ);
  48. break;
  49. }
  50. mutex_unlock(&devfreq->lock);
  51. return ret;
  52. }
  53. static struct devfreq_governor devfreq_performance = {
  54. .name = "performance",
  55. .get_target_freq = devfreq_performance_func,
  56. .event_handler = devfreq_performance_handler,
  57. };
  58. static int __init devfreq_performance_init(void)
  59. {
  60. return devfreq_add_governor(&devfreq_performance);
  61. }
  62. subsys_initcall(devfreq_performance_init);
  63. static void __exit devfreq_performance_exit(void)
  64. {
  65. int ret;
  66. ret = devfreq_remove_governor(&devfreq_performance);
  67. if (ret)
  68. pr_err("%s: failed remove governor %d\n", __func__, ret);
  69. return;
  70. }
  71. module_exit(devfreq_performance_exit);
  72. MODULE_LICENSE("GPL");