2 * Copyright 2017 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.
26 #ifndef DM_PP_SMU_IF__H
27 #define DM_PP_SMU_IF__H
30 * interface to PPLIB/SMU to setup clocks and pstate requirements on SoC
37 * PP_SMU_INTERFACE_X should be interpreted as the interface defined
38 * starting from X, where X is some family of ASICs. This is as
39 * opposed to interfaces used only for X. There will be some degree
40 * of interface sharing between families of ASIcs.
44 #ifndef CONFIG_TRIM_DRM_AMD_DC_DCN2_0
56 * interim extra handle for backwards compatibility
57 * as some existing functionality not yet implemented
64 PP_SMU_RESULT_UNDEFINED = 0,
67 PP_SMU_RESULT_UNSUPPORTED
70 #define PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN 0x0
71 #define PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX 0xFFFF
74 WM_TYPE_PSTATE_CHG = 0,
75 WM_TYPE_RETRAINING = 1,
78 /* This structure is a copy of WatermarkRowGeneric_t defined by smuxx_driver_if.h*/
79 struct pp_smu_wm_set_range {
80 uint16_t min_fill_clk_mhz;
81 uint16_t max_fill_clk_mhz;
82 uint16_t min_drain_clk_mhz;
83 uint16_t max_drain_clk_mhz;
89 #define MAX_WATERMARK_SETS 4
91 struct pp_smu_wm_range_sets {
92 unsigned int num_reader_wm_sets;
93 struct pp_smu_wm_set_range reader_wm_sets[MAX_WATERMARK_SETS];
95 unsigned int num_writer_wm_sets;
96 struct pp_smu_wm_set_range writer_wm_sets[MAX_WATERMARK_SETS];
99 struct pp_smu_funcs_rv {
100 struct pp_smu pp_smu;
102 /* PPSMC_MSG_SetDisplayCount
103 * 0 triggers S0i2 optimization
106 void (*set_display_count)(struct pp_smu *pp, int count);
108 /* reader and writer WM's are sent together as part of one table*/
110 * PPSMC_MSG_SetDriverDramAddrHigh
111 * PPSMC_MSG_SetDriverDramAddrLow
112 * PPSMC_MSG_TransferTableDram2Smu
115 void (*set_wm_ranges)(struct pp_smu *pp,
116 struct pp_smu_wm_range_sets *ranges);
118 /* PPSMC_MSG_SetHardMinDcfclkByFreq
119 * fixed clock at requested freq, either from FCH bypass or DFS
121 void (*set_hard_min_dcfclk_by_freq)(struct pp_smu *pp, int mhz);
123 /* PPSMC_MSG_SetMinDeepSleepDcfclk
124 * when DF is in cstate, dcf clock is further divided down
125 * to just above given frequency
127 void (*set_min_deep_sleep_dcfclk)(struct pp_smu *pp, int mhz);
129 /* PPSMC_MSG_SetHardMinFclkByFreq
130 * FCLK will vary with DPM, but never below requested hard min
132 void (*set_hard_min_fclk_by_freq)(struct pp_smu *pp, int mhz);
134 /* PPSMC_MSG_SetHardMinSocclkByFreq
135 * Needed for DWB support
137 void (*set_hard_min_socclk_by_freq)(struct pp_smu *pp, int mhz);
140 void (*set_pme_wa_enable)(struct pp_smu *pp);
143 #ifndef CONFIG_TRIM_DRM_AMD_DC_DCN2_0
144 /* Used by pp_smu_funcs_nv.set_voltage_by_freq
147 enum pp_smu_nv_clock_id {
154 * Used by pp_smu_funcs_nv.get_maximum_sustainable_clocks
156 struct pp_smu_nv_clock_table {
157 // voltage managed SMU, freq set by driver
158 unsigned int displayClockInKhz;
159 unsigned int dppClockInKhz;
160 unsigned int phyClockInKhz;
161 unsigned int pixelClockInKhz;
162 unsigned int dscClockInKhz;
164 // freq/voltage managed by SMU
165 unsigned int fabricClockInKhz;
166 unsigned int socClockInKhz;
167 unsigned int dcfClockInKhz;
168 unsigned int uClockInKhz;
171 struct pp_smu_funcs_nv {
172 struct pp_smu pp_smu;
174 /* PPSMC_MSG_SetDisplayCount
175 * 0 triggers S0i2 optimization
177 enum pp_smu_status (*set_display_count)(struct pp_smu *pp, int count);
179 /* PPSMC_MSG_SetHardMinDcfclkByFreq
180 * fixed clock at requested freq, either from FCH bypass or DFS
182 enum pp_smu_status (*set_hard_min_dcfclk_by_freq)(struct pp_smu *pp, int Mhz);
184 /* PPSMC_MSG_SetMinDeepSleepDcfclk
185 * when DF is in cstate, dcf clock is further divided down
186 * to just above given frequency
188 enum pp_smu_status (*set_min_deep_sleep_dcfclk)(struct pp_smu *pp, int Mhz);
190 /* PPSMC_MSG_SetHardMinUclkByFreq
191 * UCLK will vary with DPM, but never below requested hard min
193 enum pp_smu_status (*set_hard_min_uclk_by_freq)(struct pp_smu *pp, int Mhz);
195 /* PPSMC_MSG_SetHardMinSocclkByFreq
196 * Needed for DWB support
198 enum pp_smu_status (*set_hard_min_socclk_by_freq)(struct pp_smu *pp, int Mhz);
201 enum pp_smu_status (*set_pme_wa_enable)(struct pp_smu *pp);
203 /* PPSMC_MSG_SetHardMinByFreq
204 * Needed to set ASIC voltages for clocks programmed by DAL
206 enum pp_smu_status (*set_voltage_by_freq)(struct pp_smu *pp,
207 enum pp_smu_nv_clock_id clock_id, int Mhz);
209 /* reader and writer WM's are sent together as part of one table*/
211 * PPSMC_MSG_SetDriverDramAddrHigh
212 * PPSMC_MSG_SetDriverDramAddrLow
213 * PPSMC_MSG_TransferTableDram2Smu
216 * reader fill clk = uclk
217 * reader drain clk = dcfclk
218 * writer fill clk = socclk
219 * writer drain clk = uclk
221 enum pp_smu_status (*set_wm_ranges)(struct pp_smu *pp,
222 struct pp_smu_wm_range_sets *ranges);
224 /* Not a single SMU message. This call should return maximum sustainable limit for all
225 * clocks that DC depends on. These will be used as basis for mode enumeration.
227 enum pp_smu_status (*get_maximum_sustainable_clocks)(struct pp_smu *pp,
228 struct pp_smu_nv_clock_table *max_clocks);
230 /* This call should return the discrete uclk DPM states available
232 enum pp_smu_status (*get_uclk_dpm_states)(struct pp_smu *pp,
233 unsigned int *clock_values_in_khz, unsigned int *num_states);
235 /* Not a single SMU message. This call informs PPLIB that display will not be able
236 * to perform pstate handshaking in its current state. Typically this handshake
237 * is used to perform uCLK switching, so disabling pstate disables uCLK switching.
239 * Note that when setting handshake to unsupported, the call is pre-emptive. That means
240 * DC will make the call BEFORE setting up the display state which would cause pstate
241 * request to go un-acked. Only when the call completes should such a state be applied to
244 enum pp_smu_status (*set_pstate_handshake_support)(struct pp_smu *pp,
245 BOOLEAN pstate_handshake_supported);
249 struct pp_smu_funcs {
252 struct pp_smu_funcs_rv rv_funcs;
253 #ifndef CONFIG_TRIM_DRM_AMD_DC_DCN2_0
254 struct pp_smu_funcs_nv nv_funcs;
260 #endif /* DM_PP_SMU_IF__H */