drm/amd/pm: add a new sysfs entry for default power limit
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / pm / inc / amdgpu_smu.h
1 /*
2  * Copyright 2019 Advanced Micro Devices, Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  */
22 #ifndef __AMDGPU_SMU_H__
23 #define __AMDGPU_SMU_H__
24
25 #include "amdgpu.h"
26 #include "kgd_pp_interface.h"
27 #include "dm_pp_interface.h"
28 #include "dm_pp_smu.h"
29 #include "smu_types.h"
30
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
35
36 #define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)
37
38 struct smu_hw_power_state {
39         unsigned int magic;
40 };
41
42 struct smu_power_state;
43
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,
52 };
53
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,
76 };
77
78 struct smu_state_classification_block {
79         enum smu_state_ui_label         ui_label;
80         enum smu_state_classification_flag  flags;
81         int                          bios_index;
82         bool                      temporary_state;
83         bool                      to_be_deleted;
84 };
85
86 struct smu_state_pcie_block {
87         unsigned int lanes;
88 };
89
90 enum smu_refreshrate_source {
91         SMU_REFRESHRATE_SOURCE_EDID,
92         SMU_REFRESHRATE_SOURCE_EXPLICIT
93 };
94
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;
102 };
103
104 struct smu_state_memory_block {
105         bool              dll_off;
106         uint8_t                 m3arb;
107         uint8_t                 unused[3];
108 };
109
110 struct smu_state_software_algorithm_block {
111         bool disable_load_balancing;
112         bool enable_sleep_for_timestamps;
113 };
114
115 struct smu_temperature_range {
116         int min;
117         int max;
118         int edge_emergency_max;
119         int hotspot_min;
120         int hotspot_crit_max;
121         int hotspot_emergency_max;
122         int mem_min;
123         int mem_crit_max;
124         int mem_emergency_max;
125         int software_shutdown_temp;
126 };
127
128 struct smu_state_validation_block {
129         bool single_display_only;
130         bool disallow_on_dc;
131         uint8_t supported_power_levels;
132 };
133
134 struct smu_uvd_clocks {
135         uint32_t vclk;
136         uint32_t dclk;
137 };
138
139 /**
140 * Structure to hold a SMU Power State.
141 */
142 struct smu_power_state {
143         uint32_t                                      id;
144         struct list_head                              ordered_list;
145         struct list_head                              all_states_list;
146
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;
155 };
156
157 enum smu_power_src_type
158 {
159         SMU_POWER_SOURCE_AC,
160         SMU_POWER_SOURCE_DC,
161         SMU_POWER_SOURCE_COUNT,
162 };
163
164 enum smu_ppt_limit_type
165 {
166         SMU_DEFAULT_PPT_LIMIT = 0,
167         SMU_FAST_PPT_LIMIT,
168 };
169
170 enum smu_ppt_limit_level
171 {
172         SMU_PPT_LIMIT_MIN = -1,
173         SMU_PPT_LIMIT_CURRENT,
174         SMU_PPT_LIMIT_DEFAULT,
175         SMU_PPT_LIMIT_MAX,
176 };
177
178 enum smu_memory_pool_size
179 {
180     SMU_MEMORY_POOL_SIZE_ZERO   = 0,
181     SMU_MEMORY_POOL_SIZE_256_MB = 0x10000000,
182     SMU_MEMORY_POOL_SIZE_512_MB = 0x20000000,
183     SMU_MEMORY_POOL_SIZE_1_GB   = 0x40000000,
184     SMU_MEMORY_POOL_SIZE_2_GB   = 0x80000000,
185 };
186
187 struct smu_user_dpm_profile {
188         uint32_t fan_mode;
189         uint32_t power_limit;
190         uint32_t fan_speed_percent;
191         uint32_t flags;
192
193         /* user clock state information */
194         uint32_t clk_mask[SMU_CLK_COUNT];
195         uint32_t clk_dependency;
196 };
197
198 #define SMU_TABLE_INIT(tables, table_id, s, a, d)       \
199         do {                                            \
200                 tables[table_id].size = s;              \
201                 tables[table_id].align = a;             \
202                 tables[table_id].domain = d;            \
203         } while (0)
204
205 struct smu_table {
206         uint64_t size;
207         uint32_t align;
208         uint8_t domain;
209         uint64_t mc_address;
210         void *cpu_addr;
211         struct amdgpu_bo *bo;
212 };
213
214 enum smu_perf_level_designation {
215         PERF_LEVEL_ACTIVITY,
216         PERF_LEVEL_POWER_CONTAINMENT,
217 };
218
219 struct smu_performance_level {
220         uint32_t core_clock;
221         uint32_t memory_clock;
222         uint32_t vddc;
223         uint32_t vddci;
224         uint32_t non_local_mem_freq;
225         uint32_t non_local_mem_width;
226 };
227
228 struct smu_clock_info {
229         uint32_t min_mem_clk;
230         uint32_t max_mem_clk;
231         uint32_t min_eng_clk;
232         uint32_t max_eng_clk;
233         uint32_t min_bus_bandwidth;
234         uint32_t max_bus_bandwidth;
235 };
236
237 struct smu_bios_boot_up_values
238 {
239         uint32_t                        revision;
240         uint32_t                        gfxclk;
241         uint32_t                        uclk;
242         uint32_t                        socclk;
243         uint32_t                        dcefclk;
244         uint32_t                        eclk;
245         uint32_t                        vclk;
246         uint32_t                        dclk;
247         uint16_t                        vddc;
248         uint16_t                        vddci;
249         uint16_t                        mvddc;
250         uint16_t                        vdd_gfx;
251         uint8_t                         cooling_id;
252         uint32_t                        pp_table_id;
253         uint32_t                        format_revision;
254         uint32_t                        content_revision;
255         uint32_t                        fclk;
256         uint32_t                        lclk;
257         uint32_t                        firmware_caps;
258 };
259
260 enum smu_table_id
261 {
262         SMU_TABLE_PPTABLE = 0,
263         SMU_TABLE_WATERMARKS,
264         SMU_TABLE_CUSTOM_DPM,
265         SMU_TABLE_DPMCLOCKS,
266         SMU_TABLE_AVFS,
267         SMU_TABLE_AVFS_PSM_DEBUG,
268         SMU_TABLE_AVFS_FUSE_OVERRIDE,
269         SMU_TABLE_PMSTATUSLOG,
270         SMU_TABLE_SMU_METRICS,
271         SMU_TABLE_DRIVER_SMU_CONFIG,
272         SMU_TABLE_ACTIVITY_MONITOR_COEFF,
273         SMU_TABLE_OVERDRIVE,
274         SMU_TABLE_I2C_COMMANDS,
275         SMU_TABLE_PACE,
276         SMU_TABLE_COUNT,
277 };
278
279 struct smu_table_context
280 {
281         void                            *power_play_table;
282         uint32_t                        power_play_table_size;
283         void                            *hardcode_pptable;
284         unsigned long                   metrics_time;
285         void                            *metrics_table;
286         void                            *clocks_table;
287         void                            *watermarks_table;
288
289         void                            *max_sustainable_clocks;
290         struct smu_bios_boot_up_values  boot_values;
291         void                            *driver_pptable;
292         struct smu_table                tables[SMU_TABLE_COUNT];
293         /*
294          * The driver table is just a staging buffer for
295          * uploading/downloading content from the SMU.
296          *
297          * And the table_id for SMU_MSG_TransferTableSmu2Dram/
298          * SMU_MSG_TransferTableDram2Smu instructs SMU
299          * which content driver is interested.
300          */
301         struct smu_table                driver_table;
302         struct smu_table                memory_pool;
303         struct smu_table                dummy_read_1_table;
304         uint8_t                         thermal_controller_type;
305
306         void                            *overdrive_table;
307         void                            *boot_overdrive_table;
308
309         uint32_t                        gpu_metrics_table_size;
310         void                            *gpu_metrics_table;
311 };
312
313 struct smu_dpm_context {
314         uint32_t dpm_context_size;
315         void *dpm_context;
316         void *golden_dpm_context;
317         bool enable_umd_pstate;
318         enum amd_dpm_forced_level dpm_level;
319         enum amd_dpm_forced_level saved_dpm_level;
320         enum amd_dpm_forced_level requested_dpm_level;
321         struct smu_power_state *dpm_request_power_state;
322         struct smu_power_state *dpm_current_power_state;
323         struct mclock_latency_table *mclk_latency_table;
324 };
325
326 struct smu_power_gate {
327         bool uvd_gated;
328         bool vce_gated;
329         atomic_t vcn_gated;
330         atomic_t jpeg_gated;
331         struct mutex vcn_gate_lock;
332         struct mutex jpeg_gate_lock;
333 };
334
335 struct smu_power_context {
336         void *power_context;
337         uint32_t power_context_size;
338         struct smu_power_gate power_gate;
339 };
340
341
342 #define SMU_FEATURE_MAX (64)
343 struct smu_feature
344 {
345         uint32_t feature_num;
346         DECLARE_BITMAP(supported, SMU_FEATURE_MAX);
347         DECLARE_BITMAP(allowed, SMU_FEATURE_MAX);
348         DECLARE_BITMAP(enabled, SMU_FEATURE_MAX);
349         struct mutex mutex;
350 };
351
352 struct smu_clocks {
353         uint32_t engine_clock;
354         uint32_t memory_clock;
355         uint32_t bus_bandwidth;
356         uint32_t engine_clock_in_sr;
357         uint32_t dcef_clock;
358         uint32_t dcef_clock_in_sr;
359 };
360
361 #define MAX_REGULAR_DPM_NUM 16
362 struct mclk_latency_entries {
363         uint32_t  frequency;
364         uint32_t  latency;
365 };
366 struct mclock_latency_table {
367         uint32_t  count;
368         struct mclk_latency_entries  entries[MAX_REGULAR_DPM_NUM];
369 };
370
371 enum smu_reset_mode
372 {
373     SMU_RESET_MODE_0,
374     SMU_RESET_MODE_1,
375     SMU_RESET_MODE_2,
376 };
377
378 enum smu_baco_state
379 {
380         SMU_BACO_STATE_ENTER = 0,
381         SMU_BACO_STATE_EXIT,
382 };
383
384 struct smu_baco_context
385 {
386         struct mutex mutex;
387         uint32_t state;
388         bool platform_support;
389 };
390
391 struct pstates_clk_freq {
392         uint32_t                        min;
393         uint32_t                        standard;
394         uint32_t                        peak;
395 };
396
397 struct smu_umd_pstate_table {
398         struct pstates_clk_freq         gfxclk_pstate;
399         struct pstates_clk_freq         socclk_pstate;
400         struct pstates_clk_freq         uclk_pstate;
401         struct pstates_clk_freq         vclk_pstate;
402         struct pstates_clk_freq         dclk_pstate;
403 };
404
405 struct cmn2asic_msg_mapping {
406         int     valid_mapping;
407         int     map_to;
408         int     valid_in_vf;
409 };
410
411 struct cmn2asic_mapping {
412         int     valid_mapping;
413         int     map_to;
414 };
415
416 #define WORKLOAD_POLICY_MAX 7
417 struct smu_context
418 {
419         struct amdgpu_device            *adev;
420         struct amdgpu_irq_src           irq_source;
421
422         const struct pptable_funcs      *ppt_funcs;
423         const struct cmn2asic_msg_mapping       *message_map;
424         const struct cmn2asic_mapping   *clock_map;
425         const struct cmn2asic_mapping   *feature_map;
426         const struct cmn2asic_mapping   *table_map;
427         const struct cmn2asic_mapping   *pwr_src_map;
428         const struct cmn2asic_mapping   *workload_map;
429         struct mutex                    mutex;
430         struct mutex                    sensor_lock;
431         struct mutex                    metrics_lock;
432         struct mutex                    message_lock;
433         uint64_t pool_size;
434
435         struct smu_table_context        smu_table;
436         struct smu_dpm_context          smu_dpm;
437         struct smu_power_context        smu_power;
438         struct smu_feature              smu_feature;
439         struct amd_pp_display_configuration  *display_config;
440         struct smu_baco_context         smu_baco;
441         struct smu_temperature_range    thermal_range;
442         void *od_settings;
443
444         struct smu_umd_pstate_table     pstate_table;
445         uint32_t pstate_sclk;
446         uint32_t pstate_mclk;
447
448         bool od_enabled;
449         uint32_t current_power_limit;
450         uint32_t default_power_limit;
451         uint32_t max_power_limit;
452
453         /* soft pptable */
454         uint32_t ppt_offset_bytes;
455         uint32_t ppt_size_bytes;
456         uint8_t  *ppt_start_addr;
457
458         bool support_power_containment;
459         bool disable_watermark;
460
461 #define WATERMARKS_EXIST        (1 << 0)
462 #define WATERMARKS_LOADED       (1 << 1)
463         uint32_t watermarks_bitmap;
464         uint32_t hard_min_uclk_req_from_dal;
465         bool disable_uclk_switch;
466
467         uint32_t workload_mask;
468         uint32_t workload_prority[WORKLOAD_POLICY_MAX];
469         uint32_t workload_setting[WORKLOAD_POLICY_MAX];
470         uint32_t power_profile_mode;
471         uint32_t default_power_profile_mode;
472         bool pm_enabled;
473         bool is_apu;
474
475         uint32_t smc_driver_if_version;
476         uint32_t smc_fw_if_version;
477         uint32_t smc_fw_version;
478
479         bool uploading_custom_pp_table;
480         bool dc_controlled_by_gpio;
481
482         struct work_struct throttling_logging_work;
483         atomic64_t throttle_int_counter;
484         struct work_struct interrupt_work;
485
486         unsigned fan_max_rpm;
487         unsigned manual_fan_speed_percent;
488
489         uint32_t gfx_default_hard_min_freq;
490         uint32_t gfx_default_soft_max_freq;
491         uint32_t gfx_actual_hard_min_freq;
492         uint32_t gfx_actual_soft_max_freq;
493
494         /* APU only */
495         uint32_t cpu_default_soft_min_freq;
496         uint32_t cpu_default_soft_max_freq;
497         uint32_t cpu_actual_soft_min_freq;
498         uint32_t cpu_actual_soft_max_freq;
499         uint32_t cpu_core_id_select;
500         uint16_t cpu_core_num;
501
502         struct smu_user_dpm_profile user_dpm_profile;
503 };
504
505 struct i2c_adapter;
506
507 /**
508  * struct pptable_funcs - Callbacks used to interact with the SMU.
509  */
510 struct pptable_funcs {
511         /**
512          * @run_btc: Calibrate voltage/frequency curve to fit the system's
513          *           power delivery and voltage margins. Required for adaptive
514          *           voltage frequency scaling (AVFS).
515          */
516         int (*run_btc)(struct smu_context *smu);
517
518         /**
519          * @get_allowed_feature_mask: Get allowed feature mask.
520          * &feature_mask: Array to store feature mask.
521          * &num: Elements in &feature_mask.
522          */
523         int (*get_allowed_feature_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num);
524
525         /**
526          * @get_current_power_state: Get the current power state.
527          *
528          * Return: Current power state on success, negative errno on failure.
529          */
530         enum amd_pm_state_type (*get_current_power_state)(struct smu_context *smu);
531
532         /**
533          * @set_default_dpm_table: Retrieve the default overdrive settings from
534          *                         the SMU.
535          */
536         int (*set_default_dpm_table)(struct smu_context *smu);
537
538         int (*set_power_state)(struct smu_context *smu);
539
540         /**
541          * @populate_umd_state_clk: Populate the UMD power state table with
542          *                          defaults.
543          */
544         int (*populate_umd_state_clk)(struct smu_context *smu);
545
546         /**
547          * @print_clk_levels: Print DPM clock levels for a clock domain
548          *                    to buffer. Star current level.
549          *
550          * Used for sysfs interfaces.
551          */
552         int (*print_clk_levels)(struct smu_context *smu, enum smu_clk_type clk_type, char *buf);
553
554         /**
555          * @force_clk_levels: Set a range of allowed DPM levels for a clock
556          *                    domain.
557          * &clk_type: Clock domain.
558          * &mask: Range of allowed DPM levels.
559          */
560         int (*force_clk_levels)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t mask);
561
562         /**
563          * @od_edit_dpm_table: Edit the custom overdrive DPM table.
564          * &type: Type of edit.
565          * &input: Edit parameters.
566          * &size: Size of &input.
567          */
568         int (*od_edit_dpm_table)(struct smu_context *smu,
569                                  enum PP_OD_DPM_TABLE_COMMAND type,
570                                  long *input, uint32_t size);
571
572         /**
573          * @get_clock_by_type_with_latency: Get the speed and latency of a clock
574          *                                  domain.
575          */
576         int (*get_clock_by_type_with_latency)(struct smu_context *smu,
577                                               enum smu_clk_type clk_type,
578                                               struct
579                                               pp_clock_levels_with_latency
580                                               *clocks);
581         /**
582          * @get_clock_by_type_with_voltage: Get the speed and voltage of a clock
583          *                                  domain.
584          */
585         int (*get_clock_by_type_with_voltage)(struct smu_context *smu,
586                                               enum amd_pp_clock_type type,
587                                               struct
588                                               pp_clock_levels_with_voltage
589                                               *clocks);
590
591         /**
592          * @get_power_profile_mode: Print all power profile modes to
593          *                          buffer. Star current mode.
594          */
595         int (*get_power_profile_mode)(struct smu_context *smu, char *buf);
596
597         /**
598          * @set_power_profile_mode: Set a power profile mode. Also used to
599          *                          create/set custom power profile modes.
600          * &input: Power profile mode parameters.
601          * &size: Size of &input.
602          */
603         int (*set_power_profile_mode)(struct smu_context *smu, long *input, uint32_t size);
604
605         /**
606          * @dpm_set_vcn_enable: Enable/disable VCN engine dynamic power
607          *                      management.
608          */
609         int (*dpm_set_vcn_enable)(struct smu_context *smu, bool enable);
610
611         /**
612          * @dpm_set_jpeg_enable: Enable/disable JPEG engine dynamic power
613          *                       management.
614          */
615         int (*dpm_set_jpeg_enable)(struct smu_context *smu, bool enable);
616
617         /**
618          * @read_sensor: Read data from a sensor.
619          * &sensor: Sensor to read data from.
620          * &data: Sensor reading.
621          * &size: Size of &data.
622          */
623         int (*read_sensor)(struct smu_context *smu, enum amd_pp_sensors sensor,
624                            void *data, uint32_t *size);
625
626         /**
627          * @pre_display_config_changed: Prepare GPU for a display configuration
628          *                              change.
629          *
630          * Disable display tracking and pin memory clock speed to maximum. Used
631          * in display component synchronization.
632          */
633         int (*pre_display_config_changed)(struct smu_context *smu);
634
635         /**
636          * @display_config_changed: Notify the SMU of the current display
637          *                          configuration.
638          *
639          * Allows SMU to properly track blanking periods for memory clock
640          * adjustment. Used in display component synchronization.
641          */
642         int (*display_config_changed)(struct smu_context *smu);
643
644         int (*apply_clocks_adjust_rules)(struct smu_context *smu);
645
646         /**
647          * @notify_smc_display_config: Applies display requirements to the
648          *                             current power state.
649          *
650          * Optimize deep sleep DCEFclk and mclk for the current display
651          * configuration. Used in display component synchronization.
652          */
653         int (*notify_smc_display_config)(struct smu_context *smu);
654
655         /**
656          * @is_dpm_running: Check if DPM is running.
657          *
658          * Return: True if DPM is running, false otherwise.
659          */
660         bool (*is_dpm_running)(struct smu_context *smu);
661
662         /**
663          * @get_fan_speed_percent: Get the current fan speed in percent.
664          */
665         int (*get_fan_speed_percent)(struct smu_context *smu, uint32_t *speed);
666
667         /**
668          * @set_watermarks_table: Configure and upload the watermarks tables to
669          *                        the SMU.
670          */
671         int (*set_watermarks_table)(struct smu_context *smu,
672                                     struct pp_smu_wm_range_sets *clock_ranges);
673
674         /**
675          * @get_thermal_temperature_range: Get safe thermal limits in Celcius.
676          */
677         int (*get_thermal_temperature_range)(struct smu_context *smu, struct smu_temperature_range *range);
678
679         /**
680          * @get_uclk_dpm_states: Get memory clock DPM levels in kHz.
681          * &clocks_in_khz: Array of DPM levels.
682          * &num_states: Elements in &clocks_in_khz.
683          */
684         int (*get_uclk_dpm_states)(struct smu_context *smu, uint32_t *clocks_in_khz, uint32_t *num_states);
685
686         /**
687          * @set_default_od_settings: Set the overdrive tables to defaults.
688          */
689         int (*set_default_od_settings)(struct smu_context *smu);
690
691         /**
692          * @set_performance_level: Set a performance level.
693          */
694         int (*set_performance_level)(struct smu_context *smu, enum amd_dpm_forced_level level);
695
696         /**
697          * @display_disable_memory_clock_switch: Enable/disable dynamic memory
698          *                                       clock switching.
699          *
700          * Disabling this feature forces memory clock speed to maximum.
701          * Enabling sets the minimum memory clock capable of driving the
702          * current display configuration.
703          */
704         int (*display_disable_memory_clock_switch)(struct smu_context *smu, bool disable_memory_clock_switch);
705
706         /**
707          * @dump_pptable: Print the power play table to the system log.
708          */
709         void (*dump_pptable)(struct smu_context *smu);
710
711         /**
712          * @get_power_limit: Get the device's power limits.
713          */
714         int (*get_power_limit)(struct smu_context *smu);
715
716         /**
717          * @get_ppt_limit: Get the device's ppt limits.
718          */
719         int (*get_ppt_limit)(struct smu_context *smu, uint32_t *ppt_limit,
720                         enum smu_ppt_limit_type limit_type, enum smu_ppt_limit_level limit_level);
721
722         /**
723          * @set_df_cstate: Set data fabric cstate.
724          */
725         int (*set_df_cstate)(struct smu_context *smu, enum pp_df_cstate state);
726
727         /**
728          * @allow_xgmi_power_down: Enable/disable external global memory
729          *                         interconnect power down.
730          */
731         int (*allow_xgmi_power_down)(struct smu_context *smu, bool en);
732
733         /**
734          * @update_pcie_parameters: Update and upload the system's PCIe
735          *                          capabilites to the SMU.
736          * &pcie_gen_cap: Maximum allowed PCIe generation.
737          * &pcie_width_cap: Maximum allowed PCIe width.
738          */
739         int (*update_pcie_parameters)(struct smu_context *smu, uint32_t pcie_gen_cap, uint32_t pcie_width_cap);
740
741         /**
742          * @i2c_init: Initialize i2c.
743          *
744          * The i2c bus is used internally by the SMU voltage regulators and
745          * other devices. The i2c's EEPROM also stores bad page tables on boards
746          * with ECC.
747          */
748         int (*i2c_init)(struct smu_context *smu, struct i2c_adapter *control);
749
750         /**
751          * @i2c_fini: Tear down i2c.
752          */
753         void (*i2c_fini)(struct smu_context *smu, struct i2c_adapter *control);
754
755         /**
756          * @get_unique_id: Get the GPU's unique id. Used for asset tracking.
757          */
758         void (*get_unique_id)(struct smu_context *smu);
759
760         /**
761          * @get_dpm_clock_table: Get a copy of the DPM clock table.
762          *
763          * Used by display component in bandwidth and watermark calculations.
764          */
765         int (*get_dpm_clock_table)(struct smu_context *smu, struct dpm_clocks *clock_table);
766
767         /**
768          * @init_microcode: Request the SMU's firmware from the kernel.
769          */
770         int (*init_microcode)(struct smu_context *smu);
771
772         /**
773          * @load_microcode: Load firmware onto the SMU.
774          */
775         int (*load_microcode)(struct smu_context *smu);
776
777         /**
778          * @fini_microcode: Release the SMU's firmware.
779          */
780         void (*fini_microcode)(struct smu_context *smu);
781
782         /**
783          * @init_smc_tables: Initialize the SMU tables.
784          */
785         int (*init_smc_tables)(struct smu_context *smu);
786
787         /**
788          * @fini_smc_tables: Release the SMU tables.
789          */
790         int (*fini_smc_tables)(struct smu_context *smu);
791
792         /**
793          * @init_power: Initialize the power gate table context.
794          */
795         int (*init_power)(struct smu_context *smu);
796
797         /**
798          * @fini_power: Release the power gate table context.
799          */
800         int (*fini_power)(struct smu_context *smu);
801
802         /**
803          * @check_fw_status: Check the SMU's firmware status.
804          *
805          * Return: Zero if check passes, negative errno on failure.
806          */
807         int (*check_fw_status)(struct smu_context *smu);
808
809         /**
810          * @setup_pptable: Initialize the power play table and populate it with
811          *                 default values.
812          */
813         int (*setup_pptable)(struct smu_context *smu);
814
815         /**
816          * @get_vbios_bootup_values: Get default boot values from the VBIOS.
817          */
818         int (*get_vbios_bootup_values)(struct smu_context *smu);
819
820         /**
821          * @check_fw_version: Print driver and SMU interface versions to the
822          *                    system log.
823          *
824          * Interface mismatch is not a critical failure.
825          */
826         int (*check_fw_version)(struct smu_context *smu);
827
828         /**
829          * @powergate_sdma: Power up/down system direct memory access.
830          */
831         int (*powergate_sdma)(struct smu_context *smu, bool gate);
832
833         /**
834          * @set_gfx_cgpg: Enable/disable graphics engine course grain power
835          *                gating.
836          */
837         int (*set_gfx_cgpg)(struct smu_context *smu, bool enable);
838
839         /**
840          * @write_pptable: Write the power play table to the SMU.
841          */
842         int (*write_pptable)(struct smu_context *smu);
843
844         /**
845          * @set_driver_table_location: Send the location of the driver table to
846          *                             the SMU.
847          */
848         int (*set_driver_table_location)(struct smu_context *smu);
849
850         /**
851          * @set_tool_table_location: Send the location of the tool table to the
852          *                           SMU.
853          */
854         int (*set_tool_table_location)(struct smu_context *smu);
855
856         /**
857          * @notify_memory_pool_location: Send the location of the memory pool to
858          *                               the SMU.
859          */
860         int (*notify_memory_pool_location)(struct smu_context *smu);
861
862         /**
863          * @system_features_control: Enable/disable all SMU features.
864          */
865         int (*system_features_control)(struct smu_context *smu, bool en);
866
867         /**
868          * @send_smc_msg_with_param: Send a message with a parameter to the SMU.
869          * &msg: Type of message.
870          * &param: Message parameter.
871          * &read_arg: SMU response (optional).
872          */
873         int (*send_smc_msg_with_param)(struct smu_context *smu,
874                                        enum smu_message_type msg, uint32_t param, uint32_t *read_arg);
875
876         /**
877          * @send_smc_msg: Send a message to the SMU.
878          * &msg: Type of message.
879          * &read_arg: SMU response (optional).
880          */
881         int (*send_smc_msg)(struct smu_context *smu,
882                             enum smu_message_type msg,
883                             uint32_t *read_arg);
884
885         /**
886          * @init_display_count: Notify the SMU of the number of display
887          *                      components in current display configuration.
888          */
889         int (*init_display_count)(struct smu_context *smu, uint32_t count);
890
891         /**
892          * @set_allowed_mask: Notify the SMU of the features currently allowed
893          *                    by the driver.
894          */
895         int (*set_allowed_mask)(struct smu_context *smu);
896
897         /**
898          * @get_enabled_mask: Get a mask of features that are currently enabled
899          *                    on the SMU.
900          * &feature_mask: Array representing enabled feature mask.
901          * &num: Elements in &feature_mask.
902          */
903         int (*get_enabled_mask)(struct smu_context *smu, uint32_t *feature_mask, uint32_t num);
904
905         /**
906          * @feature_is_enabled: Test if a feature is enabled.
907          *
908          * Return: One if enabled, zero if disabled.
909          */
910         int (*feature_is_enabled)(struct smu_context *smu, enum smu_feature_mask mask);
911
912         /**
913          * @disable_all_features_with_exception: Disable all features with
914          *                                       exception to those in &mask.
915          */
916         int (*disable_all_features_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
917
918         /**
919          * @notify_display_change: Enable fast memory clock switching.
920          *
921          * Allows for fine grained memory clock switching but has more stringent
922          * timing requirements.
923          */
924         int (*notify_display_change)(struct smu_context *smu);
925
926         /**
927          * @set_power_limit: Set power limit in watts.
928          */
929         int (*set_power_limit)(struct smu_context *smu, uint32_t n);
930
931         /**
932          * @init_max_sustainable_clocks: Populate max sustainable clock speed
933          *                               table with values from the SMU.
934          */
935         int (*init_max_sustainable_clocks)(struct smu_context *smu);
936
937         /**
938          * @enable_thermal_alert: Enable thermal alert interrupts.
939          */
940         int (*enable_thermal_alert)(struct smu_context *smu);
941
942         /**
943          * @disable_thermal_alert: Disable thermal alert interrupts.
944          */
945         int (*disable_thermal_alert)(struct smu_context *smu);
946
947         /**
948          * @set_min_dcef_deep_sleep: Set a minimum display fabric deep sleep
949          *                           clock speed in MHz.
950          */
951         int (*set_min_dcef_deep_sleep)(struct smu_context *smu, uint32_t clk);
952
953         /**
954          * @display_clock_voltage_request: Set a hard minimum frequency
955          * for a clock domain.
956          */
957         int (*display_clock_voltage_request)(struct smu_context *smu, struct
958                                              pp_display_clock_request
959                                              *clock_req);
960
961         /**
962          * @get_fan_control_mode: Get the current fan control mode.
963          */
964         uint32_t (*get_fan_control_mode)(struct smu_context *smu);
965
966         /**
967          * @set_fan_control_mode: Set the fan control mode.
968          */
969         int (*set_fan_control_mode)(struct smu_context *smu, uint32_t mode);
970
971         /**
972          * @set_fan_speed_percent: Set a static fan speed in percent.
973          */
974         int (*set_fan_speed_percent)(struct smu_context *smu, uint32_t speed);
975
976         /**
977          * @set_xgmi_pstate: Set inter-chip global memory interconnect pstate.
978          * &pstate: Pstate to set. D0 if Nonzero, D3 otherwise.
979          */
980         int (*set_xgmi_pstate)(struct smu_context *smu, uint32_t pstate);
981
982         /**
983          * @gfx_off_control: Enable/disable graphics engine poweroff.
984          */
985         int (*gfx_off_control)(struct smu_context *smu, bool enable);
986
987
988         /**
989          * @get_gfx_off_status: Get graphics engine poweroff status.
990          *
991          * Return:
992          * 0 - GFXOFF(default).
993          * 1 - Transition out of GFX State.
994          * 2 - Not in GFXOFF.
995          * 3 - Transition into GFXOFF.
996          */
997         uint32_t (*get_gfx_off_status)(struct smu_context *smu);
998
999         /**
1000          * @register_irq_handler: Register interupt request handlers.
1001          */
1002         int (*register_irq_handler)(struct smu_context *smu);
1003
1004         /**
1005          * @set_azalia_d3_pme: Wake the audio decode engine from d3 sleep.
1006          */
1007         int (*set_azalia_d3_pme)(struct smu_context *smu);
1008
1009         /**
1010          * @get_max_sustainable_clocks_by_dc: Get a copy of the max sustainable
1011          *                                    clock speeds table.
1012          *
1013          * Provides a way for the display component (DC) to get the max
1014          * sustainable clocks from the SMU.
1015          */
1016         int (*get_max_sustainable_clocks_by_dc)(struct smu_context *smu, struct pp_smu_nv_clock_table *max_clocks);
1017
1018         /**
1019          * @baco_is_support: Check if GPU supports BACO (Bus Active, Chip Off).
1020          */
1021         bool (*baco_is_support)(struct smu_context *smu);
1022
1023         /**
1024          * @baco_get_state: Get the current BACO state.
1025          *
1026          * Return: Current BACO state.
1027          */
1028         enum smu_baco_state (*baco_get_state)(struct smu_context *smu);
1029
1030         /**
1031          * @baco_set_state: Enter/exit BACO.
1032          */
1033         int (*baco_set_state)(struct smu_context *smu, enum smu_baco_state state);
1034
1035         /**
1036          * @baco_enter: Enter BACO.
1037          */
1038         int (*baco_enter)(struct smu_context *smu);
1039
1040         /**
1041          * @baco_exit: Exit Baco.
1042          */
1043         int (*baco_exit)(struct smu_context *smu);
1044
1045         /**
1046          * @mode1_reset_is_support: Check if GPU supports mode1 reset.
1047          */
1048         bool (*mode1_reset_is_support)(struct smu_context *smu);
1049         /**
1050          * @mode2_reset_is_support: Check if GPU supports mode2 reset.
1051          */
1052         bool (*mode2_reset_is_support)(struct smu_context *smu);
1053
1054         /**
1055          * @mode1_reset: Perform mode1 reset.
1056          *
1057          * Complete GPU reset.
1058          */
1059         int (*mode1_reset)(struct smu_context *smu);
1060
1061         /**
1062          * @mode2_reset: Perform mode2 reset.
1063          *
1064          * Mode2 reset generally does not reset as many IPs as mode1 reset. The
1065          * IPs reset varies by asic.
1066          */
1067         int (*mode2_reset)(struct smu_context *smu);
1068
1069         /**
1070          * @get_dpm_ultimate_freq: Get the hard frequency range of a clock
1071          *                         domain in MHz.
1072          */
1073         int (*get_dpm_ultimate_freq)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t *min, uint32_t *max);
1074
1075         /**
1076          * @set_soft_freq_limited_range: Set the soft frequency range of a clock
1077          *                               domain in MHz.
1078          */
1079         int (*set_soft_freq_limited_range)(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t min, uint32_t max);
1080
1081         /**
1082          * @set_power_source: Notify the SMU of the current power source.
1083          */
1084         int (*set_power_source)(struct smu_context *smu, enum smu_power_src_type power_src);
1085
1086         /**
1087          * @log_thermal_throttling_event: Print a thermal throttling warning to
1088          *                                the system's log.
1089          */
1090         void (*log_thermal_throttling_event)(struct smu_context *smu);
1091
1092         /**
1093          * @get_pp_feature_mask: Print a human readable table of enabled
1094          *                       features to buffer.
1095          */
1096         size_t (*get_pp_feature_mask)(struct smu_context *smu, char *buf);
1097
1098         /**
1099          * @set_pp_feature_mask: Request the SMU enable/disable features to
1100          *                       match those enabled in &new_mask.
1101          */
1102         int (*set_pp_feature_mask)(struct smu_context *smu, uint64_t new_mask);
1103
1104         /**
1105          * @get_gpu_metrics: Get a copy of the GPU metrics table from the SMU.
1106          *
1107          * Return: Size of &table
1108          */
1109         ssize_t (*get_gpu_metrics)(struct smu_context *smu, void **table);
1110
1111         /**
1112          * @enable_mgpu_fan_boost: Enable multi-GPU fan boost.
1113          */
1114         int (*enable_mgpu_fan_boost)(struct smu_context *smu);
1115
1116         /**
1117          * @gfx_ulv_control: Enable/disable ultra low voltage.
1118          */
1119         int (*gfx_ulv_control)(struct smu_context *smu, bool enablement);
1120
1121         /**
1122          * @deep_sleep_control: Enable/disable deep sleep.
1123          */
1124         int (*deep_sleep_control)(struct smu_context *smu, bool enablement);
1125
1126         /**
1127          * @get_fan_parameters: Get fan parameters.
1128          *
1129          * Get maximum fan speed from the power play table.
1130          */
1131         int (*get_fan_parameters)(struct smu_context *smu);
1132
1133         /**
1134          * @post_init: Helper function for asic specific workarounds.
1135          */
1136         int (*post_init)(struct smu_context *smu);
1137
1138         /**
1139          * @interrupt_work: Work task scheduled from SMU interrupt handler.
1140          */
1141         void (*interrupt_work)(struct smu_context *smu);
1142
1143         /**
1144          * @gpo_control: Enable/disable graphics power optimization if supported.
1145          */
1146         int (*gpo_control)(struct smu_context *smu, bool enablement);
1147
1148         /**
1149          * @gfx_state_change_set: Send the current graphics state to the SMU.
1150          */
1151         int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);
1152
1153         /**
1154          * @set_fine_grain_gfx_freq_parameters: Set fine grain graphics clock
1155          *                                      parameters to defaults.
1156          */
1157         int (*set_fine_grain_gfx_freq_parameters)(struct smu_context *smu);
1158
1159         /**
1160          * @set_light_sbr:  Set light sbr mode for the SMU.
1161          */
1162         int (*set_light_sbr)(struct smu_context *smu, bool enable);
1163 };
1164
1165 typedef enum {
1166         METRICS_CURR_GFXCLK,
1167         METRICS_CURR_SOCCLK,
1168         METRICS_CURR_UCLK,
1169         METRICS_CURR_VCLK,
1170         METRICS_CURR_VCLK1,
1171         METRICS_CURR_DCLK,
1172         METRICS_CURR_DCLK1,
1173         METRICS_CURR_FCLK,
1174         METRICS_CURR_DCEFCLK,
1175         METRICS_AVERAGE_CPUCLK,
1176         METRICS_AVERAGE_GFXCLK,
1177         METRICS_AVERAGE_SOCCLK,
1178         METRICS_AVERAGE_FCLK,
1179         METRICS_AVERAGE_UCLK,
1180         METRICS_AVERAGE_VCLK,
1181         METRICS_AVERAGE_DCLK,
1182         METRICS_AVERAGE_GFXACTIVITY,
1183         METRICS_AVERAGE_MEMACTIVITY,
1184         METRICS_AVERAGE_VCNACTIVITY,
1185         METRICS_AVERAGE_SOCKETPOWER,
1186         METRICS_TEMPERATURE_EDGE,
1187         METRICS_TEMPERATURE_HOTSPOT,
1188         METRICS_TEMPERATURE_MEM,
1189         METRICS_TEMPERATURE_VRGFX,
1190         METRICS_TEMPERATURE_VRSOC,
1191         METRICS_TEMPERATURE_VRMEM,
1192         METRICS_THROTTLER_STATUS,
1193         METRICS_CURR_FANSPEED,
1194         METRICS_VOLTAGE_VDDSOC,
1195         METRICS_VOLTAGE_VDDGFX,
1196 } MetricsMember_t;
1197
1198 enum smu_cmn2asic_mapping_type {
1199         CMN2ASIC_MAPPING_MSG,
1200         CMN2ASIC_MAPPING_CLK,
1201         CMN2ASIC_MAPPING_FEATURE,
1202         CMN2ASIC_MAPPING_TABLE,
1203         CMN2ASIC_MAPPING_PWR,
1204         CMN2ASIC_MAPPING_WORKLOAD,
1205 };
1206
1207 #define MSG_MAP(msg, index, valid_in_vf) \
1208         [SMU_MSG_##msg] = {1, (index), (valid_in_vf)}
1209
1210 #define CLK_MAP(clk, index) \
1211         [SMU_##clk] = {1, (index)}
1212
1213 #define FEA_MAP(fea) \
1214         [SMU_FEATURE_##fea##_BIT] = {1, FEATURE_##fea##_BIT}
1215
1216 #define FEA_MAP_REVERSE(fea) \
1217         [SMU_FEATURE_DPM_##fea##_BIT] = {1, FEATURE_##fea##_DPM_BIT}
1218
1219 #define FEA_MAP_HALF_REVERSE(fea) \
1220         [SMU_FEATURE_DPM_##fea##CLK_BIT] = {1, FEATURE_##fea##_DPM_BIT}
1221
1222 #define TAB_MAP(tab) \
1223         [SMU_TABLE_##tab] = {1, TABLE_##tab}
1224
1225 #define TAB_MAP_VALID(tab) \
1226         [SMU_TABLE_##tab] = {1, TABLE_##tab}
1227
1228 #define TAB_MAP_INVALID(tab) \
1229         [SMU_TABLE_##tab] = {0, TABLE_##tab}
1230
1231 #define PWR_MAP(tab) \
1232         [SMU_POWER_SOURCE_##tab] = {1, POWER_SOURCE_##tab}
1233
1234 #define WORKLOAD_MAP(profile, workload) \
1235         [profile] = {1, (workload)}
1236
1237 #if !defined(SWSMU_CODE_LAYER_L2) && !defined(SWSMU_CODE_LAYER_L3) && !defined(SWSMU_CODE_LAYER_L4)
1238 int smu_load_microcode(struct smu_context *smu);
1239
1240 int smu_check_fw_status(struct smu_context *smu);
1241
1242 int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled);
1243
1244 int smu_set_fan_speed_rpm(void *handle, uint32_t speed);
1245
1246 int smu_get_power_limit(struct smu_context *smu,
1247                         uint32_t *limit,
1248                         enum smu_ppt_limit_level limit_level);
1249
1250 int smu_set_power_limit(void *handle, uint32_t limit);
1251 int smu_print_ppclk_levels(void *handle, enum pp_clock_type type, char *buf);
1252
1253 int smu_od_edit_dpm_table(void *handle,
1254                           enum PP_OD_DPM_TABLE_COMMAND type,
1255                           long *input, uint32_t size);
1256
1257 int smu_read_sensor(void *handle, int sensor, void *data, int *size);
1258 int smu_get_power_profile_mode(void *handle, char *buf);
1259 int smu_set_power_profile_mode(void *handle, long *param, uint32_t param_size);
1260 u32 smu_get_fan_control_mode(void *handle);
1261 int smu_set_fan_control_mode(struct smu_context *smu, int value);
1262 void smu_pp_set_fan_control_mode(void *handle, u32 value);
1263 int smu_get_fan_speed_percent(void *handle, u32 *speed);
1264 int smu_set_fan_speed_percent(void *handle, u32 speed);
1265 int smu_get_fan_speed_rpm(void *handle, uint32_t *speed);
1266
1267 int smu_set_deep_sleep_dcefclk(struct smu_context *smu, int clk);
1268
1269 int smu_get_clock_by_type_with_latency(struct smu_context *smu,
1270                                        enum smu_clk_type clk_type,
1271                                        struct pp_clock_levels_with_latency *clocks);
1272
1273 int smu_display_clock_voltage_request(struct smu_context *smu,
1274                                       struct pp_display_clock_request *clock_req);
1275 int smu_display_disable_memory_clock_switch(struct smu_context *smu, bool disable_memory_clock_switch);
1276
1277 int smu_set_xgmi_pstate(void *handle,
1278                         uint32_t pstate);
1279
1280 int smu_set_azalia_d3_pme(struct smu_context *smu);
1281
1282 bool smu_baco_is_support(struct smu_context *smu);
1283 int smu_get_baco_capability(void *handle, bool *cap);
1284
1285 int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state);
1286
1287 int smu_baco_enter(struct smu_context *smu);
1288 int smu_baco_exit(struct smu_context *smu);
1289 int smu_baco_set_state(void *handle, int state);
1290
1291
1292 bool smu_mode1_reset_is_support(struct smu_context *smu);
1293 bool smu_mode2_reset_is_support(struct smu_context *smu);
1294 int smu_mode1_reset(struct smu_context *smu);
1295 int smu_mode2_reset(void *handle);
1296
1297 extern const struct amd_ip_funcs smu_ip_funcs;
1298
1299 extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;
1300 extern const struct amdgpu_ip_block_version smu_v12_0_ip_block;
1301 extern const struct amdgpu_ip_block_version smu_v13_0_ip_block;
1302
1303 bool is_support_sw_smu(struct amdgpu_device *adev);
1304 bool is_support_cclk_dpm(struct amdgpu_device *adev);
1305 int smu_reset(struct smu_context *smu);
1306 int smu_sys_get_pp_table(void *handle, char **table);
1307 int smu_sys_set_pp_table(void *handle, const char *buf, size_t size);
1308 int smu_get_power_num_states(void *handle, struct pp_states_info *state_info);
1309 enum amd_pm_state_type smu_get_current_power_state(void *handle);
1310 int smu_write_watermarks_table(struct smu_context *smu);
1311 int smu_set_watermarks_for_clock_ranges(
1312                 struct smu_context *smu,
1313                 struct pp_smu_wm_range_sets *clock_ranges);
1314
1315 /* smu to display interface */
1316 extern int smu_display_configuration_change(struct smu_context *smu, const
1317                                             struct amd_pp_display_configuration
1318                                             *display_config);
1319 extern int smu_dpm_set_power_gate(void *handle, uint32_t block_type, bool gate);
1320 extern int smu_handle_task(struct smu_context *smu,
1321                            enum amd_dpm_forced_level level,
1322                            enum amd_pp_task task_id,
1323                            bool lock_needed);
1324 extern int smu_handle_dpm_task(void *handle,
1325                                enum amd_pp_task task_id,
1326                                enum amd_pm_state_type *user_state);
1327 int smu_switch_power_profile(void *handle,
1328                              enum PP_SMC_POWER_PROFILE type,
1329                              bool en);
1330 int smu_get_dpm_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
1331                            uint32_t *min, uint32_t *max);
1332 u32 smu_get_mclk(void *handle, bool low);
1333 u32 smu_get_sclk(void *handle, bool low);
1334 int smu_set_soft_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
1335                             uint32_t min, uint32_t max);
1336 enum amd_dpm_forced_level smu_get_performance_level(void *handle);
1337 int smu_force_performance_level(void *handle, enum amd_dpm_forced_level level);
1338 int smu_set_display_count(struct smu_context *smu, uint32_t count);
1339 int smu_set_ac_dc(struct smu_context *smu);
1340 int smu_sys_get_pp_feature_mask(void *handle, char *buf);
1341 int smu_sys_set_pp_feature_mask(void *handle, uint64_t new_mask);
1342 int smu_force_ppclk_levels(void *handle, enum pp_clock_type type, uint32_t mask);
1343 int smu_set_mp1_state(void *handle,
1344                       enum pp_mp1_state mp1_state);
1345 int smu_set_df_cstate(void *handle,
1346                       enum pp_df_cstate state);
1347 int smu_allow_xgmi_power_down(struct smu_context *smu, bool en);
1348
1349 int smu_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
1350                                          struct pp_smu_nv_clock_table *max_clocks);
1351
1352 int smu_get_uclk_dpm_states(struct smu_context *smu,
1353                             unsigned int *clock_values_in_khz,
1354                             unsigned int *num_states);
1355
1356 int smu_get_dpm_clock_table(struct smu_context *smu,
1357                             struct dpm_clocks *clock_table);
1358
1359 int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value);
1360
1361 ssize_t smu_sys_get_gpu_metrics(void *handle, void **table);
1362
1363 int smu_enable_mgpu_fan_boost(void *handle);
1364 int smu_gfx_state_change_set(struct smu_context *smu, uint32_t state);
1365
1366 int smu_set_light_sbr(struct smu_context *smu, bool enable);
1367
1368 #endif
1369 #endif