drm/amd/display: FW release 1.0.10
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dmub / inc / dmub_cmd.h
1 /*
2  * Copyright 2019 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
26 #ifndef _DMUB_CMD_H_
27 #define _DMUB_CMD_H_
28
29 #include "dmub_types.h"
30 #include "dmub_cmd_dal.h"
31 #include "dmub_cmd_vbios.h"
32 #include "atomfirmware.h"
33
34 #define DMUB_RB_CMD_SIZE 64
35 #define DMUB_RB_MAX_ENTRY 128
36 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)
37 #define REG_SET_MASK 0xFFFF
38
39 #define SET_ABM_PIPE_GRADUALLY_DISABLE           0
40 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE         255
41 #define SET_ABM_PIPE_NORMAL                      1
42
43 /*
44  * Command IDs should be treated as stable ABI.
45  * Do not reuse or modify IDs.
46  */
47
48 enum dmub_cmd_type {
49         DMUB_CMD__NULL = 0,
50         DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
51         DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
52         DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
53         DMUB_CMD__REG_REG_WAIT = 4,
54         DMUB_CMD__PLAT_54186_WA = 5,
55         DMUB_CMD__PSR = 64,
56         DMUB_CMD__ABM = 66,
57         DMUB_CMD__VBIOS = 128,
58 };
59
60 #pragma pack(push, 1)
61
62 struct dmub_cmd_header {
63         unsigned int type : 8;
64         unsigned int sub_type : 8;
65         unsigned int reserved0 : 8;
66         unsigned int payload_bytes : 6;  /* up to 60 bytes */
67         unsigned int reserved1 : 2;
68 };
69
70 /*
71  * Read modify write
72  *
73  * 60 payload bytes can hold up to 5 sets of read modify writes,
74  * each take 3 dwords.
75  *
76  * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
77  *
78  * modify_mask = 0xffff'ffff means all fields are going to be updated.  in this case
79  * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
80  */
81 struct dmub_cmd_read_modify_write_sequence {
82         uint32_t addr;
83         uint32_t modify_mask;
84         uint32_t modify_value;
85 };
86
87 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX         5
88 struct dmub_rb_cmd_read_modify_write {
89         struct dmub_cmd_header header;  // type = DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE
90         struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
91 };
92
93 /*
94  * Update a register with specified masks and values sequeunce
95  *
96  * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
97  *
98  * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
99  *
100  *
101  * USE CASE:
102  *   1. auto-increment register where additional read would update pointer and produce wrong result
103  *   2. toggle a bit without read in the middle
104  */
105
106 struct dmub_cmd_reg_field_update_sequence {
107         uint32_t modify_mask;  // 0xffff'ffff to skip initial read
108         uint32_t modify_value;
109 };
110
111 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX          7
112
113 struct dmub_rb_cmd_reg_field_update_sequence {
114         struct dmub_cmd_header header;
115         uint32_t addr;
116         struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
117 };
118
119
120 /*
121  * Burst write
122  *
123  * support use case such as writing out LUTs.
124  *
125  * 60 payload bytes can hold up to 14 values to write to given address
126  *
127  * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
128  */
129 #define DMUB_BURST_WRITE_VALUES__MAX  14
130 struct dmub_rb_cmd_burst_write {
131         struct dmub_cmd_header header;  // type = DMUB_CMD__REG_SEQ_BURST_WRITE
132         uint32_t addr;
133         uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
134 };
135
136
137 struct dmub_rb_cmd_common {
138         struct dmub_cmd_header header;
139         uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
140 };
141
142 struct dmub_cmd_reg_wait_data {
143         uint32_t addr;
144         uint32_t mask;
145         uint32_t condition_field_value;
146         uint32_t time_out_us;
147 };
148
149 struct dmub_rb_cmd_reg_wait {
150         struct dmub_cmd_header header;
151         struct dmub_cmd_reg_wait_data reg_wait;
152 };
153
154 #ifndef PHYSICAL_ADDRESS_LOC
155 #define PHYSICAL_ADDRESS_LOC union large_integer
156 #endif
157
158 struct dmub_cmd_PLAT_54186_wa {
159         uint32_t DCSURF_SURFACE_CONTROL;
160         uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH;
161         uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS;
162         uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C;
163         uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C;
164         struct {
165                 uint8_t hubp_inst : 4;
166                 uint8_t tmz_surface : 1;
167                 uint8_t immediate :1;
168                 uint8_t vmid : 4;
169                 uint8_t grph_stereo : 1;
170                 uint32_t reserved : 21;
171         } flip_params;
172         uint32_t reserved[9];
173 };
174
175 struct dmub_rb_cmd_PLAT_54186_wa {
176         struct dmub_cmd_header header;
177         struct dmub_cmd_PLAT_54186_wa flip;
178 };
179
180 struct dmub_cmd_digx_encoder_control_data {
181         union dig_encoder_control_parameters_v1_5 dig;
182 };
183
184 struct dmub_rb_cmd_digx_encoder_control {
185         struct dmub_cmd_header header;
186         struct dmub_cmd_digx_encoder_control_data encoder_control;
187 };
188
189 struct dmub_cmd_set_pixel_clock_data {
190         struct set_pixel_clock_parameter_v1_7 clk;
191 };
192
193 struct dmub_rb_cmd_set_pixel_clock {
194         struct dmub_cmd_header header;
195         struct dmub_cmd_set_pixel_clock_data pixel_clock;
196 };
197
198 struct dmub_cmd_enable_disp_power_gating_data {
199         struct enable_disp_power_gating_parameters_v2_1 pwr;
200 };
201
202 struct dmub_rb_cmd_enable_disp_power_gating {
203         struct dmub_cmd_header header;
204         struct dmub_cmd_enable_disp_power_gating_data power_gating;
205 };
206
207 struct dmub_cmd_dig1_transmitter_control_data {
208         struct dig_transmitter_control_parameters_v1_6 dig;
209 };
210
211 struct dmub_rb_cmd_dig1_transmitter_control {
212         struct dmub_cmd_header header;
213         struct dmub_cmd_dig1_transmitter_control_data transmitter_control;
214 };
215
216 struct dmub_rb_cmd_dpphy_init {
217         struct dmub_cmd_header header;
218         uint8_t reserved[60];
219 };
220
221 struct dmub_cmd_psr_copy_settings_data {
222         union dmub_psr_debug_flags debug;
223         uint16_t psr_level;
224         uint8_t dpp_inst;
225         uint8_t mpcc_inst;
226         uint8_t opp_inst;
227         uint8_t otg_inst;
228         uint8_t digfe_inst;
229         uint8_t digbe_inst;
230         uint8_t dpphy_inst;
231         uint8_t aux_inst;
232         uint8_t smu_optimizations_en;
233         uint8_t frame_delay;
234         uint8_t frame_cap_ind;
235         uint8_t pad[3];
236 };
237
238 struct dmub_rb_cmd_psr_copy_settings {
239         struct dmub_cmd_header header;
240         struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
241 };
242
243 struct dmub_cmd_psr_set_level_data {
244         uint16_t psr_level;
245         uint8_t pad[2];
246 };
247
248 struct dmub_rb_cmd_psr_set_level {
249         struct dmub_cmd_header header;
250         struct dmub_cmd_psr_set_level_data psr_set_level_data;
251 };
252
253 struct dmub_rb_cmd_psr_enable {
254         struct dmub_cmd_header header;
255 };
256
257 struct dmub_cmd_psr_set_version_data {
258         enum psr_version version; // PSR version 1 or 2
259 };
260
261 struct dmub_rb_cmd_psr_set_version {
262         struct dmub_cmd_header header;
263         struct dmub_cmd_psr_set_version_data psr_set_version_data;
264 };
265
266 struct dmub_cmd_abm_set_pipe_data {
267         uint8_t otg_inst;
268         uint8_t panel_inst;
269         uint8_t set_pipe_option;
270         uint8_t ramping_boundary; // TODO: Remove this
271 };
272
273 struct dmub_rb_cmd_abm_set_pipe {
274         struct dmub_cmd_header header;
275         struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data;
276 };
277
278 struct dmub_cmd_abm_set_backlight_data {
279         uint32_t frame_ramp;
280         uint32_t backlight_user_level;
281 };
282
283 struct dmub_rb_cmd_abm_set_backlight {
284         struct dmub_cmd_header header;
285         struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data;
286 };
287
288 struct dmub_cmd_abm_set_level_data {
289         uint32_t level;
290 };
291
292 struct dmub_rb_cmd_abm_set_level {
293         struct dmub_cmd_header header;
294         struct dmub_cmd_abm_set_level_data abm_set_level_data;
295 };
296
297 struct dmub_cmd_abm_set_ambient_level_data {
298         uint32_t ambient_lux;
299 };
300
301 struct dmub_rb_cmd_abm_set_ambient_level {
302         struct dmub_cmd_header header;
303         struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data;
304 };
305
306 struct dmub_cmd_abm_set_pwm_frac_data {
307         uint32_t fractional_pwm;
308 };
309
310 struct dmub_rb_cmd_abm_set_pwm_frac {
311         struct dmub_cmd_header header;
312         struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data;
313 };
314
315 struct dmub_cmd_abm_init_config_data {
316         union dmub_addr src;
317         uint16_t bytes;
318 };
319
320 struct dmub_rb_cmd_abm_init_config {
321         struct dmub_cmd_header header;
322         struct dmub_cmd_abm_init_config_data abm_init_config_data;
323 };
324
325 union dmub_rb_cmd {
326         struct dmub_rb_cmd_read_modify_write read_modify_write;
327         struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
328         struct dmub_rb_cmd_burst_write burst_write;
329         struct dmub_rb_cmd_reg_wait reg_wait;
330         struct dmub_rb_cmd_common cmd_common;
331         struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
332         struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
333         struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
334         struct dmub_rb_cmd_dpphy_init dpphy_init;
335         struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
336         struct dmub_rb_cmd_psr_set_version psr_set_version;
337         struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
338         struct dmub_rb_cmd_psr_enable psr_enable;
339         struct dmub_rb_cmd_psr_set_level psr_set_level;
340         struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa;
341         struct dmub_rb_cmd_abm_set_pipe abm_set_pipe;
342         struct dmub_rb_cmd_abm_set_backlight abm_set_backlight;
343         struct dmub_rb_cmd_abm_set_level abm_set_level;
344         struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level;
345         struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac;
346         struct dmub_rb_cmd_abm_init_config abm_init_config;
347 };
348
349 #pragma pack(pop)
350
351 #endif /* _DMUB_CMD_H_ */