1*18b4f1a0SMichael Strauss /*
2*18b4f1a0SMichael Strauss  * Copyright 2019 Advanced Micro Devices, Inc.
3*18b4f1a0SMichael Strauss  *
4*18b4f1a0SMichael Strauss  * Permission is hereby granted, free of charge, to any person obtaining a
5*18b4f1a0SMichael Strauss  * copy of this software and associated documentation files (the "Software"),
6*18b4f1a0SMichael Strauss  * to deal in the Software without restriction, including without limitation
7*18b4f1a0SMichael Strauss  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*18b4f1a0SMichael Strauss  * and/or sell copies of the Software, and to permit persons to whom the
9*18b4f1a0SMichael Strauss  * Software is furnished to do so, subject to the following conditions:
10*18b4f1a0SMichael Strauss  *
11*18b4f1a0SMichael Strauss  * The above copyright notice and this permission notice shall be included in
12*18b4f1a0SMichael Strauss  * all copies or substantial portions of the Software.
13*18b4f1a0SMichael Strauss  *
14*18b4f1a0SMichael Strauss  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*18b4f1a0SMichael Strauss  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*18b4f1a0SMichael Strauss  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*18b4f1a0SMichael Strauss  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*18b4f1a0SMichael Strauss  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*18b4f1a0SMichael Strauss  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*18b4f1a0SMichael Strauss  * OTHER DEALINGS IN THE SOFTWARE.
21*18b4f1a0SMichael Strauss  *
22*18b4f1a0SMichael Strauss  * Authors: AMD
23*18b4f1a0SMichael Strauss  *
24*18b4f1a0SMichael Strauss  */
25*18b4f1a0SMichael Strauss 
26*18b4f1a0SMichael Strauss #ifndef __DAL_DCN31_VPG_H__
27*18b4f1a0SMichael Strauss #define __DAL_DCN31_VPG_H__
28*18b4f1a0SMichael Strauss 
29*18b4f1a0SMichael Strauss 
30*18b4f1a0SMichael Strauss #define DCN31_VPG_FROM_VPG(vpg)\
31*18b4f1a0SMichael Strauss 	container_of(vpg, struct dcn31_vpg, base)
32*18b4f1a0SMichael Strauss 
33*18b4f1a0SMichael Strauss #define VPG_DCN31_REG_LIST(id) \
34*18b4f1a0SMichael Strauss 	SRI(VPG_GENERIC_STATUS, VPG, id), \
35*18b4f1a0SMichael Strauss 	SRI(VPG_GENERIC_PACKET_ACCESS_CTRL, VPG, id), \
36*18b4f1a0SMichael Strauss 	SRI(VPG_GENERIC_PACKET_DATA, VPG, id), \
37*18b4f1a0SMichael Strauss 	SRI(VPG_GSP_FRAME_UPDATE_CTRL, VPG, id), \
38*18b4f1a0SMichael Strauss 	SRI(VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG, id), \
39*18b4f1a0SMichael Strauss 	SRI(VPG_MEM_PWR, VPG, id)
40*18b4f1a0SMichael Strauss 
41*18b4f1a0SMichael Strauss struct dcn31_vpg_registers {
42*18b4f1a0SMichael Strauss 	uint32_t VPG_GENERIC_STATUS;
43*18b4f1a0SMichael Strauss 	uint32_t VPG_GENERIC_PACKET_ACCESS_CTRL;
44*18b4f1a0SMichael Strauss 	uint32_t VPG_GENERIC_PACKET_DATA;
45*18b4f1a0SMichael Strauss 	uint32_t VPG_GSP_FRAME_UPDATE_CTRL;
46*18b4f1a0SMichael Strauss 	uint32_t VPG_GSP_IMMEDIATE_UPDATE_CTRL;
47*18b4f1a0SMichael Strauss 	uint32_t VPG_MEM_PWR;
48*18b4f1a0SMichael Strauss };
49*18b4f1a0SMichael Strauss 
50*18b4f1a0SMichael Strauss #define DCN31_VPG_MASK_SH_LIST(mask_sh)\
51*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_STATUS, VPG_GENERIC_CONFLICT_OCCURED, mask_sh),\
52*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_STATUS, VPG_GENERIC_CONFLICT_CLR, mask_sh),\
53*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_PACKET_ACCESS_CTRL, VPG_GENERIC_DATA_INDEX, mask_sh),\
54*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_PACKET_DATA, VPG_GENERIC_DATA_BYTE0, mask_sh),\
55*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_PACKET_DATA, VPG_GENERIC_DATA_BYTE1, mask_sh),\
56*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_PACKET_DATA, VPG_GENERIC_DATA_BYTE2, mask_sh),\
57*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GENERIC_PACKET_DATA, VPG_GENERIC_DATA_BYTE3, mask_sh),\
58*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC0_FRAME_UPDATE, mask_sh),\
59*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC1_FRAME_UPDATE, mask_sh),\
60*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC2_FRAME_UPDATE, mask_sh),\
61*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC3_FRAME_UPDATE, mask_sh),\
62*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC4_FRAME_UPDATE, mask_sh),\
63*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC5_FRAME_UPDATE, mask_sh),\
64*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC6_FRAME_UPDATE, mask_sh),\
65*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC7_FRAME_UPDATE, mask_sh),\
66*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC8_FRAME_UPDATE, mask_sh),\
67*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC9_FRAME_UPDATE, mask_sh),\
68*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC10_FRAME_UPDATE, mask_sh),\
69*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC11_FRAME_UPDATE, mask_sh),\
70*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC12_FRAME_UPDATE, mask_sh),\
71*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC13_FRAME_UPDATE, mask_sh),\
72*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_FRAME_UPDATE_CTRL, VPG_GENERIC14_FRAME_UPDATE, mask_sh),\
73*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC0_IMMEDIATE_UPDATE, mask_sh),\
74*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC1_IMMEDIATE_UPDATE, mask_sh),\
75*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC2_IMMEDIATE_UPDATE, mask_sh),\
76*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC3_IMMEDIATE_UPDATE, mask_sh),\
77*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC4_IMMEDIATE_UPDATE, mask_sh),\
78*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC5_IMMEDIATE_UPDATE, mask_sh),\
79*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC6_IMMEDIATE_UPDATE, mask_sh),\
80*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC7_IMMEDIATE_UPDATE, mask_sh),\
81*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC8_IMMEDIATE_UPDATE, mask_sh),\
82*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC9_IMMEDIATE_UPDATE, mask_sh),\
83*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC10_IMMEDIATE_UPDATE, mask_sh),\
84*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC11_IMMEDIATE_UPDATE, mask_sh),\
85*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC12_IMMEDIATE_UPDATE, mask_sh),\
86*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC13_IMMEDIATE_UPDATE, mask_sh),\
87*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_GSP_IMMEDIATE_UPDATE_CTRL, VPG_GENERIC14_IMMEDIATE_UPDATE, mask_sh),\
88*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_MEM_PWR, VPG_GSP_MEM_LIGHT_SLEEP_DIS, mask_sh),\
89*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_MEM_PWR, VPG_GSP_LIGHT_SLEEP_FORCE, mask_sh),\
90*18b4f1a0SMichael Strauss 	SE_SF(VPG0_VPG_MEM_PWR, VPG_GSP_MEM_PWR_STATE, mask_sh)
91*18b4f1a0SMichael Strauss 
92*18b4f1a0SMichael Strauss #define VPG_DCN31_REG_FIELD_LIST(type) \
93*18b4f1a0SMichael Strauss 	type VPG_GENERIC_CONFLICT_OCCURED;\
94*18b4f1a0SMichael Strauss 	type VPG_GENERIC_CONFLICT_CLR;\
95*18b4f1a0SMichael Strauss 	type VPG_GENERIC_DATA_INDEX;\
96*18b4f1a0SMichael Strauss 	type VPG_GENERIC_DATA_BYTE0;\
97*18b4f1a0SMichael Strauss 	type VPG_GENERIC_DATA_BYTE1;\
98*18b4f1a0SMichael Strauss 	type VPG_GENERIC_DATA_BYTE2;\
99*18b4f1a0SMichael Strauss 	type VPG_GENERIC_DATA_BYTE3;\
100*18b4f1a0SMichael Strauss 	type VPG_GENERIC0_FRAME_UPDATE;\
101*18b4f1a0SMichael Strauss 	type VPG_GENERIC1_FRAME_UPDATE;\
102*18b4f1a0SMichael Strauss 	type VPG_GENERIC2_FRAME_UPDATE;\
103*18b4f1a0SMichael Strauss 	type VPG_GENERIC3_FRAME_UPDATE;\
104*18b4f1a0SMichael Strauss 	type VPG_GENERIC4_FRAME_UPDATE;\
105*18b4f1a0SMichael Strauss 	type VPG_GENERIC5_FRAME_UPDATE;\
106*18b4f1a0SMichael Strauss 	type VPG_GENERIC6_FRAME_UPDATE;\
107*18b4f1a0SMichael Strauss 	type VPG_GENERIC7_FRAME_UPDATE;\
108*18b4f1a0SMichael Strauss 	type VPG_GENERIC8_FRAME_UPDATE;\
109*18b4f1a0SMichael Strauss 	type VPG_GENERIC9_FRAME_UPDATE;\
110*18b4f1a0SMichael Strauss 	type VPG_GENERIC10_FRAME_UPDATE;\
111*18b4f1a0SMichael Strauss 	type VPG_GENERIC11_FRAME_UPDATE;\
112*18b4f1a0SMichael Strauss 	type VPG_GENERIC12_FRAME_UPDATE;\
113*18b4f1a0SMichael Strauss 	type VPG_GENERIC13_FRAME_UPDATE;\
114*18b4f1a0SMichael Strauss 	type VPG_GENERIC14_FRAME_UPDATE;\
115*18b4f1a0SMichael Strauss 	type VPG_GENERIC0_IMMEDIATE_UPDATE;\
116*18b4f1a0SMichael Strauss 	type VPG_GENERIC1_IMMEDIATE_UPDATE;\
117*18b4f1a0SMichael Strauss 	type VPG_GENERIC2_IMMEDIATE_UPDATE;\
118*18b4f1a0SMichael Strauss 	type VPG_GENERIC3_IMMEDIATE_UPDATE;\
119*18b4f1a0SMichael Strauss 	type VPG_GENERIC4_IMMEDIATE_UPDATE;\
120*18b4f1a0SMichael Strauss 	type VPG_GENERIC5_IMMEDIATE_UPDATE;\
121*18b4f1a0SMichael Strauss 	type VPG_GENERIC6_IMMEDIATE_UPDATE;\
122*18b4f1a0SMichael Strauss 	type VPG_GENERIC7_IMMEDIATE_UPDATE;\
123*18b4f1a0SMichael Strauss 	type VPG_GENERIC8_IMMEDIATE_UPDATE;\
124*18b4f1a0SMichael Strauss 	type VPG_GENERIC9_IMMEDIATE_UPDATE;\
125*18b4f1a0SMichael Strauss 	type VPG_GENERIC10_IMMEDIATE_UPDATE;\
126*18b4f1a0SMichael Strauss 	type VPG_GENERIC11_IMMEDIATE_UPDATE;\
127*18b4f1a0SMichael Strauss 	type VPG_GENERIC12_IMMEDIATE_UPDATE;\
128*18b4f1a0SMichael Strauss 	type VPG_GENERIC13_IMMEDIATE_UPDATE;\
129*18b4f1a0SMichael Strauss 	type VPG_GENERIC14_IMMEDIATE_UPDATE;\
130*18b4f1a0SMichael Strauss 	type VPG_GSP_MEM_LIGHT_SLEEP_DIS;\
131*18b4f1a0SMichael Strauss 	type VPG_GSP_LIGHT_SLEEP_FORCE;\
132*18b4f1a0SMichael Strauss 	type VPG_GSP_MEM_PWR_STATE
133*18b4f1a0SMichael Strauss 
134*18b4f1a0SMichael Strauss struct dcn31_vpg_shift {
135*18b4f1a0SMichael Strauss 	VPG_DCN31_REG_FIELD_LIST(uint8_t);
136*18b4f1a0SMichael Strauss };
137*18b4f1a0SMichael Strauss 
138*18b4f1a0SMichael Strauss struct dcn31_vpg_mask {
139*18b4f1a0SMichael Strauss 	VPG_DCN31_REG_FIELD_LIST(uint32_t);
140*18b4f1a0SMichael Strauss };
141*18b4f1a0SMichael Strauss 
142*18b4f1a0SMichael Strauss struct dcn31_vpg {
143*18b4f1a0SMichael Strauss 	struct vpg base;
144*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_registers *regs;
145*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_shift *vpg_shift;
146*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_mask *vpg_mask;
147*18b4f1a0SMichael Strauss };
148*18b4f1a0SMichael Strauss 
149*18b4f1a0SMichael Strauss void vpg31_poweron(
150*18b4f1a0SMichael Strauss 		struct vpg *vpg);
151*18b4f1a0SMichael Strauss 
152*18b4f1a0SMichael Strauss void vpg31_powerdown(
153*18b4f1a0SMichael Strauss 		struct vpg *vpg);
154*18b4f1a0SMichael Strauss 
155*18b4f1a0SMichael Strauss void vpg31_construct(struct dcn31_vpg *vpg31,
156*18b4f1a0SMichael Strauss 	struct dc_context *ctx,
157*18b4f1a0SMichael Strauss 	uint32_t inst,
158*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_registers *vpg_regs,
159*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_shift *vpg_shift,
160*18b4f1a0SMichael Strauss 	const struct dcn31_vpg_mask *vpg_mask);
161*18b4f1a0SMichael Strauss 
162*18b4f1a0SMichael Strauss #endif
163