2 * Copyright 2019 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef __AMDGPU_SMU_H__
23 #define __AMDGPU_SMU_H__
26 #include "kgd_pp_interface.h"
27 #include "dm_pp_interface.h"
28 #include "dm_pp_smu.h"
29 #include "smu_types.h"
31 #define SMU_THERMAL_MINIMUM_ALERT_TEMP 0
32 #define SMU_THERMAL_MAXIMUM_ALERT_TEMP 255
33 #define SMU_TEMPERATURE_UNITS_PER_CENTIGRADES 1000
34 #define SMU_FW_NAME_LEN 0x24
36 #define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)
38 struct smu_hw_power_state {
42 struct smu_power_state;
44 enum smu_state_ui_label {
45 SMU_STATE_UI_LABEL_NONE,
46 SMU_STATE_UI_LABEL_BATTERY,
47 SMU_STATE_UI_TABEL_MIDDLE_LOW,
48 SMU_STATE_UI_LABEL_BALLANCED,
49 SMU_STATE_UI_LABEL_MIDDLE_HIGHT,
50 SMU_STATE_UI_LABEL_PERFORMANCE,
51 SMU_STATE_UI_LABEL_BACO,
54 enum smu_state_classification_flag {
55 SMU_STATE_CLASSIFICATION_FLAG_BOOT = 0x0001,
56 SMU_STATE_CLASSIFICATION_FLAG_THERMAL = 0x0002,
57 SMU_STATE_CLASSIFICATIN_FLAG_LIMITED_POWER_SOURCE = 0x0004,
58 SMU_STATE_CLASSIFICATION_FLAG_RESET = 0x0008,
59 SMU_STATE_CLASSIFICATION_FLAG_FORCED = 0x0010,
60 SMU_STATE_CLASSIFICATION_FLAG_USER_3D_PERFORMANCE = 0x0020,
61 SMU_STATE_CLASSIFICATION_FLAG_USER_2D_PERFORMANCE = 0x0040,
62 SMU_STATE_CLASSIFICATION_FLAG_3D_PERFORMANCE = 0x0080,
63 SMU_STATE_CLASSIFICATION_FLAG_AC_OVERDIRVER_TEMPLATE = 0x0100,
64 SMU_STATE_CLASSIFICATION_FLAG_UVD = 0x0200,
65 SMU_STATE_CLASSIFICATION_FLAG_3D_PERFORMANCE_LOW = 0x0400,
66 SMU_STATE_CLASSIFICATION_FLAG_ACPI = 0x0800,
67 SMU_STATE_CLASSIFICATION_FLAG_HD2 = 0x1000,
68 SMU_STATE_CLASSIFICATION_FLAG_UVD_HD = 0x2000,
69 SMU_STATE_CLASSIFICATION_FLAG_UVD_SD = 0x4000,
70 SMU_STATE_CLASSIFICATION_FLAG_USER_DC_PERFORMANCE = 0x8000,
71 SMU_STATE_CLASSIFICATION_FLAG_DC_OVERDIRVER_TEMPLATE = 0x10000,
72 SMU_STATE_CLASSIFICATION_FLAG_BACO = 0x20000,
73 SMU_STATE_CLASSIFICATIN_FLAG_LIMITED_POWER_SOURCE2 = 0x40000,
74 SMU_STATE_CLASSIFICATION_FLAG_ULV = 0x80000,
75 SMU_STATE_CLASSIFICATION_FLAG_UVD_MVC = 0x100000,
78 struct smu_state_classification_block {
79 enum smu_state_ui_label ui_label;
80 enum smu_state_classification_flag flags;
86 struct smu_state_pcie_block {
90 enum smu_refreshrate_source {
91 SMU_REFRESHRATE_SOURCE_EDID,
92 SMU_REFRESHRATE_SOURCE_EXPLICIT
95 struct smu_state_display_block {
96 bool disable_frame_modulation;
97 bool limit_refreshrate;
98 enum smu_refreshrate_source refreshrate_source;
99 int explicit_refreshrate;
100 int edid_refreshrate_index;
101 bool enable_vari_bright;
104 struct smu_state_memory_block {
110 struct smu_state_software_algorithm_block {
111 bool disable_load_balancing;
112 bool enable_sleep_for_timestamps;
115 struct smu_temperature_range {
118 int edge_emergency_max;
120 int hotspot_crit_max;
121 int hotspot_emergency_max;
124 int mem_emergency_max;
125 int software_shutdown_temp;
128 struct smu_state_validation_block {
129 bool single_display_only;
131 uint8_t supported_power_levels;
134 struct smu_uvd_clocks {
140 * Structure to hold a SMU Power State.
142 struct smu_power_state {
144 struct list_head ordered_list;
145 struct list_head all_states_list;
147 struct smu_state_classification_block classification;
148 struct smu_state_validation_block validation;
149 struct smu_state_pcie_block pcie;
150 struct smu_state_display_block display;
151 struct smu_state_memory_block memory;
152 struct smu_state_software_algorithm_block software;
153 struct smu_uvd_clocks uvd_clocks;
154 struct smu_hw_power_state hardware;
157 enum smu_power_src_type
161 SMU_POWER_SOURCE_COUNT,
164 enum smu_ppt_limit_type
166 SMU_DEFAULT_PPT_LIMIT = 0,
170 enum smu_ppt_limit_level
172 SMU_PPT_LIMIT_MIN = -1,
173 SMU_PPT_LIMIT_CURRENT,
177 enum smu_memory_pool_size
179 SMU_MEMORY_POOL_SIZE_ZERO = 0,
180 SMU_MEMORY_POOL_SIZE_256_MB = 0x10000000,
181 SMU_MEMORY_POOL_SIZE_512_MB = 0x20000000,
182 SMU_MEMORY_POOL_SIZE_1_GB = 0x40000000,
183 SMU_MEMORY_POOL_SIZE_2_GB = 0x80000000,
186 struct smu_user_dpm_profile {
188 uint32_t power_limit;
189 uint32_t fan_speed_percent;
192 /* user clock state information */
193 uint32_t clk_mask[SMU_CLK_COUNT];
194 uint32_t clk_dependency;
197 #define SMU_TABLE_INIT(tables, table_id, s, a, d) \
199 tables[table_id].size = s; \
200 tables[table_id].align = a; \
201 tables[table_id].domain = d; \
210 struct amdgpu_bo *bo;
213 enum smu_perf_level_designation {
215 PERF_LEVEL_POWER_CONTAINMENT,
218 struct smu_performance_level {
220 uint32_t memory_clock;
223 uint32_t non_local_mem_freq;
224 uint32_t non_local_mem_width;
227 struct smu_clock_info {
228 uint32_t min_mem_clk;
229 uint32_t max_mem_clk;
230 uint32_t min_eng_clk;
231 uint32_t max_eng_clk;
232 uint32_t min_bus_bandwidth;
233 uint32_t max_bus_bandwidth;
236 struct smu_bios_boot_up_values
251 uint32_t pp_table_id;
252 uint32_t format_revision;
253 uint32_t content_revision;
256 uint32_t firmware_caps;
261 SMU_TABLE_PPTABLE = 0,
262 SMU_TABLE_WATERMARKS,
263 SMU_TABLE_CUSTOM_DPM,
266 SMU_TABLE_AVFS_PSM_DEBUG,
267 SMU_TABLE_AVFS_FUSE_OVERRIDE,
268 SMU_TABLE_PMSTATUSLOG,
269 SMU_TABLE_SMU_METRICS,
270 SMU_TABLE_DRIVER_SMU_CONFIG,
271 SMU_TABLE_ACTIVITY_MONITOR_COEFF,
273 SMU_TABLE_I2C_COMMANDS,
278 struct smu_table_context
280 void *power_play_table;
281 uint32_t power_play_table_size;
282 void *hardcode_pptable;
283 unsigned long metrics_time;
286 void *watermarks_table;
288 void *max_sustainable_clocks;
289 struct smu_bios_boot_up_values boot_values;
290 void *driver_pptable;
291 struct smu_table tables[SMU_TABLE_COUNT];
293 * The driver table is just a staging buffer for
294 * uploading/downloading content from the SMU.
296 * And the table_id for SMU_MSG_TransferTableSmu2Dram/
297 * SMU_MSG_TransferTableDram2Smu instructs SMU
298 * which content driver is interested.
300 struct smu_table driver_table;
301 struct smu_table memory_pool;
302 struct smu_table dummy_read_1_table;
303 uint8_t thermal_controller_type;
305 void *overdrive_table;
306 void *boot_overdrive_table;
308 uint32_t gpu_metrics_table_size;
309 void *gpu_metrics_table;
312 struct smu_dpm_context {
313 uint32_t dpm_context_size;
315 void *golden_dpm_context;
316 bool enable_umd_pstate;
317 enum amd_dpm_forced_level dpm_level;
318 enum amd_dpm_forced_level saved_dpm_level;
319 enum amd_dpm_forced_level requested_dpm_level;
320 struct smu_power_state *dpm_request_power_state;
321 struct smu_power_state *dpm_current_power_state;
322 struct mclock_latency_table *mclk_latency_table;
325 struct smu_power_gate {
330 struct mutex vcn_gate_lock;
331 struct mutex jpeg_gate_lock;
334 struct smu_power_context {
336 uint32_t power_context_size;
337 struct smu_power_gate power_gate;
341 #define SMU_FEATURE_MAX (64)
344 uint32_t feature_num;
345 DECLARE_BITMAP(supported, SMU_FEATURE_MAX);
346 DECLARE_BITMAP(allowed, SMU_FEATURE_MAX);
347 DECLARE_BITMAP(enabled, SMU_FEATURE_MAX);
352 uint32_t engine_clock;
353 uint32_t memory_clock;
354 uint32_t bus_bandwidth;
355 uint32_t engine_clock_in_sr;
357 uint32_t dcef_clock_in_sr;
360 #define MAX_REGULAR_DPM_NUM 16
361 struct mclk_latency_entries {
365 struct mclock_latency_table {
367 struct mclk_latency_entries entries[MAX_REGULAR_DPM_NUM];
379 SMU_BACO_STATE_ENTER = 0,
383 struct smu_baco_context
387 bool platform_support;
390 struct pstates_clk_freq {
396 struct smu_umd_pstate_table {
397 struct pstates_clk_freq gfxclk_pstate;
398 struct pstates_clk_freq socclk_pstate;
399 struct pstates_clk_freq uclk_pstate;
400 struct pstates_clk_freq vclk_pstate;
401 struct pstates_clk_freq dclk_pstate;
404 struct cmn2asic_msg_mapping {
410 struct cmn2asic_mapping {
415 #define WORKLOAD_POLICY_MAX 7
418 struct amdgpu_device *adev;
419 struct amdgpu_irq_src irq_source;
421 const struct pptable_funcs *ppt_funcs;
422 const struct cmn2asic_msg_mapping *message_map;
423 const struct cmn2asic_mapping *clock_map;
424 const struct cmn2asic_mapping *feature_map;
425 const struct cmn2asic_mapping *table_map;
426 const struct cmn2asic_mapping *pwr_src_map;
427 const struct cmn2asic_mapping *workload_map;
429 struct mutex sensor_lock;
430 struct mutex metrics_lock;
431 struct mutex message_lock;
434 struct smu_table_context smu_table;
435 struct smu_dpm_context smu_dpm;
436 struct smu_power_context smu_power;
437 struct smu_feature smu_feature;
438 struct amd_pp_display_configuration *display_config;
439 struct smu_baco_context smu_baco;
440 struct smu_temperature_range thermal_range;
442 #if defined(CONFIG_DEBUG_FS)
443 struct dentry *debugfs_sclk;
446 struct smu_umd_pstate_table pstate_table;
447 uint32_t pstate_sclk;
448 uint32_t pstate_mclk;
451 uint32_t current_power_limit;
452 uint32_t max_power_limit;
455 uint32_t ppt_offset_bytes;
456 uint32_t ppt_size_bytes;
457 uint8_t *ppt_start_addr;
459 bool support_power_containment;
460 bool disable_watermark;
462 #define WATERMARKS_EXIST (1 << 0)
463 #define WATERMARKS_LOADED (1 << 1)
464 uint32_t watermarks_bitmap;
465 uint32_t hard_min_uclk_req_from_dal;
466 bool disable_uclk_switch;
468 uint32_t workload_mask;
469 uint32_t workload_prority[WORKLOAD_POLICY_MAX];
470 uint32_t workload_setting[WORKLOAD_POLICY_MAX];
471 uint32_t power_profile_mode;
472 uint32_t default_power_profile_mode;
476 uint32_t smc_driver_if_version;
477 uint32_t smc_fw_if_version;
478 uint32_t smc_fw_version;
480 bool uploading_custom_pp_table;
481 bool dc_controlled_by_gpio;
483 struct work_struct throttling_logging_work;
484 atomic64_t throttle_int_counter;
485 struct work_struct interrupt_work;
487 unsigned fan_max_rpm;
488 unsigned manual_fan_speed_percent;
490 uint32_t gfx_default_hard_min_freq;
491 uint32_t gfx_default_soft_max_freq;
492 uint32_t gfx_actual_hard_min_freq;
493 uint32_t gfx_actual_soft_max_freq;
496 uint32_t cpu_default_soft_min_freq;
497 uint32_t cpu_default_soft_max_freq;
498 uint32_t cpu_actual_soft_min_freq;
499 uint32_t cpu_actual_soft_max_freq;
500 uint32_t cpu_core_id_select;
501 uint16_t cpu_core_num;
503 struct smu_user_dpm_profile user_dpm_profile;
509 * struct pptable_funcs - Callbacks used to interact with the SMU.
511 struct pptable_funcs {
513 * @run_btc: Calibrate voltage/frequency curve to fit the system's
514 * power delivery and voltage margins. Required for adaptive
515 * voltage frequency scaling (AVFS).
517 int (*run_btc)(struct smu_context *smu);
520 * @get_allowed_feature_mask: Get allowed feature mask.
521 * &feature_mask: Array to store feature mask.
522 * &num: Elements in &feature_mask.
524 int (*get_allowed_feature_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num);
527 * @get_current_power_state: Get the current power state.
529 * Return: Current power state on success, negative errno on failure.
531 enum amd_pm_state_type (*get_current_power_state)(struct smu_context *smu);
534 * @set_default_dpm_table: Retrieve the default overdrive settings from
537 int (*set_default_dpm_table)(struct smu_context *smu);
539 int (*set_power_state)(struct smu_context *smu);
542 * @populate_umd_state_clk: Populate the UMD power state table with
545 int (*populate_umd_state_clk)(struct smu_context *smu);
548 * @print_clk_levels: Print DPM clock levels for a clock domain
549 * to buffer. Star current level.
551 * Used for sysfs interfaces.
553 int (*print_clk_levels)(struct smu_context *smu, enum smu_clk_type clk_type, char *buf);
556 * @force_clk_levels: Set a range of allowed DPM levels for a clock
558 * &clk_type: Clock domain.
559 * &mask: Range of allowed DPM levels.
561 int (*force_clk_levels)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t mask);
564 * @od_edit_dpm_table: Edit the custom overdrive DPM table.
565 * &type: Type of edit.
566 * &input: Edit parameters.
567 * &size: Size of &input.
569 int (*od_edit_dpm_table)(struct smu_context *smu,
570 enum PP_OD_DPM_TABLE_COMMAND type,
571 long *input, uint32_t size);
574 * @get_clock_by_type_with_latency: Get the speed and latency of a clock
577 int (*get_clock_by_type_with_latency)(struct smu_context *smu,
578 enum smu_clk_type clk_type,
580 pp_clock_levels_with_latency
583 * @get_clock_by_type_with_voltage: Get the speed and voltage of a clock
586 int (*get_clock_by_type_with_voltage)(struct smu_context *smu,
587 enum amd_pp_clock_type type,
589 pp_clock_levels_with_voltage
593 * @get_power_profile_mode: Print all power profile modes to
594 * buffer. Star current mode.
596 int (*get_power_profile_mode)(struct smu_context *smu, char *buf);
599 * @set_power_profile_mode: Set a power profile mode. Also used to
600 * create/set custom power profile modes.
601 * &input: Power profile mode parameters.
602 * &size: Size of &input.
604 int (*set_power_profile_mode)(struct smu_context *smu, long *input, uint32_t size);
607 * @dpm_set_vcn_enable: Enable/disable VCN engine dynamic power
610 int (*dpm_set_vcn_enable)(struct smu_context *smu, bool enable);
613 * @dpm_set_jpeg_enable: Enable/disable JPEG engine dynamic power
616 int (*dpm_set_jpeg_enable)(struct smu_context *smu, bool enable);
619 * @read_sensor: Read data from a sensor.
620 * &sensor: Sensor to read data from.
621 * &data: Sensor reading.
622 * &size: Size of &data.
624 int (*read_sensor)(struct smu_context *smu, enum amd_pp_sensors sensor,
625 void *data, uint32_t *size);
628 * @pre_display_config_changed: Prepare GPU for a display configuration
631 * Disable display tracking and pin memory clock speed to maximum. Used
632 * in display component synchronization.
634 int (*pre_display_config_changed)(struct smu_context *smu);
637 * @display_config_changed: Notify the SMU of the current display
640 * Allows SMU to properly track blanking periods for memory clock
641 * adjustment. Used in display component synchronization.
643 int (*display_config_changed)(struct smu_context *smu);
645 int (*apply_clocks_adjust_rules)(struct smu_context *smu);
648 * @notify_smc_display_config: Applies display requirements to the
649 * current power state.
651 * Optimize deep sleep DCEFclk and mclk for the current display
652 * configuration. Used in display component synchronization.
654 int (*notify_smc_display_config)(struct smu_context *smu);
657 * @is_dpm_running: Check if DPM is running.
659 * Return: True if DPM is running, false otherwise.
661 bool (*is_dpm_running)(struct smu_context *smu);
664 * @get_fan_speed_percent: Get the current fan speed in percent.
666 int (*get_fan_speed_percent)(struct smu_context *smu, uint32_t *speed);
669 * @set_watermarks_table: Configure and upload the watermarks tables to
672 int (*set_watermarks_table)(struct smu_context *smu,
673 struct pp_smu_wm_range_sets *clock_ranges);
676 * @get_thermal_temperature_range: Get safe thermal limits in Celcius.
678 int (*get_thermal_temperature_range)(struct smu_context *smu, struct smu_temperature_range *range);
681 * @get_uclk_dpm_states: Get memory clock DPM levels in kHz.
682 * &clocks_in_khz: Array of DPM levels.
683 * &num_states: Elements in &clocks_in_khz.
685 int (*get_uclk_dpm_states)(struct smu_context *smu, uint32_t *clocks_in_khz, uint32_t *num_states);
688 * @set_default_od_settings: Set the overdrive tables to defaults.
690 int (*set_default_od_settings)(struct smu_context *smu);
693 * @set_performance_level: Set a performance level.
695 int (*set_performance_level)(struct smu_context *smu, enum amd_dpm_forced_level level);
698 * @display_disable_memory_clock_switch: Enable/disable dynamic memory
701 * Disabling this feature forces memory clock speed to maximum.
702 * Enabling sets the minimum memory clock capable of driving the
703 * current display configuration.
705 int (*display_disable_memory_clock_switch)(struct smu_context *smu, bool disable_memory_clock_switch);
708 * @dump_pptable: Print the power play table to the system log.
710 void (*dump_pptable)(struct smu_context *smu);
713 * @get_power_limit: Get the device's power limits.
715 int (*get_power_limit)(struct smu_context *smu);
718 * @get_ppt_limit: Get the device's ppt limits.
720 int (*get_ppt_limit)(struct smu_context *smu, uint32_t *ppt_limit,
721 enum smu_ppt_limit_type limit_type, enum smu_ppt_limit_level limit_level);
724 * @set_df_cstate: Set data fabric cstate.
726 int (*set_df_cstate)(struct smu_context *smu, enum pp_df_cstate state);
729 * @allow_xgmi_power_down: Enable/disable external global memory
730 * interconnect power down.
732 int (*allow_xgmi_power_down)(struct smu_context *smu, bool en);
735 * @update_pcie_parameters: Update and upload the system's PCIe
736 * capabilites to the SMU.
737 * &pcie_gen_cap: Maximum allowed PCIe generation.
738 * &pcie_width_cap: Maximum allowed PCIe width.
740 int (*update_pcie_parameters)(struct smu_context *smu, uint32_t pcie_gen_cap, uint32_t pcie_width_cap);
743 * @i2c_init: Initialize i2c.
745 * The i2c bus is used internally by the SMU voltage regulators and
746 * other devices. The i2c's EEPROM also stores bad page tables on boards
749 int (*i2c_init)(struct smu_context *smu, struct i2c_adapter *control);
752 * @i2c_fini: Tear down i2c.
754 void (*i2c_fini)(struct smu_context *smu, struct i2c_adapter *control);
757 * @get_unique_id: Get the GPU's unique id. Used for asset tracking.
759 void (*get_unique_id)(struct smu_context *smu);
762 * @get_dpm_clock_table: Get a copy of the DPM clock table.
764 * Used by display component in bandwidth and watermark calculations.
766 int (*get_dpm_clock_table)(struct smu_context *smu, struct dpm_clocks *clock_table);
769 * @init_microcode: Request the SMU's firmware from the kernel.
771 int (*init_microcode)(struct smu_context *smu);
774 * @load_microcode: Load firmware onto the SMU.
776 int (*load_microcode)(struct smu_context *smu);
779 * @fini_microcode: Release the SMU's firmware.
781 void (*fini_microcode)(struct smu_context *smu);
784 * @init_smc_tables: Initialize the SMU tables.
786 int (*init_smc_tables)(struct smu_context *smu);
789 * @fini_smc_tables: Release the SMU tables.
791 int (*fini_smc_tables)(struct smu_context *smu);
794 * @init_power: Initialize the power gate table context.
796 int (*init_power)(struct smu_context *smu);
799 * @fini_power: Release the power gate table context.
801 int (*fini_power)(struct smu_context *smu);
804 * @check_fw_status: Check the SMU's firmware status.
806 * Return: Zero if check passes, negative errno on failure.
808 int (*check_fw_status)(struct smu_context *smu);
811 * @setup_pptable: Initialize the power play table and populate it with
814 int (*setup_pptable)(struct smu_context *smu);
817 * @get_vbios_bootup_values: Get default boot values from the VBIOS.
819 int (*get_vbios_bootup_values)(struct smu_context *smu);
822 * @check_fw_version: Print driver and SMU interface versions to the
825 * Interface mismatch is not a critical failure.
827 int (*check_fw_version)(struct smu_context *smu);
830 * @powergate_sdma: Power up/down system direct memory access.
832 int (*powergate_sdma)(struct smu_context *smu, bool gate);
835 * @set_gfx_cgpg: Enable/disable graphics engine course grain power
838 int (*set_gfx_cgpg)(struct smu_context *smu, bool enable);
841 * @write_pptable: Write the power play table to the SMU.
843 int (*write_pptable)(struct smu_context *smu);
846 * @set_driver_table_location: Send the location of the driver table to
849 int (*set_driver_table_location)(struct smu_context *smu);
852 * @set_tool_table_location: Send the location of the tool table to the
855 int (*set_tool_table_location)(struct smu_context *smu);
858 * @notify_memory_pool_location: Send the location of the memory pool to
861 int (*notify_memory_pool_location)(struct smu_context *smu);
864 * @system_features_control: Enable/disable all SMU features.
866 int (*system_features_control)(struct smu_context *smu, bool en);
869 * @send_smc_msg_with_param: Send a message with a parameter to the SMU.
870 * &msg: Type of message.
871 * ¶m: Message parameter.
872 * &read_arg: SMU response (optional).
874 int (*send_smc_msg_with_param)(struct smu_context *smu,
875 enum smu_message_type msg, uint32_t param, uint32_t *read_arg);
878 * @send_smc_msg: Send a message to the SMU.
879 * &msg: Type of message.
880 * &read_arg: SMU response (optional).
882 int (*send_smc_msg)(struct smu_context *smu,
883 enum smu_message_type msg,
887 * @init_display_count: Notify the SMU of the number of display
888 * components in current display configuration.
890 int (*init_display_count)(struct smu_context *smu, uint32_t count);
893 * @set_allowed_mask: Notify the SMU of the features currently allowed
896 int (*set_allowed_mask)(struct smu_context *smu);
899 * @get_enabled_mask: Get a mask of features that are currently enabled
901 * &feature_mask: Array representing enabled feature mask.
902 * &num: Elements in &feature_mask.
904 int (*get_enabled_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num);
907 * @feature_is_enabled: Test if a feature is enabled.
909 * Return: One if enabled, zero if disabled.
911 int (*feature_is_enabled)(struct smu_context *smu, enum smu_feature_mask mask);
914 * @disable_all_features_with_exception: Disable all features with
915 * exception to those in &mask.
917 int (*disable_all_features_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
920 * @notify_display_change: Enable fast memory clock switching.
922 * Allows for fine grained memory clock switching but has more stringent
923 * timing requirements.
925 int (*notify_display_change)(struct smu_context *smu);
928 * @set_power_limit: Set power limit in watts.
930 int (*set_power_limit)(struct smu_context *smu, uint32_t n);
933 * @init_max_sustainable_clocks: Populate max sustainable clock speed
934 * table with values from the SMU.
936 int (*init_max_sustainable_clocks)(struct smu_context *smu);
939 * @enable_thermal_alert: Enable thermal alert interrupts.
941 int (*enable_thermal_alert)(struct smu_context *smu);
944 * @disable_thermal_alert: Disable thermal alert interrupts.
946 int (*disable_thermal_alert)(struct smu_context *smu);
949 * @set_min_dcef_deep_sleep: Set a minimum display fabric deep sleep
950 * clock speed in MHz.
952 int (*set_min_dcef_deep_sleep)(struct smu_context *smu, uint32_t clk);
955 * @display_clock_voltage_request: Set a hard minimum frequency
956 * for a clock domain.
958 int (*display_clock_voltage_request)(struct smu_context *smu, struct
959 pp_display_clock_request
963 * @get_fan_control_mode: Get the current fan control mode.
965 uint32_t (*get_fan_control_mode)(struct smu_context *smu);
968 * @set_fan_control_mode: Set the fan control mode.
970 int (*set_fan_control_mode)(struct smu_context *smu, uint32_t mode);
973 * @set_fan_speed_percent: Set a static fan speed in percent.
975 int (*set_fan_speed_percent)(struct smu_context *smu, uint32_t speed);
978 * @set_xgmi_pstate: Set inter-chip global memory interconnect pstate.
979 * &pstate: Pstate to set. D0 if Nonzero, D3 otherwise.
981 int (*set_xgmi_pstate)(struct smu_context *smu, uint32_t pstate);
984 * @gfx_off_control: Enable/disable graphics engine poweroff.
986 int (*gfx_off_control)(struct smu_context *smu, bool enable);
990 * @get_gfx_off_status: Get graphics engine poweroff status.
993 * 0 - GFXOFF(default).
994 * 1 - Transition out of GFX State.
996 * 3 - Transition into GFXOFF.
998 uint32_t (*get_gfx_off_status)(struct smu_context *smu);
1001 * @register_irq_handler: Register interupt request handlers.
1003 int (*register_irq_handler)(struct smu_context *smu);
1006 * @set_azalia_d3_pme: Wake the audio decode engine from d3 sleep.
1008 int (*set_azalia_d3_pme)(struct smu_context *smu);
1011 * @get_max_sustainable_clocks_by_dc: Get a copy of the max sustainable
1012 * clock speeds table.
1014 * Provides a way for the display component (DC) to get the max
1015 * sustainable clocks from the SMU.
1017 int (*get_max_sustainable_clocks_by_dc)(struct smu_context *smu, struct pp_smu_nv_clock_table *max_clocks);
1020 * @baco_is_support: Check if GPU supports BACO (Bus Active, Chip Off).
1022 bool (*baco_is_support)(struct smu_context *smu);
1025 * @baco_get_state: Get the current BACO state.
1027 * Return: Current BACO state.
1029 enum smu_baco_state (*baco_get_state)(struct smu_context *smu);
1032 * @baco_set_state: Enter/exit BACO.
1034 int (*baco_set_state)(struct smu_context *smu, enum smu_baco_state state);
1037 * @baco_enter: Enter BACO.
1039 int (*baco_enter)(struct smu_context *smu);
1042 * @baco_exit: Exit Baco.
1044 int (*baco_exit)(struct smu_context *smu);
1047 * @mode1_reset_is_support: Check if GPU supports mode1 reset.
1049 bool (*mode1_reset_is_support)(struct smu_context *smu);
1052 * @mode1_reset: Perform mode1 reset.
1054 * Complete GPU reset.
1056 int (*mode1_reset)(struct smu_context *smu);
1059 * @mode2_reset: Perform mode2 reset.
1061 * Mode2 reset generally does not reset as many IPs as mode1 reset. The
1062 * IPs reset varies by asic.
1064 int (*mode2_reset)(struct smu_context *smu);
1067 * @get_dpm_ultimate_freq: Get the hard frequency range of a clock
1070 int (*get_dpm_ultimate_freq)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t *min, uint32_t *max);
1073 * @set_soft_freq_limited_range: Set the soft frequency range of a clock
1076 int (*set_soft_freq_limited_range)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t min, uint32_t max);
1079 * @set_power_source: Notify the SMU of the current power source.
1081 int (*set_power_source)(struct smu_context *smu, enum smu_power_src_type power_src);
1084 * @log_thermal_throttling_event: Print a thermal throttling warning to
1087 void (*log_thermal_throttling_event)(struct smu_context *smu);
1090 * @get_pp_feature_mask: Print a human readable table of enabled
1091 * features to buffer.
1093 size_t (*get_pp_feature_mask)(struct smu_context *smu, char *buf);
1096 * @set_pp_feature_mask: Request the SMU enable/disable features to
1097 * match those enabled in &new_mask.
1099 int (*set_pp_feature_mask)(struct smu_context *smu, uint64_t new_mask);
1102 * @get_gpu_metrics: Get a copy of the GPU metrics table from the SMU.
1104 * Return: Size of &table
1106 ssize_t (*get_gpu_metrics)(struct smu_context *smu, void **table);
1109 * @enable_mgpu_fan_boost: Enable multi-GPU fan boost.
1111 int (*enable_mgpu_fan_boost)(struct smu_context *smu);
1114 * @gfx_ulv_control: Enable/disable ultra low voltage.
1116 int (*gfx_ulv_control)(struct smu_context *smu, bool enablement);
1119 * @deep_sleep_control: Enable/disable deep sleep.
1121 int (*deep_sleep_control)(struct smu_context *smu, bool enablement);
1124 * @get_fan_parameters: Get fan parameters.
1126 * Get maximum fan speed from the power play table.
1128 int (*get_fan_parameters)(struct smu_context *smu);
1131 * @post_init: Helper function for asic specific workarounds.
1133 int (*post_init)(struct smu_context *smu);
1136 * @interrupt_work: Work task scheduled from SMU interrupt handler.
1138 void (*interrupt_work)(struct smu_context *smu);
1141 * @gpo_control: Enable/disable graphics power optimization if supported.
1143 int (*gpo_control)(struct smu_context *smu, bool enablement);
1146 * @gfx_state_change_set: Send the current graphics state to the SMU.
1148 int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);
1151 * @set_fine_grain_gfx_freq_parameters: Set fine grain graphics clock
1152 * parameters to defaults.
1154 int (*set_fine_grain_gfx_freq_parameters)(struct smu_context *smu);
1158 METRICS_CURR_GFXCLK,
1159 METRICS_CURR_SOCCLK,
1166 METRICS_CURR_DCEFCLK,
1167 METRICS_AVERAGE_CPUCLK,
1168 METRICS_AVERAGE_GFXCLK,
1169 METRICS_AVERAGE_SOCCLK,
1170 METRICS_AVERAGE_FCLK,
1171 METRICS_AVERAGE_UCLK,
1172 METRICS_AVERAGE_VCLK,
1173 METRICS_AVERAGE_DCLK,
1174 METRICS_AVERAGE_GFXACTIVITY,
1175 METRICS_AVERAGE_MEMACTIVITY,
1176 METRICS_AVERAGE_VCNACTIVITY,
1177 METRICS_AVERAGE_SOCKETPOWER,
1178 METRICS_TEMPERATURE_EDGE,
1179 METRICS_TEMPERATURE_HOTSPOT,
1180 METRICS_TEMPERATURE_MEM,
1181 METRICS_TEMPERATURE_VRGFX,
1182 METRICS_TEMPERATURE_VRSOC,
1183 METRICS_TEMPERATURE_VRMEM,
1184 METRICS_THROTTLER_STATUS,
1185 METRICS_CURR_FANSPEED,
1186 METRICS_VOLTAGE_VDDSOC,
1187 METRICS_VOLTAGE_VDDGFX,
1190 enum smu_cmn2asic_mapping_type {
1191 CMN2ASIC_MAPPING_MSG,
1192 CMN2ASIC_MAPPING_CLK,
1193 CMN2ASIC_MAPPING_FEATURE,
1194 CMN2ASIC_MAPPING_TABLE,
1195 CMN2ASIC_MAPPING_PWR,
1196 CMN2ASIC_MAPPING_WORKLOAD,
1199 #define MSG_MAP(msg, index, valid_in_vf) \
1200 [SMU_MSG_##msg] = {1, (index), (valid_in_vf)}
1202 #define CLK_MAP(clk, index) \
1203 [SMU_##clk] = {1, (index)}
1205 #define FEA_MAP(fea) \
1206 [SMU_FEATURE_##fea##_BIT] = {1, FEATURE_##fea##_BIT}
1208 #define FEA_MAP_REVERSE(fea) \
1209 [SMU_FEATURE_DPM_##fea##_BIT] = {1, FEATURE_##fea##_DPM_BIT}
1211 #define FEA_MAP_HALF_REVERSE(fea) \
1212 [SMU_FEATURE_DPM_##fea##CLK_BIT] = {1, FEATURE_##fea##_DPM_BIT}
1214 #define TAB_MAP(tab) \
1215 [SMU_TABLE_##tab] = {1, TABLE_##tab}
1217 #define TAB_MAP_VALID(tab) \
1218 [SMU_TABLE_##tab] = {1, TABLE_##tab}
1220 #define TAB_MAP_INVALID(tab) \
1221 [SMU_TABLE_##tab] = {0, TABLE_##tab}
1223 #define PWR_MAP(tab) \
1224 [SMU_POWER_SOURCE_##tab] = {1, POWER_SOURCE_##tab}
1226 #define WORKLOAD_MAP(profile, workload) \
1227 [profile] = {1, (workload)}
1229 #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4)
1230 int smu_load_microcode(struct smu_context *smu);
1232 int smu_check_fw_status(struct smu_context *smu);
1234 int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled);
1236 int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed);
1238 int smu_get_power_limit(struct smu_context *smu,
1240 enum smu_ppt_limit_level limit_level);
1242 int smu_set_power_limit(struct smu_context *smu, uint32_t limit);
1243 int smu_print_clk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf);
1245 int smu_od_edit_dpm_table(struct smu_context *smu,
1246 enum PP_OD_DPM_TABLE_COMMAND type,
1247 long *input, uint32_t size);
1249 int smu_read_sensor(struct smu_context *smu,
1250 enum amd_pp_sensors sensor,
1251 void *data, uint32_t *size);
1252 int smu_get_power_profile_mode(struct smu_context *smu, char *buf);
1254 int smu_set_power_profile_mode(struct smu_context *smu,
1256 uint32_t param_size,
1258 int smu_get_fan_control_mode(struct smu_context *smu);
1259 int smu_set_fan_control_mode(struct smu_context *smu, int value);
1260 int smu_get_fan_speed_percent(struct smu_context *smu, uint32_t *speed);
1261 int smu_set_fan_speed_percent(struct smu_context *smu, uint32_t speed);
1262 int smu_get_fan_speed_rpm(struct smu_context *smu, uint32_t *speed);
1264 int smu_set_deep_sleep_dcefclk(struct smu_context *smu, int clk);
1266 int smu_get_clock_by_type_with_latency(struct smu_context *smu,
1267 enum smu_clk_type clk_type,
1268 struct pp_clock_levels_with_latency *clocks);
1270 int smu_display_clock_voltage_request(struct smu_context *smu,
1271 struct pp_display_clock_request *clock_req);
1272 int smu_display_disable_memory_clock_switch(struct smu_context *smu, bool disable_memory_clock_switch);
1274 int smu_set_xgmi_pstate(struct smu_context *smu,
1277 int smu_set_azalia_d3_pme(struct smu_context *smu);
1279 bool smu_baco_is_support(struct smu_context *smu);
1281 int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state);
1283 int smu_baco_enter(struct smu_context *smu);
1284 int smu_baco_exit(struct smu_context *smu);
1286 bool smu_mode1_reset_is_support(struct smu_context *smu);
1287 int smu_mode1_reset(struct smu_context *smu);
1288 int smu_mode2_reset(struct smu_context *smu);
1290 extern const struct amd_ip_funcs smu_ip_funcs;
1292 extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;
1293 extern const struct amdgpu_ip_block_version smu_v12_0_ip_block;
1295 bool is_support_sw_smu(struct amdgpu_device *adev);
1296 bool is_support_cclk_dpm(struct amdgpu_device *adev);
1297 int smu_reset(struct smu_context *smu);
1298 int smu_sys_get_pp_table(struct smu_context *smu, void **table);
1299 int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size);
1300 int smu_get_power_num_states(struct smu_context *smu, struct pp_states_info *state_info);
1301 enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu);
1302 int smu_write_watermarks_table(struct smu_context *smu);
1303 int smu_set_watermarks_for_clock_ranges(
1304 struct smu_context *smu,
1305 struct pp_smu_wm_range_sets *clock_ranges);
1307 /* smu to display interface */
1308 extern int smu_display_configuration_change(struct smu_context *smu, const
1309 struct amd_pp_display_configuration
1311 extern int smu_dpm_set_power_gate(struct smu_context *smu,uint32_t block_type, bool gate);
1312 extern int smu_handle_task(struct smu_context *smu,
1313 enum amd_dpm_forced_level level,
1314 enum amd_pp_task task_id,
1316 int smu_switch_power_profile(struct smu_context *smu,
1317 enum PP_SMC_POWER_PROFILE type,
1319 int smu_get_dpm_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
1320 uint32_t *min, uint32_t *max);
1321 int smu_set_soft_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
1322 uint32_t min, uint32_t max);
1323 enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);
1324 int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level);
1325 int smu_set_display_count(struct smu_context *smu, uint32_t count);
1326 int smu_set_ac_dc(struct smu_context *smu);
1327 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf);
1328 int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask);
1329 int smu_force_clk_levels(struct smu_context *smu,
1330 enum smu_clk_type clk_type,
1332 int smu_set_mp1_state(struct smu_context *smu,
1333 enum pp_mp1_state mp1_state);
1334 int smu_set_df_cstate(struct smu_context *smu,
1335 enum pp_df_cstate state);
1336 int smu_allow_xgmi_power_down(struct smu_context *smu, bool en);
1338 int smu_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
1339 struct pp_smu_nv_clock_table *max_clocks);
1341 int smu_get_uclk_dpm_states(struct smu_context *smu,
1342 unsigned int *clock_values_in_khz,
1343 unsigned int *num_states);
1345 int smu_get_dpm_clock_table(struct smu_context *smu,
1346 struct dpm_clocks *clock_table);
1348 int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value);
1350 ssize_t smu_sys_get_gpu_metrics(struct smu_context *smu, void **table);
1352 int smu_enable_mgpu_fan_boost(struct smu_context *smu);
1353 int smu_gfx_state_change_set(struct smu_context *smu, uint32_t state);