1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "dc_bios_types.h"
28#include "dcn30_vpg.h"
29#include "reg_helper.h"
30
31#define DC_LOGGER \
32 vpg3->base.ctx->logger
33
34#define REG(reg)\
35 (vpg3->regs->reg)
36
37#undef FN
38#define FN(reg_name, field_name) \
39 vpg3->vpg_shift->field_name, vpg3->vpg_mask->field_name
40
41
42#define CTX \
43 vpg3->base.ctx
44
45
46static void vpg3_update_generic_info_packet(
47 struct vpg *vpg,
48 uint32_t packet_index,
49 const struct dc_info_packet *info_packet)
50{
51 struct dcn30_vpg *vpg3 = DCN30_VPG_FROM_VPG(vpg);
52 uint32_t i;
53
54
55
56
57 uint32_t max_retries = 50;
58
59 if (packet_index > 14)
60 ASSERT(0);
61
62
63
64
65
66
67
68
69
70
71 REG_WAIT(VPG_GENERIC_STATUS, VPG_GENERIC_CONFLICT_OCCURED,
72 0, 10, max_retries);
73
74
75
76
77
78 REG_UPDATE(VPG_GENERIC_STATUS, VPG_GENERIC_CONFLICT_CLR, 1);
79
80
81 REG_UPDATE(VPG_GENERIC_PACKET_ACCESS_CTRL,
82 VPG_GENERIC_DATA_INDEX, packet_index*9);
83
84
85
86
87 REG_SET_4(VPG_GENERIC_PACKET_DATA, 0,
88 VPG_GENERIC_DATA_BYTE0, info_packet->hb0,
89 VPG_GENERIC_DATA_BYTE1, info_packet->hb1,
90 VPG_GENERIC_DATA_BYTE2, info_packet->hb2,
91 VPG_GENERIC_DATA_BYTE3, info_packet->hb3);
92
93
94
95
96
97 {
98 const uint32_t *content =
99 (const uint32_t *) &info_packet->sb[0];
100
101 for (i = 0; i < 8; i++) {
102 REG_WRITE(VPG_GENERIC_PACKET_DATA, *content++);
103 }
104 }
105
106
107
108
109 switch (packet_index) {
110 case 0:
111 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
112 VPG_GENERIC0_IMMEDIATE_UPDATE, 1);
113 break;
114 case 1:
115 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
116 VPG_GENERIC1_IMMEDIATE_UPDATE, 1);
117 break;
118 case 2:
119 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
120 VPG_GENERIC2_IMMEDIATE_UPDATE, 1);
121 break;
122 case 3:
123 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
124 VPG_GENERIC3_IMMEDIATE_UPDATE, 1);
125 break;
126 case 4:
127 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
128 VPG_GENERIC4_IMMEDIATE_UPDATE, 1);
129 break;
130 case 5:
131 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
132 VPG_GENERIC5_IMMEDIATE_UPDATE, 1);
133 break;
134 case 6:
135 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
136 VPG_GENERIC6_IMMEDIATE_UPDATE, 1);
137 break;
138 case 7:
139 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
140 VPG_GENERIC7_IMMEDIATE_UPDATE, 1);
141 break;
142 case 8:
143 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
144 VPG_GENERIC8_IMMEDIATE_UPDATE, 1);
145 break;
146 case 9:
147 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
148 VPG_GENERIC9_IMMEDIATE_UPDATE, 1);
149 break;
150 case 10:
151 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
152 VPG_GENERIC10_IMMEDIATE_UPDATE, 1);
153 break;
154 case 11:
155 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
156 VPG_GENERIC11_IMMEDIATE_UPDATE, 1);
157 break;
158 case 12:
159 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
160 VPG_GENERIC12_IMMEDIATE_UPDATE, 1);
161 break;
162 case 13:
163 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
164 VPG_GENERIC13_IMMEDIATE_UPDATE, 1);
165 break;
166 case 14:
167 REG_UPDATE(VPG_GSP_IMMEDIATE_UPDATE_CTRL,
168 VPG_GENERIC14_IMMEDIATE_UPDATE, 1);
169 break;
170 default:
171 break;
172 }
173}
174
175static struct vpg_funcs dcn30_vpg_funcs = {
176 .update_generic_info_packet = vpg3_update_generic_info_packet,
177};
178
179void vpg3_construct(struct dcn30_vpg *vpg3,
180 struct dc_context *ctx,
181 uint32_t inst,
182 const struct dcn30_vpg_registers *vpg_regs,
183 const struct dcn30_vpg_shift *vpg_shift,
184 const struct dcn30_vpg_mask *vpg_mask)
185{
186 vpg3->base.ctx = ctx;
187
188 vpg3->base.inst = inst;
189 vpg3->base.funcs = &dcn30_vpg_funcs;
190
191 vpg3->regs = vpg_regs;
192 vpg3->vpg_shift = vpg_shift;
193 vpg3->vpg_mask = vpg_mask;
194}
195