aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2017-09-01 01:48:11 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-12 14:22:14 -0400
commit47047263c52779f1f3393c32e3e53661b53a372e (patch)
tree331b968b47b868c6e0d41cd33aa6c69ae7efdcba /drivers/gpu
parentdf1e63942063a0638a5813e5904988d834db2665 (diff)
drm/amd/powerplay: delete eventmgr related files.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/Makefile11
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c291
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.h62
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.c195
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.h34
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.c215
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.h59
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c104
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.c410
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.h100
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c445
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.h89
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/psm.c119
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/psm.h38
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/eventmanager.h109
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/eventmgr.h124
16 files changed, 0 insertions, 2405 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/Makefile b/drivers/gpu/drm/amd/powerplay/eventmgr/Makefile
deleted file mode 100644
index 7509e3850087..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1#
2# Makefile for the 'event manager' sub-component of powerplay.
3# It provides the event management services for the driver.
4
5EVENT_MGR = eventmgr.o eventinit.o eventmanagement.o \
6 eventactionchains.o eventsubchains.o eventtasks.o psm.o
7
8AMD_PP_EVENT = $(addprefix $(AMD_PP_PATH)/eventmgr/,$(EVENT_MGR))
9
10AMD_POWERPLAY_FILES += $(AMD_PP_EVENT)
11
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
deleted file mode 100644
index 8cee4e0f9fde..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
+++ /dev/null
@@ -1,291 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include "eventmgr.h"
24#include "eventactionchains.h"
25#include "eventsubchains.h"
26
27static const pem_event_action * const initialize_event[] = {
28 block_adjust_power_state_tasks,
29 power_budget_tasks,
30 system_config_tasks,
31 setup_asic_tasks,
32 enable_dynamic_state_management_tasks,
33 get_2d_performance_state_tasks,
34 set_performance_state_tasks,
35 initialize_thermal_controller_tasks,
36 conditionally_force_3d_performance_state_tasks,
37 process_vbios_eventinfo_tasks,
38 broadcast_power_policy_tasks,
39 NULL
40};
41
42const struct action_chain initialize_action_chain = {
43 "Initialize",
44 initialize_event
45};
46
47static const pem_event_action * const uninitialize_event[] = {
48 ungate_all_display_phys_tasks,
49 uninitialize_display_phy_access_tasks,
50 disable_gfx_voltage_island_power_gating_tasks,
51 disable_gfx_clock_gating_tasks,
52 uninitialize_thermal_controller_tasks,
53 set_boot_state_tasks,
54 adjust_power_state_tasks,
55 disable_dynamic_state_management_tasks,
56 disable_clock_power_gatings_tasks,
57 cleanup_asic_tasks,
58 prepare_for_pnp_stop_tasks,
59 NULL
60};
61
62const struct action_chain uninitialize_action_chain = {
63 "Uninitialize",
64 uninitialize_event
65};
66
67static const pem_event_action * const power_source_change_event_pp_enabled[] = {
68 set_power_source_tasks,
69 set_power_saving_state_tasks,
70 adjust_power_state_tasks,
71 enable_disable_fps_tasks,
72 set_nbmcu_state_tasks,
73 broadcast_power_policy_tasks,
74 NULL
75};
76
77const struct action_chain power_source_change_action_chain_pp_enabled = {
78 "Power source change - PowerPlay enabled",
79 power_source_change_event_pp_enabled
80};
81
82static const pem_event_action * const power_source_change_event_pp_disabled[] = {
83 set_power_source_tasks,
84 set_nbmcu_state_tasks,
85 NULL
86};
87
88const struct action_chain power_source_changes_action_chain_pp_disabled = {
89 "Power source change - PowerPlay disabled",
90 power_source_change_event_pp_disabled
91};
92
93static const pem_event_action * const power_source_change_event_hardware_dc[] = {
94 set_power_source_tasks,
95 set_power_saving_state_tasks,
96 adjust_power_state_tasks,
97 enable_disable_fps_tasks,
98 reset_hardware_dc_notification_tasks,
99 set_nbmcu_state_tasks,
100 broadcast_power_policy_tasks,
101 NULL
102};
103
104const struct action_chain power_source_change_action_chain_hardware_dc = {
105 "Power source change - with Hardware DC switching",
106 power_source_change_event_hardware_dc
107};
108
109static const pem_event_action * const suspend_event[] = {
110 reset_display_phy_access_tasks,
111 unregister_interrupt_tasks,
112 disable_gfx_voltage_island_power_gating_tasks,
113 disable_gfx_clock_gating_tasks,
114 notify_smu_suspend_tasks,
115 disable_smc_firmware_ctf_tasks,
116 set_boot_state_tasks,
117 adjust_power_state_tasks,
118 disable_fps_tasks,
119 vari_bright_suspend_tasks,
120 reset_fan_speed_to_default_tasks,
121 power_down_asic_tasks,
122 disable_stutter_mode_tasks,
123 set_connected_standby_tasks,
124 block_hw_access_tasks,
125 NULL
126};
127
128const struct action_chain suspend_action_chain = {
129 "Suspend",
130 suspend_event
131};
132
133static const pem_event_action * const resume_event[] = {
134 unblock_hw_access_tasks,
135 resume_connected_standby_tasks,
136 notify_smu_resume_tasks,
137 reset_display_configCounter_tasks,
138 update_dal_configuration_tasks,
139 vari_bright_resume_tasks,
140 setup_asic_tasks,
141 enable_stutter_mode_tasks, /*must do this in boot state and before SMC is started */
142 enable_dynamic_state_management_tasks,
143 enable_disable_bapm_tasks,
144 initialize_thermal_controller_tasks,
145 get_2d_performance_state_tasks,
146 set_performance_state_tasks,
147 adjust_power_state_tasks,
148 enable_disable_fps_tasks,
149 notify_hw_power_source_tasks,
150 process_vbios_event_info_tasks,
151 enable_gfx_clock_gating_tasks,
152 enable_gfx_voltage_island_power_gating_tasks,
153 reset_clock_gating_tasks,
154 notify_smu_vpu_recovery_end_tasks,
155 disable_vpu_cap_tasks,
156 execute_escape_sequence_tasks,
157 NULL
158};
159
160
161const struct action_chain resume_action_chain = {
162 "resume",
163 resume_event
164};
165
166static const pem_event_action * const complete_init_event[] = {
167 unblock_adjust_power_state_tasks,
168 adjust_power_state_tasks,
169 enable_gfx_clock_gating_tasks,
170 enable_gfx_voltage_island_power_gating_tasks,
171 notify_power_state_change_tasks,
172 NULL
173};
174
175const struct action_chain complete_init_action_chain = {
176 "complete init",
177 complete_init_event
178};
179
180static const pem_event_action * const enable_gfx_clock_gating_event[] = {
181 enable_gfx_clock_gating_tasks,
182 NULL
183};
184
185const struct action_chain enable_gfx_clock_gating_action_chain = {
186 "enable gfx clock gate",
187 enable_gfx_clock_gating_event
188};
189
190static const pem_event_action * const disable_gfx_clock_gating_event[] = {
191 disable_gfx_clock_gating_tasks,
192 NULL
193};
194
195const struct action_chain disable_gfx_clock_gating_action_chain = {
196 "disable gfx clock gate",
197 disable_gfx_clock_gating_event
198};
199
200static const pem_event_action * const enable_cgpg_event[] = {
201 enable_cgpg_tasks,
202 NULL
203};
204
205const struct action_chain enable_cgpg_action_chain = {
206 "eable cg pg",
207 enable_cgpg_event
208};
209
210static const pem_event_action * const disable_cgpg_event[] = {
211 disable_cgpg_tasks,
212 NULL
213};
214
215const struct action_chain disable_cgpg_action_chain = {
216 "disable cg pg",
217 disable_cgpg_event
218};
219
220
221/* Enable user _2d performance and activate */
222
223static const pem_event_action * const enable_user_state_event[] = {
224 create_new_user_performance_state_tasks,
225 adjust_power_state_tasks,
226 NULL
227};
228
229const struct action_chain enable_user_state_action_chain = {
230 "Enable user state",
231 enable_user_state_event
232};
233
234static const pem_event_action * const enable_user_2d_performance_event[] = {
235 enable_user_2d_performance_tasks,
236 add_user_2d_performance_state_tasks,
237 set_performance_state_tasks,
238 adjust_power_state_tasks,
239 delete_user_2d_performance_state_tasks,
240 NULL
241};
242
243const struct action_chain enable_user_2d_performance_action_chain = {
244 "enable_user_2d_performance_event_activate",
245 enable_user_2d_performance_event
246};
247
248
249static const pem_event_action * const disable_user_2d_performance_event[] = {
250 disable_user_2d_performance_tasks,
251 delete_user_2d_performance_state_tasks,
252 NULL
253};
254
255const struct action_chain disable_user_2d_performance_action_chain = {
256 "disable_user_2d_performance_event",
257 disable_user_2d_performance_event
258};
259
260
261static const pem_event_action * const display_config_change_event[] = {
262 /* countDisplayConfigurationChangeEventTasks, */
263 unblock_adjust_power_state_tasks,
264 set_cpu_power_state,
265 notify_hw_power_source_tasks,
266 get_2d_performance_state_tasks,
267 set_performance_state_tasks,
268 /* updateDALConfigurationTasks,
269 variBrightDisplayConfigurationChangeTasks, */
270 adjust_power_state_tasks,
271 /*enableDisableFPSTasks,
272 setNBMCUStateTasks,
273 notifyPCIEDeviceReadyTasks,*/
274 NULL
275};
276
277const struct action_chain display_config_change_action_chain = {
278 "Display configuration change",
279 display_config_change_event
280};
281
282static const pem_event_action * const readjust_power_state_event[] = {
283 adjust_power_state_tasks,
284 NULL
285};
286
287const struct action_chain readjust_power_state_action_chain = {
288 "re-adjust power state",
289 readjust_power_state_event
290};
291
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.h b/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.h
deleted file mode 100644
index f181e53cdcda..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#ifndef _EVENT_ACTION_CHAINS_H_
24#define _EVENT_ACTION_CHAINS_H_
25#include "eventmgr.h"
26
27extern const struct action_chain initialize_action_chain;
28
29extern const struct action_chain uninitialize_action_chain;
30
31extern const struct action_chain power_source_change_action_chain_pp_enabled;
32
33extern const struct action_chain power_source_changes_action_chain_pp_disabled;
34
35extern const struct action_chain power_source_change_action_chain_hardware_dc;
36
37extern const struct action_chain suspend_action_chain;
38
39extern const struct action_chain resume_action_chain;
40
41extern const struct action_chain complete_init_action_chain;
42
43extern const struct action_chain enable_gfx_clock_gating_action_chain;
44
45extern const struct action_chain disable_gfx_clock_gating_action_chain;
46
47extern const struct action_chain enable_cgpg_action_chain;
48
49extern const struct action_chain disable_cgpg_action_chain;
50
51extern const struct action_chain enable_user_2d_performance_action_chain;
52
53extern const struct action_chain disable_user_2d_performance_action_chain;
54
55extern const struct action_chain enable_user_state_action_chain;
56
57extern const struct action_chain readjust_power_state_action_chain;
58
59extern const struct action_chain display_config_change_action_chain;
60
61#endif /*_EVENT_ACTION_CHAINS_H_*/
62
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.c
deleted file mode 100644
index a3cd230d636d..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.c
+++ /dev/null
@@ -1,195 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include "eventmgr.h"
24#include "eventinit.h"
25#include "ppinterrupt.h"
26#include "hardwaremanager.h"
27
28void pem_init_feature_info(struct pp_eventmgr *eventmgr)
29{
30
31 /* PowerPlay info */
32 eventmgr->ui_state_info[PP_PowerSource_AC].default_ui_lable =
33 PP_StateUILabel_Performance;
34
35 eventmgr->ui_state_info[PP_PowerSource_AC].current_ui_label =
36 PP_StateUILabel_Performance;
37
38 eventmgr->ui_state_info[PP_PowerSource_DC].default_ui_lable =
39 PP_StateUILabel_Battery;
40
41 eventmgr->ui_state_info[PP_PowerSource_DC].current_ui_label =
42 PP_StateUILabel_Battery;
43
44 if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_PowerPlaySupport)) {
45 eventmgr->features[PP_Feature_PowerPlay].supported = true;
46 eventmgr->features[PP_Feature_PowerPlay].version = PEM_CURRENT_POWERPLAY_FEATURE_VERSION;
47 eventmgr->features[PP_Feature_PowerPlay].enabled_default = true;
48 eventmgr->features[PP_Feature_PowerPlay].enabled = true;
49 } else {
50 eventmgr->features[PP_Feature_PowerPlay].supported = false;
51 eventmgr->features[PP_Feature_PowerPlay].enabled = false;
52 eventmgr->features[PP_Feature_PowerPlay].enabled_default = false;
53 }
54
55 eventmgr->features[PP_Feature_Force3DClock].supported = true;
56 eventmgr->features[PP_Feature_Force3DClock].enabled = false;
57 eventmgr->features[PP_Feature_Force3DClock].enabled_default = false;
58 eventmgr->features[PP_Feature_Force3DClock].version = 1;
59
60 /* over drive*/
61 eventmgr->features[PP_Feature_User2DPerformance].version = 4;
62 eventmgr->features[PP_Feature_User3DPerformance].version = 4;
63 eventmgr->features[PP_Feature_OverdriveTest].version = 4;
64
65 eventmgr->features[PP_Feature_OverDrive].version = 4;
66 eventmgr->features[PP_Feature_OverDrive].enabled = false;
67 eventmgr->features[PP_Feature_OverDrive].enabled_default = false;
68
69 eventmgr->features[PP_Feature_User2DPerformance].supported = false;
70 eventmgr->features[PP_Feature_User2DPerformance].enabled = false;
71 eventmgr->features[PP_Feature_User2DPerformance].enabled_default = false;
72
73 eventmgr->features[PP_Feature_User3DPerformance].supported = false;
74 eventmgr->features[PP_Feature_User3DPerformance].enabled = false;
75 eventmgr->features[PP_Feature_User3DPerformance].enabled_default = false;
76
77 eventmgr->features[PP_Feature_OverdriveTest].supported = false;
78 eventmgr->features[PP_Feature_OverdriveTest].enabled = false;
79 eventmgr->features[PP_Feature_OverdriveTest].enabled_default = false;
80
81 eventmgr->features[PP_Feature_OverDrive].supported = false;
82
83 eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled_default = false;
84 eventmgr->features[PP_Feature_PowerBudgetWaiver].version = 1;
85 eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
86 eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled = false;
87
88 /* Multi UVD States support */
89 eventmgr->features[PP_Feature_MultiUVDState].supported = false;
90 eventmgr->features[PP_Feature_MultiUVDState].enabled = false;
91 eventmgr->features[PP_Feature_MultiUVDState].enabled_default = false;
92
93 /* Dynamic UVD States support */
94 eventmgr->features[PP_Feature_DynamicUVDState].supported = false;
95 eventmgr->features[PP_Feature_DynamicUVDState].enabled = false;
96 eventmgr->features[PP_Feature_DynamicUVDState].enabled_default = false;
97
98 /* VCE DPM support */
99 eventmgr->features[PP_Feature_VCEDPM].supported = false;
100 eventmgr->features[PP_Feature_VCEDPM].enabled = false;
101 eventmgr->features[PP_Feature_VCEDPM].enabled_default = false;
102
103 /* ACP PowerGating support */
104 eventmgr->features[PP_Feature_ACP_POWERGATING].supported = false;
105 eventmgr->features[PP_Feature_ACP_POWERGATING].enabled = false;
106 eventmgr->features[PP_Feature_ACP_POWERGATING].enabled_default = false;
107
108 /* PPM support */
109 eventmgr->features[PP_Feature_PPM].version = 1;
110 eventmgr->features[PP_Feature_PPM].supported = false;
111 eventmgr->features[PP_Feature_PPM].enabled = false;
112
113 /* FFC support (enables fan and temp settings, Gemini needs temp settings) */
114 if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_ODFuzzyFanControlSupport) ||
115 phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_GeminiRegulatorFanControlSupport)) {
116 eventmgr->features[PP_Feature_FFC].version = 1;
117 eventmgr->features[PP_Feature_FFC].supported = true;
118 eventmgr->features[PP_Feature_FFC].enabled = true;
119 eventmgr->features[PP_Feature_FFC].enabled_default = true;
120 } else {
121 eventmgr->features[PP_Feature_FFC].supported = false;
122 eventmgr->features[PP_Feature_FFC].enabled = false;
123 eventmgr->features[PP_Feature_FFC].enabled_default = false;
124 }
125
126 eventmgr->features[PP_Feature_VariBright].supported = false;
127 eventmgr->features[PP_Feature_VariBright].enabled = false;
128 eventmgr->features[PP_Feature_VariBright].enabled_default = false;
129
130 eventmgr->features[PP_Feature_BACO].supported = false;
131 eventmgr->features[PP_Feature_BACO].supported = false;
132 eventmgr->features[PP_Feature_BACO].enabled_default = false;
133
134 /* PowerDown feature support */
135 eventmgr->features[PP_Feature_PowerDown].supported = false;
136 eventmgr->features[PP_Feature_PowerDown].enabled = false;
137 eventmgr->features[PP_Feature_PowerDown].enabled_default = false;
138
139 eventmgr->features[PP_Feature_FPS].version = 1;
140 eventmgr->features[PP_Feature_FPS].supported = false;
141 eventmgr->features[PP_Feature_FPS].enabled_default = false;
142 eventmgr->features[PP_Feature_FPS].enabled = false;
143
144 eventmgr->features[PP_Feature_ViPG].version = 1;
145 eventmgr->features[PP_Feature_ViPG].supported = false;
146 eventmgr->features[PP_Feature_ViPG].enabled_default = false;
147 eventmgr->features[PP_Feature_ViPG].enabled = false;
148}
149
150static int thermal_interrupt_callback(void *private_data,
151 unsigned src_id, const uint32_t *iv_entry)
152{
153 /* TO DO hanle PEM_Event_ThermalNotification (struct pp_eventmgr *)private_data*/
154 pr_info("current thermal is out of range \n");
155 return 0;
156}
157
158int pem_register_interrupts(struct pp_eventmgr *eventmgr)
159{
160 int result = 0;
161 struct pp_interrupt_registration_info info;
162
163 info.call_back = thermal_interrupt_callback;
164 info.context = eventmgr;
165
166 result = phm_register_thermal_interrupt(eventmgr->hwmgr, &info);
167
168 /* TODO:
169 * 2. Register CTF event interrupt
170 * 3. Register for vbios events interrupt
171 * 4. Register External Throttle Interrupt
172 * 5. Register Smc To Host Interrupt
173 * */
174 return result;
175}
176
177
178int pem_unregister_interrupts(struct pp_eventmgr *eventmgr)
179{
180 return 0;
181}
182
183
184void pem_uninit_featureInfo(struct pp_eventmgr *eventmgr)
185{
186 eventmgr->features[PP_Feature_MultiUVDState].supported = false;
187 eventmgr->features[PP_Feature_VariBright].supported = false;
188 eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
189 eventmgr->features[PP_Feature_OverDrive].supported = false;
190 eventmgr->features[PP_Feature_OverdriveTest].supported = false;
191 eventmgr->features[PP_Feature_User3DPerformance].supported = false;
192 eventmgr->features[PP_Feature_User2DPerformance].supported = false;
193 eventmgr->features[PP_Feature_PowerPlay].supported = false;
194 eventmgr->features[PP_Feature_Force3DClock].supported = false;
195}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.h b/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.h
deleted file mode 100644
index 9ef96aab3f24..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#ifndef _EVENTINIT_H_
25#define _EVENTINIT_H_
26
27#define PEM_CURRENT_POWERPLAY_FEATURE_VERSION 4
28
29void pem_init_feature_info(struct pp_eventmgr *eventmgr);
30void pem_uninit_featureInfo(struct pp_eventmgr *eventmgr);
31int pem_register_interrupts(struct pp_eventmgr *eventmgr);
32int pem_unregister_interrupts(struct pp_eventmgr *eventmgr);
33
34#endif /* _EVENTINIT_H_ */
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.c
deleted file mode 100644
index cd1ca07ef7f7..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.c
+++ /dev/null
@@ -1,215 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include "eventmanagement.h"
24#include "eventmgr.h"
25#include "eventactionchains.h"
26
27int pem_init_event_action_chains(struct pp_eventmgr *eventmgr)
28{
29 int i;
30
31 for (i = 0; i < AMD_PP_EVENT_MAX; i++)
32 eventmgr->event_chain[i] = NULL;
33
34 eventmgr->event_chain[AMD_PP_EVENT_SUSPEND] = pem_get_suspend_action_chain(eventmgr);
35 eventmgr->event_chain[AMD_PP_EVENT_INITIALIZE] = pem_get_initialize_action_chain(eventmgr);
36 eventmgr->event_chain[AMD_PP_EVENT_UNINITIALIZE] = pem_get_uninitialize_action_chain(eventmgr);
37 eventmgr->event_chain[AMD_PP_EVENT_POWER_SOURCE_CHANGE] = pem_get_power_source_change_action_chain(eventmgr);
38 eventmgr->event_chain[AMD_PP_EVENT_HIBERNATE] = pem_get_hibernate_action_chain(eventmgr);
39 eventmgr->event_chain[AMD_PP_EVENT_RESUME] = pem_get_resume_action_chain(eventmgr);
40 eventmgr->event_chain[AMD_PP_EVENT_THERMAL_NOTIFICATION] = pem_get_thermal_notification_action_chain(eventmgr);
41 eventmgr->event_chain[AMD_PP_EVENT_VBIOS_NOTIFICATION] = pem_get_vbios_notification_action_chain(eventmgr);
42 eventmgr->event_chain[AMD_PP_EVENT_ENTER_THERMAL_STATE] = pem_get_enter_thermal_state_action_chain(eventmgr);
43 eventmgr->event_chain[AMD_PP_EVENT_EXIT_THERMAL_STATE] = pem_get_exit_thermal_state_action_chain(eventmgr);
44 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_POWER_PLAY] = pem_get_enable_powerplay_action_chain(eventmgr);
45 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_POWER_PLAY] = pem_get_disable_powerplay_action_chain(eventmgr);
46 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_OVER_DRIVE_TEST] = pem_get_enable_overdrive_test_action_chain(eventmgr);
47 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_OVER_DRIVE_TEST] = pem_get_disable_overdrive_test_action_chain(eventmgr);
48 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_GFX_CLOCK_GATING] = pem_get_enable_gfx_clock_gating_action_chain(eventmgr);
49 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_GFX_CLOCK_GATING] = pem_get_disable_gfx_clock_gating_action_chain(eventmgr);
50 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_CGPG] = pem_get_enable_cgpg_action_chain(eventmgr);
51 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_CGPG] = pem_get_disable_cgpg_action_chain(eventmgr);
52 eventmgr->event_chain[AMD_PP_EVENT_COMPLETE_INIT] = pem_get_complete_init_action_chain(eventmgr);
53 eventmgr->event_chain[AMD_PP_EVENT_SCREEN_ON] = pem_get_screen_on_action_chain(eventmgr);
54 eventmgr->event_chain[AMD_PP_EVENT_SCREEN_OFF] = pem_get_screen_off_action_chain(eventmgr);
55 eventmgr->event_chain[AMD_PP_EVENT_PRE_SUSPEND] = pem_get_pre_suspend_action_chain(eventmgr);
56 eventmgr->event_chain[AMD_PP_EVENT_PRE_RESUME] = pem_get_pre_resume_action_chain(eventmgr);
57 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_USER_STATE] = pem_enable_user_state_action_chain(eventmgr);
58 eventmgr->event_chain[AMD_PP_EVENT_READJUST_POWER_STATE] = pem_readjust_power_state_action_chain(eventmgr);
59 eventmgr->event_chain[AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE] = pem_display_config_change_action_chain(eventmgr);
60 return 0;
61}
62
63int pem_excute_event_chain(struct pp_eventmgr *eventmgr, const struct action_chain *event_chain, struct pem_event_data *event_data)
64{
65 const pem_event_action * const *paction_chain;
66 const pem_event_action *psub_chain;
67 int tmp_result = 0;
68 int result = 0;
69
70 if (eventmgr == NULL || event_chain == NULL || event_data == NULL)
71 return -EINVAL;
72
73 for (paction_chain = event_chain->action_chain; NULL != *paction_chain; paction_chain++) {
74 if (0 != result)
75 return result;
76
77 for (psub_chain = *paction_chain; NULL != *psub_chain; psub_chain++) {
78 tmp_result = (*psub_chain)(eventmgr, event_data);
79 if (0 == result)
80 result = tmp_result;
81 }
82 }
83
84 return result;
85}
86
87const struct action_chain *pem_get_suspend_action_chain(struct pp_eventmgr *eventmgr)
88{
89 return &suspend_action_chain;
90}
91
92const struct action_chain *pem_get_initialize_action_chain(struct pp_eventmgr *eventmgr)
93{
94 return &initialize_action_chain;
95}
96
97const struct action_chain *pem_get_uninitialize_action_chain(struct pp_eventmgr *eventmgr)
98{
99 return &uninitialize_action_chain;
100}
101
102const struct action_chain *pem_get_power_source_change_action_chain(struct pp_eventmgr *eventmgr)
103{
104 return &power_source_change_action_chain_pp_enabled; /* other case base on feature info*/
105}
106
107const struct action_chain *pem_get_resume_action_chain(struct pp_eventmgr *eventmgr)
108{
109 return &resume_action_chain;
110}
111
112const struct action_chain *pem_get_hibernate_action_chain(struct pp_eventmgr *eventmgr)
113{
114 return NULL;
115}
116
117const struct action_chain *pem_get_thermal_notification_action_chain(struct pp_eventmgr *eventmgr)
118{
119 return NULL;
120}
121
122const struct action_chain *pem_get_vbios_notification_action_chain(struct pp_eventmgr *eventmgr)
123{
124 return NULL;
125}
126
127const struct action_chain *pem_get_enter_thermal_state_action_chain(struct pp_eventmgr *eventmgr)
128{
129 return NULL;
130}
131
132const struct action_chain *pem_get_exit_thermal_state_action_chain(struct pp_eventmgr *eventmgr)
133{
134 return NULL;
135}
136
137const struct action_chain *pem_get_enable_powerplay_action_chain(struct pp_eventmgr *eventmgr)
138{
139 return NULL;
140}
141
142const struct action_chain *pem_get_disable_powerplay_action_chain(struct pp_eventmgr *eventmgr)
143{
144 return NULL;
145}
146
147const struct action_chain *pem_get_enable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr)
148{
149 return NULL;
150}
151
152const struct action_chain *pem_get_disable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr)
153{
154 return NULL;
155}
156
157const struct action_chain *pem_get_enable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr)
158{
159 return &enable_gfx_clock_gating_action_chain;
160}
161
162const struct action_chain *pem_get_disable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr)
163{
164 return &disable_gfx_clock_gating_action_chain;
165}
166
167const struct action_chain *pem_get_enable_cgpg_action_chain(struct pp_eventmgr *eventmgr)
168{
169 return &enable_cgpg_action_chain;
170}
171
172const struct action_chain *pem_get_disable_cgpg_action_chain(struct pp_eventmgr *eventmgr)
173{
174 return &disable_cgpg_action_chain;
175}
176
177const struct action_chain *pem_get_complete_init_action_chain(struct pp_eventmgr *eventmgr)
178{
179 return &complete_init_action_chain;
180}
181
182const struct action_chain *pem_get_screen_on_action_chain(struct pp_eventmgr *eventmgr)
183{
184 return NULL;
185}
186
187const struct action_chain *pem_get_screen_off_action_chain(struct pp_eventmgr *eventmgr)
188{
189 return NULL;
190}
191
192const struct action_chain *pem_get_pre_suspend_action_chain(struct pp_eventmgr *eventmgr)
193{
194 return NULL;
195}
196
197const struct action_chain *pem_get_pre_resume_action_chain(struct pp_eventmgr *eventmgr)
198{
199 return NULL;
200}
201
202const struct action_chain *pem_enable_user_state_action_chain(struct pp_eventmgr *eventmgr)
203{
204 return &enable_user_state_action_chain;
205}
206
207const struct action_chain *pem_readjust_power_state_action_chain(struct pp_eventmgr *eventmgr)
208{
209 return &readjust_power_state_action_chain;
210}
211
212const struct action_chain *pem_display_config_change_action_chain(struct pp_eventmgr *eventmgr)
213{
214 return &display_config_change_action_chain;
215}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.h b/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.h
deleted file mode 100644
index 383d4b295aa9..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmanagement.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#ifndef _EVENT_MANAGEMENT_H_
24#define _EVENT_MANAGEMENT_H_
25
26#include "eventmgr.h"
27
28int pem_init_event_action_chains(struct pp_eventmgr *eventmgr);
29int pem_excute_event_chain(struct pp_eventmgr *eventmgr, const struct action_chain *event_chain, struct pem_event_data *event_data);
30const struct action_chain *pem_get_suspend_action_chain(struct pp_eventmgr *eventmgr);
31const struct action_chain *pem_get_initialize_action_chain(struct pp_eventmgr *eventmgr);
32const struct action_chain *pem_get_uninitialize_action_chain(struct pp_eventmgr *eventmgr);
33const struct action_chain *pem_get_power_source_change_action_chain(struct pp_eventmgr *eventmgr);
34const struct action_chain *pem_get_resume_action_chain(struct pp_eventmgr *eventmgr);
35const struct action_chain *pem_get_hibernate_action_chain(struct pp_eventmgr *eventmgr);
36const struct action_chain *pem_get_thermal_notification_action_chain(struct pp_eventmgr *eventmgr);
37const struct action_chain *pem_get_vbios_notification_action_chain(struct pp_eventmgr *eventmgr);
38const struct action_chain *pem_get_enter_thermal_state_action_chain(struct pp_eventmgr *eventmgr);
39const struct action_chain *pem_get_exit_thermal_state_action_chain(struct pp_eventmgr *eventmgr);
40const struct action_chain *pem_get_enable_powerplay_action_chain(struct pp_eventmgr *eventmgr);
41const struct action_chain *pem_get_disable_powerplay_action_chain(struct pp_eventmgr *eventmgr);
42const struct action_chain *pem_get_enable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr);
43const struct action_chain *pem_get_disable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr);
44const struct action_chain *pem_get_enable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr);
45const struct action_chain *pem_get_disable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr);
46const struct action_chain *pem_get_enable_cgpg_action_chain(struct pp_eventmgr *eventmgr);
47const struct action_chain *pem_get_disable_cgpg_action_chain(struct pp_eventmgr *eventmgr);
48const struct action_chain *pem_get_complete_init_action_chain(struct pp_eventmgr *eventmgr);
49const struct action_chain *pem_get_screen_on_action_chain(struct pp_eventmgr *eventmgr);
50const struct action_chain *pem_get_screen_off_action_chain(struct pp_eventmgr *eventmgr);
51const struct action_chain *pem_get_pre_suspend_action_chain(struct pp_eventmgr *eventmgr);
52const struct action_chain *pem_get_pre_resume_action_chain(struct pp_eventmgr *eventmgr);
53
54extern const struct action_chain *pem_enable_user_state_action_chain(struct pp_eventmgr *eventmgr);
55extern const struct action_chain *pem_readjust_power_state_action_chain(struct pp_eventmgr *eventmgr);
56const struct action_chain *pem_display_config_change_action_chain(struct pp_eventmgr *eventmgr);
57
58
59#endif /* _EVENT_MANAGEMENT_H_ */
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
deleted file mode 100644
index 3e3ca03bd344..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include <linux/types.h>
24#include <linux/kernel.h>
25#include <linux/slab.h>
26#include "eventmgr.h"
27#include "hwmgr.h"
28#include "eventinit.h"
29#include "eventmanagement.h"
30
31static int pem_init(struct pp_eventmgr *eventmgr)
32{
33 int result = 0;
34 struct pem_event_data event_data = { {0} };
35
36 /* Initialize PowerPlay feature info */
37 pem_init_feature_info(eventmgr);
38
39 /* Initialize event action chains */
40 pem_init_event_action_chains(eventmgr);
41
42 /* Call initialization event */
43 result = pem_handle_event(eventmgr, AMD_PP_EVENT_INITIALIZE, &event_data);
44
45 /* if (0 != result)
46 return result; */
47
48 /* Register interrupt callback functions */
49 result = pem_register_interrupts(eventmgr);
50 return 0;
51}
52
53static void pem_fini(struct pp_eventmgr *eventmgr)
54{
55 struct pem_event_data event_data = { {0} };
56
57 pem_uninit_featureInfo(eventmgr);
58 pem_unregister_interrupts(eventmgr);
59
60 pem_handle_event(eventmgr, AMD_PP_EVENT_UNINITIALIZE, &event_data);
61}
62
63int eventmgr_early_init(struct pp_instance *handle)
64{
65 struct pp_eventmgr *eventmgr;
66
67 if (handle == NULL)
68 return -EINVAL;
69
70 eventmgr = kzalloc(sizeof(struct pp_eventmgr), GFP_KERNEL);
71 if (eventmgr == NULL)
72 return -ENOMEM;
73
74 eventmgr->hwmgr = handle->hwmgr;
75 handle->eventmgr = eventmgr;
76
77 eventmgr->platform_descriptor = &(eventmgr->hwmgr->platform_descriptor);
78 eventmgr->pp_eventmgr_init = pem_init;
79 eventmgr->pp_eventmgr_fini = pem_fini;
80
81 return 0;
82}
83
84static int pem_handle_event_unlocked(struct pp_eventmgr *eventmgr, enum amd_pp_event event, struct pem_event_data *data)
85{
86 if (eventmgr == NULL || event >= AMD_PP_EVENT_MAX || data == NULL)
87 return -EINVAL;
88
89 return pem_excute_event_chain(eventmgr, eventmgr->event_chain[event], data);
90}
91
92int pem_handle_event(struct pp_eventmgr *eventmgr, enum amd_pp_event event, struct pem_event_data *event_data)
93{
94 int r = 0;
95
96 r = pem_handle_event_unlocked(eventmgr, event, event_data);
97
98 return r;
99}
100
101bool pem_is_hw_access_blocked(struct pp_eventmgr *eventmgr)
102{
103 return (eventmgr->block_adjust_power_state || phm_is_hw_access_blocked(eventmgr->hwmgr));
104}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.c
deleted file mode 100644
index b82c43af59ab..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.c
+++ /dev/null
@@ -1,410 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#include "eventmgr.h"
25#include "eventsubchains.h"
26#include "eventtasks.h"
27#include "hardwaremanager.h"
28
29const pem_event_action reset_display_phy_access_tasks[] = {
30 pem_task_reset_display_phys_access,
31 NULL
32};
33
34const pem_event_action broadcast_power_policy_tasks[] = {
35 /* PEM_Task_BroadcastPowerPolicyChange, */
36 NULL
37};
38
39const pem_event_action unregister_interrupt_tasks[] = {
40 pem_task_unregister_interrupts,
41 NULL
42};
43
44/* Disable GFX Voltage Islands Power Gating */
45const pem_event_action disable_gfx_voltage_island_powergating_tasks[] = {
46 pem_task_disable_voltage_island_power_gating,
47 NULL
48};
49
50const pem_event_action disable_gfx_clockgating_tasks[] = {
51 pem_task_disable_gfx_clock_gating,
52 NULL
53};
54
55const pem_event_action block_adjust_power_state_tasks[] = {
56 pem_task_block_adjust_power_state,
57 NULL
58};
59
60
61const pem_event_action unblock_adjust_power_state_tasks[] = {
62 pem_task_unblock_adjust_power_state,
63 NULL
64};
65
66const pem_event_action set_performance_state_tasks[] = {
67 pem_task_set_performance_state,
68 NULL
69};
70
71const pem_event_action get_2d_performance_state_tasks[] = {
72 pem_task_get_2D_performance_state_id,
73 NULL
74};
75
76const pem_event_action conditionally_force3D_performance_state_tasks[] = {
77 pem_task_conditionally_force_3d_performance_state,
78 NULL
79};
80
81const pem_event_action process_vbios_eventinfo_tasks[] = {
82 /* PEM_Task_ProcessVbiosEventInfo,*/
83 NULL
84};
85
86const pem_event_action enable_dynamic_state_management_tasks[] = {
87 /* PEM_Task_ResetBAPMPolicyChangedFlag,*/
88 pem_task_get_boot_state_id,
89 pem_task_enable_dynamic_state_management,
90 pem_task_register_interrupts,
91 NULL
92};
93
94const pem_event_action enable_clock_power_gatings_tasks[] = {
95 pem_task_enable_clock_power_gatings_tasks,
96 pem_task_powerdown_uvd_tasks,
97 pem_task_powerdown_vce_tasks,
98 NULL
99};
100
101const pem_event_action setup_asic_tasks[] = {
102 pem_task_setup_asic,
103 NULL
104};
105
106const pem_event_action power_budget_tasks[] = {
107 /* TODO
108 * PEM_Task_PowerBudgetWaiverAvailable,
109 * PEM_Task_PowerBudgetWarningMessage,
110 * PEM_Task_PruneStatesBasedOnPowerBudget,
111 */
112 NULL
113};
114
115const pem_event_action system_config_tasks[] = {
116 /* PEM_Task_PruneStatesBasedOnSystemConfig,*/
117 NULL
118};
119
120
121const pem_event_action conditionally_force_3d_performance_state_tasks[] = {
122 pem_task_conditionally_force_3d_performance_state,
123 NULL
124};
125
126const pem_event_action ungate_all_display_phys_tasks[] = {
127 /* PEM_Task_GetDisplayPhyAccessInfo */
128 NULL
129};
130
131const pem_event_action uninitialize_display_phy_access_tasks[] = {
132 /* PEM_Task_UninitializeDisplayPhysAccess, */
133 NULL
134};
135
136const pem_event_action disable_gfx_voltage_island_power_gating_tasks[] = {
137 /* PEM_Task_DisableVoltageIslandPowerGating, */
138 NULL
139};
140
141const pem_event_action disable_gfx_clock_gating_tasks[] = {
142 pem_task_disable_gfx_clock_gating,
143 NULL
144};
145
146const pem_event_action set_boot_state_tasks[] = {
147 pem_task_get_boot_state_id,
148 pem_task_set_boot_state,
149 NULL
150};
151
152const pem_event_action adjust_power_state_tasks[] = {
153 pem_task_notify_hw_mgr_display_configuration_change,
154 pem_task_adjust_power_state,
155 pem_task_notify_smc_display_config_after_power_state_adjustment,
156 pem_task_update_allowed_performance_levels,
157 /* to do pem_task_Enable_disable_bapm, */
158 NULL
159};
160
161const pem_event_action disable_dynamic_state_management_tasks[] = {
162 pem_task_unregister_interrupts,
163 pem_task_get_boot_state_id,
164 pem_task_disable_dynamic_state_management,
165 NULL
166};
167
168const pem_event_action disable_clock_power_gatings_tasks[] = {
169 pem_task_disable_clock_power_gatings_tasks,
170 NULL
171};
172
173const pem_event_action cleanup_asic_tasks[] = {
174 /* PEM_Task_DisableFPS,*/
175 pem_task_cleanup_asic,
176 NULL
177};
178
179const pem_event_action prepare_for_pnp_stop_tasks[] = {
180 /* PEM_Task_PrepareForPnpStop,*/
181 NULL
182};
183
184const pem_event_action set_power_source_tasks[] = {
185 pem_task_set_power_source,
186 pem_task_notify_hw_of_power_source,
187 NULL
188};
189
190const pem_event_action set_power_saving_state_tasks[] = {
191 pem_task_reset_power_saving_state,
192 pem_task_get_power_saving_state,
193 pem_task_set_power_saving_state,
194 /* PEM_Task_ResetODDCState,
195 * PEM_Task_GetODDCState,
196 * PEM_Task_SetODDCState,*/
197 NULL
198};
199
200const pem_event_action enable_disable_fps_tasks[] = {
201 /* PEM_Task_EnableDisableFPS,*/
202 NULL
203};
204
205const pem_event_action set_nbmcu_state_tasks[] = {
206 /* PEM_Task_NBMCUStateChange,*/
207 NULL
208};
209
210const pem_event_action reset_hardware_dc_notification_tasks[] = {
211 /* PEM_Task_ResetHardwareDCNotification,*/
212 NULL
213};
214
215
216const pem_event_action notify_smu_suspend_tasks[] = {
217 /* PEM_Task_NotifySMUSuspend,*/
218 NULL
219};
220
221const pem_event_action disable_smc_firmware_ctf_tasks[] = {
222 pem_task_disable_smc_firmware_ctf,
223 NULL
224};
225
226const pem_event_action disable_fps_tasks[] = {
227 /* PEM_Task_DisableFPS,*/
228 NULL
229};
230
231const pem_event_action vari_bright_suspend_tasks[] = {
232 /* PEM_Task_VariBright_Suspend,*/
233 NULL
234};
235
236const pem_event_action reset_fan_speed_to_default_tasks[] = {
237 /* PEM_Task_ResetFanSpeedToDefault,*/
238 NULL
239};
240
241const pem_event_action power_down_asic_tasks[] = {
242 /* PEM_Task_DisableFPS,*/
243 pem_task_power_down_asic,
244 NULL
245};
246
247const pem_event_action disable_stutter_mode_tasks[] = {
248 /* PEM_Task_DisableStutterMode,*/
249 NULL
250};
251
252const pem_event_action set_connected_standby_tasks[] = {
253 /* PEM_Task_SetConnectedStandby,*/
254 NULL
255};
256
257const pem_event_action block_hw_access_tasks[] = {
258 pem_task_block_hw_access,
259 NULL
260};
261
262const pem_event_action unblock_hw_access_tasks[] = {
263 pem_task_un_block_hw_access,
264 NULL
265};
266
267const pem_event_action resume_connected_standby_tasks[] = {
268 /* PEM_Task_ResumeConnectedStandby,*/
269 NULL
270};
271
272const pem_event_action notify_smu_resume_tasks[] = {
273 /* PEM_Task_NotifySMUResume,*/
274 NULL
275};
276
277const pem_event_action reset_display_configCounter_tasks[] = {
278 pem_task_reset_display_phys_access,
279 NULL
280};
281
282const pem_event_action update_dal_configuration_tasks[] = {
283 /* PEM_Task_CheckVBlankTime,*/
284 NULL
285};
286
287const pem_event_action vari_bright_resume_tasks[] = {
288 /* PEM_Task_VariBright_Resume,*/
289 NULL
290};
291
292const pem_event_action notify_hw_power_source_tasks[] = {
293 pem_task_notify_hw_of_power_source,
294 NULL
295};
296
297const pem_event_action process_vbios_event_info_tasks[] = {
298 /* PEM_Task_ProcessVbiosEventInfo,*/
299 NULL
300};
301
302const pem_event_action enable_gfx_clock_gating_tasks[] = {
303 pem_task_enable_gfx_clock_gating,
304 NULL
305};
306
307const pem_event_action enable_gfx_voltage_island_power_gating_tasks[] = {
308 pem_task_enable_voltage_island_power_gating,
309 NULL
310};
311
312const pem_event_action reset_clock_gating_tasks[] = {
313 /* PEM_Task_ResetClockGating*/
314 NULL
315};
316
317const pem_event_action notify_smu_vpu_recovery_end_tasks[] = {
318 /* PEM_Task_NotifySmuVPURecoveryEnd,*/
319 NULL
320};
321
322const pem_event_action disable_vpu_cap_tasks[] = {
323 /* PEM_Task_DisableVPUCap,*/
324 NULL
325};
326
327const pem_event_action execute_escape_sequence_tasks[] = {
328 /* PEM_Task_ExecuteEscapesequence,*/
329 NULL
330};
331
332const pem_event_action notify_power_state_change_tasks[] = {
333 pem_task_notify_power_state_change,
334 NULL
335};
336
337const pem_event_action enable_cgpg_tasks[] = {
338 pem_task_enable_cgpg,
339 NULL
340};
341
342const pem_event_action disable_cgpg_tasks[] = {
343 pem_task_disable_cgpg,
344 NULL
345};
346
347const pem_event_action enable_user_2d_performance_tasks[] = {
348 /* PEM_Task_SetUser2DPerformanceFlag,*/
349 /* PEM_Task_UpdateUser2DPerformanceEnableEvents,*/
350 NULL
351};
352
353const pem_event_action add_user_2d_performance_state_tasks[] = {
354 /* PEM_Task_Get2DPerformanceTemplate,*/
355 /* PEM_Task_AllocateNewPowerStateMemory,*/
356 /* PEM_Task_CopyNewPowerStateInfo,*/
357 /* PEM_Task_UpdateNewPowerStateClocks,*/
358 /* PEM_Task_UpdateNewPowerStateUser2DPerformanceFlag,*/
359 /* PEM_Task_AddPowerState,*/
360 /* PEM_Task_ReleaseNewPowerStateMemory,*/
361 NULL
362};
363
364const pem_event_action delete_user_2d_performance_state_tasks[] = {
365 /* PEM_Task_GetCurrentUser2DPerformanceStateID,*/
366 /* PEM_Task_DeletePowerState,*/
367 /* PEM_Task_SetCurrentUser2DPerformanceStateID,*/
368 NULL
369};
370
371const pem_event_action disable_user_2d_performance_tasks[] = {
372 /* PEM_Task_ResetUser2DPerformanceFlag,*/
373 /* PEM_Task_UpdateUser2DPerformanceDisableEvents,*/
374 NULL
375};
376
377const pem_event_action enable_stutter_mode_tasks[] = {
378 pem_task_enable_stutter_mode,
379 NULL
380};
381
382const pem_event_action enable_disable_bapm_tasks[] = {
383 /*PEM_Task_EnableDisableBAPM,*/
384 NULL
385};
386
387const pem_event_action reset_boot_state_tasks[] = {
388 pem_task_reset_boot_state,
389 NULL
390};
391
392const pem_event_action create_new_user_performance_state_tasks[] = {
393 pem_task_create_user_performance_state,
394 NULL
395};
396
397const pem_event_action initialize_thermal_controller_tasks[] = {
398 pem_task_initialize_thermal_controller,
399 NULL
400};
401
402const pem_event_action uninitialize_thermal_controller_tasks[] = {
403 pem_task_uninitialize_thermal_controller,
404 NULL
405};
406
407const pem_event_action set_cpu_power_state[] = {
408 pem_task_set_cpu_power_state,
409 NULL
410}; \ No newline at end of file
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.h b/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.h
deleted file mode 100644
index 7714cb927428..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventsubchains.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#ifndef _EVENT_SUB_CHAINS_H_
25#define _EVENT_SUB_CHAINS_H_
26
27#include "eventmgr.h"
28
29extern const pem_event_action reset_display_phy_access_tasks[];
30extern const pem_event_action broadcast_power_policy_tasks[];
31extern const pem_event_action unregister_interrupt_tasks[];
32extern const pem_event_action disable_GFX_voltage_island_powergating_tasks[];
33extern const pem_event_action disable_GFX_clockgating_tasks[];
34extern const pem_event_action block_adjust_power_state_tasks[];
35extern const pem_event_action unblock_adjust_power_state_tasks[];
36extern const pem_event_action set_performance_state_tasks[];
37extern const pem_event_action get_2D_performance_state_tasks[];
38extern const pem_event_action conditionally_force3D_performance_state_tasks[];
39extern const pem_event_action process_vbios_eventinfo_tasks[];
40extern const pem_event_action enable_dynamic_state_management_tasks[];
41extern const pem_event_action enable_clock_power_gatings_tasks[];
42extern const pem_event_action conditionally_force3D_performance_state_tasks[];
43extern const pem_event_action setup_asic_tasks[];
44extern const pem_event_action power_budget_tasks[];
45extern const pem_event_action system_config_tasks[];
46extern const pem_event_action get_2d_performance_state_tasks[];
47extern const pem_event_action conditionally_force_3d_performance_state_tasks[];
48extern const pem_event_action ungate_all_display_phys_tasks[];
49extern const pem_event_action uninitialize_display_phy_access_tasks[];
50extern const pem_event_action disable_gfx_voltage_island_power_gating_tasks[];
51extern const pem_event_action disable_gfx_clock_gating_tasks[];
52extern const pem_event_action set_boot_state_tasks[];
53extern const pem_event_action adjust_power_state_tasks[];
54extern const pem_event_action disable_dynamic_state_management_tasks[];
55extern const pem_event_action disable_clock_power_gatings_tasks[];
56extern const pem_event_action cleanup_asic_tasks[];
57extern const pem_event_action prepare_for_pnp_stop_tasks[];
58extern const pem_event_action set_power_source_tasks[];
59extern const pem_event_action set_power_saving_state_tasks[];
60extern const pem_event_action enable_disable_fps_tasks[];
61extern const pem_event_action set_nbmcu_state_tasks[];
62extern const pem_event_action reset_hardware_dc_notification_tasks[];
63extern const pem_event_action notify_smu_suspend_tasks[];
64extern const pem_event_action disable_smc_firmware_ctf_tasks[];
65extern const pem_event_action disable_fps_tasks[];
66extern const pem_event_action vari_bright_suspend_tasks[];
67extern const pem_event_action reset_fan_speed_to_default_tasks[];
68extern const pem_event_action power_down_asic_tasks[];
69extern const pem_event_action disable_stutter_mode_tasks[];
70extern const pem_event_action set_connected_standby_tasks[];
71extern const pem_event_action block_hw_access_tasks[];
72extern const pem_event_action unblock_hw_access_tasks[];
73extern const pem_event_action resume_connected_standby_tasks[];
74extern const pem_event_action notify_smu_resume_tasks[];
75extern const pem_event_action reset_display_configCounter_tasks[];
76extern const pem_event_action update_dal_configuration_tasks[];
77extern const pem_event_action vari_bright_resume_tasks[];
78extern const pem_event_action notify_hw_power_source_tasks[];
79extern const pem_event_action process_vbios_event_info_tasks[];
80extern const pem_event_action enable_gfx_clock_gating_tasks[];
81extern const pem_event_action enable_gfx_voltage_island_power_gating_tasks[];
82extern const pem_event_action reset_clock_gating_tasks[];
83extern const pem_event_action notify_smu_vpu_recovery_end_tasks[];
84extern const pem_event_action disable_vpu_cap_tasks[];
85extern const pem_event_action execute_escape_sequence_tasks[];
86extern const pem_event_action notify_power_state_change_tasks[];
87extern const pem_event_action enable_cgpg_tasks[];
88extern const pem_event_action disable_cgpg_tasks[];
89extern const pem_event_action enable_user_2d_performance_tasks[];
90extern const pem_event_action add_user_2d_performance_state_tasks[];
91extern const pem_event_action delete_user_2d_performance_state_tasks[];
92extern const pem_event_action disable_user_2d_performance_tasks[];
93extern const pem_event_action enable_stutter_mode_tasks[];
94extern const pem_event_action enable_disable_bapm_tasks[];
95extern const pem_event_action reset_boot_state_tasks[];
96extern const pem_event_action create_new_user_performance_state_tasks[];
97extern const pem_event_action initialize_thermal_controller_tasks[];
98extern const pem_event_action uninitialize_thermal_controller_tasks[];
99extern const pem_event_action set_cpu_power_state[];
100#endif /* _EVENT_SUB_CHAINS_H_ */
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c
deleted file mode 100644
index 8c4ebaae1e0c..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c
+++ /dev/null
@@ -1,445 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#include "eventmgr.h"
25#include "eventinit.h"
26#include "eventmanagement.h"
27#include "eventmanager.h"
28#include "hardwaremanager.h"
29#include "eventtasks.h"
30#include "power_state.h"
31#include "hwmgr.h"
32#include "amd_powerplay.h"
33#include "psm.h"
34
35#define TEMP_RANGE_MIN (90 * 1000)
36#define TEMP_RANGE_MAX (120 * 1000)
37
38int pem_task_update_allowed_performance_levels(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
39{
40
41 if (eventmgr == NULL || eventmgr->hwmgr == NULL)
42 return -EINVAL;
43
44 if (pem_is_hw_access_blocked(eventmgr))
45 return 0;
46
47 phm_force_dpm_levels(eventmgr->hwmgr, eventmgr->hwmgr->dpm_level);
48
49 return 0;
50}
51
52/* eventtasks_generic.c */
53int pem_task_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
54{
55 struct pp_hwmgr *hwmgr;
56
57 if (pem_is_hw_access_blocked(eventmgr))
58 return 0;
59
60 hwmgr = eventmgr->hwmgr;
61 if (event_data->pnew_power_state != NULL)
62 hwmgr->request_ps = event_data->pnew_power_state;
63
64 if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_DynamicPatchPowerState))
65 psm_adjust_power_state_dynamic(eventmgr, event_data->skip_state_adjust_rules);
66 else
67 psm_adjust_power_state_static(eventmgr, event_data->skip_state_adjust_rules);
68
69 return 0;
70}
71
72int pem_task_power_down_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
73{
74 return phm_power_down_asic(eventmgr->hwmgr);
75}
76
77int pem_task_set_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
78{
79 if (pem_is_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID))
80 return psm_set_states(eventmgr, &(event_data->requested_state_id));
81
82 return 0;
83}
84
85int pem_task_reset_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
86{
87 /* TODO */
88 return 0;
89}
90
91int pem_task_update_new_power_state_clocks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
92{
93 /* TODO */
94 return 0;
95}
96
97int pem_task_system_shutdown(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
98{
99 /* TODO */
100 return 0;
101}
102
103int pem_task_register_interrupts(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
104{
105 /* TODO */
106 return 0;
107}
108
109int pem_task_unregister_interrupts(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
110{
111 return pem_unregister_interrupts(eventmgr);
112}
113
114int pem_task_get_boot_state_id(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
115{
116 int result;
117
118 result = psm_get_state_by_classification(eventmgr,
119 PP_StateClassificationFlag_Boot,
120 &(event_data->requested_state_id)
121 );
122
123 if (0 == result)
124 pem_set_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID);
125 else
126 pem_unset_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID);
127
128 return result;
129}
130
131int pem_task_enable_dynamic_state_management(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
132{
133 return phm_enable_dynamic_state_management(eventmgr->hwmgr);
134}
135
136int pem_task_disable_dynamic_state_management(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
137{
138 return phm_disable_dynamic_state_management(eventmgr->hwmgr);
139}
140
141int pem_task_enable_clock_power_gatings_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
142{
143 return phm_enable_clock_power_gatings(eventmgr->hwmgr);
144}
145
146int pem_task_powerdown_uvd_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
147{
148 return phm_powerdown_uvd(eventmgr->hwmgr);
149}
150
151int pem_task_powerdown_vce_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
152{
153 phm_powergate_uvd(eventmgr->hwmgr, true);
154 phm_powergate_vce(eventmgr->hwmgr, true);
155 return 0;
156}
157
158int pem_task_disable_clock_power_gatings_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
159{
160 phm_disable_clock_power_gatings(eventmgr->hwmgr);
161 return 0;
162}
163
164int pem_task_start_asic_block_usage(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
165{
166 /* TODO */
167 return 0;
168}
169
170int pem_task_stop_asic_block_usage(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
171{
172 /* TODO */
173 return 0;
174}
175
176int pem_task_disable_smc_firmware_ctf(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
177{
178 return phm_disable_smc_firmware_ctf(eventmgr->hwmgr);
179}
180
181int pem_task_setup_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
182{
183 return phm_setup_asic(eventmgr->hwmgr);
184}
185
186int pem_task_cleanup_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
187{
188 /* TODO */
189 return 0;
190}
191
192int pem_task_store_dal_configuration(struct pp_eventmgr *eventmgr, const struct amd_display_configuration *display_config)
193{
194 /* TODO */
195 return 0;
196 /*phm_store_dal_configuration_data(eventmgr->hwmgr, display_config) */
197}
198
199int pem_task_notify_hw_mgr_display_configuration_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
200{
201 if (pem_is_hw_access_blocked(eventmgr))
202 return 0;
203
204 return phm_display_configuration_changed(eventmgr->hwmgr);
205}
206
207int pem_task_notify_hw_mgr_pre_display_configuration_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
208{
209 return 0;
210}
211
212int pem_task_notify_smc_display_config_after_power_state_adjustment(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
213{
214 if (pem_is_hw_access_blocked(eventmgr))
215 return 0;
216
217 return phm_notify_smc_display_config_after_ps_adjustment(eventmgr->hwmgr);
218}
219
220int pem_task_block_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
221{
222 eventmgr->block_adjust_power_state = true;
223 /* to do PHM_ResetIPSCounter(pEventMgr->pHwMgr);*/
224 return 0;
225}
226
227int pem_task_unblock_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
228{
229 eventmgr->block_adjust_power_state = false;
230 return 0;
231}
232
233int pem_task_notify_power_state_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
234{
235 /* TODO */
236 return 0;
237}
238
239int pem_task_block_hw_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
240{
241 /* TODO */
242 return 0;
243}
244
245int pem_task_un_block_hw_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
246{
247 /* TODO */
248 return 0;
249}
250
251int pem_task_reset_display_phys_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
252{
253 /* TODO */
254 return 0;
255}
256
257int pem_task_set_cpu_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
258{
259 return phm_set_cpu_power_state(eventmgr->hwmgr);
260}
261
262/*powersaving*/
263
264int pem_task_set_power_source(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
265{
266 /* TODO */
267 return 0;
268}
269
270int pem_task_notify_hw_of_power_source(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
271{
272 /* TODO */
273 return 0;
274}
275
276int pem_task_get_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
277{
278 /* TODO */
279 return 0;
280}
281
282int pem_task_reset_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
283{
284 /* TODO */
285 return 0;
286}
287
288int pem_task_set_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
289{
290 /* TODO */
291 return 0;
292}
293
294int pem_task_set_screen_state_on(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
295{
296 /* TODO */
297 return 0;
298}
299
300int pem_task_set_screen_state_off(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
301{
302 /* TODO */
303 return 0;
304}
305
306int pem_task_enable_voltage_island_power_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
307{
308 /* TODO */
309 return 0;
310}
311
312int pem_task_disable_voltage_island_power_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
313{
314 /* TODO */
315 return 0;
316}
317
318int pem_task_enable_cgpg(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
319{
320 /* TODO */
321 return 0;
322}
323
324int pem_task_disable_cgpg(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
325{
326 /* TODO */
327 return 0;
328}
329
330int pem_task_enable_clock_power_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
331{
332 /* TODO */
333 return 0;
334}
335
336
337int pem_task_enable_gfx_clock_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
338{
339 /* TODO */
340 return 0;
341}
342
343int pem_task_disable_gfx_clock_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
344{
345 /* TODO */
346 return 0;
347}
348
349
350/* performance */
351int pem_task_set_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
352{
353 if (pem_is_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID))
354 return psm_set_states(eventmgr, &(event_data->requested_state_id));
355
356 return 0;
357}
358
359int pem_task_conditionally_force_3d_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
360{
361 /* TODO */
362 return 0;
363}
364
365int pem_task_enable_stutter_mode(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
366{
367 /* TODO */
368 return 0;
369}
370
371int pem_task_get_2D_performance_state_id(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
372{
373 int result;
374
375 if (eventmgr->features[PP_Feature_PowerPlay].supported &&
376 !(eventmgr->features[PP_Feature_PowerPlay].enabled))
377 result = psm_get_state_by_classification(eventmgr,
378 PP_StateClassificationFlag_Boot,
379 &(event_data->requested_state_id));
380 else if (eventmgr->features[PP_Feature_User2DPerformance].enabled)
381 result = psm_get_state_by_classification(eventmgr,
382 PP_StateClassificationFlag_User2DPerformance,
383 &(event_data->requested_state_id));
384 else
385 result = psm_get_ui_state(eventmgr, PP_StateUILabel_Performance,
386 &(event_data->requested_state_id));
387
388 if (0 == result)
389 pem_set_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID);
390 else
391 pem_unset_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID);
392
393 return result;
394}
395
396int pem_task_create_user_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
397{
398 struct pp_power_state *state;
399 int table_entries;
400 struct pp_hwmgr *hwmgr = eventmgr->hwmgr;
401 int i;
402
403 table_entries = hwmgr->num_ps;
404 state = hwmgr->ps;
405
406restart_search:
407 for (i = 0; i < table_entries; i++) {
408 if (state->classification.ui_label & event_data->requested_ui_label) {
409 event_data->pnew_power_state = state;
410 return 0;
411 }
412 state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
413 }
414
415 switch (event_data->requested_ui_label) {
416 case PP_StateUILabel_Battery:
417 case PP_StateUILabel_Balanced:
418 event_data->requested_ui_label = PP_StateUILabel_Performance;
419 goto restart_search;
420 default:
421 break;
422 }
423 return -1;
424}
425
426int pem_task_initialize_thermal_controller(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
427{
428 struct PP_TemperatureRange range;
429
430 range.max = TEMP_RANGE_MAX;
431 range.min = TEMP_RANGE_MIN;
432
433 if (eventmgr == NULL || eventmgr->platform_descriptor == NULL)
434 return -EINVAL;
435
436 if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_ThermalController))
437 return phm_start_thermal_controller(eventmgr->hwmgr, &range);
438
439 return 0;
440}
441
442int pem_task_uninitialize_thermal_controller(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
443{
444 return phm_stop_thermal_controller(eventmgr->hwmgr);
445}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.h b/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.h
deleted file mode 100644
index 37e7ca5a58e0..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#ifndef _EVENT_TASKS_H_
25#define _EVENT_TASKS_H_
26#include "eventmgr.h"
27
28struct amd_display_configuration;
29
30/* eventtasks_generic.c */
31int pem_task_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
32int pem_task_power_down_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
33int pem_task_get_boot_state_id(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
34int pem_task_set_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
35int pem_task_reset_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
36int pem_task_update_new_power_state_clocks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
37int pem_task_system_shutdown(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
38int pem_task_register_interrupts(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
39int pem_task_unregister_interrupts(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
40int pem_task_enable_dynamic_state_management(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
41int pem_task_disable_dynamic_state_management(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
42int pem_task_enable_clock_power_gatings_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
43int pem_task_powerdown_uvd_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
44int pem_task_powerdown_vce_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
45int pem_task_disable_clock_power_gatings_tasks(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
46int pem_task_start_asic_block_usage(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
47int pem_task_stop_asic_block_usage(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
48int pem_task_setup_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
49int pem_task_cleanup_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
50int pem_task_store_dal_configuration (struct pp_eventmgr *eventmgr, const struct amd_display_configuration *display_config);
51int pem_task_notify_hw_mgr_display_configuration_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
52int pem_task_notify_hw_mgr_pre_display_configuration_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
53int pem_task_block_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
54int pem_task_unblock_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
55int pem_task_notify_power_state_change(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
56int pem_task_block_hw_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
57int pem_task_un_block_hw_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
58int pem_task_reset_display_phys_access(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
59int pem_task_set_cpu_power_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
60int pem_task_notify_smc_display_config_after_power_state_adjustment(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
61/*powersaving*/
62
63int pem_task_set_power_source(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
64int pem_task_notify_hw_of_power_source(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
65int pem_task_get_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
66int pem_task_reset_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
67int pem_task_set_power_saving_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
68int pem_task_set_screen_state_on(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
69int pem_task_set_screen_state_off(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
70int pem_task_enable_voltage_island_power_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
71int pem_task_disable_voltage_island_power_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
72int pem_task_enable_cgpg(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
73int pem_task_disable_cgpg(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
74int pem_task_enable_gfx_clock_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
75int pem_task_disable_gfx_clock_gating(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
76int pem_task_enable_stutter_mode(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
77
78/* performance */
79int pem_task_set_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
80int pem_task_conditionally_force_3d_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
81int pem_task_get_2D_performance_state_id(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
82int pem_task_create_user_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
83int pem_task_update_allowed_performance_levels(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
84/*thermal */
85int pem_task_initialize_thermal_controller(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
86int pem_task_uninitialize_thermal_controller(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
87int pem_task_disable_smc_firmware_ctf(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data);
88
89#endif /* _EVENT_TASKS_H_ */
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c
deleted file mode 100644
index 489908887e9c..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include "psm.h"
24
25int psm_get_ui_state(struct pp_eventmgr *eventmgr, enum PP_StateUILabel ui_label, unsigned long *state_id)
26{
27 struct pp_power_state *state;
28 int table_entries;
29 struct pp_hwmgr *hwmgr = eventmgr->hwmgr;
30 int i;
31
32 table_entries = hwmgr->num_ps;
33 state = hwmgr->ps;
34
35 for (i = 0; i < table_entries; i++) {
36 if (state->classification.ui_label & ui_label) {
37 *state_id = state->id;
38 return 0;
39 }
40 state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
41 }
42 return -1;
43}
44
45int psm_get_state_by_classification(struct pp_eventmgr *eventmgr, enum PP_StateClassificationFlag flag, unsigned long *state_id)
46{
47 struct pp_power_state *state;
48 int table_entries;
49 struct pp_hwmgr *hwmgr = eventmgr->hwmgr;
50 int i;
51
52 table_entries = hwmgr->num_ps;
53 state = hwmgr->ps;
54
55 for (i = 0; i < table_entries; i++) {
56 if (state->classification.flags & flag) {
57 *state_id = state->id;
58 return 0;
59 }
60 state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
61 }
62 return -1;
63}
64
65int psm_set_states(struct pp_eventmgr *eventmgr, unsigned long *state_id)
66{
67 struct pp_power_state *state;
68 int table_entries;
69 struct pp_hwmgr *hwmgr = eventmgr->hwmgr;
70 int i;
71
72 table_entries = hwmgr->num_ps;
73
74 state = hwmgr->ps;
75
76 for (i = 0; i < table_entries; i++) {
77 if (state->id == *state_id) {
78 memcpy(hwmgr->request_ps, state, hwmgr->ps_size);
79 return 0;
80 }
81 state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
82 }
83 return -1;
84}
85
86int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip)
87{
88
89 struct pp_power_state *pcurrent;
90 struct pp_power_state *requested;
91 struct pp_hwmgr *hwmgr;
92 bool equal;
93
94 if (skip)
95 return 0;
96
97 hwmgr = eventmgr->hwmgr;
98 pcurrent = hwmgr->current_ps;
99 requested = hwmgr->request_ps;
100
101 if (requested == NULL)
102 return 0;
103
104 phm_apply_state_adjust_rules(hwmgr, requested, pcurrent);
105
106 if (pcurrent == NULL || (0 != phm_check_states_equal(hwmgr, &pcurrent->hardware, &requested->hardware, &equal)))
107 equal = false;
108
109 if (!equal || phm_check_smc_update_required_for_display_configuration(hwmgr)) {
110 phm_set_power_state(hwmgr, &pcurrent->hardware, &requested->hardware);
111 memcpy(hwmgr->current_ps, hwmgr->request_ps, hwmgr->ps_size);
112 }
113 return 0;
114}
115
116int psm_adjust_power_state_static(struct pp_eventmgr *eventmgr, bool skip)
117{
118 return 0;
119}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h
deleted file mode 100644
index fbdff3e02aa3..000000000000
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#include "eventmgr.h"
24#include "eventinit.h"
25#include "eventmanagement.h"
26#include "eventmanager.h"
27#include "power_state.h"
28#include "hardwaremanager.h"
29
30int psm_get_ui_state(struct pp_eventmgr *eventmgr, enum PP_StateUILabel ui_label, unsigned long *state_id);
31
32int psm_get_state_by_classification(struct pp_eventmgr *eventmgr, enum PP_StateClassificationFlag flag, unsigned long *state_id);
33
34int psm_set_states(struct pp_eventmgr *eventmgr, unsigned long *state_id);
35
36int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip);
37
38int psm_adjust_power_state_static(struct pp_eventmgr *eventmgr, bool skip);
diff --git a/drivers/gpu/drm/amd/powerplay/inc/eventmanager.h b/drivers/gpu/drm/amd/powerplay/inc/eventmanager.h
deleted file mode 100644
index b9d84de8a44d..000000000000
--- a/drivers/gpu/drm/amd/powerplay/inc/eventmanager.h
+++ /dev/null
@@ -1,109 +0,0 @@
1/*
2 * Copyright 2015 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 */
23#ifndef _EVENT_MANAGER_H_
24#define _EVENT_MANAGER_H_
25
26#include "power_state.h"
27#include "pp_power_source.h"
28#include "hardwaremanager.h"
29#include "pp_asicblocks.h"
30
31struct pp_eventmgr;
32enum amd_pp_event;
33
34enum PEM_EventDataValid {
35 PEM_EventDataValid_RequestedStateID = 0,
36 PEM_EventDataValid_RequestedUILabel,
37 PEM_EventDataValid_NewPowerState,
38 PEM_EventDataValid_RequestedPowerSource,
39 PEM_EventDataValid_RequestedClocks,
40 PEM_EventDataValid_CurrentTemperature,
41 PEM_EventDataValid_AsicBlocks,
42 PEM_EventDataValid_ODParameters,
43 PEM_EventDataValid_PXAdapterPrefs,
44 PEM_EventDataValid_PXUserPrefs,
45 PEM_EventDataValid_PXSwitchReason,
46 PEM_EventDataValid_PXSwitchPhase,
47 PEM_EventDataValid_HdVideo,
48 PEM_EventDataValid_BacklightLevel,
49 PEM_EventDatavalid_VariBrightParams,
50 PEM_EventDataValid_VariBrightLevel,
51 PEM_EventDataValid_VariBrightImmediateChange,
52 PEM_EventDataValid_PercentWhite,
53 PEM_EventDataValid_SdVideo,
54 PEM_EventDataValid_HTLinkChangeReason,
55 PEM_EventDataValid_HWBlocks,
56 PEM_EventDataValid_RequestedThermalState,
57 PEM_EventDataValid_MvcVideo,
58 PEM_EventDataValid_Max
59};
60
61typedef enum PEM_EventDataValid PEM_EventDataValid;
62
63/* Number of bits in ULONG variable */
64#define PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD (sizeof(unsigned long)*8)
65
66/* Number of ULONG entries used by event data valid bits */
67#define PEM_MAX_NUM_EVENTDATAVALID_ULONG_ENTRIES \
68 ((PEM_EventDataValid_Max + PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD - 1) / \
69 PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD)
70
71static inline void pem_set_event_data_valid(unsigned long *fields, PEM_EventDataValid valid_field)
72{
73 fields[valid_field / PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD] |=
74 (1UL << (valid_field % PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD));
75}
76
77static inline void pem_unset_event_data_valid(unsigned long *fields, PEM_EventDataValid valid_field)
78{
79 fields[valid_field / PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD] &=
80 ~(1UL << (valid_field % PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD));
81}
82
83static inline unsigned long pem_is_event_data_valid(const unsigned long *fields, PEM_EventDataValid valid_field)
84{
85 return fields[valid_field / PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD] &
86 (1UL << (valid_field % PEM_MAX_NUM_EVENTDATAVALID_BITS_PER_FIELD));
87}
88
89struct pem_event_data {
90 unsigned long valid_fields[100];
91 unsigned long requested_state_id;
92 enum PP_StateUILabel requested_ui_label;
93 struct pp_power_state *pnew_power_state;
94 enum pp_power_source requested_power_source;
95 struct PP_Clocks requested_clocks;
96 bool skip_state_adjust_rules;
97 struct phm_asic_blocks asic_blocks;
98 /* to doPP_ThermalState requestedThermalState;
99 enum ThermalStateRequestSrc requestThermalStateSrc;
100 PP_Temperature currentTemperature;*/
101
102};
103
104int pem_handle_event(struct pp_eventmgr *eventmgr, enum amd_pp_event event,
105 struct pem_event_data *event_data);
106
107bool pem_is_hw_access_blocked(struct pp_eventmgr *eventmgr);
108
109#endif /* _EVENT_MANAGER_H_ */
diff --git a/drivers/gpu/drm/amd/powerplay/inc/eventmgr.h b/drivers/gpu/drm/amd/powerplay/inc/eventmgr.h
deleted file mode 100644
index 7bd8a7e57080..000000000000
--- a/drivers/gpu/drm/amd/powerplay/inc/eventmgr.h
+++ /dev/null
@@ -1,124 +0,0 @@
1/*
2 * Copyright 2015 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 */
23
24#ifndef _EVENTMGR_H_
25#define _EVENTMGR_H_
26
27#include <linux/mutex.h>
28#include "pp_instance.h"
29#include "hardwaremanager.h"
30#include "eventmanager.h"
31#include "pp_feature.h"
32#include "pp_power_source.h"
33#include "power_state.h"
34
35typedef int (*pem_event_action)(struct pp_eventmgr *eventmgr,
36 struct pem_event_data *event_data);
37
38struct action_chain {
39 const char *description; /* action chain description for debugging purpose */
40 const pem_event_action * const *action_chain; /* pointer to chain of event actions */
41};
42
43struct pem_power_source_ui_state_info {
44 enum PP_StateUILabel current_ui_label;
45 enum PP_StateUILabel default_ui_lable;
46 unsigned long configurable_ui_mapping;
47};
48
49struct pp_clock_range {
50 uint32_t min_sclk_khz;
51 uint32_t max_sclk_khz;
52
53 uint32_t min_mclk_khz;
54 uint32_t max_mclk_khz;
55
56 uint32_t min_vclk_khz;
57 uint32_t max_vclk_khz;
58
59 uint32_t min_dclk_khz;
60 uint32_t max_dclk_khz;
61
62 uint32_t min_aclk_khz;
63 uint32_t max_aclk_khz;
64
65 uint32_t min_eclk_khz;
66 uint32_t max_eclk_khz;
67};
68
69enum pp_state {
70 UNINITIALIZED,
71 INACTIVE,
72 ACTIVE
73};
74
75enum pp_ring_index {
76 PP_RING_TYPE_GFX_INDEX = 0,
77 PP_RING_TYPE_DMA_INDEX,
78 PP_RING_TYPE_DMA1_INDEX,
79 PP_RING_TYPE_UVD_INDEX,
80 PP_RING_TYPE_VCE0_INDEX,
81 PP_RING_TYPE_VCE1_INDEX,
82 PP_RING_TYPE_CP1_INDEX,
83 PP_RING_TYPE_CP2_INDEX,
84 PP_NUM_RINGS,
85};
86
87struct pp_request {
88 uint32_t flags;
89 uint32_t sclk;
90 uint32_t sclk_throttle;
91 uint32_t mclk;
92 uint32_t vclk;
93 uint32_t dclk;
94 uint32_t eclk;
95 uint32_t aclk;
96 uint32_t iclk;
97 uint32_t vp8clk;
98 uint32_t rsv[32];
99};
100
101struct pp_eventmgr {
102 struct pp_hwmgr *hwmgr;
103 struct pp_smumgr *smumgr;
104
105 struct pp_feature_info features[PP_Feature_Max];
106 const struct action_chain *event_chain[AMD_PP_EVENT_MAX];
107 struct phm_platform_descriptor *platform_descriptor;
108 struct pp_clock_range clock_range;
109 enum pp_power_source current_power_source;
110 struct pem_power_source_ui_state_info ui_state_info[PP_PowerSource_Max];
111 enum pp_state states[PP_NUM_RINGS];
112 struct pp_request hi_req;
113 struct list_head context_list;
114 struct mutex lock;
115 bool block_adjust_power_state;
116 bool enable_cg;
117 bool enable_gfx_cgpg;
118 int (*pp_eventmgr_init)(struct pp_eventmgr *eventmgr);
119 void (*pp_eventmgr_fini)(struct pp_eventmgr *eventmgr);
120};
121
122int eventmgr_early_init(struct pp_instance *handle);
123
124#endif /* _EVENTMGR_H_ */