1a2dd023aSEric Huang /*
2a2dd023aSEric Huang  * Copyright 2016 Advanced Micro Devices, Inc.
3a2dd023aSEric Huang  *
4a2dd023aSEric Huang  * Permission is hereby granted, free of charge, to any person obtaining a
5a2dd023aSEric Huang  * copy of this software and associated documentation files (the "Software"),
6a2dd023aSEric Huang  * to deal in the Software without restriction, including without limitation
7a2dd023aSEric Huang  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a2dd023aSEric Huang  * and/or sell copies of the Software, and to permit persons to whom the
9a2dd023aSEric Huang  * Software is furnished to do so, subject to the following conditions:
10a2dd023aSEric Huang  *
11a2dd023aSEric Huang  * The above copyright notice and this permission notice shall be included in
12a2dd023aSEric Huang  * all copies or substantial portions of the Software.
13a2dd023aSEric Huang  *
14a2dd023aSEric Huang  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a2dd023aSEric Huang  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a2dd023aSEric Huang  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17a2dd023aSEric Huang  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18a2dd023aSEric Huang  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19a2dd023aSEric Huang  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20a2dd023aSEric Huang  * OTHER DEALINGS IN THE SOFTWARE.
21a2dd023aSEric Huang  *
22a2dd023aSEric Huang  */
23a2dd023aSEric Huang #ifndef _DM_PP_INTERFACE_
24a2dd023aSEric Huang #define _DM_PP_INTERFACE_
25a2dd023aSEric Huang 
26a2dd023aSEric Huang #define PP_MAX_CLOCK_LEVELS 8
27a2dd023aSEric Huang 
28*2c2b67b4SRex Zhu enum amd_pp_display_config_type{
29*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_None = 0,
30*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP54 ,
31*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP432 ,
32*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP324 ,
33*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP27,
34*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP243,
35*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP216,
36*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP162,
37*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI6G ,
38*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI297 ,
39*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI162,
40*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_LVDS,
41*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DVI,
42*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_WIRELESS,
43*2c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_VGA
44*2c2b67b4SRex Zhu };
45*2c2b67b4SRex Zhu 
46*2c2b67b4SRex Zhu struct single_display_configuration
47*2c2b67b4SRex Zhu {
48*2c2b67b4SRex Zhu 	uint32_t controller_index;
49*2c2b67b4SRex Zhu 	uint32_t controller_id;
50*2c2b67b4SRex Zhu 	uint32_t signal_type;
51*2c2b67b4SRex Zhu 	uint32_t display_state;
52*2c2b67b4SRex Zhu 	/* phy id for the primary internal transmitter */
53*2c2b67b4SRex Zhu 	uint8_t primary_transmitter_phyi_d;
54*2c2b67b4SRex Zhu 	/* bitmap with the active lanes */
55*2c2b67b4SRex Zhu 	uint8_t primary_transmitter_active_lanemap;
56*2c2b67b4SRex Zhu 	/* phy id for the secondary internal transmitter (for dual-link dvi) */
57*2c2b67b4SRex Zhu 	uint8_t secondary_transmitter_phy_id;
58*2c2b67b4SRex Zhu 	/* bitmap with the active lanes */
59*2c2b67b4SRex Zhu 	uint8_t secondary_transmitter_active_lanemap;
60*2c2b67b4SRex Zhu 	/* misc phy settings for SMU. */
61*2c2b67b4SRex Zhu 	uint32_t config_flags;
62*2c2b67b4SRex Zhu 	uint32_t display_type;
63*2c2b67b4SRex Zhu 	uint32_t view_resolution_cx;
64*2c2b67b4SRex Zhu 	uint32_t view_resolution_cy;
65*2c2b67b4SRex Zhu 	enum amd_pp_display_config_type displayconfigtype;
66*2c2b67b4SRex Zhu 	uint32_t vertical_refresh; /* for active display */
67*2c2b67b4SRex Zhu };
68*2c2b67b4SRex Zhu 
69*2c2b67b4SRex Zhu #define MAX_NUM_DISPLAY 32
70*2c2b67b4SRex Zhu 
71*2c2b67b4SRex Zhu struct amd_pp_display_configuration {
72*2c2b67b4SRex Zhu 	bool nb_pstate_switch_disable;/* controls NB PState switch */
73*2c2b67b4SRex Zhu 	bool cpu_cc6_disable; /* controls CPU CState switch ( on or off) */
74*2c2b67b4SRex Zhu 	bool cpu_pstate_disable;
75*2c2b67b4SRex Zhu 	uint32_t cpu_pstate_separation_time;
76*2c2b67b4SRex Zhu 
77*2c2b67b4SRex Zhu 	uint32_t num_display;  /* total number of display*/
78*2c2b67b4SRex Zhu 	uint32_t num_path_including_non_display;
79*2c2b67b4SRex Zhu 	uint32_t crossfire_display_index;
80*2c2b67b4SRex Zhu 	uint32_t min_mem_set_clock;
81*2c2b67b4SRex Zhu 	uint32_t min_core_set_clock;
82*2c2b67b4SRex Zhu 	/* unit 10KHz x bit*/
83*2c2b67b4SRex Zhu 	uint32_t min_bus_bandwidth;
84*2c2b67b4SRex Zhu 	/* minimum required stutter sclk, in 10khz uint32_t ulMinCoreSetClk;*/
85*2c2b67b4SRex Zhu 	uint32_t min_core_set_clock_in_sr;
86*2c2b67b4SRex Zhu 
87*2c2b67b4SRex Zhu 	struct single_display_configuration displays[MAX_NUM_DISPLAY];
88*2c2b67b4SRex Zhu 
89*2c2b67b4SRex Zhu 	uint32_t vrefresh; /* for active display*/
90*2c2b67b4SRex Zhu 
91*2c2b67b4SRex Zhu 	uint32_t min_vblank_time; /* for active display*/
92*2c2b67b4SRex Zhu 	bool multi_monitor_in_sync;
93*2c2b67b4SRex Zhu 	/* Controller Index of primary display - used in MCLK SMC switching hang
94*2c2b67b4SRex Zhu 	 * SW Workaround*/
95*2c2b67b4SRex Zhu 	uint32_t crtc_index;
96*2c2b67b4SRex Zhu 	/* htotal*1000/pixelclk - used in MCLK SMC switching hang SW Workaround*/
97*2c2b67b4SRex Zhu 	uint32_t line_time_in_us;
98*2c2b67b4SRex Zhu 	bool invalid_vblank_time;
99*2c2b67b4SRex Zhu 
100*2c2b67b4SRex Zhu 	uint32_t display_clk;
101*2c2b67b4SRex Zhu 	/*
102*2c2b67b4SRex Zhu 	 * for given display configuration if multimonitormnsync == false then
103*2c2b67b4SRex Zhu 	 * Memory clock DPMS with this latency or below is allowed, DPMS with
104*2c2b67b4SRex Zhu 	 * higher latency not allowed.
105*2c2b67b4SRex Zhu 	 */
106*2c2b67b4SRex Zhu 	uint32_t dce_tolerable_mclk_in_active_latency;
107*2c2b67b4SRex Zhu 	uint32_t min_dcef_set_clk;
108*2c2b67b4SRex Zhu 	uint32_t min_dcef_deep_sleep_set_clk;
109*2c2b67b4SRex Zhu };
110*2c2b67b4SRex Zhu 
111*2c2b67b4SRex Zhu struct amd_pp_simple_clock_info {
112*2c2b67b4SRex Zhu 	uint32_t	engine_max_clock;
113*2c2b67b4SRex Zhu 	uint32_t	memory_max_clock;
114*2c2b67b4SRex Zhu 	uint32_t	level;
115*2c2b67b4SRex Zhu };
116*2c2b67b4SRex Zhu 
117*2c2b67b4SRex Zhu enum PP_DAL_POWERLEVEL {
118*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_INVALID = 0,
119*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_ULTRALOW,
120*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_LOW,
121*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_NOMINAL,
122*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_PERFORMANCE,
123*2c2b67b4SRex Zhu 
124*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_0 = PP_DAL_POWERLEVEL_ULTRALOW,
125*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_1 = PP_DAL_POWERLEVEL_LOW,
126*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_2 = PP_DAL_POWERLEVEL_NOMINAL,
127*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_3 = PP_DAL_POWERLEVEL_PERFORMANCE,
128*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_4 = PP_DAL_POWERLEVEL_3+1,
129*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_5 = PP_DAL_POWERLEVEL_4+1,
130*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_6 = PP_DAL_POWERLEVEL_5+1,
131*2c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_7 = PP_DAL_POWERLEVEL_6+1,
132*2c2b67b4SRex Zhu };
133*2c2b67b4SRex Zhu 
134*2c2b67b4SRex Zhu struct amd_pp_clock_info {
135*2c2b67b4SRex Zhu 	uint32_t min_engine_clock;
136*2c2b67b4SRex Zhu 	uint32_t max_engine_clock;
137*2c2b67b4SRex Zhu 	uint32_t min_memory_clock;
138*2c2b67b4SRex Zhu 	uint32_t max_memory_clock;
139*2c2b67b4SRex Zhu 	uint32_t min_bus_bandwidth;
140*2c2b67b4SRex Zhu 	uint32_t max_bus_bandwidth;
141*2c2b67b4SRex Zhu 	uint32_t max_engine_clock_in_sr;
142*2c2b67b4SRex Zhu 	uint32_t min_engine_clock_in_sr;
143*2c2b67b4SRex Zhu 	enum PP_DAL_POWERLEVEL max_clocks_state;
144*2c2b67b4SRex Zhu };
145*2c2b67b4SRex Zhu 
146*2c2b67b4SRex Zhu enum amd_pp_clock_type {
147*2c2b67b4SRex Zhu 	amd_pp_disp_clock = 1,
148*2c2b67b4SRex Zhu 	amd_pp_sys_clock,
149*2c2b67b4SRex Zhu 	amd_pp_mem_clock,
150*2c2b67b4SRex Zhu 	amd_pp_dcef_clock,
151*2c2b67b4SRex Zhu 	amd_pp_soc_clock,
152*2c2b67b4SRex Zhu 	amd_pp_pixel_clock,
153*2c2b67b4SRex Zhu 	amd_pp_phy_clock,
154*2c2b67b4SRex Zhu 	amd_pp_dcf_clock,
155*2c2b67b4SRex Zhu 	amd_pp_dpp_clock,
156*2c2b67b4SRex Zhu 	amd_pp_f_clock = amd_pp_dcef_clock,
157*2c2b67b4SRex Zhu };
158*2c2b67b4SRex Zhu 
159*2c2b67b4SRex Zhu #define MAX_NUM_CLOCKS 16
160*2c2b67b4SRex Zhu 
161*2c2b67b4SRex Zhu struct amd_pp_clocks {
162*2c2b67b4SRex Zhu 	uint32_t count;
163*2c2b67b4SRex Zhu 	uint32_t clock[MAX_NUM_CLOCKS];
164*2c2b67b4SRex Zhu 	uint32_t latency[MAX_NUM_CLOCKS];
165*2c2b67b4SRex Zhu };
166*2c2b67b4SRex Zhu 
167a2dd023aSEric Huang struct pp_clock_with_latency {
168a2dd023aSEric Huang 	uint32_t clocks_in_khz;
169a2dd023aSEric Huang 	uint32_t latency_in_us;
170a2dd023aSEric Huang };
171a2dd023aSEric Huang 
172a2dd023aSEric Huang struct pp_clock_levels_with_latency {
173a2dd023aSEric Huang 	uint32_t num_levels;
174a2dd023aSEric Huang 	struct pp_clock_with_latency data[PP_MAX_CLOCK_LEVELS];
175a2dd023aSEric Huang };
176a2dd023aSEric Huang 
177a2dd023aSEric Huang struct pp_clock_with_voltage {
178a2dd023aSEric Huang 	uint32_t clocks_in_khz;
179a2dd023aSEric Huang 	uint32_t voltage_in_mv;
180a2dd023aSEric Huang };
181a2dd023aSEric Huang 
182a2dd023aSEric Huang struct pp_clock_levels_with_voltage {
183a2dd023aSEric Huang 	uint32_t num_levels;
184a2dd023aSEric Huang 	struct pp_clock_with_voltage data[PP_MAX_CLOCK_LEVELS];
185a2dd023aSEric Huang };
186a2dd023aSEric Huang 
187*2c2b67b4SRex Zhu struct pp_display_clock_request {
188*2c2b67b4SRex Zhu 	enum amd_pp_clock_type clock_type;
189*2c2b67b4SRex Zhu 	uint32_t clock_freq_in_khz;
190*2c2b67b4SRex Zhu };
191*2c2b67b4SRex Zhu 
192a2dd023aSEric Huang #define PP_MAX_WM_SETS 4
193a2dd023aSEric Huang 
194a2dd023aSEric Huang enum pp_wm_set_id {
195a2dd023aSEric Huang 	DC_WM_SET_A = 0,
196a2dd023aSEric Huang 	DC_WM_SET_B,
197a2dd023aSEric Huang 	DC_WM_SET_C,
198a2dd023aSEric Huang 	DC_WM_SET_D,
199a2dd023aSEric Huang 	DC_WM_SET_INVALID = 0xffff,
200a2dd023aSEric Huang };
201a2dd023aSEric Huang 
202a2dd023aSEric Huang struct pp_wm_set_with_dmif_clock_range_soc15 {
203a2dd023aSEric Huang 	enum pp_wm_set_id wm_set_id;
204a2dd023aSEric Huang 	uint32_t wm_min_dcefclk_in_khz;
205a2dd023aSEric Huang 	uint32_t wm_max_dcefclk_in_khz;
206a2dd023aSEric Huang 	uint32_t wm_min_memclk_in_khz;
207a2dd023aSEric Huang 	uint32_t wm_max_memclk_in_khz;
208a2dd023aSEric Huang };
209a2dd023aSEric Huang 
210a2dd023aSEric Huang struct pp_wm_set_with_mcif_clock_range_soc15 {
211a2dd023aSEric Huang 	enum pp_wm_set_id wm_set_id;
212a2dd023aSEric Huang 	uint32_t wm_min_socclk_in_khz;
213a2dd023aSEric Huang 	uint32_t wm_max_socclk_in_khz;
214a2dd023aSEric Huang 	uint32_t wm_min_memclk_in_khz;
215a2dd023aSEric Huang 	uint32_t wm_max_memclk_in_khz;
216a2dd023aSEric Huang };
217a2dd023aSEric Huang 
218a2dd023aSEric Huang struct pp_wm_sets_with_clock_ranges_soc15 {
219a2dd023aSEric Huang 	uint32_t num_wm_sets_dmif;
220a2dd023aSEric Huang 	uint32_t num_wm_sets_mcif;
221a2dd023aSEric Huang 	struct pp_wm_set_with_dmif_clock_range_soc15
222a2dd023aSEric Huang 		wm_sets_dmif[PP_MAX_WM_SETS];
223a2dd023aSEric Huang 	struct pp_wm_set_with_mcif_clock_range_soc15
224a2dd023aSEric Huang 		wm_sets_mcif[PP_MAX_WM_SETS];
225a2dd023aSEric Huang };
226a2dd023aSEric Huang 
227a2dd023aSEric Huang #endif /* _DM_PP_INTERFACE_ */
228