dce_clocks.h 4.1 KB

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