clock_source.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright 2012-15 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 __DC_CLOCK_SOURCE_H__
  26. #define __DC_CLOCK_SOURCE_H__
  27. #include "dc_types.h"
  28. #include "include/grph_object_id.h"
  29. #include "include/bios_parser_types.h"
  30. struct clock_source;
  31. struct spread_spectrum_data {
  32. uint32_t percentage; /*> In unit of 0.01% or 0.001%*/
  33. uint32_t percentage_divider; /*> 100 or 1000 */
  34. uint32_t freq_range_khz;
  35. uint32_t modulation_freq_hz;
  36. struct spread_spectrum_flags flags;
  37. };
  38. struct delta_sigma_data {
  39. uint32_t feedback_amount;
  40. uint32_t nfrac_amount;
  41. uint32_t ds_frac_size;
  42. uint32_t ds_frac_amount;
  43. };
  44. /**
  45. * Pixel Clock Parameters structure
  46. * These parameters are required as input
  47. * when calculating Pixel Clock Dividers for requested Pixel Clock
  48. */
  49. struct pixel_clk_flags {
  50. uint32_t ENABLE_SS:1;
  51. uint32_t DISPLAY_BLANKED:1;
  52. uint32_t PROGRAM_PIXEL_CLOCK:1;
  53. uint32_t PROGRAM_ID_CLOCK:1;
  54. uint32_t SUPPORT_YCBCR420:1;
  55. };
  56. /**
  57. * Display Port HW De spread of Reference Clock related Parameters structure
  58. * Store it once at boot for later usage
  59. */
  60. struct csdp_ref_clk_ds_params {
  61. bool hw_dso_n_dp_ref_clk;
  62. /* Flag for HW De Spread enabled (if enabled SS on DP Reference Clock)*/
  63. uint32_t avg_dp_ref_clk_khz;
  64. /* Average DP Reference clock (in KHz)*/
  65. uint32_t ss_percentage_on_dp_ref_clk;
  66. /* DP Reference clock SS percentage
  67. * (not to be mixed with DP IDCLK SS from PLL Settings)*/
  68. uint32_t ss_percentage_divider;
  69. /* DP Reference clock SS percentage divider */
  70. };
  71. struct pixel_clk_params {
  72. uint32_t requested_pix_clk; /* in KHz */
  73. /*> Requested Pixel Clock
  74. * (based on Video Timing standard used for requested mode)*/
  75. uint32_t requested_sym_clk; /* in KHz */
  76. /*> Requested Sym Clock (relevant only for display port)*/
  77. uint32_t dp_ref_clk; /* in KHz */
  78. /*> DP reference clock - calculated only for DP signal for specific cases*/
  79. struct graphics_object_id encoder_object_id;
  80. /*> Encoder object Id - needed by VBIOS Exec table*/
  81. enum signal_type signal_type;
  82. /*> signalType -> Encoder Mode - needed by VBIOS Exec table*/
  83. enum controller_id controller_id;
  84. /*> ControllerId - which controller using this PLL*/
  85. enum dc_color_depth color_depth;
  86. struct csdp_ref_clk_ds_params de_spread_params;
  87. /*> de-spread info, relevant only for on-the-fly tune-up pixel rate*/
  88. enum dc_pixel_encoding pixel_encoding;
  89. struct pixel_clk_flags flags;
  90. };
  91. /**
  92. * Pixel Clock Dividers structure with desired Pixel Clock
  93. * (adjusted after VBIOS exec table),
  94. * with actually calculated Clock and reference Crystal frequency
  95. */
  96. struct pll_settings {
  97. uint32_t actual_pix_clk;
  98. uint32_t adjusted_pix_clk;
  99. uint32_t calculated_pix_clk;
  100. uint32_t vco_freq;
  101. uint32_t reference_freq;
  102. uint32_t reference_divider;
  103. uint32_t feedback_divider;
  104. uint32_t fract_feedback_divider;
  105. uint32_t pix_clk_post_divider;
  106. uint32_t ss_percentage;
  107. bool use_external_clk;
  108. };
  109. struct calc_pll_clock_source_init_data {
  110. struct dc_bios *bp;
  111. uint32_t min_pix_clk_pll_post_divider;
  112. uint32_t max_pix_clk_pll_post_divider;
  113. uint32_t min_pll_ref_divider;
  114. uint32_t max_pll_ref_divider;
  115. uint32_t min_override_input_pxl_clk_pll_freq_khz;
  116. /* if not 0, override the firmware info */
  117. uint32_t max_override_input_pxl_clk_pll_freq_khz;
  118. /* if not 0, override the firmware info */
  119. uint32_t num_fract_fb_divider_decimal_point;
  120. /* number of decimal point for fractional feedback divider value */
  121. uint32_t num_fract_fb_divider_decimal_point_precision;
  122. /* number of decimal point to round off for fractional feedback divider value*/
  123. struct dc_context *ctx;
  124. };
  125. struct calc_pll_clock_source {
  126. uint32_t ref_freq_khz;
  127. uint32_t min_pix_clock_pll_post_divider;
  128. uint32_t max_pix_clock_pll_post_divider;
  129. uint32_t min_pll_ref_divider;
  130. uint32_t max_pll_ref_divider;
  131. uint32_t max_vco_khz;
  132. uint32_t min_vco_khz;
  133. uint32_t min_pll_input_freq_khz;
  134. uint32_t max_pll_input_freq_khz;
  135. uint32_t fract_fb_divider_decimal_points_num;
  136. uint32_t fract_fb_divider_factor;
  137. uint32_t fract_fb_divider_precision;
  138. uint32_t fract_fb_divider_precision_factor;
  139. struct dc_context *ctx;
  140. };
  141. struct clock_source_funcs {
  142. bool (*cs_power_down)(
  143. struct clock_source *);
  144. bool (*program_pix_clk)(struct clock_source *,
  145. struct pixel_clk_params *, struct pll_settings *);
  146. uint32_t (*get_pix_clk_dividers)(
  147. struct clock_source *,
  148. struct pixel_clk_params *,
  149. struct pll_settings *);
  150. uint32_t (*get_pix_rate_in_hz)(
  151. struct clock_source *,
  152. struct pixel_clk_params *,
  153. struct pll_settings *);
  154. };
  155. struct clock_source {
  156. const struct clock_source_funcs *funcs;
  157. struct dc_context *ctx;
  158. enum clock_source_id id;
  159. bool dp_clk_src;
  160. };
  161. #endif