/drivers/gpu/mali/mali/linux/mali_osk_pm.c

https://bitbucket.org/ndreys/linux-sunxi · C · 83 lines · 59 code · 9 blank · 15 comment · 6 complexity · 2dffdcb2ea58e892d72e883025e85af5 MD5 · raw file

  1. /**
  2. * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
  3. *
  4. * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  5. * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
  6. *
  7. * A copy of the licence is included with the program, and can also be obtained from Free Software
  8. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  9. */
  10. /**
  11. * @file mali_osk_pm.c
  12. * Implementation of the callback functions from common power management
  13. */
  14. #include <linux/sched.h>
  15. #ifdef CONFIG_PM_RUNTIME
  16. #include <linux/pm_runtime.h>
  17. #endif /* CONFIG_PM_RUNTIME */
  18. #include <linux/platform_device.h>
  19. #include "mali_platform.h"
  20. #include "mali_osk.h"
  21. #include "mali_uk_types.h"
  22. #include "mali_kernel_common.h"
  23. #include "mali_kernel_license.h"
  24. #include "mali_linux_pm.h"
  25. #include "mali_kernel_license.h"
  26. #if ! MALI_LICENSE_IS_GPL
  27. #undef CONFIG_PM_RUNTIME
  28. #endif
  29. extern struct platform_device mali_gpu_device;
  30. #ifdef CONFIG_PM_RUNTIME
  31. static mali_bool have_runtime_reference = MALI_FALSE;
  32. #endif
  33. void _mali_osk_pm_dev_enable(void)
  34. {
  35. #ifdef CONFIG_PM_RUNTIME
  36. pm_runtime_enable(&(mali_gpu_device.dev));
  37. #endif
  38. }
  39. /* NB: Function is not thread safe */
  40. _mali_osk_errcode_t _mali_osk_pm_dev_idle(void)
  41. {
  42. #ifdef CONFIG_PM_RUNTIME
  43. if (MALI_TRUE == have_runtime_reference)
  44. {
  45. int err;
  46. err = pm_runtime_put_sync(&(mali_gpu_device.dev));
  47. if (0 > err)
  48. {
  49. MALI_PRINT_ERROR(("OSK PM: pm_runtime_put_sync() returned error code %d\n", err));
  50. return _MALI_OSK_ERR_FAULT;
  51. }
  52. have_runtime_reference = MALI_FALSE;
  53. }
  54. #endif
  55. return _MALI_OSK_ERR_OK;
  56. }
  57. /* NB: Function is not thread safe */
  58. _mali_osk_errcode_t _mali_osk_pm_dev_activate(void)
  59. {
  60. #ifdef CONFIG_PM_RUNTIME
  61. if (MALI_TRUE != have_runtime_reference)
  62. {
  63. int err;
  64. err = pm_runtime_get_sync(&(mali_gpu_device.dev));
  65. if (0 > err)
  66. {
  67. MALI_PRINT_ERROR(("OSK PM: pm_runtime_get_sync() returned error code %d\n", err));
  68. return _MALI_OSK_ERR_FAULT;
  69. }
  70. have_runtime_reference = MALI_TRUE;
  71. }
  72. #endif
  73. return _MALI_OSK_ERR_OK;
  74. }