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 
26*2cac05deSEvan Quan #define PP_MAX_CLOCK_LEVELS 16
27a2dd023aSEric Huang 
282c2b67b4SRex Zhu enum amd_pp_display_config_type{
292c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_None = 0,
302c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP54 ,
312c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP432 ,
322c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP324 ,
332c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP27,
342c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP243,
352c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP216,
362c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DP162,
372c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI6G ,
382c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI297 ,
392c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_HDMI162,
402c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_LVDS,
412c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_DVI,
422c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_WIRELESS,
432c2b67b4SRex Zhu 	AMD_PP_DisplayConfigType_VGA
442c2b67b4SRex Zhu };
452c2b67b4SRex Zhu 
462c2b67b4SRex Zhu struct single_display_configuration
472c2b67b4SRex Zhu {
482c2b67b4SRex Zhu 	uint32_t controller_index;
492c2b67b4SRex Zhu 	uint32_t controller_id;
502c2b67b4SRex Zhu 	uint32_t signal_type;
512c2b67b4SRex Zhu 	uint32_t display_state;
522c2b67b4SRex Zhu 	/* phy id for the primary internal transmitter */
532c2b67b4SRex Zhu 	uint8_t primary_transmitter_phyi_d;
542c2b67b4SRex Zhu 	/* bitmap with the active lanes */
552c2b67b4SRex Zhu 	uint8_t primary_transmitter_active_lanemap;
562c2b67b4SRex Zhu 	/* phy id for the secondary internal transmitter (for dual-link dvi) */
572c2b67b4SRex Zhu 	uint8_t secondary_transmitter_phy_id;
582c2b67b4SRex Zhu 	/* bitmap with the active lanes */
592c2b67b4SRex Zhu 	uint8_t secondary_transmitter_active_lanemap;
602c2b67b4SRex Zhu 	/* misc phy settings for SMU. */
612c2b67b4SRex Zhu 	uint32_t config_flags;
622c2b67b4SRex Zhu 	uint32_t display_type;
632c2b67b4SRex Zhu 	uint32_t view_resolution_cx;
642c2b67b4SRex Zhu 	uint32_t view_resolution_cy;
652c2b67b4SRex Zhu 	enum amd_pp_display_config_type displayconfigtype;
662c2b67b4SRex Zhu 	uint32_t vertical_refresh; /* for active display */
672c2b67b4SRex Zhu };
682c2b67b4SRex Zhu 
692c2b67b4SRex Zhu #define MAX_NUM_DISPLAY 32
702c2b67b4SRex Zhu 
712c2b67b4SRex Zhu struct amd_pp_display_configuration {
722c2b67b4SRex Zhu 	bool nb_pstate_switch_disable;/* controls NB PState switch */
732c2b67b4SRex Zhu 	bool cpu_cc6_disable; /* controls CPU CState switch ( on or off) */
742c2b67b4SRex Zhu 	bool cpu_pstate_disable;
752c2b67b4SRex Zhu 	uint32_t cpu_pstate_separation_time;
762c2b67b4SRex Zhu 
772c2b67b4SRex Zhu 	uint32_t num_display;  /* total number of display*/
782c2b67b4SRex Zhu 	uint32_t num_path_including_non_display;
792c2b67b4SRex Zhu 	uint32_t crossfire_display_index;
802c2b67b4SRex Zhu 	uint32_t min_mem_set_clock;
812c2b67b4SRex Zhu 	uint32_t min_core_set_clock;
822c2b67b4SRex Zhu 	/* unit 10KHz x bit*/
832c2b67b4SRex Zhu 	uint32_t min_bus_bandwidth;
842c2b67b4SRex Zhu 	/* minimum required stutter sclk, in 10khz uint32_t ulMinCoreSetClk;*/
852c2b67b4SRex Zhu 	uint32_t min_core_set_clock_in_sr;
862c2b67b4SRex Zhu 
872c2b67b4SRex Zhu 	struct single_display_configuration displays[MAX_NUM_DISPLAY];
882c2b67b4SRex Zhu 
892c2b67b4SRex Zhu 	uint32_t vrefresh; /* for active display*/
902c2b67b4SRex Zhu 
912c2b67b4SRex Zhu 	uint32_t min_vblank_time; /* for active display*/
922c2b67b4SRex Zhu 	bool multi_monitor_in_sync;
932c2b67b4SRex Zhu 	/* Controller Index of primary display - used in MCLK SMC switching hang
942c2b67b4SRex Zhu 	 * SW Workaround*/
952c2b67b4SRex Zhu 	uint32_t crtc_index;
962c2b67b4SRex Zhu 	/* htotal*1000/pixelclk - used in MCLK SMC switching hang SW Workaround*/
972c2b67b4SRex Zhu 	uint32_t line_time_in_us;
982c2b67b4SRex Zhu 	bool invalid_vblank_time;
992c2b67b4SRex Zhu 
1002c2b67b4SRex Zhu 	uint32_t display_clk;
1012c2b67b4SRex Zhu 	/*
1022c2b67b4SRex Zhu 	 * for given display configuration if multimonitormnsync == false then
1032c2b67b4SRex Zhu 	 * Memory clock DPMS with this latency or below is allowed, DPMS with
1042c2b67b4SRex Zhu 	 * higher latency not allowed.
1052c2b67b4SRex Zhu 	 */
1062c2b67b4SRex Zhu 	uint32_t dce_tolerable_mclk_in_active_latency;
1072c2b67b4SRex Zhu 	uint32_t min_dcef_set_clk;
1082c2b67b4SRex Zhu 	uint32_t min_dcef_deep_sleep_set_clk;
1092c2b67b4SRex Zhu };
1102c2b67b4SRex Zhu 
1112c2b67b4SRex Zhu struct amd_pp_simple_clock_info {
1122c2b67b4SRex Zhu 	uint32_t	engine_max_clock;
1132c2b67b4SRex Zhu 	uint32_t	memory_max_clock;
1142c2b67b4SRex Zhu 	uint32_t	level;
1152c2b67b4SRex Zhu };
1162c2b67b4SRex Zhu 
1172c2b67b4SRex Zhu enum PP_DAL_POWERLEVEL {
1182c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_INVALID = 0,
1192c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_ULTRALOW,
1202c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_LOW,
1212c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_NOMINAL,
1222c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_PERFORMANCE,
1232c2b67b4SRex Zhu 
1242c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_0 = PP_DAL_POWERLEVEL_ULTRALOW,
1252c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_1 = PP_DAL_POWERLEVEL_LOW,
1262c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_2 = PP_DAL_POWERLEVEL_NOMINAL,
1272c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_3 = PP_DAL_POWERLEVEL_PERFORMANCE,
1282c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_4 = PP_DAL_POWERLEVEL_3+1,
1292c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_5 = PP_DAL_POWERLEVEL_4+1,
1302c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_6 = PP_DAL_POWERLEVEL_5+1,
1312c2b67b4SRex Zhu 	PP_DAL_POWERLEVEL_7 = PP_DAL_POWERLEVEL_6+1,
1322c2b67b4SRex Zhu };
1332c2b67b4SRex Zhu 
1342c2b67b4SRex Zhu struct amd_pp_clock_info {
1352c2b67b4SRex Zhu 	uint32_t min_engine_clock;
1362c2b67b4SRex Zhu 	uint32_t max_engine_clock;
1372c2b67b4SRex Zhu 	uint32_t min_memory_clock;
1382c2b67b4SRex Zhu 	uint32_t max_memory_clock;
1392c2b67b4SRex Zhu 	uint32_t min_bus_bandwidth;
1402c2b67b4SRex Zhu 	uint32_t max_bus_bandwidth;
1412c2b67b4SRex Zhu 	uint32_t max_engine_clock_in_sr;
1422c2b67b4SRex Zhu 	uint32_t min_engine_clock_in_sr;
1432c2b67b4SRex Zhu 	enum PP_DAL_POWERLEVEL max_clocks_state;
1442c2b67b4SRex Zhu };
1452c2b67b4SRex Zhu 
1462c2b67b4SRex Zhu enum amd_pp_clock_type {
1472c2b67b4SRex Zhu 	amd_pp_disp_clock = 1,
1482c2b67b4SRex Zhu 	amd_pp_sys_clock,
1492c2b67b4SRex Zhu 	amd_pp_mem_clock,
1502c2b67b4SRex Zhu 	amd_pp_dcef_clock,
1512c2b67b4SRex Zhu 	amd_pp_soc_clock,
1522c2b67b4SRex Zhu 	amd_pp_pixel_clock,
1532c2b67b4SRex Zhu 	amd_pp_phy_clock,
1542c2b67b4SRex Zhu 	amd_pp_dcf_clock,
1552c2b67b4SRex Zhu 	amd_pp_dpp_clock,
1562c2b67b4SRex Zhu 	amd_pp_f_clock = amd_pp_dcef_clock,
1572c2b67b4SRex Zhu };
1582c2b67b4SRex Zhu 
1592c2b67b4SRex Zhu #define MAX_NUM_CLOCKS 16
1602c2b67b4SRex Zhu 
1612c2b67b4SRex Zhu struct amd_pp_clocks {
1622c2b67b4SRex Zhu 	uint32_t count;
1632c2b67b4SRex Zhu 	uint32_t clock[MAX_NUM_CLOCKS];
1642c2b67b4SRex Zhu 	uint32_t latency[MAX_NUM_CLOCKS];
1652c2b67b4SRex Zhu };
1662c2b67b4SRex 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 
1872c2b67b4SRex Zhu struct pp_display_clock_request {
1882c2b67b4SRex Zhu 	enum amd_pp_clock_type clock_type;
1892c2b67b4SRex Zhu 	uint32_t clock_freq_in_khz;
1902c2b67b4SRex Zhu };
1912c2b67b4SRex 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