1 /* 2 * Copyright 2016 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 26 #ifndef __DC_HUBBUB_DCN10_H__ 27 #define __DC_HUBBUB_DCN10_H__ 28 29 #include "core_types.h" 30 31 #define HUBHUB_REG_LIST_DCN()\ 32 SR(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A),\ 33 SR(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_A),\ 34 SR(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_A),\ 35 SR(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_B),\ 36 SR(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_B),\ 37 SR(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_B),\ 38 SR(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_C),\ 39 SR(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_C),\ 40 SR(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_C),\ 41 SR(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_D),\ 42 SR(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_D),\ 43 SR(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D),\ 44 SR(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL),\ 45 SR(DCHUBBUB_ARB_DRAM_STATE_CNTL),\ 46 SR(DCHUBBUB_ARB_SAT_LEVEL),\ 47 SR(DCHUBBUB_ARB_DF_REQ_OUTSTAND),\ 48 SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \ 49 SR(DCHUBBUB_TEST_DEBUG_INDEX), \ 50 SR(DCHUBBUB_TEST_DEBUG_DATA) 51 52 #define HUBBUB_SR_WATERMARK_REG_LIST()\ 53 SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_A),\ 54 SR(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_A),\ 55 SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_B),\ 56 SR(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_B),\ 57 SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_C),\ 58 SR(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_C),\ 59 SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_D),\ 60 SR(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_D) 61 62 #define HUBBUB_REG_LIST_DCN10(id)\ 63 HUBHUB_REG_LIST_DCN(), \ 64 HUBBUB_SR_WATERMARK_REG_LIST(), \ 65 SR(DCHUBBUB_SDPIF_FB_TOP),\ 66 SR(DCHUBBUB_SDPIF_FB_BASE),\ 67 SR(DCHUBBUB_SDPIF_FB_OFFSET),\ 68 SR(DCHUBBUB_SDPIF_AGP_BASE),\ 69 SR(DCHUBBUB_SDPIF_AGP_BOT),\ 70 SR(DCHUBBUB_SDPIF_AGP_TOP) 71 72 struct dcn_hubbub_registers { 73 uint32_t DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A; 74 uint32_t DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_A; 75 uint32_t DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_A; 76 uint32_t DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_A; 77 uint32_t DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_A; 78 uint32_t DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_B; 79 uint32_t DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_B; 80 uint32_t DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_B; 81 uint32_t DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_B; 82 uint32_t DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_B; 83 uint32_t DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_C; 84 uint32_t DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_C; 85 uint32_t DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_C; 86 uint32_t DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_C; 87 uint32_t DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_C; 88 uint32_t DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_D; 89 uint32_t DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_D; 90 uint32_t DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_D; 91 uint32_t DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_D; 92 uint32_t DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D; 93 uint32_t DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL; 94 uint32_t DCHUBBUB_ARB_SAT_LEVEL; 95 uint32_t DCHUBBUB_ARB_DF_REQ_OUTSTAND; 96 uint32_t DCHUBBUB_GLOBAL_TIMER_CNTL; 97 uint32_t DCHUBBUB_ARB_DRAM_STATE_CNTL; 98 uint32_t DCHUBBUB_TEST_DEBUG_INDEX; 99 uint32_t DCHUBBUB_TEST_DEBUG_DATA; 100 uint32_t DCHUBBUB_SDPIF_FB_TOP; 101 uint32_t DCHUBBUB_SDPIF_FB_BASE; 102 uint32_t DCHUBBUB_SDPIF_FB_OFFSET; 103 uint32_t DCHUBBUB_SDPIF_AGP_BASE; 104 uint32_t DCHUBBUB_SDPIF_AGP_BOT; 105 uint32_t DCHUBBUB_SDPIF_AGP_TOP; 106 uint32_t DCHUBBUB_CRC_CTRL; 107 }; 108 109 /* set field name */ 110 #define HUBBUB_SF(reg_name, field_name, post_fix)\ 111 .field_name = reg_name ## __ ## field_name ## post_fix 112 113 114 #define HUBBUB_MASK_SH_LIST_DCN(mask_sh)\ 115 HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, mask_sh), \ 116 HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, mask_sh), \ 117 HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_DONE_INTERRUPT_DISABLE, mask_sh), \ 118 HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_VALUE, mask_sh), \ 119 HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE, mask_sh), \ 120 HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_PSTATE_CHANGE_FORCE_VALUE, mask_sh), \ 121 HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_PSTATE_CHANGE_FORCE_ENABLE, mask_sh), \ 122 HUBBUB_SF(DCHUBBUB_ARB_SAT_LEVEL, DCHUBBUB_ARB_SAT_LEVEL, mask_sh), \ 123 HUBBUB_SF(DCHUBBUB_ARB_DF_REQ_OUTSTAND, DCHUBBUB_ARB_MIN_REQ_OUTSTAND, mask_sh) 124 125 #define HUBBUB_MASK_SH_LIST_DCN10(mask_sh)\ 126 HUBBUB_MASK_SH_LIST_DCN(mask_sh), \ 127 HUBBUB_SF(DCHUBBUB_SDPIF_FB_TOP, SDPIF_FB_TOP, mask_sh), \ 128 HUBBUB_SF(DCHUBBUB_SDPIF_FB_BASE, SDPIF_FB_BASE, mask_sh), \ 129 HUBBUB_SF(DCHUBBUB_SDPIF_FB_OFFSET, SDPIF_FB_OFFSET, mask_sh), \ 130 HUBBUB_SF(DCHUBBUB_SDPIF_AGP_BASE, SDPIF_AGP_BASE, mask_sh), \ 131 HUBBUB_SF(DCHUBBUB_SDPIF_AGP_BOT, SDPIF_AGP_BOT, mask_sh), \ 132 HUBBUB_SF(DCHUBBUB_SDPIF_AGP_TOP, SDPIF_AGP_TOP, mask_sh) 133 134 #define DCN_HUBBUB_REG_FIELD_LIST(type) \ 135 type DCHUBBUB_GLOBAL_TIMER_ENABLE; \ 136 type DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST;\ 137 type DCHUBBUB_ARB_WATERMARK_CHANGE_DONE_INTERRUPT_DISABLE;\ 138 type DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_VALUE;\ 139 type DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE;\ 140 type DCHUBBUB_ARB_ALLOW_PSTATE_CHANGE_FORCE_VALUE;\ 141 type DCHUBBUB_ARB_ALLOW_PSTATE_CHANGE_FORCE_ENABLE;\ 142 type DCHUBBUB_ARB_SAT_LEVEL;\ 143 type DCHUBBUB_ARB_MIN_REQ_OUTSTAND;\ 144 type DCHUBBUB_GLOBAL_TIMER_REFDIV;\ 145 type SDPIF_FB_TOP;\ 146 type SDPIF_FB_BASE;\ 147 type SDPIF_FB_OFFSET;\ 148 type SDPIF_AGP_BASE;\ 149 type SDPIF_AGP_BOT;\ 150 type SDPIF_AGP_TOP 151 152 153 struct dcn_hubbub_shift { 154 DCN_HUBBUB_REG_FIELD_LIST(uint8_t); 155 }; 156 157 struct dcn_hubbub_mask { 158 DCN_HUBBUB_REG_FIELD_LIST(uint32_t); 159 }; 160 161 struct dc; 162 163 struct dcn_hubbub_wm_set { 164 uint32_t wm_set; 165 uint32_t data_urgent; 166 uint32_t pte_meta_urgent; 167 uint32_t sr_enter; 168 uint32_t sr_exit; 169 uint32_t dram_clk_chanage; 170 }; 171 172 struct dcn_hubbub_wm { 173 struct dcn_hubbub_wm_set sets[4]; 174 }; 175 176 struct hubbub_funcs { 177 void (*update_dchub)( 178 struct hubbub *hubbub, 179 struct dchub_init_data *dh_data); 180 }; 181 182 struct hubbub { 183 const struct hubbub_funcs *funcs; 184 struct dc_context *ctx; 185 const struct dcn_hubbub_registers *regs; 186 const struct dcn_hubbub_shift *shifts; 187 const struct dcn_hubbub_mask *masks; 188 }; 189 190 void hubbub1_update_dchub( 191 struct hubbub *hubbub, 192 struct dchub_init_data *dh_data); 193 194 bool hubbub1_verify_allow_pstate_change_high( 195 struct hubbub *hubbub); 196 197 void hubbub1_program_watermarks( 198 struct hubbub *hubbub, 199 struct dcn_watermark_set *watermarks, 200 unsigned int refclk_mhz); 201 202 void hubbub1_toggle_watermark_change_req( 203 struct hubbub *hubbub); 204 205 void hubbub1_wm_read_state(struct hubbub *hubbub, 206 struct dcn_hubbub_wm *wm); 207 208 void hubbub1_construct(struct hubbub *hubbub, 209 struct dc_context *ctx, 210 const struct dcn_hubbub_registers *hubbub_regs, 211 const struct dcn_hubbub_shift *hubbub_shift, 212 const struct dcn_hubbub_mask *hubbub_mask); 213 214 #endif 215