1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2012-16 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev 27*b843c749SSergey Zigachev #ifndef _DCE_CLOCKS_H_ 28*b843c749SSergey Zigachev #define _DCE_CLOCKS_H_ 29*b843c749SSergey Zigachev 30*b843c749SSergey Zigachev #include "display_clock.h" 31*b843c749SSergey Zigachev 32*b843c749SSergey Zigachev #define CLK_COMMON_REG_LIST_DCE_BASE() \ 33*b843c749SSergey Zigachev .DPREFCLK_CNTL = mmDPREFCLK_CNTL, \ 34*b843c749SSergey Zigachev .DENTIST_DISPCLK_CNTL = mmDENTIST_DISPCLK_CNTL 35*b843c749SSergey Zigachev 36*b843c749SSergey Zigachev #define CLK_COMMON_REG_LIST_DCN_BASE() \ 37*b843c749SSergey Zigachev SR(DENTIST_DISPCLK_CNTL) 38*b843c749SSergey Zigachev 39*b843c749SSergey Zigachev #define CLK_SF(reg_name, field_name, post_fix)\ 40*b843c749SSergey Zigachev .field_name = reg_name ## __ ## field_name ## post_fix 41*b843c749SSergey Zigachev 42*b843c749SSergey Zigachev #define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \ 43*b843c749SSergey Zigachev CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \ 44*b843c749SSergey Zigachev CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh) 45*b843c749SSergey Zigachev 46*b843c749SSergey Zigachev #define CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh) \ 47*b843c749SSergey Zigachev CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_WDIVIDER, mask_sh),\ 48*b843c749SSergey Zigachev CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, mask_sh) 49*b843c749SSergey Zigachev 50*b843c749SSergey Zigachev #define CLK_REG_FIELD_LIST(type) \ 51*b843c749SSergey Zigachev type DPREFCLK_SRC_SEL; \ 52*b843c749SSergey Zigachev type DENTIST_DPREFCLK_WDIVIDER; \ 53*b843c749SSergey Zigachev type DENTIST_DISPCLK_WDIVIDER; \ 54*b843c749SSergey Zigachev type DENTIST_DISPCLK_CHG_DONE; 55*b843c749SSergey Zigachev 56*b843c749SSergey Zigachev struct dccg_shift { 57*b843c749SSergey Zigachev CLK_REG_FIELD_LIST(uint8_t) 58*b843c749SSergey Zigachev }; 59*b843c749SSergey Zigachev 60*b843c749SSergey Zigachev struct dccg_mask { 61*b843c749SSergey Zigachev CLK_REG_FIELD_LIST(uint32_t) 62*b843c749SSergey Zigachev }; 63*b843c749SSergey Zigachev 64*b843c749SSergey Zigachev struct dccg_registers { 65*b843c749SSergey Zigachev uint32_t DPREFCLK_CNTL; 66*b843c749SSergey Zigachev uint32_t DENTIST_DISPCLK_CNTL; 67*b843c749SSergey Zigachev }; 68*b843c749SSergey Zigachev 69*b843c749SSergey Zigachev struct dce_dccg { 70*b843c749SSergey Zigachev struct dccg base; 71*b843c749SSergey Zigachev const struct dccg_registers *regs; 72*b843c749SSergey Zigachev const struct dccg_shift *clk_shift; 73*b843c749SSergey Zigachev const struct dccg_mask *clk_mask; 74*b843c749SSergey Zigachev 75*b843c749SSergey Zigachev struct state_dependent_clocks max_clks_by_state[DM_PP_CLOCKS_MAX_STATES]; 76*b843c749SSergey Zigachev 77*b843c749SSergey Zigachev int dentist_vco_freq_khz; 78*b843c749SSergey Zigachev 79*b843c749SSergey Zigachev /* Cache the status of DFS-bypass feature*/ 80*b843c749SSergey Zigachev bool dfs_bypass_enabled; 81*b843c749SSergey Zigachev /* Cache the display clock returned by VBIOS if DFS-bypass is enabled. 82*b843c749SSergey Zigachev * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */ 83*b843c749SSergey Zigachev int dfs_bypass_disp_clk; 84*b843c749SSergey Zigachev 85*b843c749SSergey Zigachev /* Flag for Enabled SS on DPREFCLK */ 86*b843c749SSergey Zigachev bool ss_on_dprefclk; 87*b843c749SSergey Zigachev /* DPREFCLK SS percentage (if down-spread enabled) */ 88*b843c749SSergey Zigachev int dprefclk_ss_percentage; 89*b843c749SSergey Zigachev /* DPREFCLK SS percentage Divider (100 or 1000) */ 90*b843c749SSergey Zigachev int dprefclk_ss_divider; 91*b843c749SSergey Zigachev }; 92*b843c749SSergey Zigachev 93*b843c749SSergey Zigachev 94*b843c749SSergey Zigachev struct dccg *dce_dccg_create( 95*b843c749SSergey Zigachev struct dc_context *ctx, 96*b843c749SSergey Zigachev const struct dccg_registers *regs, 97*b843c749SSergey Zigachev const struct dccg_shift *clk_shift, 98*b843c749SSergey Zigachev const struct dccg_mask *clk_mask); 99*b843c749SSergey Zigachev 100*b843c749SSergey Zigachev struct dccg *dce110_dccg_create( 101*b843c749SSergey Zigachev struct dc_context *ctx, 102*b843c749SSergey Zigachev const struct dccg_registers *regs, 103*b843c749SSergey Zigachev const struct dccg_shift *clk_shift, 104*b843c749SSergey Zigachev const struct dccg_mask *clk_mask); 105*b843c749SSergey Zigachev 106*b843c749SSergey Zigachev struct dccg *dce112_dccg_create( 107*b843c749SSergey Zigachev struct dc_context *ctx, 108*b843c749SSergey Zigachev const struct dccg_registers *regs, 109*b843c749SSergey Zigachev const struct dccg_shift *clk_shift, 110*b843c749SSergey Zigachev const struct dccg_mask *clk_mask); 111*b843c749SSergey Zigachev 112*b843c749SSergey Zigachev struct dccg *dce120_dccg_create(struct dc_context *ctx); 113*b843c749SSergey Zigachev 114*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMD_DC_DCN1_0 115*b843c749SSergey Zigachev struct dccg *dcn1_dccg_create(struct dc_context *ctx); 116*b843c749SSergey Zigachev #endif 117*b843c749SSergey Zigachev 118*b843c749SSergey Zigachev void dce_dccg_destroy(struct dccg **dccg); 119*b843c749SSergey Zigachev 120*b843c749SSergey Zigachev #endif /* _DCE_CLOCKS_H_ */ 121