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