1fb4d8502Sjsg /* 2fb4d8502Sjsg * Copyright 2012-15 Advanced Micro Devices, Inc. 3fb4d8502Sjsg * 4fb4d8502Sjsg * Permission is hereby granted, free of charge, to any person obtaining a 5fb4d8502Sjsg * copy of this software and associated documentation files (the "Software"), 6fb4d8502Sjsg * to deal in the Software without restriction, including without limitation 7fb4d8502Sjsg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8fb4d8502Sjsg * and/or sell copies of the Software, and to permit persons to whom the 9fb4d8502Sjsg * Software is furnished to do so, subject to the following conditions: 10fb4d8502Sjsg * 11fb4d8502Sjsg * The above copyright notice and this permission notice shall be included in 12fb4d8502Sjsg * all copies or substantial portions of the Software. 13fb4d8502Sjsg * 14fb4d8502Sjsg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15fb4d8502Sjsg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16fb4d8502Sjsg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17fb4d8502Sjsg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18fb4d8502Sjsg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19fb4d8502Sjsg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20fb4d8502Sjsg * OTHER DEALINGS IN THE SOFTWARE. 21fb4d8502Sjsg * 22fb4d8502Sjsg * Authors: AMD 23fb4d8502Sjsg * 24fb4d8502Sjsg */ 25fb4d8502Sjsg 26fb4d8502Sjsg #ifndef __DC_CLOCK_SOURCE_H__ 27fb4d8502Sjsg #define __DC_CLOCK_SOURCE_H__ 28fb4d8502Sjsg 29fb4d8502Sjsg #include "dc_types.h" 30fb4d8502Sjsg #include "include/grph_object_id.h" 31fb4d8502Sjsg #include "include/bios_parser_types.h" 32fb4d8502Sjsg 33fb4d8502Sjsg struct clock_source; 34fb4d8502Sjsg 35fb4d8502Sjsg struct spread_spectrum_data { 36fb4d8502Sjsg uint32_t percentage; /*> In unit of 0.01% or 0.001%*/ 37fb4d8502Sjsg uint32_t percentage_divider; /*> 100 or 1000 */ 38fb4d8502Sjsg uint32_t freq_range_khz; 39fb4d8502Sjsg uint32_t modulation_freq_hz; 40fb4d8502Sjsg 41fb4d8502Sjsg struct spread_spectrum_flags flags; 42fb4d8502Sjsg }; 43fb4d8502Sjsg 44fb4d8502Sjsg struct delta_sigma_data { 45fb4d8502Sjsg uint32_t feedback_amount; 46fb4d8502Sjsg uint32_t nfrac_amount; 47fb4d8502Sjsg uint32_t ds_frac_size; 48fb4d8502Sjsg uint32_t ds_frac_amount; 49fb4d8502Sjsg }; 50fb4d8502Sjsg 51fb4d8502Sjsg /** 52fb4d8502Sjsg * Pixel Clock Parameters structure 53fb4d8502Sjsg * These parameters are required as input 54fb4d8502Sjsg * when calculating Pixel Clock Dividers for requested Pixel Clock 55fb4d8502Sjsg */ 56fb4d8502Sjsg struct pixel_clk_flags { 57fb4d8502Sjsg uint32_t ENABLE_SS:1; 58fb4d8502Sjsg uint32_t DISPLAY_BLANKED:1; 59fb4d8502Sjsg uint32_t PROGRAM_PIXEL_CLOCK:1; 60fb4d8502Sjsg uint32_t PROGRAM_ID_CLOCK:1; 61fb4d8502Sjsg uint32_t SUPPORT_YCBCR420:1; 62fb4d8502Sjsg }; 63fb4d8502Sjsg 64fb4d8502Sjsg /** 65fb4d8502Sjsg * Display Port HW De spread of Reference Clock related Parameters structure 66fb4d8502Sjsg * Store it once at boot for later usage 67fb4d8502Sjsg */ 68fb4d8502Sjsg struct csdp_ref_clk_ds_params { 69fb4d8502Sjsg bool hw_dso_n_dp_ref_clk; 70fb4d8502Sjsg /* Flag for HW De Spread enabled (if enabled SS on DP Reference Clock)*/ 71fb4d8502Sjsg uint32_t avg_dp_ref_clk_khz; 72fb4d8502Sjsg /* Average DP Reference clock (in KHz)*/ 73fb4d8502Sjsg uint32_t ss_percentage_on_dp_ref_clk; 74fb4d8502Sjsg /* DP Reference clock SS percentage 75fb4d8502Sjsg * (not to be mixed with DP IDCLK SS from PLL Settings)*/ 76fb4d8502Sjsg uint32_t ss_percentage_divider; 77fb4d8502Sjsg /* DP Reference clock SS percentage divider */ 78fb4d8502Sjsg }; 79fb4d8502Sjsg 80fb4d8502Sjsg struct pixel_clk_params { 81c349dbc7Sjsg uint32_t requested_pix_clk_100hz; 82fb4d8502Sjsg /*> Requested Pixel Clock 83fb4d8502Sjsg * (based on Video Timing standard used for requested mode)*/ 84fb4d8502Sjsg uint32_t requested_sym_clk; /* in KHz */ 85fb4d8502Sjsg /*> Requested Sym Clock (relevant only for display port)*/ 86fb4d8502Sjsg uint32_t dp_ref_clk; /* in KHz */ 87fb4d8502Sjsg /*> DP reference clock - calculated only for DP signal for specific cases*/ 88fb4d8502Sjsg struct graphics_object_id encoder_object_id; 89fb4d8502Sjsg /*> Encoder object Id - needed by VBIOS Exec table*/ 90fb4d8502Sjsg enum amd_signal_type signal_type; 91fb4d8502Sjsg /*> signalType -> Encoder Mode - needed by VBIOS Exec table*/ 92fb4d8502Sjsg enum controller_id controller_id; 93fb4d8502Sjsg /*> ControllerId - which controller using this PLL*/ 94fb4d8502Sjsg enum dc_color_depth color_depth; 95fb4d8502Sjsg struct csdp_ref_clk_ds_params de_spread_params; 96fb4d8502Sjsg /*> de-spread info, relevant only for on-the-fly tune-up pixel rate*/ 97fb4d8502Sjsg enum dc_pixel_encoding pixel_encoding; 98fb4d8502Sjsg struct pixel_clk_flags flags; 99fb4d8502Sjsg }; 100fb4d8502Sjsg 101fb4d8502Sjsg /** 102fb4d8502Sjsg * Pixel Clock Dividers structure with desired Pixel Clock 103fb4d8502Sjsg * (adjusted after VBIOS exec table), 104fb4d8502Sjsg * with actually calculated Clock and reference Crystal frequency 105fb4d8502Sjsg */ 106fb4d8502Sjsg struct pll_settings { 107c349dbc7Sjsg uint32_t actual_pix_clk_100hz; 108c349dbc7Sjsg uint32_t adjusted_pix_clk_100hz; 109c349dbc7Sjsg uint32_t calculated_pix_clk_100hz; 110fb4d8502Sjsg uint32_t vco_freq; 111fb4d8502Sjsg uint32_t reference_freq; 112fb4d8502Sjsg uint32_t reference_divider; 113fb4d8502Sjsg uint32_t feedback_divider; 114fb4d8502Sjsg uint32_t fract_feedback_divider; 115fb4d8502Sjsg uint32_t pix_clk_post_divider; 116fb4d8502Sjsg uint32_t ss_percentage; 117fb4d8502Sjsg bool use_external_clk; 118fb4d8502Sjsg }; 119fb4d8502Sjsg 120fb4d8502Sjsg struct calc_pll_clock_source_init_data { 121fb4d8502Sjsg struct dc_bios *bp; 122fb4d8502Sjsg uint32_t min_pix_clk_pll_post_divider; 123fb4d8502Sjsg uint32_t max_pix_clk_pll_post_divider; 124fb4d8502Sjsg uint32_t min_pll_ref_divider; 125fb4d8502Sjsg uint32_t max_pll_ref_divider; 126fb4d8502Sjsg uint32_t min_override_input_pxl_clk_pll_freq_khz; 127fb4d8502Sjsg /* if not 0, override the firmware info */ 128fb4d8502Sjsg 129fb4d8502Sjsg uint32_t max_override_input_pxl_clk_pll_freq_khz; 130fb4d8502Sjsg /* if not 0, override the firmware info */ 131fb4d8502Sjsg 132fb4d8502Sjsg uint32_t num_fract_fb_divider_decimal_point; 133fb4d8502Sjsg /* number of decimal point for fractional feedback divider value */ 134fb4d8502Sjsg 135fb4d8502Sjsg uint32_t num_fract_fb_divider_decimal_point_precision; 136fb4d8502Sjsg /* number of decimal point to round off for fractional feedback divider value*/ 137fb4d8502Sjsg struct dc_context *ctx; 138fb4d8502Sjsg 139fb4d8502Sjsg }; 140fb4d8502Sjsg 141fb4d8502Sjsg struct calc_pll_clock_source { 142fb4d8502Sjsg uint32_t ref_freq_khz; 143fb4d8502Sjsg uint32_t min_pix_clock_pll_post_divider; 144fb4d8502Sjsg uint32_t max_pix_clock_pll_post_divider; 145fb4d8502Sjsg uint32_t min_pll_ref_divider; 146fb4d8502Sjsg uint32_t max_pll_ref_divider; 147fb4d8502Sjsg 148fb4d8502Sjsg uint32_t max_vco_khz; 149fb4d8502Sjsg uint32_t min_vco_khz; 150fb4d8502Sjsg uint32_t min_pll_input_freq_khz; 151fb4d8502Sjsg uint32_t max_pll_input_freq_khz; 152fb4d8502Sjsg 153fb4d8502Sjsg uint32_t fract_fb_divider_decimal_points_num; 154fb4d8502Sjsg uint32_t fract_fb_divider_factor; 155fb4d8502Sjsg uint32_t fract_fb_divider_precision; 156fb4d8502Sjsg uint32_t fract_fb_divider_precision_factor; 157fb4d8502Sjsg struct dc_context *ctx; 158fb4d8502Sjsg }; 159fb4d8502Sjsg 160fb4d8502Sjsg struct clock_source_funcs { 161fb4d8502Sjsg bool (*cs_power_down)( 162fb4d8502Sjsg struct clock_source *); 163*1bb76ff1Sjsg bool (*program_pix_clk)( 164*1bb76ff1Sjsg struct clock_source *, 165*1bb76ff1Sjsg struct pixel_clk_params *, 166*1bb76ff1Sjsg enum dp_link_encoding encoding, 167*1bb76ff1Sjsg struct pll_settings *); 168fb4d8502Sjsg uint32_t (*get_pix_clk_dividers)( 169fb4d8502Sjsg struct clock_source *, 170fb4d8502Sjsg struct pixel_clk_params *, 171fb4d8502Sjsg struct pll_settings *); 172c349dbc7Sjsg bool (*get_pixel_clk_frequency_100hz)( 173c349dbc7Sjsg const struct clock_source *clock_source, 174c349dbc7Sjsg unsigned int inst, 175c349dbc7Sjsg unsigned int *pixel_clk_khz); 1765ca02815Sjsg bool (*override_dp_pix_clk)( 1775ca02815Sjsg struct clock_source *clock_source, 1785ca02815Sjsg unsigned int inst, 1795ca02815Sjsg unsigned int pixel_clk, 1805ca02815Sjsg unsigned int ref_clk); 181fb4d8502Sjsg }; 182fb4d8502Sjsg 183fb4d8502Sjsg struct clock_source { 184fb4d8502Sjsg const struct clock_source_funcs *funcs; 185fb4d8502Sjsg struct dc_context *ctx; 186fb4d8502Sjsg enum clock_source_id id; 187fb4d8502Sjsg bool dp_clk_src; 188fb4d8502Sjsg }; 189fb4d8502Sjsg 190fb4d8502Sjsg #endif 191