1 // SPDX-License-Identifier: MIT
2 //
3 // Copyright 2024 Advanced Micro Devices, Inc.
4 
5 #ifndef __dml2_TOP_DCHUB_REGISTERS_H__
6 #define __dml2_TOP_DCHUB_REGISTERS_H__
7 
8 #include "dml2_external_lib_deps.h"
9 // These types are uint32_t as they represent actual calculated register values for HW
10 
11 struct dml2_display_dlg_regs {
12 	uint32_t refcyc_h_blank_end;
13 	uint32_t dlg_vblank_end;
14 	uint32_t min_dst_y_next_start;
15 	uint32_t refcyc_per_htotal;
16 	uint32_t refcyc_x_after_scaler;
17 	uint32_t dst_y_after_scaler;
18 	uint32_t dst_y_prefetch;
19 	uint32_t dst_y_per_vm_vblank;
20 	uint32_t dst_y_per_row_vblank;
21 	uint32_t dst_y_per_vm_flip;
22 	uint32_t dst_y_per_row_flip;
23 	uint32_t ref_freq_to_pix_freq;
24 	uint32_t vratio_prefetch;
25 	uint32_t vratio_prefetch_c;
26 	uint32_t refcyc_per_tdlut_group;
27 	uint32_t refcyc_per_pte_group_vblank_l;
28 	uint32_t refcyc_per_pte_group_vblank_c;
29 	uint32_t refcyc_per_pte_group_flip_l;
30 	uint32_t refcyc_per_pte_group_flip_c;
31 	uint32_t dst_y_per_pte_row_nom_l;
32 	uint32_t dst_y_per_pte_row_nom_c;
33 	uint32_t refcyc_per_pte_group_nom_l;
34 	uint32_t refcyc_per_pte_group_nom_c;
35 	uint32_t refcyc_per_line_delivery_pre_l;
36 	uint32_t refcyc_per_line_delivery_pre_c;
37 	uint32_t refcyc_per_line_delivery_l;
38 	uint32_t refcyc_per_line_delivery_c;
39 	uint32_t refcyc_per_vm_group_vblank;
40 	uint32_t refcyc_per_vm_group_flip;
41 	uint32_t refcyc_per_vm_req_vblank;
42 	uint32_t refcyc_per_vm_req_flip;
43 	uint32_t dst_y_offset_cur0;
44 	uint32_t chunk_hdl_adjust_cur0;
45 	uint32_t vready_after_vcount0;
46 	uint32_t dst_y_delta_drq_limit;
47 	uint32_t refcyc_per_vm_dmdata;
48 	uint32_t dmdata_dl_delta;
49 
50 	// MRQ
51 	uint32_t refcyc_per_meta_chunk_vblank_l;
52 	uint32_t refcyc_per_meta_chunk_vblank_c;
53 	uint32_t refcyc_per_meta_chunk_flip_l;
54 	uint32_t refcyc_per_meta_chunk_flip_c;
55 	uint32_t dst_y_per_meta_row_nom_l;
56 	uint32_t dst_y_per_meta_row_nom_c;
57 	uint32_t refcyc_per_meta_chunk_nom_l;
58 	uint32_t refcyc_per_meta_chunk_nom_c;
59 };
60 
61 struct dml2_display_ttu_regs {
62 	uint32_t qos_level_low_wm;
63 	uint32_t qos_level_high_wm;
64 	uint32_t min_ttu_vblank;
65 	uint32_t qos_level_flip;
66 	uint32_t refcyc_per_req_delivery_l;
67 	uint32_t refcyc_per_req_delivery_c;
68 	uint32_t refcyc_per_req_delivery_cur0;
69 	uint32_t refcyc_per_req_delivery_pre_l;
70 	uint32_t refcyc_per_req_delivery_pre_c;
71 	uint32_t refcyc_per_req_delivery_pre_cur0;
72 	uint32_t qos_level_fixed_l;
73 	uint32_t qos_level_fixed_c;
74 	uint32_t qos_level_fixed_cur0;
75 	uint32_t qos_ramp_disable_l;
76 	uint32_t qos_ramp_disable_c;
77 	uint32_t qos_ramp_disable_cur0;
78 };
79 
80 struct dml2_display_arb_regs {
81 	uint32_t max_req_outstanding;
82 	uint32_t min_req_outstanding;
83 	uint32_t sat_level_us;
84 	uint32_t hvm_max_qos_commit_threshold;
85 	uint32_t hvm_min_req_outstand_commit_threshold;
86 	uint32_t compbuf_reserved_space_kbytes;
87 	uint32_t compbuf_size;
88 	uint32_t sdpif_request_rate_limit;
89 	uint32_t allow_sdpif_rate_limit_when_cstate_req;
90 	uint32_t dcfclk_deep_sleep_hysteresis;
91 };
92 
93 struct dml2_cursor_dlg_regs{
94 	uint32_t dst_x_offset;			   // CURSOR0_DST_X_OFFSET
95 	uint32_t dst_y_offset;			   // CURSOR0_DST_Y_OFFSET
96 	uint32_t chunk_hdl_adjust;		   // CURSOR0_CHUNK_HDL_ADJUST
97 
98 	uint32_t qos_level_fixed;
99 	uint32_t qos_ramp_disable;
100 };
101 
102 struct dml2_display_plane_rq_regs {
103 	uint32_t chunk_size;
104 	uint32_t min_chunk_size;
105 	uint32_t dpte_group_size;
106 	uint32_t mpte_group_size;
107 	uint32_t swath_height;
108 	uint32_t pte_row_height_linear;
109 
110 	// MRQ
111 	uint32_t meta_chunk_size;
112 	uint32_t min_meta_chunk_size;
113 };
114 
115 struct dml2_display_rq_regs {
116 	struct dml2_display_plane_rq_regs rq_regs_l;
117 	struct dml2_display_plane_rq_regs rq_regs_c;
118 	uint32_t drq_expansion_mode;
119 	uint32_t prq_expansion_mode;
120 	uint32_t crq_expansion_mode;
121 	uint32_t plane1_base_address;
122 	uint32_t unbounded_request_enabled;
123 
124 	// MRQ
125 	uint32_t mrq_expansion_mode;
126 };
127 
128 struct dml2_display_mcache_regs {
129 	uint32_t mcache_id_first;
130 	uint32_t mcache_id_second;
131 	uint32_t split_location;
132 };
133 
134 struct dml2_hubp_pipe_mcache_regs {
135 	struct {
136 		struct dml2_display_mcache_regs p0;
137 		struct dml2_display_mcache_regs p1;
138 	} main;
139 	struct {
140 		struct dml2_display_mcache_regs p0;
141 		struct dml2_display_mcache_regs p1;
142 	} mall;
143 };
144 
145 struct dml2_dchub_per_pipe_register_set {
146 	struct dml2_display_rq_regs rq_regs;
147 	struct dml2_display_ttu_regs ttu_regs;
148 	struct dml2_display_dlg_regs dlg_regs;
149 
150 	uint32_t det_size;
151 };
152 
153 struct dml2_dchub_watermark_regs {
154 	/* watermarks */
155 	uint32_t urgent;
156 	uint32_t sr_enter;
157 	uint32_t sr_exit;
158 	uint32_t uclk_pstate;
159 	uint32_t fclk_pstate;
160 	uint32_t temp_read_or_ppt;
161 	uint32_t usr;
162 	/* qos */
163 	uint32_t refcyc_per_trip_to_mem;
164 	uint32_t refcyc_per_meta_trip_to_mem;
165 	uint32_t frac_urg_bw_flip;
166 	uint32_t frac_urg_bw_nom;
167 	uint32_t frac_urg_bw_mall;
168 };
169 
170 enum dml2_dchub_watermark_reg_set_index {
171 	DML2_DCHUB_WATERMARK_SET_A = 0,
172 	DML2_DCHUB_WATERMARK_SET_B = 1,
173 	DML2_DCHUB_WATERMARK_SET_C = 2,
174 	DML2_DCHUB_WATERMARK_SET_D = 3,
175 	DML2_DCHUB_WATERMARK_SET_NUM = 4,
176 };
177 
178 struct dml2_dchub_global_register_set {
179 	struct dml2_display_arb_regs arb_regs;
180 	struct dml2_dchub_watermark_regs wm_regs[DML2_DCHUB_WATERMARK_SET_NUM];
181 	unsigned int num_watermark_sets;
182 };
183 
184 #endif
185