drm/amd/display: Split DMUB cmd type into type/subtype
[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 /*
40  * Command IDs should be treated as stable ABI.
41  * Do not reuse or modify IDs.
42  */
43
44 enum dmub_cmd_type {
45         DMUB_CMD__NULL = 0,
46         DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
47         DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
48         DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
49         DMUB_CMD__REG_REG_WAIT = 4,
50         DMUB_CMD__PSR = 64,
51         DMUB_CMD__VBIOS = 128,
52 };
53
54 #pragma pack(push, 1)
55
56 struct dmub_cmd_header {
57         unsigned int type : 8;
58         unsigned int sub_type : 8;
59         unsigned int reserved0 : 8;
60         unsigned int payload_bytes : 6;  /* up to 60 bytes */
61         unsigned int reserved1 : 2;
62 };
63
64 /*
65  * Read modify write
66  *
67  * 60 payload bytes can hold up to 5 sets of read modify writes,
68  * each take 3 dwords.
69  *
70  * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
71  *
72  * modify_mask = 0xffff'ffff means all fields are going to be updated.  in this case
73  * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
74  */
75 struct dmub_cmd_read_modify_write_sequence {
76         uint32_t addr;
77         uint32_t modify_mask;
78         uint32_t modify_value;
79 };
80
81 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX         5
82 struct dmub_rb_cmd_read_modify_write {
83         struct dmub_cmd_header header;  // type = DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE
84         struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
85 };
86
87 /*
88  * Update a register with specified masks and values sequeunce
89  *
90  * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
91  *
92  * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
93  *
94  *
95  * USE CASE:
96  *   1. auto-increment register where additional read would update pointer and produce wrong result
97  *   2. toggle a bit without read in the middle
98  */
99
100 struct dmub_cmd_reg_field_update_sequence {
101         uint32_t modify_mask;  // 0xffff'ffff to skip initial read
102         uint32_t modify_value;
103 };
104
105 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX          7
106
107 struct dmub_rb_cmd_reg_field_update_sequence {
108         struct dmub_cmd_header header;
109         uint32_t addr;
110         struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
111 };
112
113
114 /*
115  * Burst write
116  *
117  * support use case such as writing out LUTs.
118  *
119  * 60 payload bytes can hold up to 14 values to write to given address
120  *
121  * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
122  */
123 #define DMUB_BURST_WRITE_VALUES__MAX  14
124 struct dmub_rb_cmd_burst_write {
125         struct dmub_cmd_header header;  // type = DMUB_CMD__REG_SEQ_BURST_WRITE
126         uint32_t addr;
127         uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
128 };
129
130
131 struct dmub_rb_cmd_common {
132         struct dmub_cmd_header header;
133         uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
134 };
135
136 struct dmub_cmd_reg_wait_data {
137         uint32_t addr;
138         uint32_t mask;
139         uint32_t condition_field_value;
140         uint32_t time_out_us;
141 };
142
143 struct dmub_rb_cmd_reg_wait {
144         struct dmub_cmd_header header;
145         struct dmub_cmd_reg_wait_data reg_wait;
146 };
147
148 struct dmub_cmd_digx_encoder_control_data {
149         union dig_encoder_control_parameters_v1_5 dig;
150 };
151
152 struct dmub_rb_cmd_digx_encoder_control {
153         struct dmub_cmd_header header;
154         struct dmub_cmd_digx_encoder_control_data encoder_control;
155 };
156
157 struct dmub_cmd_set_pixel_clock_data {
158         struct set_pixel_clock_parameter_v1_7 clk;
159 };
160
161 struct dmub_rb_cmd_set_pixel_clock {
162         struct dmub_cmd_header header;
163         struct dmub_cmd_set_pixel_clock_data pixel_clock;
164 };
165
166 struct dmub_cmd_enable_disp_power_gating_data {
167         struct enable_disp_power_gating_parameters_v2_1 pwr;
168 };
169
170 struct dmub_rb_cmd_enable_disp_power_gating {
171         struct dmub_cmd_header header;
172         struct dmub_cmd_enable_disp_power_gating_data power_gating;
173 };
174
175 struct dmub_cmd_dig1_transmitter_control_data {
176         struct dig_transmitter_control_parameters_v1_6 dig;
177 };
178
179 struct dmub_rb_cmd_dig1_transmitter_control {
180         struct dmub_cmd_header header;
181         struct dmub_cmd_dig1_transmitter_control_data transmitter_control;
182 };
183
184 struct dmub_rb_cmd_dpphy_init {
185         struct dmub_cmd_header header;
186         uint8_t reserved[60];
187 };
188
189 struct dmub_cmd_psr_copy_settings_data {
190         uint32_t reg1;
191         uint32_t reg2;
192         uint32_t reg3;
193 };
194
195 struct dmub_rb_cmd_psr_copy_settings {
196         struct dmub_cmd_header header;
197         struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
198 };
199
200 struct dmub_cmd_psr_set_level_data {
201         uint16_t psr_level;
202 };
203
204 struct dmub_rb_cmd_psr_set_level {
205         struct dmub_cmd_header header;
206         struct dmub_cmd_psr_set_level_data psr_set_level_data;
207 };
208
209 struct dmub_rb_cmd_psr_disable {
210         struct dmub_cmd_header header;
211 };
212
213 struct dmub_rb_cmd_psr_enable {
214         struct dmub_cmd_header header;
215 };
216
217 struct dmub_cmd_psr_notify_vblank_data {
218         uint32_t vblank_int; // Which vblank interrupt was triggered
219 };
220
221 struct dmub_rb_cmd_notify_vblank {
222         struct dmub_cmd_header header;
223         struct dmub_cmd_psr_notify_vblank_data psr_notify_vblank_data;
224 };
225
226 struct dmub_cmd_psr_notify_static_state_data {
227         uint32_t ss_int;   // Which static screen interrupt was triggered
228         uint32_t ss_enter; // Enter (1) or exit (0) static screen
229 };
230
231 struct dmub_rb_cmd_psr_notify_static_state {
232         struct dmub_cmd_header header;
233         struct dmub_cmd_psr_notify_static_state_data psr_notify_static_state_data;
234 };
235
236 union dmub_rb_cmd {
237         struct dmub_rb_cmd_read_modify_write read_modify_write;
238         struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
239         struct dmub_rb_cmd_burst_write burst_write;
240         struct dmub_rb_cmd_reg_wait reg_wait;
241         struct dmub_rb_cmd_common cmd_common;
242         struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
243         struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
244         struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
245         struct dmub_rb_cmd_dpphy_init dpphy_init;
246         struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
247         struct dmub_rb_cmd_psr_enable psr_enable;
248         struct dmub_rb_cmd_psr_disable psr_disable;
249         struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
250         struct dmub_rb_cmd_psr_set_level psr_set_level;
251 };
252
253 #pragma pack(pop)
254
255 #endif /* _DMUB_CMD_H_ */