xref: /openbsd-src/sys/dev/pci/drm/amd/display/dc/inc/hw/dchubbub.h (revision f005ef32267c16bdb134f0e9fa4477dbe07c263a)
1fb4d8502Sjsg /*
2fb4d8502Sjsg  * Copyright 2012-15 Advanced Micro Devices, Inc.
3fb4d8502Sjsg  *
4fb4d8502Sjsg  * Permission is hereby granted, free of charge, to any person obtaining a
5fb4d8502Sjsg  * copy of this software and associated documentation files (the "Software"),
6fb4d8502Sjsg  * to deal in the Software without restriction, including without limitation
7fb4d8502Sjsg  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8fb4d8502Sjsg  * and/or sell copies of the Software, and to permit persons to whom the
9fb4d8502Sjsg  * Software is furnished to do so, subject to the following conditions:
10fb4d8502Sjsg  *
11fb4d8502Sjsg  * The above copyright notice and this permission notice shall be included in
12fb4d8502Sjsg  * all copies or substantial portions of the Software.
13fb4d8502Sjsg  *
14fb4d8502Sjsg  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15fb4d8502Sjsg  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16fb4d8502Sjsg  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17fb4d8502Sjsg  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18fb4d8502Sjsg  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19fb4d8502Sjsg  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20fb4d8502Sjsg  * OTHER DEALINGS IN THE SOFTWARE.
21fb4d8502Sjsg  *
22fb4d8502Sjsg  * Authors: AMD
23fb4d8502Sjsg  *
24fb4d8502Sjsg  */
25fb4d8502Sjsg 
26fb4d8502Sjsg #ifndef __DAL_DCHUBBUB_H__
27fb4d8502Sjsg #define __DAL_DCHUBBUB_H__
28fb4d8502Sjsg 
29fb4d8502Sjsg 
30fb4d8502Sjsg enum dcc_control {
31fb4d8502Sjsg 	dcc_control__256_256_xxx,
32fb4d8502Sjsg 	dcc_control__128_128_xxx,
33fb4d8502Sjsg 	dcc_control__256_64_64,
34ad8b1aafSjsg 	dcc_control__256_128_128,
35fb4d8502Sjsg };
36fb4d8502Sjsg 
37fb4d8502Sjsg enum segment_order {
38fb4d8502Sjsg 	segment_order__na,
39fb4d8502Sjsg 	segment_order__contiguous,
40fb4d8502Sjsg 	segment_order__non_contiguous,
41fb4d8502Sjsg };
42fb4d8502Sjsg 
43c349dbc7Sjsg struct dcn_hubbub_wm_set {
44c349dbc7Sjsg 	uint32_t wm_set;
45c349dbc7Sjsg 	uint32_t data_urgent;
46c349dbc7Sjsg 	uint32_t pte_meta_urgent;
47c349dbc7Sjsg 	uint32_t sr_enter;
48c349dbc7Sjsg 	uint32_t sr_exit;
49*f005ef32Sjsg 	uint32_t dram_clk_change;
501bb76ff1Sjsg 	uint32_t usr_retrain;
511bb76ff1Sjsg 	uint32_t fclk_pstate_change;
52*f005ef32Sjsg 	uint32_t sr_enter_exit_Z8;
53*f005ef32Sjsg 	uint32_t sr_enter_Z8;
54c349dbc7Sjsg };
55c349dbc7Sjsg 
56c349dbc7Sjsg struct dcn_hubbub_wm {
57c349dbc7Sjsg 	struct dcn_hubbub_wm_set sets[4];
58c349dbc7Sjsg };
59c349dbc7Sjsg 
60c349dbc7Sjsg enum dcn_hubbub_page_table_depth {
61c349dbc7Sjsg 	DCN_PAGE_TABLE_DEPTH_1_LEVEL,
62c349dbc7Sjsg 	DCN_PAGE_TABLE_DEPTH_2_LEVEL,
63c349dbc7Sjsg 	DCN_PAGE_TABLE_DEPTH_3_LEVEL,
64c349dbc7Sjsg 	DCN_PAGE_TABLE_DEPTH_4_LEVEL
65c349dbc7Sjsg };
66c349dbc7Sjsg 
67c349dbc7Sjsg enum dcn_hubbub_page_table_block_size {
68c349dbc7Sjsg 	DCN_PAGE_TABLE_BLOCK_SIZE_4KB = 0,
69c349dbc7Sjsg 	DCN_PAGE_TABLE_BLOCK_SIZE_64KB = 4,
70ad8b1aafSjsg 	DCN_PAGE_TABLE_BLOCK_SIZE_32KB = 3
71c349dbc7Sjsg };
72c349dbc7Sjsg 
73c349dbc7Sjsg struct dcn_hubbub_phys_addr_config {
74c349dbc7Sjsg 	struct {
75c349dbc7Sjsg 		uint64_t fb_top;
76c349dbc7Sjsg 		uint64_t fb_offset;
77c349dbc7Sjsg 		uint64_t fb_base;
78c349dbc7Sjsg 		uint64_t agp_top;
79c349dbc7Sjsg 		uint64_t agp_bot;
80c349dbc7Sjsg 		uint64_t agp_base;
81c349dbc7Sjsg 	} system_aperture;
82c349dbc7Sjsg 
83c349dbc7Sjsg 	struct {
84c349dbc7Sjsg 		uint64_t page_table_start_addr;
85c349dbc7Sjsg 		uint64_t page_table_end_addr;
86c349dbc7Sjsg 		uint64_t page_table_base_addr;
87c349dbc7Sjsg 	} gart_config;
88c349dbc7Sjsg 
89c349dbc7Sjsg 	uint64_t page_table_default_page_addr;
90c349dbc7Sjsg };
91c349dbc7Sjsg 
92c349dbc7Sjsg struct dcn_hubbub_virt_addr_config {
93c349dbc7Sjsg 	uint64_t				page_table_start_addr;
94c349dbc7Sjsg 	uint64_t				page_table_end_addr;
95c349dbc7Sjsg 	enum dcn_hubbub_page_table_block_size	page_table_block_size;
96c349dbc7Sjsg 	enum dcn_hubbub_page_table_depth	page_table_depth;
97c349dbc7Sjsg 	uint64_t				page_table_base_addr;
98c349dbc7Sjsg };
99c349dbc7Sjsg 
100c349dbc7Sjsg struct hubbub_addr_config {
101c349dbc7Sjsg 	struct dcn_hubbub_phys_addr_config pa_config;
102c349dbc7Sjsg 	struct dcn_hubbub_virt_addr_config va_config;
103c349dbc7Sjsg 	struct {
104c349dbc7Sjsg 		uint64_t aperture_check_fault;
105c349dbc7Sjsg 		uint64_t generic_fault;
106c349dbc7Sjsg 	} default_addrs;
107c349dbc7Sjsg };
108fb4d8502Sjsg 
1095ca02815Sjsg struct dcn_hubbub_state {
1105ca02815Sjsg 	uint32_t vm_fault_addr_msb;
1115ca02815Sjsg 	uint32_t vm_fault_addr_lsb;
1125ca02815Sjsg 	uint32_t vm_error_status;
1135ca02815Sjsg 	uint32_t vm_error_vmid;
1145ca02815Sjsg 	uint32_t vm_error_pipe;
1155ca02815Sjsg 	uint32_t vm_error_mode;
116*f005ef32Sjsg 	uint32_t test_debug_data;
117*f005ef32Sjsg 	uint32_t watermark_change_cntl;
118*f005ef32Sjsg 	uint32_t dram_state_cntl;
1195ca02815Sjsg };
1205ca02815Sjsg 
121fb4d8502Sjsg struct hubbub_funcs {
122fb4d8502Sjsg 	void (*update_dchub)(
123fb4d8502Sjsg 			struct hubbub *hubbub,
124fb4d8502Sjsg 			struct dchub_init_data *dh_data);
125fb4d8502Sjsg 
126c349dbc7Sjsg 	int (*init_dchub_sys_ctx)(
127c349dbc7Sjsg 			struct hubbub *hubbub,
128c349dbc7Sjsg 			struct dcn_hubbub_phys_addr_config *pa_config);
129c349dbc7Sjsg 	void (*init_vm_ctx)(
130c349dbc7Sjsg 			struct hubbub *hubbub,
131c349dbc7Sjsg 			struct dcn_hubbub_virt_addr_config *va_config,
132c349dbc7Sjsg 			int vmid);
133c349dbc7Sjsg 
134fb4d8502Sjsg 	bool (*get_dcc_compression_cap)(struct hubbub *hubbub,
135fb4d8502Sjsg 			const struct dc_dcc_surface_param *input,
136fb4d8502Sjsg 			struct dc_surface_dcc_cap *output);
137fb4d8502Sjsg 
138fb4d8502Sjsg 	bool (*dcc_support_swizzle)(
139fb4d8502Sjsg 			enum swizzle_mode_values swizzle,
140fb4d8502Sjsg 			unsigned int bytes_per_element,
141fb4d8502Sjsg 			enum segment_order *segment_order_horz,
142fb4d8502Sjsg 			enum segment_order *segment_order_vert);
143fb4d8502Sjsg 
144fb4d8502Sjsg 	bool (*dcc_support_pixel_format)(
145fb4d8502Sjsg 			enum surface_pixel_format format,
146fb4d8502Sjsg 			unsigned int *bytes_per_element);
147c349dbc7Sjsg 
148c349dbc7Sjsg 	void (*wm_read_state)(struct hubbub *hubbub,
149c349dbc7Sjsg 			struct dcn_hubbub_wm *wm);
150c349dbc7Sjsg 
151c349dbc7Sjsg 	void (*get_dchub_ref_freq)(struct hubbub *hubbub,
152c349dbc7Sjsg 			unsigned int dccg_ref_freq_inKhz,
153c349dbc7Sjsg 			unsigned int *dchub_ref_freq_inKhz);
154c349dbc7Sjsg 
155c349dbc7Sjsg 	bool (*program_watermarks)(
156c349dbc7Sjsg 			struct hubbub *hubbub,
157c349dbc7Sjsg 			struct dcn_watermark_set *watermarks,
158c349dbc7Sjsg 			unsigned int refclk_mhz,
159c349dbc7Sjsg 			bool safe_to_lower);
160c349dbc7Sjsg 
161c349dbc7Sjsg 	bool (*is_allow_self_refresh_enabled)(struct hubbub *hubbub);
162c349dbc7Sjsg 	void (*allow_self_refresh_control)(struct hubbub *hubbub, bool allow);
163c349dbc7Sjsg 
164bb701e4eSjsg 	bool (*verify_allow_pstate_change_high)(struct hubbub *hubbub);
165bb701e4eSjsg 
166c349dbc7Sjsg 	void (*apply_DEDCN21_147_wa)(struct hubbub *hubbub);
167749fe90aSjsg 
168749fe90aSjsg 	void (*force_wm_propagate_to_pipes)(struct hubbub *hubbub);
1695ca02815Sjsg 
1705ca02815Sjsg 	void (*hubbub_read_state)(struct hubbub *hubbub, struct dcn_hubbub_state *hubbub_state);
1715ca02815Sjsg 
1725ca02815Sjsg 	void (*force_pstate_change_control)(struct hubbub *hubbub, bool force, bool allow);
1735ca02815Sjsg 
1745ca02815Sjsg 	void (*init_watermarks)(struct hubbub *hubbub);
175*f005ef32Sjsg 
176*f005ef32Sjsg 	/**
177*f005ef32Sjsg 	 * @program_det_size:
178*f005ef32Sjsg 	 *
179*f005ef32Sjsg 	 * DE-Tile buffers (DET) is a memory that is used to convert the tiled
180*f005ef32Sjsg 	 * data into linear, which the rest of the display can use to generate
181*f005ef32Sjsg 	 * the graphics output. One of the main features of this component is
182*f005ef32Sjsg 	 * that each pipe has a configurable DET buffer which means that when a
183*f005ef32Sjsg 	 * pipe is not enabled, the device can assign the memory to other
184*f005ef32Sjsg 	 * enabled pipes to try to be more efficient.
185*f005ef32Sjsg 	 *
186*f005ef32Sjsg 	 * DET logic is handled by dchubbub. Some ASICs provide a feature named
187*f005ef32Sjsg 	 * Configurable Return Buffer (CRB) segments which can be allocated to
188*f005ef32Sjsg 	 * compressed or detiled buffers.
189*f005ef32Sjsg 	 */
1905ca02815Sjsg 	void (*program_det_size)(struct hubbub *hubbub, int hubp_inst, unsigned det_buffer_size_in_kbyte);
1915ca02815Sjsg 	void (*program_compbuf_size)(struct hubbub *hubbub, unsigned compbuf_size_kb, bool safe_to_increase);
1925ca02815Sjsg 	void (*init_crb)(struct hubbub *hubbub);
1931bb76ff1Sjsg 	void (*force_usr_retraining_allow)(struct hubbub *hubbub, bool allow);
194*f005ef32Sjsg 	void (*set_request_limit)(struct hubbub *hubbub, int memory_channel_count, int words_per_channel);
195*f005ef32Sjsg 	void (*dchubbub_init)(struct hubbub *hubbub);
196fb4d8502Sjsg };
197fb4d8502Sjsg 
198c349dbc7Sjsg struct hubbub {
199c349dbc7Sjsg 	const struct hubbub_funcs *funcs;
200c349dbc7Sjsg 	struct dc_context *ctx;
2015ca02815Sjsg 	bool riommu_active;
202c349dbc7Sjsg };
203fb4d8502Sjsg 
204fb4d8502Sjsg #endif
205