eventmgr.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef _EVENTMGR_H_
  24. #define _EVENTMGR_H_
  25. #include <linux/mutex.h>
  26. #include "pp_instance.h"
  27. #include "hardwaremanager.h"
  28. #include "eventmanager.h"
  29. #include "pp_feature.h"
  30. #include "pp_power_source.h"
  31. #include "power_state.h"
  32. typedef int (*pem_event_action)(struct pp_eventmgr *eventmgr,
  33. struct pem_event_data *event_data);
  34. struct action_chain {
  35. const char *description; /* action chain description for debugging purpose */
  36. const pem_event_action * const *action_chain; /* pointer to chain of event actions */
  37. };
  38. struct pem_power_source_ui_state_info {
  39. enum PP_StateUILabel current_ui_label;
  40. enum PP_StateUILabel default_ui_lable;
  41. unsigned long configurable_ui_mapping;
  42. };
  43. struct pp_clock_range {
  44. uint32_t min_sclk_khz;
  45. uint32_t max_sclk_khz;
  46. uint32_t min_mclk_khz;
  47. uint32_t max_mclk_khz;
  48. uint32_t min_vclk_khz;
  49. uint32_t max_vclk_khz;
  50. uint32_t min_dclk_khz;
  51. uint32_t max_dclk_khz;
  52. uint32_t min_aclk_khz;
  53. uint32_t max_aclk_khz;
  54. uint32_t min_eclk_khz;
  55. uint32_t max_eclk_khz;
  56. };
  57. enum pp_state {
  58. UNINITIALIZED,
  59. INACTIVE,
  60. ACTIVE
  61. };
  62. enum pp_ring_index {
  63. PP_RING_TYPE_GFX_INDEX = 0,
  64. PP_RING_TYPE_DMA_INDEX,
  65. PP_RING_TYPE_DMA1_INDEX,
  66. PP_RING_TYPE_UVD_INDEX,
  67. PP_RING_TYPE_VCE0_INDEX,
  68. PP_RING_TYPE_VCE1_INDEX,
  69. PP_RING_TYPE_CP1_INDEX,
  70. PP_RING_TYPE_CP2_INDEX,
  71. PP_NUM_RINGS,
  72. };
  73. struct pp_request {
  74. uint32_t flags;
  75. uint32_t sclk;
  76. uint32_t sclk_throttle;
  77. uint32_t mclk;
  78. uint32_t vclk;
  79. uint32_t dclk;
  80. uint32_t eclk;
  81. uint32_t aclk;
  82. uint32_t iclk;
  83. uint32_t vp8clk;
  84. uint32_t rsv[32];
  85. };
  86. struct pp_eventmgr {
  87. struct pp_hwmgr *hwmgr;
  88. struct pp_smumgr *smumgr;
  89. struct pp_feature_info features[PP_Feature_Max];
  90. const struct action_chain *event_chain[AMD_PP_EVENT_MAX];
  91. struct phm_platform_descriptor *platform_descriptor;
  92. struct pp_clock_range clock_range;
  93. enum pp_power_source current_power_source;
  94. struct pem_power_source_ui_state_info ui_state_info[PP_PowerSource_Max];
  95. enum pp_state states[PP_NUM_RINGS];
  96. struct pp_request hi_req;
  97. struct list_head context_list;
  98. struct mutex lock;
  99. bool block_adjust_power_state;
  100. bool enable_cg;
  101. bool enable_gfx_cgpg;
  102. int (*pp_eventmgr_init)(struct pp_eventmgr *eventmgr);
  103. void (*pp_eventmgr_fini)(struct pp_eventmgr *eventmgr);
  104. };
  105. int eventmgr_early_init(struct pp_instance *handle);
  106. #endif /* _EVENTMGR_H_ */