dce_clocks.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_COMMON_REG_LIST_DCN_BASE() \
  32. SR(DENTIST_DISPCLK_CNTL)
  33. #define CLK_SF(reg_name, field_name, post_fix)\
  34. .field_name = reg_name ## __ ## field_name ## post_fix
  35. #define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
  36. CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \
  37. CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh)
  38. #define CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh) \
  39. CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_WDIVIDER, mask_sh),\
  40. CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, mask_sh)
  41. #define CLK_REG_FIELD_LIST(type) \
  42. type DPREFCLK_SRC_SEL; \
  43. type DENTIST_DPREFCLK_WDIVIDER; \
  44. type DENTIST_DISPCLK_WDIVIDER; \
  45. type DENTIST_DISPCLK_CHG_DONE;
  46. struct dccg_shift {
  47. CLK_REG_FIELD_LIST(uint8_t)
  48. };
  49. struct dccg_mask {
  50. CLK_REG_FIELD_LIST(uint32_t)
  51. };
  52. struct dccg_registers {
  53. uint32_t DPREFCLK_CNTL;
  54. uint32_t DENTIST_DISPCLK_CNTL;
  55. };
  56. struct dce_dccg {
  57. struct dccg base;
  58. const struct dccg_registers *regs;
  59. const struct dccg_shift *clk_shift;
  60. const struct dccg_mask *clk_mask;
  61. struct state_dependent_clocks max_clks_by_state[DM_PP_CLOCKS_MAX_STATES];
  62. int dentist_vco_freq_khz;
  63. /* Cache the status of DFS-bypass feature*/
  64. bool dfs_bypass_enabled;
  65. /* True if the DFS-bypass feature is enabled and active. */
  66. bool dfs_bypass_active;
  67. /* Cache the display clock returned by VBIOS if DFS-bypass is enabled.
  68. * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */
  69. int dfs_bypass_disp_clk;
  70. /* Flag for Enabled SS on DPREFCLK */
  71. bool ss_on_dprefclk;
  72. /* DPREFCLK SS percentage (if down-spread enabled) */
  73. int dprefclk_ss_percentage;
  74. /* DPREFCLK SS percentage Divider (100 or 1000) */
  75. int dprefclk_ss_divider;
  76. int dprefclk_khz;
  77. };
  78. struct dccg *dce_dccg_create(
  79. struct dc_context *ctx,
  80. const struct dccg_registers *regs,
  81. const struct dccg_shift *clk_shift,
  82. const struct dccg_mask *clk_mask);
  83. struct dccg *dce110_dccg_create(
  84. struct dc_context *ctx,
  85. const struct dccg_registers *regs,
  86. const struct dccg_shift *clk_shift,
  87. const struct dccg_mask *clk_mask);
  88. struct dccg *dce112_dccg_create(
  89. struct dc_context *ctx,
  90. const struct dccg_registers *regs,
  91. const struct dccg_shift *clk_shift,
  92. const struct dccg_mask *clk_mask);
  93. struct dccg *dce120_dccg_create(struct dc_context *ctx);
  94. #ifdef CONFIG_DRM_AMD_DC_DCN1_0
  95. struct dccg *dcn1_dccg_create(struct dc_context *ctx);
  96. #endif
  97. void dce_dccg_destroy(struct dccg **dccg);
  98. #endif /* _DCE_CLOCKS_H_ */