dce_clocks.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright 2012-16 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. * Authors: AMD
  23. *
  24. */
  25. #ifndef _DCE_CLOCKS_H_
  26. #define _DCE_CLOCKS_H_
  27. #include "display_clock.h"
  28. #define CLK_COMMON_REG_LIST_DCE_BASE() \
  29. .DPREFCLK_CNTL = mmDPREFCLK_CNTL, \
  30. .DENTIST_DISPCLK_CNTL = mmDENTIST_DISPCLK_CNTL, \
  31. .MASTER_COMM_DATA_REG1 = mmMASTER_COMM_DATA_REG1, \
  32. .MASTER_COMM_CMD_REG = mmMASTER_COMM_CMD_REG, \
  33. .MASTER_COMM_CNTL_REG = mmMASTER_COMM_CNTL_REG
  34. #define CLK_SF(reg_name, field_name, post_fix)\
  35. .field_name = reg_name ## __ ## field_name ## post_fix
  36. #define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
  37. CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \
  38. CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh), \
  39. CLK_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0, mask_sh), \
  40. CLK_SF(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, mask_sh)
  41. #define CLK_REG_FIELD_LIST(type) \
  42. type DPREFCLK_SRC_SEL; \
  43. type DENTIST_DPREFCLK_WDIVIDER; \
  44. type MASTER_COMM_CMD_REG_BYTE0; \
  45. type MASTER_COMM_INTERRUPT
  46. struct dce_disp_clk_shift {
  47. CLK_REG_FIELD_LIST(uint8_t);
  48. };
  49. struct dce_disp_clk_mask {
  50. CLK_REG_FIELD_LIST(uint32_t);
  51. };
  52. struct dce_disp_clk_registers {
  53. uint32_t DPREFCLK_CNTL;
  54. uint32_t DENTIST_DISPCLK_CNTL;
  55. uint32_t MASTER_COMM_DATA_REG1;
  56. uint32_t MASTER_COMM_CMD_REG;
  57. uint32_t MASTER_COMM_CNTL_REG;
  58. };
  59. /* Array identifiers and count for the divider ranges.*/
  60. enum dce_divider_range_count {
  61. DIVIDER_RANGE_01 = 0,
  62. DIVIDER_RANGE_02,
  63. DIVIDER_RANGE_03,
  64. DIVIDER_RANGE_MAX /* == 3*/
  65. };
  66. enum dce_divider_error_types {
  67. INVALID_DID = 0,
  68. INVALID_DIVIDER = 1
  69. };
  70. struct dce_divider_range {
  71. int div_range_start;
  72. /* The end of this range of dividers.*/
  73. int div_range_end;
  74. /* The distance between each divider in this range.*/
  75. int div_range_step;
  76. /* The divider id for the lowest divider.*/
  77. int did_min;
  78. /* The divider id for the highest divider.*/
  79. int did_max;
  80. };
  81. struct dce_disp_clk {
  82. struct display_clock base;
  83. const struct dce_disp_clk_registers *regs;
  84. const struct dce_disp_clk_shift *clk_shift;
  85. const struct dce_disp_clk_mask *clk_mask;
  86. struct state_dependent_clocks max_clks_by_state[DM_PP_CLOCKS_MAX_STATES];
  87. struct dce_divider_range divider_ranges[DIVIDER_RANGE_MAX];
  88. bool use_max_disp_clk;
  89. int dentist_vco_freq_khz;
  90. /* Cache the status of DFS-bypass feature*/
  91. bool dfs_bypass_enabled;
  92. /* Cache the display clock returned by VBIOS if DFS-bypass is enabled.
  93. * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */
  94. int dfs_bypass_disp_clk;
  95. /* Flag for Enabled SS on GPU PLL */
  96. bool ss_on_gpu_pll;
  97. /* GPU PLL SS percentage (if down-spread enabled) */
  98. int gpu_pll_ss_percentage;
  99. /* GPU PLL SS percentage Divider (100 or 1000) */
  100. int gpu_pll_ss_divider;
  101. };
  102. struct display_clock *dce_disp_clk_create(
  103. struct dc_context *ctx,
  104. const struct dce_disp_clk_registers *regs,
  105. const struct dce_disp_clk_shift *clk_shift,
  106. const struct dce_disp_clk_mask *clk_mask);
  107. struct display_clock *dce110_disp_clk_create(
  108. struct dc_context *ctx,
  109. const struct dce_disp_clk_registers *regs,
  110. const struct dce_disp_clk_shift *clk_shift,
  111. const struct dce_disp_clk_mask *clk_mask);
  112. struct display_clock *dce112_disp_clk_create(
  113. struct dc_context *ctx,
  114. const struct dce_disp_clk_registers *regs,
  115. const struct dce_disp_clk_shift *clk_shift,
  116. const struct dce_disp_clk_mask *clk_mask);
  117. void dce_disp_clk_destroy(struct display_clock **disp_clk);
  118. #endif /* _DCE_CLOCKS_H_ */