xref: /dflybsd-src/sys/dev/drm/amd/powerplay/inc/hwmgr.h (revision 789731325bde747251c28a37e0a00ed4efb88c46)
1b843c749SSergey Zigachev /*
2b843c749SSergey Zigachev  * Copyright 2015 Advanced Micro Devices, Inc.
3b843c749SSergey Zigachev  *
4b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
5b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
6b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
7b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
9b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
10b843c749SSergey Zigachev  *
11b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
12b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
13b843c749SSergey Zigachev  *
14b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
21b843c749SSergey Zigachev  *
22b843c749SSergey Zigachev  */
23b843c749SSergey Zigachev #ifndef _HWMGR_H_
24b843c749SSergey Zigachev #define _HWMGR_H_
25b843c749SSergey Zigachev 
26b843c749SSergey Zigachev #include <linux/seq_file.h>
27b843c749SSergey Zigachev #include "amd_powerplay.h"
28b843c749SSergey Zigachev #include "hardwaremanager.h"
29b843c749SSergey Zigachev #include "hwmgr_ppt.h"
30b843c749SSergey Zigachev #include "ppatomctrl.h"
31b843c749SSergey Zigachev #include "hwmgr_ppt.h"
32b843c749SSergey Zigachev #include "power_state.h"
33b843c749SSergey Zigachev #include "smu_helper.h"
34b843c749SSergey Zigachev 
35b843c749SSergey Zigachev struct pp_hwmgr;
36b843c749SSergey Zigachev struct phm_fan_speed_info;
37b843c749SSergey Zigachev struct pp_atomctrl_voltage_table;
38b843c749SSergey Zigachev 
39b843c749SSergey Zigachev #define VOLTAGE_SCALE 4
40b843c749SSergey Zigachev #define VOLTAGE_VID_OFFSET_SCALE1   625
41b843c749SSergey Zigachev #define VOLTAGE_VID_OFFSET_SCALE2   100
42b843c749SSergey Zigachev 
43b843c749SSergey Zigachev enum DISPLAY_GAP {
44b843c749SSergey Zigachev 	DISPLAY_GAP_VBLANK_OR_WM = 0,   /* Wait for vblank or MCHG watermark. */
45b843c749SSergey Zigachev 	DISPLAY_GAP_VBLANK       = 1,   /* Wait for vblank. */
46b843c749SSergey Zigachev 	DISPLAY_GAP_WATERMARK    = 2,   /* Wait for MCHG watermark. (Note that HW may deassert WM in VBI depending on DC_STUTTER_CNTL.) */
47b843c749SSergey Zigachev 	DISPLAY_GAP_IGNORE       = 3    /* Do not wait. */
48b843c749SSergey Zigachev };
49b843c749SSergey Zigachev typedef enum DISPLAY_GAP DISPLAY_GAP;
50b843c749SSergey Zigachev 
51b843c749SSergey Zigachev struct vi_dpm_level {
52b843c749SSergey Zigachev 	bool enabled;
53b843c749SSergey Zigachev 	uint32_t value;
54b843c749SSergey Zigachev 	uint32_t param1;
55b843c749SSergey Zigachev };
56b843c749SSergey Zigachev 
57b843c749SSergey Zigachev struct vi_dpm_table {
58b843c749SSergey Zigachev 	uint32_t count;
59b843c749SSergey Zigachev 	struct vi_dpm_level dpm_level[1];
60b843c749SSergey Zigachev };
61b843c749SSergey Zigachev 
62b843c749SSergey Zigachev #define PCIE_PERF_REQ_REMOVE_REGISTRY   0
63b843c749SSergey Zigachev #define PCIE_PERF_REQ_FORCE_LOWPOWER    1
64b843c749SSergey Zigachev #define PCIE_PERF_REQ_GEN1         2
65b843c749SSergey Zigachev #define PCIE_PERF_REQ_GEN2         3
66b843c749SSergey Zigachev #define PCIE_PERF_REQ_GEN3         4
67b843c749SSergey Zigachev 
68b843c749SSergey Zigachev enum PHM_BackEnd_Magic {
69b843c749SSergey Zigachev 	PHM_Dummy_Magic       = 0xAA5555AA,
70b843c749SSergey Zigachev 	PHM_RV770_Magic       = 0xDCBAABCD,
71b843c749SSergey Zigachev 	PHM_Kong_Magic        = 0x239478DF,
72b843c749SSergey Zigachev 	PHM_NIslands_Magic    = 0x736C494E,
73b843c749SSergey Zigachev 	PHM_Sumo_Magic        = 0x8339FA11,
74b843c749SSergey Zigachev 	PHM_SIslands_Magic    = 0x369431AC,
75b843c749SSergey Zigachev 	PHM_Trinity_Magic     = 0x96751873,
76b843c749SSergey Zigachev 	PHM_CIslands_Magic    = 0x38AC78B0,
77b843c749SSergey Zigachev 	PHM_Kv_Magic          = 0xDCBBABC0,
78b843c749SSergey Zigachev 	PHM_VIslands_Magic    = 0x20130307,
79b843c749SSergey Zigachev 	PHM_Cz_Magic          = 0x67DCBA25,
80b843c749SSergey Zigachev 	PHM_Rv_Magic          = 0x20161121
81b843c749SSergey Zigachev };
82b843c749SSergey Zigachev 
83b843c749SSergey Zigachev struct phm_set_power_state_input {
84b843c749SSergey Zigachev 	const struct pp_hw_power_state *pcurrent_state;
85b843c749SSergey Zigachev 	const struct pp_hw_power_state *pnew_state;
86b843c749SSergey Zigachev };
87b843c749SSergey Zigachev 
88b843c749SSergey Zigachev struct phm_clock_array {
89b843c749SSergey Zigachev 	uint32_t count;
90b843c749SSergey Zigachev 	uint32_t values[1];
91b843c749SSergey Zigachev };
92b843c749SSergey Zigachev 
93b843c749SSergey Zigachev struct phm_clock_voltage_dependency_record {
94b843c749SSergey Zigachev 	uint32_t clk;
95b843c749SSergey Zigachev 	uint32_t v;
96b843c749SSergey Zigachev };
97b843c749SSergey Zigachev 
98b843c749SSergey Zigachev struct phm_vceclock_voltage_dependency_record {
99b843c749SSergey Zigachev 	uint32_t ecclk;
100b843c749SSergey Zigachev 	uint32_t evclk;
101b843c749SSergey Zigachev 	uint32_t v;
102b843c749SSergey Zigachev };
103b843c749SSergey Zigachev 
104b843c749SSergey Zigachev struct phm_uvdclock_voltage_dependency_record {
105b843c749SSergey Zigachev 	uint32_t vclk;
106b843c749SSergey Zigachev 	uint32_t dclk;
107b843c749SSergey Zigachev 	uint32_t v;
108b843c749SSergey Zigachev };
109b843c749SSergey Zigachev 
110b843c749SSergey Zigachev struct phm_samuclock_voltage_dependency_record {
111b843c749SSergey Zigachev 	uint32_t samclk;
112b843c749SSergey Zigachev 	uint32_t v;
113b843c749SSergey Zigachev };
114b843c749SSergey Zigachev 
115b843c749SSergey Zigachev struct phm_acpclock_voltage_dependency_record {
116b843c749SSergey Zigachev 	uint32_t acpclk;
117b843c749SSergey Zigachev 	uint32_t v;
118b843c749SSergey Zigachev };
119b843c749SSergey Zigachev 
120b843c749SSergey Zigachev struct phm_clock_voltage_dependency_table {
121b843c749SSergey Zigachev 	uint32_t count;										/* Number of entries. */
122b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_record entries[1];		/* Dynamically allocate count entries. */
123b843c749SSergey Zigachev };
124b843c749SSergey Zigachev 
125b843c749SSergey Zigachev struct phm_phase_shedding_limits_record {
126b843c749SSergey Zigachev 	uint32_t  Voltage;
127b843c749SSergey Zigachev 	uint32_t    Sclk;
128b843c749SSergey Zigachev 	uint32_t    Mclk;
129b843c749SSergey Zigachev };
130b843c749SSergey Zigachev 
131b843c749SSergey Zigachev struct phm_uvd_clock_voltage_dependency_record {
132b843c749SSergey Zigachev 	uint32_t vclk;
133b843c749SSergey Zigachev 	uint32_t dclk;
134b843c749SSergey Zigachev 	uint32_t v;
135b843c749SSergey Zigachev };
136b843c749SSergey Zigachev 
137b843c749SSergey Zigachev struct phm_uvd_clock_voltage_dependency_table {
138b843c749SSergey Zigachev 	uint8_t count;
139b843c749SSergey Zigachev 	struct phm_uvd_clock_voltage_dependency_record entries[1];
140b843c749SSergey Zigachev };
141b843c749SSergey Zigachev 
142b843c749SSergey Zigachev struct phm_acp_clock_voltage_dependency_record {
143b843c749SSergey Zigachev 	uint32_t acpclk;
144b843c749SSergey Zigachev 	uint32_t v;
145b843c749SSergey Zigachev };
146b843c749SSergey Zigachev 
147b843c749SSergey Zigachev struct phm_acp_clock_voltage_dependency_table {
148b843c749SSergey Zigachev 	uint32_t count;
149b843c749SSergey Zigachev 	struct phm_acp_clock_voltage_dependency_record entries[1];
150b843c749SSergey Zigachev };
151b843c749SSergey Zigachev 
152b843c749SSergey Zigachev struct phm_vce_clock_voltage_dependency_record {
153b843c749SSergey Zigachev 	uint32_t ecclk;
154b843c749SSergey Zigachev 	uint32_t evclk;
155b843c749SSergey Zigachev 	uint32_t v;
156b843c749SSergey Zigachev };
157b843c749SSergey Zigachev 
158b843c749SSergey Zigachev struct phm_phase_shedding_limits_table {
159b843c749SSergey Zigachev 	uint32_t                           count;
160b843c749SSergey Zigachev 	struct phm_phase_shedding_limits_record  entries[1];
161b843c749SSergey Zigachev };
162b843c749SSergey Zigachev 
163b843c749SSergey Zigachev struct phm_vceclock_voltage_dependency_table {
164b843c749SSergey Zigachev 	uint8_t count;                                    /* Number of entries. */
165b843c749SSergey Zigachev 	struct phm_vceclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */
166b843c749SSergey Zigachev };
167b843c749SSergey Zigachev 
168b843c749SSergey Zigachev struct phm_uvdclock_voltage_dependency_table {
169b843c749SSergey Zigachev 	uint8_t count;                                    /* Number of entries. */
170b843c749SSergey Zigachev 	struct phm_uvdclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */
171b843c749SSergey Zigachev };
172b843c749SSergey Zigachev 
173b843c749SSergey Zigachev struct phm_samuclock_voltage_dependency_table {
174b843c749SSergey Zigachev 	uint8_t count;                                    /* Number of entries. */
175b843c749SSergey Zigachev 	struct phm_samuclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */
176b843c749SSergey Zigachev };
177b843c749SSergey Zigachev 
178b843c749SSergey Zigachev struct phm_acpclock_voltage_dependency_table {
179b843c749SSergey Zigachev 	uint32_t count;                                    /* Number of entries. */
180b843c749SSergey Zigachev 	struct phm_acpclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */
181b843c749SSergey Zigachev };
182b843c749SSergey Zigachev 
183b843c749SSergey Zigachev struct phm_vce_clock_voltage_dependency_table {
184b843c749SSergey Zigachev 	uint8_t count;
185b843c749SSergey Zigachev 	struct phm_vce_clock_voltage_dependency_record entries[1];
186b843c749SSergey Zigachev };
187b843c749SSergey Zigachev 
188b843c749SSergey Zigachev struct pp_smumgr_func {
189b843c749SSergey Zigachev 	int (*smu_init)(struct pp_hwmgr  *hwmgr);
190b843c749SSergey Zigachev 	int (*smu_fini)(struct pp_hwmgr  *hwmgr);
191b843c749SSergey Zigachev 	int (*start_smu)(struct pp_hwmgr  *hwmgr);
192b843c749SSergey Zigachev 	int (*check_fw_load_finish)(struct pp_hwmgr  *hwmgr,
193b843c749SSergey Zigachev 				    uint32_t firmware);
194b843c749SSergey Zigachev 	int (*request_smu_load_fw)(struct pp_hwmgr  *hwmgr);
195b843c749SSergey Zigachev 	int (*request_smu_load_specific_fw)(struct pp_hwmgr  *hwmgr,
196b843c749SSergey Zigachev 					    uint32_t firmware);
197b843c749SSergey Zigachev 	uint32_t (*get_argument)(struct pp_hwmgr  *hwmgr);
198b843c749SSergey Zigachev 	int (*send_msg_to_smc)(struct pp_hwmgr  *hwmgr, uint16_t msg);
199b843c749SSergey Zigachev 	int (*send_msg_to_smc_with_parameter)(struct pp_hwmgr  *hwmgr,
200b843c749SSergey Zigachev 					  uint16_t msg, uint32_t parameter);
201b843c749SSergey Zigachev 	int (*download_pptable_settings)(struct pp_hwmgr  *hwmgr,
202b843c749SSergey Zigachev 					 void **table);
203b843c749SSergey Zigachev 	int (*upload_pptable_settings)(struct pp_hwmgr  *hwmgr);
204b843c749SSergey Zigachev 	int (*update_smc_table)(struct pp_hwmgr *hwmgr, uint32_t type);
205b843c749SSergey Zigachev 	int (*process_firmware_header)(struct pp_hwmgr *hwmgr);
206b843c749SSergey Zigachev 	int (*update_sclk_threshold)(struct pp_hwmgr *hwmgr);
207b843c749SSergey Zigachev 	int (*thermal_setup_fan_table)(struct pp_hwmgr *hwmgr);
208b843c749SSergey Zigachev 	int (*thermal_avfs_enable)(struct pp_hwmgr *hwmgr);
209b843c749SSergey Zigachev 	int (*init_smc_table)(struct pp_hwmgr *hwmgr);
210b843c749SSergey Zigachev 	int (*populate_all_graphic_levels)(struct pp_hwmgr *hwmgr);
211b843c749SSergey Zigachev 	int (*populate_all_memory_levels)(struct pp_hwmgr *hwmgr);
212b843c749SSergey Zigachev 	int (*initialize_mc_reg_table)(struct pp_hwmgr *hwmgr);
213b843c749SSergey Zigachev 	uint32_t (*get_offsetof)(uint32_t type, uint32_t member);
214b843c749SSergey Zigachev 	uint32_t (*get_mac_definition)(uint32_t value);
215b843c749SSergey Zigachev 	bool (*is_dpm_running)(struct pp_hwmgr *hwmgr);
216b843c749SSergey Zigachev 	bool (*is_hw_avfs_present)(struct pp_hwmgr  *hwmgr);
217b843c749SSergey Zigachev 	int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting);
218b843c749SSergey Zigachev 	int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw); /*rw: true for read, false for write */
219b843c749SSergey Zigachev 	int (*stop_smc)(struct pp_hwmgr *hwmgr);
220b843c749SSergey Zigachev };
221b843c749SSergey Zigachev 
222b843c749SSergey Zigachev struct pp_hwmgr_func {
223b843c749SSergey Zigachev 	int (*backend_init)(struct pp_hwmgr *hw_mgr);
224b843c749SSergey Zigachev 	int (*backend_fini)(struct pp_hwmgr *hw_mgr);
225b843c749SSergey Zigachev 	int (*asic_setup)(struct pp_hwmgr *hw_mgr);
226b843c749SSergey Zigachev 	int (*get_power_state_size)(struct pp_hwmgr *hw_mgr);
227b843c749SSergey Zigachev 
228b843c749SSergey Zigachev 	int (*apply_state_adjust_rules)(struct pp_hwmgr *hwmgr,
229b843c749SSergey Zigachev 				struct pp_power_state  *prequest_ps,
230b843c749SSergey Zigachev 			const struct pp_power_state *pcurrent_ps);
231b843c749SSergey Zigachev 
232b843c749SSergey Zigachev 	int (*apply_clocks_adjust_rules)(struct pp_hwmgr *hwmgr);
233b843c749SSergey Zigachev 
234b843c749SSergey Zigachev 	int (*force_dpm_level)(struct pp_hwmgr *hw_mgr,
235b843c749SSergey Zigachev 					enum amd_dpm_forced_level level);
236b843c749SSergey Zigachev 
237b843c749SSergey Zigachev 	int (*dynamic_state_management_enable)(
238b843c749SSergey Zigachev 						struct pp_hwmgr *hw_mgr);
239b843c749SSergey Zigachev 	int (*dynamic_state_management_disable)(
240b843c749SSergey Zigachev 						struct pp_hwmgr *hw_mgr);
241b843c749SSergey Zigachev 
242b843c749SSergey Zigachev 	int (*patch_boot_state)(struct pp_hwmgr *hwmgr,
243b843c749SSergey Zigachev 				     struct pp_hw_power_state *hw_ps);
244b843c749SSergey Zigachev 
245b843c749SSergey Zigachev 	int (*get_pp_table_entry)(struct pp_hwmgr *hwmgr,
246b843c749SSergey Zigachev 			    unsigned long, struct pp_power_state *);
247b843c749SSergey Zigachev 	int (*get_num_of_pp_table_entries)(struct pp_hwmgr *hwmgr);
248b843c749SSergey Zigachev 	int (*powerdown_uvd)(struct pp_hwmgr *hwmgr);
249b843c749SSergey Zigachev 	void (*powergate_vce)(struct pp_hwmgr *hwmgr, bool bgate);
250b843c749SSergey Zigachev 	void (*powergate_uvd)(struct pp_hwmgr *hwmgr, bool bgate);
251b843c749SSergey Zigachev 	uint32_t (*get_mclk)(struct pp_hwmgr *hwmgr, bool low);
252b843c749SSergey Zigachev 	uint32_t (*get_sclk)(struct pp_hwmgr *hwmgr, bool low);
253b843c749SSergey Zigachev 	int (*power_state_set)(struct pp_hwmgr *hwmgr,
254b843c749SSergey Zigachev 						const void *state);
255b843c749SSergey Zigachev 	int (*enable_clock_power_gating)(struct pp_hwmgr *hwmgr);
256b843c749SSergey Zigachev 	int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr);
257b843c749SSergey Zigachev 	int (*pre_display_config_changed)(struct pp_hwmgr *hwmgr);
258b843c749SSergey Zigachev 	int (*display_config_changed)(struct pp_hwmgr *hwmgr);
259b843c749SSergey Zigachev 	int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr);
260b843c749SSergey Zigachev 	int (*update_clock_gatings)(struct pp_hwmgr *hwmgr,
261b843c749SSergey Zigachev 						const uint32_t *msg_id);
262b843c749SSergey Zigachev 	int (*set_max_fan_rpm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm);
263b843c749SSergey Zigachev 	int (*set_max_fan_pwm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm);
264b843c749SSergey Zigachev 	int (*stop_thermal_controller)(struct pp_hwmgr *hwmgr);
265b843c749SSergey Zigachev 	int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info);
266b843c749SSergey Zigachev 	void (*set_fan_control_mode)(struct pp_hwmgr *hwmgr, uint32_t mode);
267b843c749SSergey Zigachev 	uint32_t (*get_fan_control_mode)(struct pp_hwmgr *hwmgr);
268b843c749SSergey Zigachev 	int (*set_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t percent);
269b843c749SSergey Zigachev 	int (*get_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t *speed);
270b843c749SSergey Zigachev 	int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t percent);
271b843c749SSergey Zigachev 	int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed);
272b843c749SSergey Zigachev 	int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr);
273b843c749SSergey Zigachev 	int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr);
274b843c749SSergey Zigachev 	int (*register_irq_handlers)(struct pp_hwmgr *hwmgr);
275b843c749SSergey Zigachev 	bool (*check_smc_update_required_for_display_configuration)(struct pp_hwmgr *hwmgr);
276b843c749SSergey Zigachev 	int (*check_states_equal)(struct pp_hwmgr *hwmgr,
277b843c749SSergey Zigachev 					const struct pp_hw_power_state *pstate1,
278b843c749SSergey Zigachev 					const struct pp_hw_power_state *pstate2,
279b843c749SSergey Zigachev 					bool *equal);
280b843c749SSergey Zigachev 	int (*set_cpu_power_state)(struct pp_hwmgr *hwmgr);
281b843c749SSergey Zigachev 	int (*store_cc6_data)(struct pp_hwmgr *hwmgr, uint32_t separation_time,
282b843c749SSergey Zigachev 				bool cc6_disable, bool pstate_disable,
283b843c749SSergey Zigachev 				bool pstate_switch_disable);
284b843c749SSergey Zigachev 	int (*get_dal_power_level)(struct pp_hwmgr *hwmgr,
285b843c749SSergey Zigachev 			struct amd_pp_simple_clock_info *info);
286b843c749SSergey Zigachev 	int (*get_performance_level)(struct pp_hwmgr *, const struct pp_hw_power_state *,
287b843c749SSergey Zigachev 			PHM_PerformanceLevelDesignation, uint32_t, PHM_PerformanceLevel *);
288b843c749SSergey Zigachev 	int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr,
289b843c749SSergey Zigachev 				const struct pp_hw_power_state *state, struct pp_clock_info *clock_info);
290b843c749SSergey Zigachev 	int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks);
291b843c749SSergey Zigachev 	int (*get_clock_by_type_with_latency)(struct pp_hwmgr *hwmgr,
292b843c749SSergey Zigachev 			enum amd_pp_clock_type type,
293b843c749SSergey Zigachev 			struct pp_clock_levels_with_latency *clocks);
294b843c749SSergey Zigachev 	int (*get_clock_by_type_with_voltage)(struct pp_hwmgr *hwmgr,
295b843c749SSergey Zigachev 			enum amd_pp_clock_type type,
296b843c749SSergey Zigachev 			struct pp_clock_levels_with_voltage *clocks);
297b843c749SSergey Zigachev 	int (*set_watermarks_for_clocks_ranges)(struct pp_hwmgr *hwmgr, void *clock_ranges);
298b843c749SSergey Zigachev 	int (*display_clock_voltage_request)(struct pp_hwmgr *hwmgr,
299b843c749SSergey Zigachev 			struct pp_display_clock_request *clock);
300b843c749SSergey Zigachev 	int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);
301b843c749SSergey Zigachev 	int (*gfx_off_control)(struct pp_hwmgr *hwmgr, bool enable);
302b843c749SSergey Zigachev 	int (*power_off_asic)(struct pp_hwmgr *hwmgr);
303b843c749SSergey Zigachev 	int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask);
304b843c749SSergey Zigachev 	int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf);
305b843c749SSergey Zigachev 	int (*powergate_gfx)(struct pp_hwmgr *hwmgr, bool enable);
306b843c749SSergey Zigachev 	int (*get_sclk_od)(struct pp_hwmgr *hwmgr);
307b843c749SSergey Zigachev 	int (*set_sclk_od)(struct pp_hwmgr *hwmgr, uint32_t value);
308b843c749SSergey Zigachev 	int (*get_mclk_od)(struct pp_hwmgr *hwmgr);
309b843c749SSergey Zigachev 	int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value);
310b843c749SSergey Zigachev 	int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, void *value, int *size);
311b843c749SSergey Zigachev 	int (*avfs_control)(struct pp_hwmgr *hwmgr, bool enable);
312b843c749SSergey Zigachev 	int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr);
313b843c749SSergey Zigachev 	int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count);
314b843c749SSergey Zigachev 	int (*set_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock);
315b843c749SSergey Zigachev 	int (*start_thermal_controller)(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range);
316b843c749SSergey Zigachev 	int (*notify_cac_buffer_info)(struct pp_hwmgr *hwmgr,
317b843c749SSergey Zigachev 					uint32_t virtual_addr_low,
318b843c749SSergey Zigachev 					uint32_t virtual_addr_hi,
319b843c749SSergey Zigachev 					uint32_t mc_addr_low,
320b843c749SSergey Zigachev 					uint32_t mc_addr_hi,
321b843c749SSergey Zigachev 					uint32_t size);
322b843c749SSergey Zigachev 	int (*get_thermal_temperature_range)(struct pp_hwmgr *hwmgr,
323b843c749SSergey Zigachev 					struct PP_TemperatureRange *range);
324b843c749SSergey Zigachev 	int (*get_power_profile_mode)(struct pp_hwmgr *hwmgr, char *buf);
325b843c749SSergey Zigachev 	int (*set_power_profile_mode)(struct pp_hwmgr *hwmgr, long *input, uint32_t size);
326b843c749SSergey Zigachev 	int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr,
327b843c749SSergey Zigachev 					enum PP_OD_DPM_TABLE_COMMAND type,
328b843c749SSergey Zigachev 					long *input, uint32_t size);
329b843c749SSergey Zigachev 	int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n);
330b843c749SSergey Zigachev 	int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);
331b843c749SSergey Zigachev 	int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr);
332b843c749SSergey Zigachev };
333b843c749SSergey Zigachev 
334b843c749SSergey Zigachev struct pp_table_func {
335b843c749SSergey Zigachev 	int (*pptable_init)(struct pp_hwmgr *hw_mgr);
336b843c749SSergey Zigachev 	int (*pptable_fini)(struct pp_hwmgr *hw_mgr);
337b843c749SSergey Zigachev 	int (*pptable_get_number_of_vce_state_table_entries)(struct pp_hwmgr *hw_mgr);
338b843c749SSergey Zigachev 	int (*pptable_get_vce_state_table_entry)(
339b843c749SSergey Zigachev 						struct pp_hwmgr *hwmgr,
340b843c749SSergey Zigachev 						unsigned long i,
341b843c749SSergey Zigachev 						struct amd_vce_state *vce_state,
342b843c749SSergey Zigachev 						void **clock_info,
343b843c749SSergey Zigachev 						unsigned long *flag);
344b843c749SSergey Zigachev };
345b843c749SSergey Zigachev 
346b843c749SSergey Zigachev union phm_cac_leakage_record {
347b843c749SSergey Zigachev 	struct {
348b843c749SSergey Zigachev 		uint16_t Vddc;          /* in CI, we use it for StdVoltageHiSidd */
349b843c749SSergey Zigachev 		uint32_t Leakage;       /* in CI, we use it for StdVoltageLoSidd */
350b843c749SSergey Zigachev 	};
351b843c749SSergey Zigachev 	struct {
352b843c749SSergey Zigachev 		uint16_t Vddc1;
353b843c749SSergey Zigachev 		uint16_t Vddc2;
354b843c749SSergey Zigachev 		uint16_t Vddc3;
355b843c749SSergey Zigachev 	};
356b843c749SSergey Zigachev };
357b843c749SSergey Zigachev 
358b843c749SSergey Zigachev struct phm_cac_leakage_table {
359b843c749SSergey Zigachev 	uint32_t count;
360b843c749SSergey Zigachev 	union phm_cac_leakage_record entries[1];
361b843c749SSergey Zigachev };
362b843c749SSergey Zigachev 
363b843c749SSergey Zigachev struct phm_samu_clock_voltage_dependency_record {
364b843c749SSergey Zigachev 	uint32_t samclk;
365b843c749SSergey Zigachev 	uint32_t v;
366b843c749SSergey Zigachev };
367b843c749SSergey Zigachev 
368b843c749SSergey Zigachev 
369b843c749SSergey Zigachev struct phm_samu_clock_voltage_dependency_table {
370b843c749SSergey Zigachev 	uint8_t count;
371b843c749SSergey Zigachev 	struct phm_samu_clock_voltage_dependency_record entries[1];
372b843c749SSergey Zigachev };
373b843c749SSergey Zigachev 
374b843c749SSergey Zigachev struct phm_cac_tdp_table {
375b843c749SSergey Zigachev 	uint16_t usTDP;
376b843c749SSergey Zigachev 	uint16_t usConfigurableTDP;
377b843c749SSergey Zigachev 	uint16_t usTDC;
378b843c749SSergey Zigachev 	uint16_t usBatteryPowerLimit;
379b843c749SSergey Zigachev 	uint16_t usSmallPowerLimit;
380b843c749SSergey Zigachev 	uint16_t usLowCACLeakage;
381b843c749SSergey Zigachev 	uint16_t usHighCACLeakage;
382b843c749SSergey Zigachev 	uint16_t usMaximumPowerDeliveryLimit;
383b843c749SSergey Zigachev 	uint16_t usEDCLimit;
384b843c749SSergey Zigachev 	uint16_t usOperatingTempMinLimit;
385b843c749SSergey Zigachev 	uint16_t usOperatingTempMaxLimit;
386b843c749SSergey Zigachev 	uint16_t usOperatingTempStep;
387b843c749SSergey Zigachev 	uint16_t usOperatingTempHyst;
388b843c749SSergey Zigachev 	uint16_t usDefaultTargetOperatingTemp;
389b843c749SSergey Zigachev 	uint16_t usTargetOperatingTemp;
390b843c749SSergey Zigachev 	uint16_t usPowerTuneDataSetID;
391b843c749SSergey Zigachev 	uint16_t usSoftwareShutdownTemp;
392b843c749SSergey Zigachev 	uint16_t usClockStretchAmount;
393b843c749SSergey Zigachev 	uint16_t usTemperatureLimitHotspot;
394b843c749SSergey Zigachev 	uint16_t usTemperatureLimitLiquid1;
395b843c749SSergey Zigachev 	uint16_t usTemperatureLimitLiquid2;
396b843c749SSergey Zigachev 	uint16_t usTemperatureLimitVrVddc;
397b843c749SSergey Zigachev 	uint16_t usTemperatureLimitVrMvdd;
398b843c749SSergey Zigachev 	uint16_t usTemperatureLimitPlx;
399b843c749SSergey Zigachev 	uint8_t  ucLiquid1_I2C_address;
400b843c749SSergey Zigachev 	uint8_t  ucLiquid2_I2C_address;
401b843c749SSergey Zigachev 	uint8_t  ucLiquid_I2C_Line;
402b843c749SSergey Zigachev 	uint8_t  ucVr_I2C_address;
403b843c749SSergey Zigachev 	uint8_t  ucVr_I2C_Line;
404b843c749SSergey Zigachev 	uint8_t  ucPlx_I2C_address;
405b843c749SSergey Zigachev 	uint8_t  ucPlx_I2C_Line;
406b843c749SSergey Zigachev 	uint32_t usBoostPowerLimit;
407b843c749SSergey Zigachev 	uint8_t  ucCKS_LDO_REFSEL;
408b843c749SSergey Zigachev };
409b843c749SSergey Zigachev 
410b843c749SSergey Zigachev struct phm_tdp_table {
411b843c749SSergey Zigachev 	uint16_t usTDP;
412b843c749SSergey Zigachev 	uint16_t usConfigurableTDP;
413b843c749SSergey Zigachev 	uint16_t usTDC;
414b843c749SSergey Zigachev 	uint16_t usBatteryPowerLimit;
415b843c749SSergey Zigachev 	uint16_t usSmallPowerLimit;
416b843c749SSergey Zigachev 	uint16_t usLowCACLeakage;
417b843c749SSergey Zigachev 	uint16_t usHighCACLeakage;
418b843c749SSergey Zigachev 	uint16_t usMaximumPowerDeliveryLimit;
419b843c749SSergey Zigachev 	uint16_t usEDCLimit;
420b843c749SSergey Zigachev 	uint16_t usOperatingTempMinLimit;
421b843c749SSergey Zigachev 	uint16_t usOperatingTempMaxLimit;
422b843c749SSergey Zigachev 	uint16_t usOperatingTempStep;
423b843c749SSergey Zigachev 	uint16_t usOperatingTempHyst;
424b843c749SSergey Zigachev 	uint16_t usDefaultTargetOperatingTemp;
425b843c749SSergey Zigachev 	uint16_t usTargetOperatingTemp;
426b843c749SSergey Zigachev 	uint16_t usPowerTuneDataSetID;
427b843c749SSergey Zigachev 	uint16_t usSoftwareShutdownTemp;
428b843c749SSergey Zigachev 	uint16_t usClockStretchAmount;
429b843c749SSergey Zigachev 	uint16_t usTemperatureLimitTedge;
430b843c749SSergey Zigachev 	uint16_t usTemperatureLimitHotspot;
431b843c749SSergey Zigachev 	uint16_t usTemperatureLimitLiquid1;
432b843c749SSergey Zigachev 	uint16_t usTemperatureLimitLiquid2;
433b843c749SSergey Zigachev 	uint16_t usTemperatureLimitHBM;
434b843c749SSergey Zigachev 	uint16_t usTemperatureLimitVrVddc;
435b843c749SSergey Zigachev 	uint16_t usTemperatureLimitVrMvdd;
436b843c749SSergey Zigachev 	uint16_t usTemperatureLimitPlx;
437b843c749SSergey Zigachev 	uint8_t  ucLiquid1_I2C_address;
438b843c749SSergey Zigachev 	uint8_t  ucLiquid2_I2C_address;
439b843c749SSergey Zigachev 	uint8_t  ucLiquid_I2C_Line;
440b843c749SSergey Zigachev 	uint8_t  ucVr_I2C_address;
441b843c749SSergey Zigachev 	uint8_t  ucVr_I2C_Line;
442b843c749SSergey Zigachev 	uint8_t  ucPlx_I2C_address;
443b843c749SSergey Zigachev 	uint8_t  ucPlx_I2C_Line;
444b843c749SSergey Zigachev 	uint8_t  ucLiquid_I2C_LineSDA;
445b843c749SSergey Zigachev 	uint8_t  ucVr_I2C_LineSDA;
446b843c749SSergey Zigachev 	uint8_t  ucPlx_I2C_LineSDA;
447b843c749SSergey Zigachev 	uint32_t usBoostPowerLimit;
448b843c749SSergey Zigachev 	uint16_t usBoostStartTemperature;
449b843c749SSergey Zigachev 	uint16_t usBoostStopTemperature;
450b843c749SSergey Zigachev 	uint32_t  ulBoostClock;
451b843c749SSergey Zigachev };
452b843c749SSergey Zigachev 
453b843c749SSergey Zigachev struct phm_ppm_table {
454b843c749SSergey Zigachev 	uint8_t   ppm_design;
455b843c749SSergey Zigachev 	uint16_t  cpu_core_number;
456b843c749SSergey Zigachev 	uint32_t  platform_tdp;
457b843c749SSergey Zigachev 	uint32_t  small_ac_platform_tdp;
458b843c749SSergey Zigachev 	uint32_t  platform_tdc;
459b843c749SSergey Zigachev 	uint32_t  small_ac_platform_tdc;
460b843c749SSergey Zigachev 	uint32_t  apu_tdp;
461b843c749SSergey Zigachev 	uint32_t  dgpu_tdp;
462b843c749SSergey Zigachev 	uint32_t  dgpu_ulv_power;
463b843c749SSergey Zigachev 	uint32_t  tj_max;
464b843c749SSergey Zigachev };
465b843c749SSergey Zigachev 
466b843c749SSergey Zigachev struct phm_vq_budgeting_record {
467b843c749SSergey Zigachev 	uint32_t ulCUs;
468b843c749SSergey Zigachev 	uint32_t ulSustainableSOCPowerLimitLow;
469b843c749SSergey Zigachev 	uint32_t ulSustainableSOCPowerLimitHigh;
470b843c749SSergey Zigachev 	uint32_t ulMinSclkLow;
471b843c749SSergey Zigachev 	uint32_t ulMinSclkHigh;
472b843c749SSergey Zigachev 	uint8_t  ucDispConfig;
473b843c749SSergey Zigachev 	uint32_t ulDClk;
474b843c749SSergey Zigachev 	uint32_t ulEClk;
475b843c749SSergey Zigachev 	uint32_t ulSustainableSclk;
476b843c749SSergey Zigachev 	uint32_t ulSustainableCUs;
477b843c749SSergey Zigachev };
478b843c749SSergey Zigachev 
479b843c749SSergey Zigachev struct phm_vq_budgeting_table {
480b843c749SSergey Zigachev 	uint8_t numEntries;
481b843c749SSergey Zigachev 	struct phm_vq_budgeting_record entries[1];
482b843c749SSergey Zigachev };
483b843c749SSergey Zigachev 
484b843c749SSergey Zigachev struct phm_clock_and_voltage_limits {
485b843c749SSergey Zigachev 	uint32_t sclk;
486b843c749SSergey Zigachev 	uint32_t mclk;
487b843c749SSergey Zigachev 	uint32_t gfxclk;
488b843c749SSergey Zigachev 	uint16_t vddc;
489b843c749SSergey Zigachev 	uint16_t vddci;
490b843c749SSergey Zigachev 	uint16_t vddgfx;
491b843c749SSergey Zigachev 	uint16_t vddmem;
492b843c749SSergey Zigachev };
493b843c749SSergey Zigachev 
494b843c749SSergey Zigachev /* Structure to hold PPTable information */
495b843c749SSergey Zigachev 
496b843c749SSergey Zigachev struct phm_ppt_v1_information {
497b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk;
498b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk;
499b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk;
500b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk;
501b843c749SSergey Zigachev 	struct phm_clock_array *valid_sclk_values;
502b843c749SSergey Zigachev 	struct phm_clock_array *valid_mclk_values;
503b843c749SSergey Zigachev 	struct phm_clock_array *valid_socclk_values;
504b843c749SSergey Zigachev 	struct phm_clock_array *valid_dcefclk_values;
505b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits max_clock_voltage_on_dc;
506b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits max_clock_voltage_on_ac;
507b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl;
508b843c749SSergey Zigachev 	struct phm_ppm_table *ppm_parameter_table;
509b843c749SSergey Zigachev 	struct phm_cac_tdp_table *cac_dtp_table;
510b843c749SSergey Zigachev 	struct phm_tdp_table *tdp_table;
511b843c749SSergey Zigachev 	struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table;
512b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table;
513b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table;
514b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table;
515b843c749SSergey Zigachev 	struct phm_ppt_v1_pcie_table *pcie_table;
516b843c749SSergey Zigachev 	struct phm_ppt_v1_gpio_table *gpio_table;
517b843c749SSergey Zigachev 	uint16_t us_ulv_voltage_offset;
518b843c749SSergey Zigachev 	uint16_t us_ulv_smnclk_did;
519b843c749SSergey Zigachev 	uint16_t us_ulv_mp1clk_did;
520b843c749SSergey Zigachev 	uint16_t us_ulv_gfxclk_bypass;
521b843c749SSergey Zigachev 	uint16_t us_gfxclk_slew_rate;
522b843c749SSergey Zigachev 	uint16_t us_min_gfxclk_freq_limit;
523b843c749SSergey Zigachev };
524b843c749SSergey Zigachev 
525b843c749SSergey Zigachev struct phm_ppt_v2_information {
526b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk;
527b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk;
528b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk;
529b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk;
530b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_pixclk;
531b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dispclk;
532b843c749SSergey Zigachev 	struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_phyclk;
533b843c749SSergey Zigachev 	struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table;
534b843c749SSergey Zigachev 
535b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddc_dep_on_dalpwrl;
536b843c749SSergey Zigachev 
537b843c749SSergey Zigachev 	struct phm_clock_array *valid_sclk_values;
538b843c749SSergey Zigachev 	struct phm_clock_array *valid_mclk_values;
539b843c749SSergey Zigachev 	struct phm_clock_array *valid_socclk_values;
540b843c749SSergey Zigachev 	struct phm_clock_array *valid_dcefclk_values;
541b843c749SSergey Zigachev 
542b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits max_clock_voltage_on_dc;
543b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits max_clock_voltage_on_ac;
544b843c749SSergey Zigachev 
545b843c749SSergey Zigachev 	struct phm_ppm_table *ppm_parameter_table;
546b843c749SSergey Zigachev 	struct phm_cac_tdp_table *cac_dtp_table;
547b843c749SSergey Zigachev 	struct phm_tdp_table *tdp_table;
548b843c749SSergey Zigachev 
549b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table;
550b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table;
551b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table;
552b843c749SSergey Zigachev 	struct phm_ppt_v1_voltage_lookup_table *vddci_lookup_table;
553b843c749SSergey Zigachev 
554b843c749SSergey Zigachev 	struct phm_ppt_v1_pcie_table *pcie_table;
555b843c749SSergey Zigachev 
556b843c749SSergey Zigachev 	uint16_t us_ulv_voltage_offset;
557b843c749SSergey Zigachev 	uint16_t us_ulv_smnclk_did;
558b843c749SSergey Zigachev 	uint16_t us_ulv_mp1clk_did;
559b843c749SSergey Zigachev 	uint16_t us_ulv_gfxclk_bypass;
560b843c749SSergey Zigachev 	uint16_t us_gfxclk_slew_rate;
561b843c749SSergey Zigachev 	uint16_t us_min_gfxclk_freq_limit;
562b843c749SSergey Zigachev 
563b843c749SSergey Zigachev 	uint8_t  uc_gfx_dpm_voltage_mode;
564b843c749SSergey Zigachev 	uint8_t  uc_soc_dpm_voltage_mode;
565b843c749SSergey Zigachev 	uint8_t  uc_uclk_dpm_voltage_mode;
566b843c749SSergey Zigachev 	uint8_t  uc_uvd_dpm_voltage_mode;
567b843c749SSergey Zigachev 	uint8_t  uc_vce_dpm_voltage_mode;
568b843c749SSergey Zigachev 	uint8_t  uc_mp0_dpm_voltage_mode;
569b843c749SSergey Zigachev 	uint8_t  uc_dcef_dpm_voltage_mode;
570b843c749SSergey Zigachev };
571b843c749SSergey Zigachev 
572b843c749SSergey Zigachev struct phm_ppt_v3_information
573b843c749SSergey Zigachev {
574b843c749SSergey Zigachev 	uint8_t uc_thermal_controller_type;
575b843c749SSergey Zigachev 
576b843c749SSergey Zigachev 	uint16_t us_small_power_limit1;
577b843c749SSergey Zigachev 	uint16_t us_small_power_limit2;
578b843c749SSergey Zigachev 	uint16_t us_boost_power_limit;
579b843c749SSergey Zigachev 
580b843c749SSergey Zigachev 	uint16_t us_od_turbo_power_limit;
581b843c749SSergey Zigachev 	uint16_t us_od_powersave_power_limit;
582b843c749SSergey Zigachev 	uint16_t us_software_shutdown_temp;
583b843c749SSergey Zigachev 
584b843c749SSergey Zigachev 	uint32_t *power_saving_clock_max;
585b843c749SSergey Zigachev 	uint32_t *power_saving_clock_min;
586b843c749SSergey Zigachev 
587b843c749SSergey Zigachev 	uint32_t *od_settings_max;
588b843c749SSergey Zigachev 	uint32_t *od_settings_min;
589b843c749SSergey Zigachev 
590b843c749SSergey Zigachev 	void *smc_pptable;
591b843c749SSergey Zigachev };
592b843c749SSergey Zigachev 
593b843c749SSergey Zigachev struct phm_dynamic_state_info {
594b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk;
595b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddci_dependency_on_mclk;
596b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddc_dependency_on_mclk;
597b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *mvdd_dependency_on_mclk;
598b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl;
599b843c749SSergey Zigachev 	struct phm_clock_array                    *valid_sclk_values;
600b843c749SSergey Zigachev 	struct phm_clock_array                    *valid_mclk_values;
601b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits       max_clock_voltage_on_dc;
602b843c749SSergey Zigachev 	struct phm_clock_and_voltage_limits       max_clock_voltage_on_ac;
603b843c749SSergey Zigachev 	uint32_t                                  mclk_sclk_ratio;
604b843c749SSergey Zigachev 	uint32_t                                  sclk_mclk_delta;
605b843c749SSergey Zigachev 	uint32_t                                  vddc_vddci_delta;
606b843c749SSergey Zigachev 	uint32_t                                  min_vddc_for_pcie_gen2;
607b843c749SSergey Zigachev 	struct phm_cac_leakage_table              *cac_leakage_table;
608b843c749SSergey Zigachev 	struct phm_phase_shedding_limits_table  *vddc_phase_shed_limits_table;
609b843c749SSergey Zigachev 
610b843c749SSergey Zigachev 	struct phm_vce_clock_voltage_dependency_table
611b843c749SSergey Zigachev 					    *vce_clock_voltage_dependency_table;
612b843c749SSergey Zigachev 	struct phm_uvd_clock_voltage_dependency_table
613b843c749SSergey Zigachev 					    *uvd_clock_voltage_dependency_table;
614b843c749SSergey Zigachev 	struct phm_acp_clock_voltage_dependency_table
615b843c749SSergey Zigachev 					    *acp_clock_voltage_dependency_table;
616b843c749SSergey Zigachev 	struct phm_samu_clock_voltage_dependency_table
617b843c749SSergey Zigachev 					   *samu_clock_voltage_dependency_table;
618b843c749SSergey Zigachev 
619b843c749SSergey Zigachev 	struct phm_ppm_table                          *ppm_parameter_table;
620b843c749SSergey Zigachev 	struct phm_cac_tdp_table                      *cac_dtp_table;
621b843c749SSergey Zigachev 	struct phm_clock_voltage_dependency_table	*vdd_gfx_dependency_on_sclk;
622b843c749SSergey Zigachev };
623b843c749SSergey Zigachev 
624b843c749SSergey Zigachev struct pp_fan_info {
625b843c749SSergey Zigachev 	bool bNoFan;
626b843c749SSergey Zigachev 	uint8_t   ucTachometerPulsesPerRevolution;
627b843c749SSergey Zigachev 	uint32_t   ulMinRPM;
628b843c749SSergey Zigachev 	uint32_t   ulMaxRPM;
629b843c749SSergey Zigachev };
630b843c749SSergey Zigachev 
631b843c749SSergey Zigachev struct pp_advance_fan_control_parameters {
632b843c749SSergey Zigachev 	uint16_t  usTMin;                          /* The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. */
633b843c749SSergey Zigachev 	uint16_t  usTMed;                          /* The middle temperature where we change slopes. */
634b843c749SSergey Zigachev 	uint16_t  usTHigh;                         /* The high temperature for setting the second slope. */
635b843c749SSergey Zigachev 	uint16_t  usPWMMin;                        /* The minimum PWM value in percent (0.01% increments). */
636b843c749SSergey Zigachev 	uint16_t  usPWMMed;                        /* The PWM value (in percent) at TMed. */
637b843c749SSergey Zigachev 	uint16_t  usPWMHigh;                       /* The PWM value at THigh. */
638b843c749SSergey Zigachev 	uint8_t   ucTHyst;                         /* Temperature hysteresis. Integer. */
639b843c749SSergey Zigachev 	uint32_t   ulCycleDelay;                   /* The time between two invocations of the fan control routine in microseconds. */
640b843c749SSergey Zigachev 	uint16_t  usTMax;                          /* The max temperature */
641b843c749SSergey Zigachev 	uint8_t   ucFanControlMode;
642b843c749SSergey Zigachev 	uint16_t  usFanPWMMinLimit;
643b843c749SSergey Zigachev 	uint16_t  usFanPWMMaxLimit;
644b843c749SSergey Zigachev 	uint16_t  usFanPWMStep;
645b843c749SSergey Zigachev 	uint16_t  usDefaultMaxFanPWM;
646b843c749SSergey Zigachev 	uint16_t  usFanOutputSensitivity;
647b843c749SSergey Zigachev 	uint16_t  usDefaultFanOutputSensitivity;
648b843c749SSergey Zigachev 	uint16_t  usMaxFanPWM;                     /* The max Fan PWM value for Fuzzy Fan Control feature */
649b843c749SSergey Zigachev 	uint16_t  usFanRPMMinLimit;                /* Minimum limit range in percentage, need to calculate based on minRPM/MaxRpm */
650b843c749SSergey Zigachev 	uint16_t  usFanRPMMaxLimit;                /* Maximum limit range in percentage, usually set to 100% by default */
651b843c749SSergey Zigachev 	uint16_t  usFanRPMStep;                    /* Step increments/decerements, in percent */
652b843c749SSergey Zigachev 	uint16_t  usDefaultMaxFanRPM;              /* The max Fan RPM value for Fuzzy Fan Control feature, default from PPTable */
653b843c749SSergey Zigachev 	uint16_t  usMaxFanRPM;                     /* The max Fan RPM value for Fuzzy Fan Control feature, user defined */
654b843c749SSergey Zigachev 	uint16_t  usFanCurrentLow;                 /* Low current */
655b843c749SSergey Zigachev 	uint16_t  usFanCurrentHigh;                /* High current */
656b843c749SSergey Zigachev 	uint16_t  usFanRPMLow;                     /* Low RPM */
657b843c749SSergey Zigachev 	uint16_t  usFanRPMHigh;                    /* High RPM */
658b843c749SSergey Zigachev 	uint32_t   ulMinFanSCLKAcousticLimit;      /* Minimum Fan Controller SCLK Frequency Acoustic Limit. */
659b843c749SSergey Zigachev 	uint8_t   ucTargetTemperature;             /* Advanced fan controller target temperature. */
660b843c749SSergey Zigachev 	uint8_t   ucMinimumPWMLimit;               /* The minimum PWM that the advanced fan controller can set.  This should be set to the highest PWM that will run the fan at its lowest RPM. */
661b843c749SSergey Zigachev 	uint16_t  usFanGainEdge;                   /* The following is added for Fiji */
662b843c749SSergey Zigachev 	uint16_t  usFanGainHotspot;
663b843c749SSergey Zigachev 	uint16_t  usFanGainLiquid;
664b843c749SSergey Zigachev 	uint16_t  usFanGainVrVddc;
665b843c749SSergey Zigachev 	uint16_t  usFanGainVrMvdd;
666b843c749SSergey Zigachev 	uint16_t  usFanGainPlx;
667b843c749SSergey Zigachev 	uint16_t  usFanGainHbm;
668b843c749SSergey Zigachev 	uint8_t   ucEnableZeroRPM;
669b843c749SSergey Zigachev 	uint8_t   ucFanStopTemperature;
670b843c749SSergey Zigachev 	uint8_t   ucFanStartTemperature;
671b843c749SSergey Zigachev 	uint32_t  ulMaxFanSCLKAcousticLimit;       /* Maximum Fan Controller SCLK Frequency Acoustic Limit. */
672b843c749SSergey Zigachev 	uint32_t  ulTargetGfxClk;
673b843c749SSergey Zigachev 	uint16_t  usZeroRPMStartTemperature;
674b843c749SSergey Zigachev 	uint16_t  usZeroRPMStopTemperature;
675b843c749SSergey Zigachev };
676b843c749SSergey Zigachev 
677b843c749SSergey Zigachev struct pp_thermal_controller_info {
678b843c749SSergey Zigachev 	uint8_t ucType;
679b843c749SSergey Zigachev 	uint8_t ucI2cLine;
680b843c749SSergey Zigachev 	uint8_t ucI2cAddress;
681b843c749SSergey Zigachev 	uint8_t use_hw_fan_control;
682b843c749SSergey Zigachev 	struct pp_fan_info fanInfo;
683b843c749SSergey Zigachev 	struct pp_advance_fan_control_parameters advanceFanControlParameters;
684b843c749SSergey Zigachev };
685b843c749SSergey Zigachev 
686b843c749SSergey Zigachev struct phm_microcode_version_info {
687b843c749SSergey Zigachev 	uint32_t SMC;
688b843c749SSergey Zigachev 	uint32_t DMCU;
689b843c749SSergey Zigachev 	uint32_t MC;
690b843c749SSergey Zigachev 	uint32_t NB;
691b843c749SSergey Zigachev };
692b843c749SSergey Zigachev 
693b843c749SSergey Zigachev enum PP_TABLE_VERSION {
694b843c749SSergey Zigachev 	PP_TABLE_V0 = 0,
695b843c749SSergey Zigachev 	PP_TABLE_V1,
696b843c749SSergey Zigachev 	PP_TABLE_V2,
697b843c749SSergey Zigachev 	PP_TABLE_MAX
698b843c749SSergey Zigachev };
699b843c749SSergey Zigachev 
700b843c749SSergey Zigachev /**
701b843c749SSergey Zigachev  * The main hardware manager structure.
702b843c749SSergey Zigachev  */
703b843c749SSergey Zigachev #define Workload_Policy_Max 5
704b843c749SSergey Zigachev 
705b843c749SSergey Zigachev struct pp_hwmgr {
706b843c749SSergey Zigachev 	void *adev;
707b843c749SSergey Zigachev 	uint32_t chip_family;
708b843c749SSergey Zigachev 	uint32_t chip_id;
709b843c749SSergey Zigachev 	uint32_t smu_version;
710b843c749SSergey Zigachev 	bool not_vf;
711b843c749SSergey Zigachev 	bool pm_en;
712*78973132SSergey Zigachev 	struct lock smu_lock;
713b843c749SSergey Zigachev 
714b843c749SSergey Zigachev 	uint32_t pp_table_version;
715b843c749SSergey Zigachev 	void *device;
716b843c749SSergey Zigachev 	struct pp_smumgr *smumgr;
717b843c749SSergey Zigachev 	const void *soft_pp_table;
718b843c749SSergey Zigachev 	uint32_t soft_pp_table_size;
719b843c749SSergey Zigachev 	void *hardcode_pp_table;
720b843c749SSergey Zigachev 	bool need_pp_table_upload;
721b843c749SSergey Zigachev 
722b843c749SSergey Zigachev 	struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS];
723b843c749SSergey Zigachev 	uint32_t num_vce_state_tables;
724b843c749SSergey Zigachev 
725b843c749SSergey Zigachev 	enum amd_dpm_forced_level dpm_level;
726b843c749SSergey Zigachev 	enum amd_dpm_forced_level saved_dpm_level;
727b843c749SSergey Zigachev 	enum amd_dpm_forced_level request_dpm_level;
728b843c749SSergey Zigachev 	uint32_t usec_timeout;
729b843c749SSergey Zigachev 	void *pptable;
730b843c749SSergey Zigachev 	struct phm_platform_descriptor platform_descriptor;
731b843c749SSergey Zigachev 	void *backend;
732b843c749SSergey Zigachev 
733b843c749SSergey Zigachev 	void *smu_backend;
734b843c749SSergey Zigachev 	const struct pp_smumgr_func *smumgr_funcs;
735b843c749SSergey Zigachev 	bool is_kicker;
736b843c749SSergey Zigachev 	bool reload_fw;
737b843c749SSergey Zigachev 
738b843c749SSergey Zigachev 	enum PP_DAL_POWERLEVEL dal_power_level;
739b843c749SSergey Zigachev 	struct phm_dynamic_state_info dyn_state;
740b843c749SSergey Zigachev 	const struct pp_hwmgr_func *hwmgr_func;
741b843c749SSergey Zigachev 	const struct pp_table_func *pptable_func;
742b843c749SSergey Zigachev 
743b843c749SSergey Zigachev 	struct pp_power_state    *ps;
744b843c749SSergey Zigachev 	uint32_t num_ps;
745b843c749SSergey Zigachev 	struct pp_thermal_controller_info thermal_controller;
746b843c749SSergey Zigachev 	bool fan_ctrl_is_in_default_mode;
747b843c749SSergey Zigachev 	uint32_t fan_ctrl_default_mode;
748b843c749SSergey Zigachev 	bool fan_ctrl_enabled;
749b843c749SSergey Zigachev 	uint32_t tmin;
750b843c749SSergey Zigachev 	struct phm_microcode_version_info microcode_version_info;
751b843c749SSergey Zigachev 	uint32_t ps_size;
752b843c749SSergey Zigachev 	struct pp_power_state    *current_ps;
753b843c749SSergey Zigachev 	struct pp_power_state    *request_ps;
754b843c749SSergey Zigachev 	struct pp_power_state    *boot_ps;
755b843c749SSergey Zigachev 	struct pp_power_state    *uvd_ps;
756b843c749SSergey Zigachev 	const struct amd_pp_display_configuration *display_config;
757b843c749SSergey Zigachev 	uint32_t feature_mask;
758b843c749SSergey Zigachev 	bool avfs_supported;
759b843c749SSergey Zigachev 	/* UMD Pstate */
760b843c749SSergey Zigachev 	bool en_umd_pstate;
761b843c749SSergey Zigachev 	uint32_t power_profile_mode;
762b843c749SSergey Zigachev 	uint32_t default_power_profile_mode;
763b843c749SSergey Zigachev 	uint32_t pstate_sclk;
764b843c749SSergey Zigachev 	uint32_t pstate_mclk;
765b843c749SSergey Zigachev 	bool od_enabled;
766b843c749SSergey Zigachev 	uint32_t power_limit;
767b843c749SSergey Zigachev 	uint32_t default_power_limit;
768b843c749SSergey Zigachev 	uint32_t workload_mask;
769b843c749SSergey Zigachev 	uint32_t workload_prority[Workload_Policy_Max];
770b843c749SSergey Zigachev 	uint32_t workload_setting[Workload_Policy_Max];
771b843c749SSergey Zigachev };
772b843c749SSergey Zigachev 
773b843c749SSergey Zigachev int hwmgr_early_init(struct pp_hwmgr *hwmgr);
774b843c749SSergey Zigachev int hwmgr_sw_init(struct pp_hwmgr *hwmgr);
775b843c749SSergey Zigachev int hwmgr_sw_fini(struct pp_hwmgr *hwmgr);
776b843c749SSergey Zigachev int hwmgr_hw_init(struct pp_hwmgr *hwmgr);
777b843c749SSergey Zigachev int hwmgr_hw_fini(struct pp_hwmgr *hwmgr);
778b843c749SSergey Zigachev int hwmgr_suspend(struct pp_hwmgr *hwmgr);
779b843c749SSergey Zigachev int hwmgr_resume(struct pp_hwmgr *hwmgr);
780b843c749SSergey Zigachev 
781b843c749SSergey Zigachev int hwmgr_handle_task(struct pp_hwmgr *hwmgr,
782b843c749SSergey Zigachev 				enum amd_pp_task task_id,
783b843c749SSergey Zigachev 				enum amd_pm_state_type *user_state);
784b843c749SSergey Zigachev 
785b843c749SSergey Zigachev 
786b843c749SSergey Zigachev #define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU
787b843c749SSergey Zigachev 
788b843c749SSergey Zigachev 
789b843c749SSergey Zigachev #endif /* _HWMGR_H_ */
790