1 /*
2 * Copyright 2020 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 #include "dm_services.h"
26 #include "dcn301_hubbub.h"
27 #include "reg_helper.h"
28 
29 #define REG(reg)\
30 	hubbub1->regs->reg
31 #define DC_LOGGER \
32 	hubbub1->base.ctx->logger
33 #define CTX \
34 	hubbub1->base.ctx
35 
36 #undef FN
37 #define FN(reg_name, field_name) \
38 	hubbub1->shifts->field_name, hubbub1->masks->field_name
39 
40 #define REG(reg)\
41 	hubbub1->regs->reg
42 
43 #define CTX \
44 	hubbub1->base.ctx
45 
46 #undef FN
47 #define FN(reg_name, field_name) \
48 	hubbub1->shifts->field_name, hubbub1->masks->field_name
49 
50 
51 static const struct hubbub_funcs hubbub301_funcs = {
52 	.update_dchub = hubbub2_update_dchub,
53 	.init_dchub_sys_ctx = hubbub21_init_dchub,
54 	.init_vm_ctx = hubbub2_init_vm_ctx,
55 	.dcc_support_swizzle = hubbub3_dcc_support_swizzle,
56 	.dcc_support_pixel_format = hubbub2_dcc_support_pixel_format,
57 	.get_dcc_compression_cap = hubbub3_get_dcc_compression_cap,
58 	.wm_read_state = hubbub21_wm_read_state,
59 	.get_dchub_ref_freq = hubbub2_get_dchub_ref_freq,
60 	.program_watermarks = hubbub3_program_watermarks,
61 	.allow_self_refresh_control = hubbub1_allow_self_refresh_control,
62 	.is_allow_self_refresh_enabled = hubbub1_is_allow_self_refresh_enabled,
63 	.force_wm_propagate_to_pipes = hubbub3_force_wm_propagate_to_pipes,
64 	.force_pstate_change_control = hubbub3_force_pstate_change_control,
65 	.hubbub_read_state = hubbub2_read_state,
66 };
67 
68 void hubbub301_construct(struct dcn20_hubbub *hubbub3,
69 	struct dc_context *ctx,
70 	const struct dcn_hubbub_registers *hubbub_regs,
71 	const struct dcn_hubbub_shift *hubbub_shift,
72 	const struct dcn_hubbub_mask *hubbub_mask)
73 {
74 	hubbub3->base.ctx = ctx;
75 	hubbub3->base.funcs = &hubbub301_funcs;
76 	hubbub3->regs = hubbub_regs;
77 	hubbub3->shifts = hubbub_shift;
78 	hubbub3->masks = hubbub_mask;
79 
80 	hubbub3->debug_test_index_pstate = 0xB;
81 	hubbub3->detile_buf_size = 184 * 1024; /* 184KB for DCN3 */
82 }
83