1 1.2 riastrad /* $NetBSD: kv_dpm.h,v 1.3 2021/12/18 23:45:42 riastradh Exp $ */ 2 1.2 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2013 Advanced Micro Devices, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad * 24 1.1 riastrad */ 25 1.1 riastrad #ifndef __KV_DPM_H__ 26 1.1 riastrad #define __KV_DPM_H__ 27 1.1 riastrad 28 1.1 riastrad #define SMU__NUM_SCLK_DPM_STATE 8 29 1.1 riastrad #define SMU__NUM_MCLK_DPM_LEVELS 4 30 1.1 riastrad #define SMU__NUM_LCLK_DPM_LEVELS 8 31 1.1 riastrad #define SMU__NUM_PCIE_DPM_LEVELS 0 /* ??? */ 32 1.1 riastrad #include "smu7_fusion.h" 33 1.1 riastrad #include "trinity_dpm.h" 34 1.1 riastrad #include "ppsmc.h" 35 1.1 riastrad 36 1.1 riastrad #define KV_NUM_NBPSTATES 4 37 1.1 riastrad 38 1.1 riastrad enum kv_pt_config_reg_type { 39 1.1 riastrad KV_CONFIGREG_MMR = 0, 40 1.1 riastrad KV_CONFIGREG_SMC_IND, 41 1.1 riastrad KV_CONFIGREG_DIDT_IND, 42 1.1 riastrad KV_CONFIGREG_CACHE, 43 1.1 riastrad KV_CONFIGREG_MAX 44 1.1 riastrad }; 45 1.1 riastrad 46 1.1 riastrad struct kv_pt_config_reg { 47 1.1 riastrad u32 offset; 48 1.1 riastrad u32 mask; 49 1.1 riastrad u32 shift; 50 1.1 riastrad u32 value; 51 1.1 riastrad enum kv_pt_config_reg_type type; 52 1.1 riastrad }; 53 1.1 riastrad 54 1.1 riastrad struct kv_lcac_config_values { 55 1.1 riastrad u32 block_id; 56 1.1 riastrad u32 signal_id; 57 1.1 riastrad u32 t; 58 1.1 riastrad }; 59 1.1 riastrad 60 1.1 riastrad struct kv_lcac_config_reg { 61 1.1 riastrad u32 cntl; 62 1.1 riastrad u32 block_mask; 63 1.1 riastrad u32 block_shift; 64 1.1 riastrad u32 signal_mask; 65 1.1 riastrad u32 signal_shift; 66 1.1 riastrad u32 t_mask; 67 1.1 riastrad u32 t_shift; 68 1.1 riastrad u32 enable_mask; 69 1.1 riastrad u32 enable_shift; 70 1.1 riastrad }; 71 1.1 riastrad 72 1.1 riastrad struct kv_pl { 73 1.1 riastrad u32 sclk; 74 1.1 riastrad u8 vddc_index; 75 1.1 riastrad u8 ds_divider_index; 76 1.1 riastrad u8 ss_divider_index; 77 1.1 riastrad u8 allow_gnb_slow; 78 1.1 riastrad u8 force_nbp_state; 79 1.1 riastrad u8 display_wm; 80 1.1 riastrad u8 vce_wm; 81 1.1 riastrad }; 82 1.1 riastrad 83 1.1 riastrad struct kv_ps { 84 1.1 riastrad struct kv_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS]; 85 1.1 riastrad u32 num_levels; 86 1.1 riastrad bool need_dfs_bypass; 87 1.1 riastrad u8 dpm0_pg_nb_ps_lo; 88 1.1 riastrad u8 dpm0_pg_nb_ps_hi; 89 1.1 riastrad u8 dpmx_nb_ps_lo; 90 1.1 riastrad u8 dpmx_nb_ps_hi; 91 1.1 riastrad }; 92 1.1 riastrad 93 1.1 riastrad struct kv_sys_info { 94 1.1 riastrad u32 bootup_uma_clk; 95 1.1 riastrad u32 bootup_sclk; 96 1.1 riastrad u32 dentist_vco_freq; 97 1.1 riastrad u32 nb_dpm_enable; 98 1.1 riastrad u32 nbp_memory_clock[KV_NUM_NBPSTATES]; 99 1.1 riastrad u32 nbp_n_clock[KV_NUM_NBPSTATES]; 100 1.1 riastrad u16 bootup_nb_voltage_index; 101 1.1 riastrad u8 htc_tmp_lmt; 102 1.1 riastrad u8 htc_hyst_lmt; 103 1.1 riastrad struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table; 104 1.1 riastrad struct sumo_vid_mapping_table vid_mapping_table; 105 1.1 riastrad u32 uma_channel_number; 106 1.1 riastrad }; 107 1.1 riastrad 108 1.1 riastrad struct kv_power_info { 109 1.1 riastrad u32 at[SUMO_MAX_HARDWARE_POWERLEVELS]; 110 1.1 riastrad u32 voltage_drop_t; 111 1.1 riastrad struct kv_sys_info sys_info; 112 1.1 riastrad struct kv_pl boot_pl; 113 1.1 riastrad bool enable_nb_ps_policy; 114 1.1 riastrad bool disable_nb_ps3_in_battery; 115 1.1 riastrad bool video_start; 116 1.1 riastrad bool battery_state; 117 1.1 riastrad u32 lowest_valid; 118 1.1 riastrad u32 highest_valid; 119 1.1 riastrad u16 high_voltage_t; 120 1.1 riastrad bool cac_enabled; 121 1.1 riastrad bool bapm_enable; 122 1.1 riastrad /* smc offsets */ 123 1.1 riastrad u32 sram_end; 124 1.1 riastrad u32 dpm_table_start; 125 1.1 riastrad u32 soft_regs_start; 126 1.1 riastrad /* dpm SMU tables */ 127 1.1 riastrad u8 graphics_dpm_level_count; 128 1.1 riastrad u8 uvd_level_count; 129 1.1 riastrad u8 vce_level_count; 130 1.1 riastrad u8 acp_level_count; 131 1.1 riastrad u8 samu_level_count; 132 1.1 riastrad u16 fps_high_t; 133 1.1 riastrad SMU7_Fusion_GraphicsLevel graphics_level[SMU__NUM_SCLK_DPM_STATE]; 134 1.1 riastrad SMU7_Fusion_ACPILevel acpi_level; 135 1.1 riastrad SMU7_Fusion_UvdLevel uvd_level[SMU7_MAX_LEVELS_UVD]; 136 1.1 riastrad SMU7_Fusion_ExtClkLevel vce_level[SMU7_MAX_LEVELS_VCE]; 137 1.1 riastrad SMU7_Fusion_ExtClkLevel acp_level[SMU7_MAX_LEVELS_ACP]; 138 1.1 riastrad SMU7_Fusion_ExtClkLevel samu_level[SMU7_MAX_LEVELS_SAMU]; 139 1.1 riastrad u8 uvd_boot_level; 140 1.1 riastrad u8 vce_boot_level; 141 1.1 riastrad u8 acp_boot_level; 142 1.1 riastrad u8 samu_boot_level; 143 1.1 riastrad u8 uvd_interval; 144 1.1 riastrad u8 vce_interval; 145 1.1 riastrad u8 acp_interval; 146 1.1 riastrad u8 samu_interval; 147 1.1 riastrad u8 graphics_boot_level; 148 1.1 riastrad u8 graphics_interval; 149 1.1 riastrad u8 graphics_therm_throttle_enable; 150 1.1 riastrad u8 graphics_voltage_change_enable; 151 1.1 riastrad u8 graphics_clk_slow_enable; 152 1.1 riastrad u8 graphics_clk_slow_divider; 153 1.1 riastrad u8 fps_low_t; 154 1.1 riastrad u32 low_sclk_interrupt_t; 155 1.1 riastrad bool uvd_power_gated; 156 1.1 riastrad bool vce_power_gated; 157 1.1 riastrad bool acp_power_gated; 158 1.1 riastrad bool samu_power_gated; 159 1.1 riastrad bool nb_dpm_enabled; 160 1.1 riastrad /* flags */ 161 1.1 riastrad bool enable_didt; 162 1.1 riastrad bool enable_dpm; 163 1.1 riastrad bool enable_auto_thermal_throttling; 164 1.1 riastrad bool enable_nb_dpm; 165 1.1 riastrad /* caps */ 166 1.1 riastrad bool caps_cac; 167 1.1 riastrad bool caps_power_containment; 168 1.1 riastrad bool caps_sq_ramping; 169 1.1 riastrad bool caps_db_ramping; 170 1.1 riastrad bool caps_td_ramping; 171 1.1 riastrad bool caps_tcp_ramping; 172 1.1 riastrad bool caps_sclk_throttle_low_notification; 173 1.1 riastrad bool caps_fps; 174 1.1 riastrad bool caps_uvd_dpm; 175 1.1 riastrad bool caps_uvd_pg; 176 1.1 riastrad bool caps_vce_pg; 177 1.1 riastrad bool caps_samu_pg; 178 1.1 riastrad bool caps_acp_pg; 179 1.1 riastrad bool caps_stable_p_state; 180 1.1 riastrad bool caps_enable_dfs_bypass; 181 1.1 riastrad bool caps_sclk_ds; 182 1.1 riastrad struct radeon_ps current_rps; 183 1.1 riastrad struct kv_ps current_ps; 184 1.1 riastrad struct radeon_ps requested_rps; 185 1.1 riastrad struct kv_ps requested_ps; 186 1.1 riastrad }; 187 1.1 riastrad 188 1.1 riastrad 189 1.1 riastrad /* kv_smc.c */ 190 1.1 riastrad int kv_notify_message_to_smu(struct radeon_device *rdev, u32 id); 191 1.1 riastrad int kv_dpm_get_enable_mask(struct radeon_device *rdev, u32 *enable_mask); 192 1.1 riastrad int kv_send_msg_to_smc_with_parameter(struct radeon_device *rdev, 193 1.1 riastrad PPSMC_Msg msg, u32 parameter); 194 1.1 riastrad int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, 195 1.1 riastrad u32 *value, u32 limit); 196 1.1 riastrad int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable); 197 1.1 riastrad int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable); 198 1.1 riastrad int kv_copy_bytes_to_smc(struct radeon_device *rdev, 199 1.1 riastrad u32 smc_start_address, 200 1.1 riastrad const u8 *src, u32 byte_count, u32 limit); 201 1.1 riastrad 202 1.1 riastrad #endif 203