dce_dmcu.h 7.5 KB

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