dce_dmcu.h 8.5 KB

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