18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef __TRINITY_DPM_H__
248c2ecf20Sopenharmony_ci#define __TRINITY_DPM_H__
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "sumo_dpm.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define TRINITY_SIZEOF_DPM_STATE_TABLE (SMU_SCLK_DPM_STATE_1_CNTL_0 - SMU_SCLK_DPM_STATE_0_CNTL_0)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct trinity_pl {
318c2ecf20Sopenharmony_ci	u32 sclk;
328c2ecf20Sopenharmony_ci	u8 vddc_index;
338c2ecf20Sopenharmony_ci	u8 ds_divider_index;
348c2ecf20Sopenharmony_ci	u8 ss_divider_index;
358c2ecf20Sopenharmony_ci	u8 allow_gnb_slow;
368c2ecf20Sopenharmony_ci	u8 force_nbp_state;
378c2ecf20Sopenharmony_ci	u8 display_wm;
388c2ecf20Sopenharmony_ci	u8 vce_wm;
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define TRINITY_POWERSTATE_FLAGS_NBPS_FORCEHIGH  (1 << 0)
428c2ecf20Sopenharmony_ci#define TRINITY_POWERSTATE_FLAGS_NBPS_LOCKTOHIGH (1 << 1)
438c2ecf20Sopenharmony_ci#define TRINITY_POWERSTATE_FLAGS_NBPS_LOCKTOLOW  (1 << 2)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define TRINITY_POWERSTATE_FLAGS_BAPM_DISABLE    (1 << 0)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistruct trinity_ps {
488c2ecf20Sopenharmony_ci	u32 num_levels;
498c2ecf20Sopenharmony_ci	struct trinity_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS];
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	u32 nbps_flags;
528c2ecf20Sopenharmony_ci	u32 bapm_flags;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	u8 Dpm0PgNbPsLo;
558c2ecf20Sopenharmony_ci	u8 Dpm0PgNbPsHi;
568c2ecf20Sopenharmony_ci	u8 DpmXNbPsLo;
578c2ecf20Sopenharmony_ci	u8 DpmXNbPsHi;
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	u32 vclk_low_divider;
608c2ecf20Sopenharmony_ci	u32 vclk_high_divider;
618c2ecf20Sopenharmony_ci	u32 dclk_low_divider;
628c2ecf20Sopenharmony_ci	u32 dclk_high_divider;
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define TRINITY_NUM_NBPSTATES   4
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistruct trinity_uvd_clock_table_entry
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	u32 vclk;
708c2ecf20Sopenharmony_ci	u32 dclk;
718c2ecf20Sopenharmony_ci	u8 vclk_did;
728c2ecf20Sopenharmony_ci	u8 dclk_did;
738c2ecf20Sopenharmony_ci	u8 rsv[2];
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistruct trinity_sys_info {
778c2ecf20Sopenharmony_ci	u32 bootup_uma_clk;
788c2ecf20Sopenharmony_ci	u32 bootup_sclk;
798c2ecf20Sopenharmony_ci	u32 min_sclk;
808c2ecf20Sopenharmony_ci	u32 dentist_vco_freq;
818c2ecf20Sopenharmony_ci	u32 nb_dpm_enable;
828c2ecf20Sopenharmony_ci	u32 nbp_mclk[TRINITY_NUM_NBPSTATES];
838c2ecf20Sopenharmony_ci	u32 nbp_nclk[TRINITY_NUM_NBPSTATES];
848c2ecf20Sopenharmony_ci	u16 nbp_voltage_index[TRINITY_NUM_NBPSTATES];
858c2ecf20Sopenharmony_ci	u16 bootup_nb_voltage_index;
868c2ecf20Sopenharmony_ci	u8 htc_tmp_lmt;
878c2ecf20Sopenharmony_ci	u8 htc_hyst_lmt;
888c2ecf20Sopenharmony_ci	struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table;
898c2ecf20Sopenharmony_ci	struct sumo_vid_mapping_table vid_mapping_table;
908c2ecf20Sopenharmony_ci	u32 uma_channel_number;
918c2ecf20Sopenharmony_ci	struct trinity_uvd_clock_table_entry uvd_clock_table_entries[4];
928c2ecf20Sopenharmony_ci};
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistruct trinity_power_info {
958c2ecf20Sopenharmony_ci	u32 at[SUMO_MAX_HARDWARE_POWERLEVELS];
968c2ecf20Sopenharmony_ci	u32 dpm_interval;
978c2ecf20Sopenharmony_ci	u32 thermal_auto_throttling;
988c2ecf20Sopenharmony_ci	struct trinity_sys_info sys_info;
998c2ecf20Sopenharmony_ci	struct trinity_pl boot_pl;
1008c2ecf20Sopenharmony_ci	u32 min_sclk_did;
1018c2ecf20Sopenharmony_ci	bool enable_nbps_policy;
1028c2ecf20Sopenharmony_ci	bool voltage_drop_in_dce;
1038c2ecf20Sopenharmony_ci	bool override_dynamic_mgpg;
1048c2ecf20Sopenharmony_ci	bool enable_gfx_clock_gating;
1058c2ecf20Sopenharmony_ci	bool enable_gfx_power_gating;
1068c2ecf20Sopenharmony_ci	bool enable_mg_clock_gating;
1078c2ecf20Sopenharmony_ci	bool enable_gfx_dynamic_mgpg;
1088c2ecf20Sopenharmony_ci	bool enable_auto_thermal_throttling;
1098c2ecf20Sopenharmony_ci	bool enable_dpm;
1108c2ecf20Sopenharmony_ci	bool enable_sclk_ds;
1118c2ecf20Sopenharmony_ci	bool enable_bapm;
1128c2ecf20Sopenharmony_ci	bool uvd_dpm;
1138c2ecf20Sopenharmony_ci	struct radeon_ps current_rps;
1148c2ecf20Sopenharmony_ci	struct trinity_ps current_ps;
1158c2ecf20Sopenharmony_ci	struct radeon_ps requested_rps;
1168c2ecf20Sopenharmony_ci	struct trinity_ps requested_ps;
1178c2ecf20Sopenharmony_ci};
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define TRINITY_AT_DFLT            30
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* trinity_smc.c */
1228c2ecf20Sopenharmony_ciint trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable);
1238c2ecf20Sopenharmony_ciint trinity_dpm_config(struct radeon_device *rdev, bool enable);
1248c2ecf20Sopenharmony_ciint trinity_uvd_dpm_config(struct radeon_device *rdev);
1258c2ecf20Sopenharmony_ciint trinity_dpm_force_state(struct radeon_device *rdev, u32 n);
1268c2ecf20Sopenharmony_ciint trinity_dpm_n_levels_disabled(struct radeon_device *rdev, u32 n);
1278c2ecf20Sopenharmony_ciint trinity_dpm_no_forced_level(struct radeon_device *rdev);
1288c2ecf20Sopenharmony_ciint trinity_dce_enable_voltage_adjustment(struct radeon_device *rdev,
1298c2ecf20Sopenharmony_ci					  bool enable);
1308c2ecf20Sopenharmony_ciint trinity_gfx_dynamic_mgpg_config(struct radeon_device *rdev);
1318c2ecf20Sopenharmony_civoid trinity_acquire_mutex(struct radeon_device *rdev);
1328c2ecf20Sopenharmony_civoid trinity_release_mutex(struct radeon_device *rdev);
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#endif
135