18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2013 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 __KV_DPM_H__ 248c2ecf20Sopenharmony_ci#define __KV_DPM_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define SMU__NUM_SCLK_DPM_STATE 8 278c2ecf20Sopenharmony_ci#define SMU__NUM_MCLK_DPM_LEVELS 4 288c2ecf20Sopenharmony_ci#define SMU__NUM_LCLK_DPM_LEVELS 8 298c2ecf20Sopenharmony_ci#define SMU__NUM_PCIE_DPM_LEVELS 0 /* ??? */ 308c2ecf20Sopenharmony_ci#include "smu7_fusion.h" 318c2ecf20Sopenharmony_ci#include "trinity_dpm.h" 328c2ecf20Sopenharmony_ci#include "ppsmc.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define KV_NUM_NBPSTATES 4 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cienum kv_pt_config_reg_type { 378c2ecf20Sopenharmony_ci KV_CONFIGREG_MMR = 0, 388c2ecf20Sopenharmony_ci KV_CONFIGREG_SMC_IND, 398c2ecf20Sopenharmony_ci KV_CONFIGREG_DIDT_IND, 408c2ecf20Sopenharmony_ci KV_CONFIGREG_CACHE, 418c2ecf20Sopenharmony_ci KV_CONFIGREG_MAX 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct kv_pt_config_reg { 458c2ecf20Sopenharmony_ci u32 offset; 468c2ecf20Sopenharmony_ci u32 mask; 478c2ecf20Sopenharmony_ci u32 shift; 488c2ecf20Sopenharmony_ci u32 value; 498c2ecf20Sopenharmony_ci enum kv_pt_config_reg_type type; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct kv_lcac_config_values { 538c2ecf20Sopenharmony_ci u32 block_id; 548c2ecf20Sopenharmony_ci u32 signal_id; 558c2ecf20Sopenharmony_ci u32 t; 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct kv_lcac_config_reg { 598c2ecf20Sopenharmony_ci u32 cntl; 608c2ecf20Sopenharmony_ci u32 block_mask; 618c2ecf20Sopenharmony_ci u32 block_shift; 628c2ecf20Sopenharmony_ci u32 signal_mask; 638c2ecf20Sopenharmony_ci u32 signal_shift; 648c2ecf20Sopenharmony_ci u32 t_mask; 658c2ecf20Sopenharmony_ci u32 t_shift; 668c2ecf20Sopenharmony_ci u32 enable_mask; 678c2ecf20Sopenharmony_ci u32 enable_shift; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct kv_pl { 718c2ecf20Sopenharmony_ci u32 sclk; 728c2ecf20Sopenharmony_ci u8 vddc_index; 738c2ecf20Sopenharmony_ci u8 ds_divider_index; 748c2ecf20Sopenharmony_ci u8 ss_divider_index; 758c2ecf20Sopenharmony_ci u8 allow_gnb_slow; 768c2ecf20Sopenharmony_ci u8 force_nbp_state; 778c2ecf20Sopenharmony_ci u8 display_wm; 788c2ecf20Sopenharmony_ci u8 vce_wm; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct kv_ps { 828c2ecf20Sopenharmony_ci struct kv_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS]; 838c2ecf20Sopenharmony_ci u32 num_levels; 848c2ecf20Sopenharmony_ci bool need_dfs_bypass; 858c2ecf20Sopenharmony_ci u8 dpm0_pg_nb_ps_lo; 868c2ecf20Sopenharmony_ci u8 dpm0_pg_nb_ps_hi; 878c2ecf20Sopenharmony_ci u8 dpmx_nb_ps_lo; 888c2ecf20Sopenharmony_ci u8 dpmx_nb_ps_hi; 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistruct kv_sys_info { 928c2ecf20Sopenharmony_ci u32 bootup_uma_clk; 938c2ecf20Sopenharmony_ci u32 bootup_sclk; 948c2ecf20Sopenharmony_ci u32 dentist_vco_freq; 958c2ecf20Sopenharmony_ci u32 nb_dpm_enable; 968c2ecf20Sopenharmony_ci u32 nbp_memory_clock[KV_NUM_NBPSTATES]; 978c2ecf20Sopenharmony_ci u32 nbp_n_clock[KV_NUM_NBPSTATES]; 988c2ecf20Sopenharmony_ci u16 bootup_nb_voltage_index; 998c2ecf20Sopenharmony_ci u8 htc_tmp_lmt; 1008c2ecf20Sopenharmony_ci u8 htc_hyst_lmt; 1018c2ecf20Sopenharmony_ci struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table; 1028c2ecf20Sopenharmony_ci struct sumo_vid_mapping_table vid_mapping_table; 1038c2ecf20Sopenharmony_ci u32 uma_channel_number; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct kv_power_info { 1078c2ecf20Sopenharmony_ci u32 at[SUMO_MAX_HARDWARE_POWERLEVELS]; 1088c2ecf20Sopenharmony_ci u32 voltage_drop_t; 1098c2ecf20Sopenharmony_ci struct kv_sys_info sys_info; 1108c2ecf20Sopenharmony_ci struct kv_pl boot_pl; 1118c2ecf20Sopenharmony_ci bool enable_nb_ps_policy; 1128c2ecf20Sopenharmony_ci bool disable_nb_ps3_in_battery; 1138c2ecf20Sopenharmony_ci bool video_start; 1148c2ecf20Sopenharmony_ci bool battery_state; 1158c2ecf20Sopenharmony_ci u32 lowest_valid; 1168c2ecf20Sopenharmony_ci u32 highest_valid; 1178c2ecf20Sopenharmony_ci u16 high_voltage_t; 1188c2ecf20Sopenharmony_ci bool cac_enabled; 1198c2ecf20Sopenharmony_ci bool bapm_enable; 1208c2ecf20Sopenharmony_ci /* smc offsets */ 1218c2ecf20Sopenharmony_ci u32 sram_end; 1228c2ecf20Sopenharmony_ci u32 dpm_table_start; 1238c2ecf20Sopenharmony_ci u32 soft_regs_start; 1248c2ecf20Sopenharmony_ci /* dpm SMU tables */ 1258c2ecf20Sopenharmony_ci u8 graphics_dpm_level_count; 1268c2ecf20Sopenharmony_ci u8 uvd_level_count; 1278c2ecf20Sopenharmony_ci u8 vce_level_count; 1288c2ecf20Sopenharmony_ci u8 acp_level_count; 1298c2ecf20Sopenharmony_ci u8 samu_level_count; 1308c2ecf20Sopenharmony_ci u16 fps_high_t; 1318c2ecf20Sopenharmony_ci SMU7_Fusion_GraphicsLevel graphics_level[SMU__NUM_SCLK_DPM_STATE]; 1328c2ecf20Sopenharmony_ci SMU7_Fusion_ACPILevel acpi_level; 1338c2ecf20Sopenharmony_ci SMU7_Fusion_UvdLevel uvd_level[SMU7_MAX_LEVELS_UVD]; 1348c2ecf20Sopenharmony_ci SMU7_Fusion_ExtClkLevel vce_level[SMU7_MAX_LEVELS_VCE]; 1358c2ecf20Sopenharmony_ci SMU7_Fusion_ExtClkLevel acp_level[SMU7_MAX_LEVELS_ACP]; 1368c2ecf20Sopenharmony_ci SMU7_Fusion_ExtClkLevel samu_level[SMU7_MAX_LEVELS_SAMU]; 1378c2ecf20Sopenharmony_ci u8 uvd_boot_level; 1388c2ecf20Sopenharmony_ci u8 vce_boot_level; 1398c2ecf20Sopenharmony_ci u8 acp_boot_level; 1408c2ecf20Sopenharmony_ci u8 samu_boot_level; 1418c2ecf20Sopenharmony_ci u8 uvd_interval; 1428c2ecf20Sopenharmony_ci u8 vce_interval; 1438c2ecf20Sopenharmony_ci u8 acp_interval; 1448c2ecf20Sopenharmony_ci u8 samu_interval; 1458c2ecf20Sopenharmony_ci u8 graphics_boot_level; 1468c2ecf20Sopenharmony_ci u8 graphics_interval; 1478c2ecf20Sopenharmony_ci u8 graphics_therm_throttle_enable; 1488c2ecf20Sopenharmony_ci u8 graphics_voltage_change_enable; 1498c2ecf20Sopenharmony_ci u8 graphics_clk_slow_enable; 1508c2ecf20Sopenharmony_ci u8 graphics_clk_slow_divider; 1518c2ecf20Sopenharmony_ci u8 fps_low_t; 1528c2ecf20Sopenharmony_ci u32 low_sclk_interrupt_t; 1538c2ecf20Sopenharmony_ci bool uvd_power_gated; 1548c2ecf20Sopenharmony_ci bool vce_power_gated; 1558c2ecf20Sopenharmony_ci bool acp_power_gated; 1568c2ecf20Sopenharmony_ci bool samu_power_gated; 1578c2ecf20Sopenharmony_ci bool nb_dpm_enabled; 1588c2ecf20Sopenharmony_ci /* flags */ 1598c2ecf20Sopenharmony_ci bool enable_didt; 1608c2ecf20Sopenharmony_ci bool enable_dpm; 1618c2ecf20Sopenharmony_ci bool enable_auto_thermal_throttling; 1628c2ecf20Sopenharmony_ci bool enable_nb_dpm; 1638c2ecf20Sopenharmony_ci /* caps */ 1648c2ecf20Sopenharmony_ci bool caps_cac; 1658c2ecf20Sopenharmony_ci bool caps_power_containment; 1668c2ecf20Sopenharmony_ci bool caps_sq_ramping; 1678c2ecf20Sopenharmony_ci bool caps_db_ramping; 1688c2ecf20Sopenharmony_ci bool caps_td_ramping; 1698c2ecf20Sopenharmony_ci bool caps_tcp_ramping; 1708c2ecf20Sopenharmony_ci bool caps_sclk_throttle_low_notification; 1718c2ecf20Sopenharmony_ci bool caps_fps; 1728c2ecf20Sopenharmony_ci bool caps_uvd_dpm; 1738c2ecf20Sopenharmony_ci bool caps_uvd_pg; 1748c2ecf20Sopenharmony_ci bool caps_vce_pg; 1758c2ecf20Sopenharmony_ci bool caps_samu_pg; 1768c2ecf20Sopenharmony_ci bool caps_acp_pg; 1778c2ecf20Sopenharmony_ci bool caps_stable_p_state; 1788c2ecf20Sopenharmony_ci bool caps_enable_dfs_bypass; 1798c2ecf20Sopenharmony_ci bool caps_sclk_ds; 1808c2ecf20Sopenharmony_ci struct radeon_ps current_rps; 1818c2ecf20Sopenharmony_ci struct kv_ps current_ps; 1828c2ecf20Sopenharmony_ci struct radeon_ps requested_rps; 1838c2ecf20Sopenharmony_ci struct kv_ps requested_ps; 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* kv_smc.c */ 1888c2ecf20Sopenharmony_ciint kv_notify_message_to_smu(struct radeon_device *rdev, u32 id); 1898c2ecf20Sopenharmony_ciint kv_dpm_get_enable_mask(struct radeon_device *rdev, u32 *enable_mask); 1908c2ecf20Sopenharmony_ciint kv_send_msg_to_smc_with_parameter(struct radeon_device *rdev, 1918c2ecf20Sopenharmony_ci PPSMC_Msg msg, u32 parameter); 1928c2ecf20Sopenharmony_ciint kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, 1938c2ecf20Sopenharmony_ci u32 *value, u32 limit); 1948c2ecf20Sopenharmony_ciint kv_smc_dpm_enable(struct radeon_device *rdev, bool enable); 1958c2ecf20Sopenharmony_ciint kv_smc_bapm_enable(struct radeon_device *rdev, bool enable); 1968c2ecf20Sopenharmony_ciint kv_copy_bytes_to_smc(struct radeon_device *rdev, 1978c2ecf20Sopenharmony_ci u32 smc_start_address, 1988c2ecf20Sopenharmony_ci const u8 *src, u32 byte_count, u32 limit); 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#endif 201