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 26 27 #ifndef _DCE_DMCU_H_ 28 #define _DCE_DMCU_H_ 29 30 #include "dmcu.h" 31 32 #define DMCU_COMMON_REG_LIST_DCE_BASE() \ 33 SR(DMCU_CTRL), \ 34 SR(DMCU_STATUS), \ 35 SR(DMCU_RAM_ACCESS_CTRL), \ 36 SR(DMCU_IRAM_WR_CTRL), \ 37 SR(DMCU_IRAM_WR_DATA), \ 38 SR(MASTER_COMM_DATA_REG1), \ 39 SR(MASTER_COMM_DATA_REG2), \ 40 SR(MASTER_COMM_DATA_REG3), \ 41 SR(MASTER_COMM_CMD_REG), \ 42 SR(MASTER_COMM_CNTL_REG), \ 43 SR(DMCU_IRAM_RD_CTRL), \ 44 SR(DMCU_IRAM_RD_DATA), \ 45 SR(DMCU_INTERRUPT_TO_UC_EN_MASK), \ 46 SR(SMU_INTERRUPT_CONTROL), \ 47 SR(DC_DMCU_SCRATCH) 48 49 #define DMCU_DCE110_COMMON_REG_LIST() \ 50 DMCU_COMMON_REG_LIST_DCE_BASE(), \ 51 SR(DCI_MEM_PWR_STATUS) 52 53 #define DMCU_DCN10_REG_LIST()\ 54 DMCU_COMMON_REG_LIST_DCE_BASE(), \ 55 SR(DMU_MEM_PWR_CNTL) 56 57 #define DMCU_SF(reg_name, field_name, post_fix)\ 58 .field_name = reg_name ## __ ## field_name ## post_fix 59 60 #define DMCU_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \ 61 DMCU_SF(DMCU_CTRL, \ 62 DMCU_ENABLE, mask_sh), \ 63 DMCU_SF(DMCU_STATUS, \ 64 UC_IN_STOP_MODE, mask_sh), \ 65 DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ 66 IRAM_HOST_ACCESS_EN, mask_sh), \ 67 DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ 68 IRAM_WR_ADDR_AUTO_INC, mask_sh), \ 69 DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ 70 IRAM_RD_ADDR_AUTO_INC, mask_sh), \ 71 DMCU_SF(MASTER_COMM_CMD_REG, \ 72 MASTER_COMM_CMD_REG_BYTE0, mask_sh), \ 73 DMCU_SF(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, mask_sh), \ 74 DMCU_SF(DMCU_INTERRUPT_TO_UC_EN_MASK, \ 75 STATIC_SCREEN1_INT_TO_UC_EN, mask_sh), \ 76 DMCU_SF(DMCU_INTERRUPT_TO_UC_EN_MASK, \ 77 STATIC_SCREEN2_INT_TO_UC_EN, mask_sh), \ 78 DMCU_SF(DMCU_INTERRUPT_TO_UC_EN_MASK, \ 79 STATIC_SCREEN3_INT_TO_UC_EN, mask_sh), \ 80 DMCU_SF(DMCU_INTERRUPT_TO_UC_EN_MASK, \ 81 STATIC_SCREEN4_INT_TO_UC_EN, mask_sh), \ 82 DMCU_SF(SMU_INTERRUPT_CONTROL, DC_SMU_INT_ENABLE, mask_sh) 83 84 #define DMCU_MASK_SH_LIST_DCE110(mask_sh) \ 85 DMCU_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh), \ 86 DMCU_SF(DCI_MEM_PWR_STATUS, \ 87 DMCU_IRAM_MEM_PWR_STATE, mask_sh) 88 89 #define DMCU_MASK_SH_LIST_DCN10(mask_sh) \ 90 DMCU_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh), \ 91 DMCU_SF(DMU_MEM_PWR_CNTL, \ 92 DMCU_IRAM_MEM_PWR_STATE, mask_sh) 93 94 #define DMCU_REG_FIELD_LIST(type) \ 95 type DMCU_IRAM_MEM_PWR_STATE; \ 96 type IRAM_HOST_ACCESS_EN; \ 97 type IRAM_WR_ADDR_AUTO_INC; \ 98 type IRAM_RD_ADDR_AUTO_INC; \ 99 type DMCU_ENABLE; \ 100 type UC_IN_STOP_MODE; \ 101 type MASTER_COMM_CMD_REG_BYTE0; \ 102 type MASTER_COMM_INTERRUPT; \ 103 type DPHY_RX_FAST_TRAINING_CAPABLE; \ 104 type DPHY_LOAD_BS_COUNT; \ 105 type STATIC_SCREEN1_INT_TO_UC_EN; \ 106 type STATIC_SCREEN2_INT_TO_UC_EN; \ 107 type STATIC_SCREEN3_INT_TO_UC_EN; \ 108 type STATIC_SCREEN4_INT_TO_UC_EN; \ 109 type DP_SEC_GSP0_LINE_NUM; \ 110 type DP_SEC_GSP0_PRIORITY; \ 111 type DC_SMU_INT_ENABLE 112 113 struct dce_dmcu_shift { 114 DMCU_REG_FIELD_LIST(uint8_t); 115 }; 116 117 struct dce_dmcu_mask { 118 DMCU_REG_FIELD_LIST(uint32_t); 119 }; 120 121 struct dce_dmcu_registers { 122 uint32_t DMCU_CTRL; 123 uint32_t DMCU_STATUS; 124 uint32_t DMCU_RAM_ACCESS_CTRL; 125 uint32_t DCI_MEM_PWR_STATUS; 126 uint32_t DMU_MEM_PWR_CNTL; 127 uint32_t DMCU_IRAM_WR_CTRL; 128 uint32_t DMCU_IRAM_WR_DATA; 129 130 uint32_t MASTER_COMM_DATA_REG1; 131 uint32_t MASTER_COMM_DATA_REG2; 132 uint32_t MASTER_COMM_DATA_REG3; 133 uint32_t MASTER_COMM_CMD_REG; 134 uint32_t MASTER_COMM_CNTL_REG; 135 uint32_t DMCU_IRAM_RD_CTRL; 136 uint32_t DMCU_IRAM_RD_DATA; 137 uint32_t DMCU_INTERRUPT_TO_UC_EN_MASK; 138 uint32_t SMU_INTERRUPT_CONTROL; 139 uint32_t DC_DMCU_SCRATCH; 140 }; 141 142 struct dce_dmcu { 143 struct dmcu base; 144 const struct dce_dmcu_registers *regs; 145 const struct dce_dmcu_shift *dmcu_shift; 146 const struct dce_dmcu_mask *dmcu_mask; 147 }; 148 149 /******************************************************************* 150 * MASTER_COMM_DATA_REG1 Bit position Data 151 * 7:0 hyst_frames[7:0] 152 * 14:8 hyst_lines[6:0] 153 * 15 RFB_UPDATE_AUTO_EN 154 * 18:16 phy_num[2:0] 155 * 21:19 dcp_sel[2:0] 156 * 22 phy_type 157 * 23 frame_cap_ind 158 * 26:24 aux_chan[2:0] 159 * 30:27 aux_repeat[3:0] 160 * 31:31 reserved[31:31] 161 ******************************************************************/ 162 union dce_dmcu_psr_config_data_reg1 { 163 struct { 164 unsigned int timehyst_frames:8; /*[7:0]*/ 165 unsigned int hyst_lines:7; /*[14:8]*/ 166 unsigned int rfb_update_auto_en:1; /*[15:15]*/ 167 unsigned int dp_port_num:3; /*[18:16]*/ 168 unsigned int dcp_sel:3; /*[21:19]*/ 169 unsigned int phy_type:1; /*[22:22]*/ 170 unsigned int frame_cap_ind:1; /*[23:23]*/ 171 unsigned int aux_chan:3; /*[26:24]*/ 172 unsigned int aux_repeat:4; /*[30:27]*/ 173 unsigned int reserved:1; /*[31:31]*/ 174 } bits; 175 unsigned int u32All; 176 }; 177 178 /******************************************************************* 179 * MASTER_COMM_DATA_REG2 180 *******************************************************************/ 181 union dce_dmcu_psr_config_data_reg2 { 182 struct { 183 unsigned int dig_fe:3; /*[2:0]*/ 184 unsigned int dig_be:3; /*[5:3]*/ 185 unsigned int skip_wait_for_pll_lock:1; /*[6:6]*/ 186 unsigned int reserved:9; /*[15:7]*/ 187 unsigned int frame_delay:8; /*[23:16]*/ 188 unsigned int smu_phy_id:4; /*[27:24]*/ 189 unsigned int num_of_controllers:4; /*[31:28]*/ 190 } bits; 191 unsigned int u32All; 192 }; 193 194 /******************************************************************* 195 * MASTER_COMM_DATA_REG3 196 *******************************************************************/ 197 union dce_dmcu_psr_config_data_reg3 { 198 struct { 199 unsigned int psr_level:16; /*[15:0]*/ 200 unsigned int link_rate:4; /*[19:16]*/ 201 unsigned int reserved:12; /*[31:20]*/ 202 } bits; 203 unsigned int u32All; 204 }; 205 206 union dce_dmcu_psr_config_data_wait_loop_reg1 { 207 struct { 208 unsigned int wait_loop:16; /* [15:0] */ 209 unsigned int reserved:16; /* [31:16] */ 210 } bits; 211 unsigned int u32; 212 }; 213 214 struct dmcu *dce_dmcu_create( 215 struct dc_context *ctx, 216 const struct dce_dmcu_registers *regs, 217 const struct dce_dmcu_shift *dmcu_shift, 218 const struct dce_dmcu_mask *dmcu_mask); 219 220 struct dmcu *dcn10_dmcu_create( 221 struct dc_context *ctx, 222 const struct dce_dmcu_registers *regs, 223 const struct dce_dmcu_shift *dmcu_shift, 224 const struct dce_dmcu_mask *dmcu_mask); 225 226 void dce_dmcu_destroy(struct dmcu **dmcu); 227 228 #endif /* _DCE_ABM_H_ */ 229