blob: d4d1c39a0e99e4e8636dd9e1d095da4473c61e87 [file] [log] [blame]
Rafał Miłecki74338742009-11-03 00:53:02 +01001/*
2 * Permission is hereby granted, free of charge, to any person obtaining a
3 * copy of this software and associated documentation files (the "Software"),
4 * to deal in the Software without restriction, including without limitation
5 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
16 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
17 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
18 * OTHER DEALINGS IN THE SOFTWARE.
19 *
20 * Authors: Rafał Miłecki <zajec5@gmail.com>
Alex Deucher56278a82009-12-28 13:58:44 -050021 * Alex Deucher <alexdeucher@gmail.com>
Rafał Miłecki74338742009-11-03 00:53:02 +010022 */
23#include "drmP.h"
24#include "radeon.h"
Dave Airlief7352612010-02-18 15:58:36 +100025#include "avivod.h"
Rafał Miłecki74338742009-11-03 00:53:02 +010026
Rafał Miłeckic913e232009-12-22 23:02:16 +010027#define RADEON_IDLE_LOOP_MS 100
28#define RADEON_RECLOCK_DELAY_MS 200
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +010029#define RADEON_WAIT_VBLANK_TIMEOUT 200
Rafał Miłeckic913e232009-12-22 23:02:16 +010030
Rafał Miłeckic913e232009-12-22 23:02:16 +010031static void radeon_pm_set_clocks_locked(struct radeon_device *rdev);
32static void radeon_pm_set_clocks(struct radeon_device *rdev);
Rafał Miłeckic913e232009-12-22 23:02:16 +010033static void radeon_pm_idle_work_handler(struct work_struct *work);
34static int radeon_debugfs_pm_init(struct radeon_device *rdev);
35
36static const char *pm_state_names[4] = {
37 "PM_STATE_DISABLED",
38 "PM_STATE_MINIMUM",
39 "PM_STATE_PAUSED",
40 "PM_STATE_ACTIVE"
41};
Rafał Miłecki74338742009-11-03 00:53:02 +010042
Alex Deucher0ec0e742009-12-23 13:21:58 -050043static const char *pm_state_types[5] = {
44 "Default",
45 "Powersave",
46 "Battery",
47 "Balanced",
48 "Performance",
49};
50
Alex Deucher56278a82009-12-28 13:58:44 -050051static void radeon_print_power_mode_info(struct radeon_device *rdev)
52{
53 int i, j;
54 bool is_default;
55
56 DRM_INFO("%d Power State(s)\n", rdev->pm.num_power_states);
57 for (i = 0; i < rdev->pm.num_power_states; i++) {
58 if (rdev->pm.default_power_state == &rdev->pm.power_state[i])
59 is_default = true;
60 else
61 is_default = false;
Alex Deucher0ec0e742009-12-23 13:21:58 -050062 DRM_INFO("State %d %s %s\n", i,
63 pm_state_types[rdev->pm.power_state[i].type],
64 is_default ? "(default)" : "");
Alex Deucher56278a82009-12-28 13:58:44 -050065 if ((rdev->flags & RADEON_IS_PCIE) && !(rdev->flags & RADEON_IS_IGP))
66 DRM_INFO("\t%d PCIE Lanes\n", rdev->pm.power_state[i].non_clock_info.pcie_lanes);
67 DRM_INFO("\t%d Clock Mode(s)\n", rdev->pm.power_state[i].num_clock_modes);
68 for (j = 0; j < rdev->pm.power_state[i].num_clock_modes; j++) {
69 if (rdev->flags & RADEON_IS_IGP)
70 DRM_INFO("\t\t%d engine: %d\n",
71 j,
72 rdev->pm.power_state[i].clock_info[j].sclk * 10);
73 else
74 DRM_INFO("\t\t%d engine/memory: %d/%d\n",
75 j,
76 rdev->pm.power_state[i].clock_info[j].sclk * 10,
77 rdev->pm.power_state[i].clock_info[j].mclk * 10);
78 }
79 }
80}
81
Alex Deucher516d0e42009-12-23 14:28:05 -050082static struct radeon_power_state * radeon_pick_power_state(struct radeon_device *rdev,
83 enum radeon_pm_state_type type)
84{
Rafał Miłeckibc4624c2010-02-11 21:50:06 +000085 int i, j;
86 enum radeon_pm_state_type wanted_types[2];
87 int wanted_count;
Alex Deucher516d0e42009-12-23 14:28:05 -050088
89 switch (type) {
90 case POWER_STATE_TYPE_DEFAULT:
91 default:
92 return rdev->pm.default_power_state;
93 case POWER_STATE_TYPE_POWERSAVE:
Rafał Miłecki08ff2a72010-02-21 22:46:30 +000094 if (rdev->flags & RADEON_IS_MOBILITY) {
95 wanted_types[0] = POWER_STATE_TYPE_POWERSAVE;
96 wanted_types[1] = POWER_STATE_TYPE_BATTERY;
97 wanted_count = 2;
98 } else {
99 wanted_types[0] = POWER_STATE_TYPE_PERFORMANCE;
100 wanted_count = 1;
101 }
Alex Deucher516d0e42009-12-23 14:28:05 -0500102 break;
103 case POWER_STATE_TYPE_BATTERY:
Rafał Miłecki08ff2a72010-02-21 22:46:30 +0000104 if (rdev->flags & RADEON_IS_MOBILITY) {
105 wanted_types[0] = POWER_STATE_TYPE_BATTERY;
106 wanted_types[1] = POWER_STATE_TYPE_POWERSAVE;
107 wanted_count = 2;
108 } else {
109 wanted_types[0] = POWER_STATE_TYPE_PERFORMANCE;
110 wanted_count = 1;
111 }
Alex Deucher516d0e42009-12-23 14:28:05 -0500112 break;
113 case POWER_STATE_TYPE_BALANCED:
114 case POWER_STATE_TYPE_PERFORMANCE:
Rafał Miłeckibc4624c2010-02-11 21:50:06 +0000115 wanted_types[0] = type;
116 wanted_count = 1;
Alex Deucher516d0e42009-12-23 14:28:05 -0500117 break;
118 }
119
Rafał Miłeckibc4624c2010-02-11 21:50:06 +0000120 for (i = 0; i < wanted_count; i++) {
121 for (j = 0; j < rdev->pm.num_power_states; j++) {
122 if (rdev->pm.power_state[j].type == wanted_types[i])
123 return &rdev->pm.power_state[j];
124 }
125 }
Alex Deucher516d0e42009-12-23 14:28:05 -0500126
Rafał Miłeckibc4624c2010-02-11 21:50:06 +0000127 return rdev->pm.default_power_state;
Alex Deucher516d0e42009-12-23 14:28:05 -0500128}
129
130static struct radeon_pm_clock_info * radeon_pick_clock_mode(struct radeon_device *rdev,
131 struct radeon_power_state *power_state,
132 enum radeon_pm_clock_mode_type type)
133{
134 switch (type) {
135 case POWER_MODE_TYPE_DEFAULT:
136 default:
137 return power_state->default_clock_mode;
138 case POWER_MODE_TYPE_LOW:
139 return &power_state->clock_info[0];
140 case POWER_MODE_TYPE_MID:
141 if (power_state->num_clock_modes > 2)
142 return &power_state->clock_info[1];
143 else
144 return &power_state->clock_info[0];
145 break;
146 case POWER_MODE_TYPE_HIGH:
147 return &power_state->clock_info[power_state->num_clock_modes - 1];
148 }
149
150}
151
152static void radeon_get_power_state(struct radeon_device *rdev,
153 enum radeon_pm_action action)
154{
155 switch (action) {
Alex Deucher516d0e42009-12-23 14:28:05 -0500156 case PM_ACTION_MINIMUM:
157 rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_BATTERY);
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000158 rdev->pm.requested_clock_mode =
Alex Deucher516d0e42009-12-23 14:28:05 -0500159 radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_LOW);
160 break;
161 case PM_ACTION_DOWNCLOCK:
162 rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_POWERSAVE);
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000163 rdev->pm.requested_clock_mode =
Alex Deucher516d0e42009-12-23 14:28:05 -0500164 radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_MID);
165 break;
166 case PM_ACTION_UPCLOCK:
167 rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_DEFAULT);
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000168 rdev->pm.requested_clock_mode =
Alex Deucher516d0e42009-12-23 14:28:05 -0500169 radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_HIGH);
170 break;
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000171 case PM_ACTION_NONE:
172 default:
173 DRM_ERROR("Requested mode for not defined action\n");
174 return;
Alex Deucher516d0e42009-12-23 14:28:05 -0500175 }
Alex Deucher530079a2009-12-23 14:39:36 -0500176 DRM_INFO("Requested: e: %d m: %d p: %d\n",
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000177 rdev->pm.requested_clock_mode->sclk,
178 rdev->pm.requested_clock_mode->mclk,
Alex Deucher530079a2009-12-23 14:39:36 -0500179 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
Alex Deucher516d0e42009-12-23 14:28:05 -0500180}
181
182static void radeon_set_power_state(struct radeon_device *rdev)
183{
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000184 /* if *_clock_mode are the same, *_power_state are as well */
185 if (rdev->pm.requested_clock_mode == rdev->pm.current_clock_mode)
Alex Deucher516d0e42009-12-23 14:28:05 -0500186 return;
Alex Deucher530079a2009-12-23 14:39:36 -0500187
188 DRM_INFO("Setting: e: %d m: %d p: %d\n",
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000189 rdev->pm.requested_clock_mode->sclk,
190 rdev->pm.requested_clock_mode->mclk,
Alex Deucher530079a2009-12-23 14:39:36 -0500191 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
Alex Deucher516d0e42009-12-23 14:28:05 -0500192 /* set pcie lanes */
193 /* set voltage */
194 /* set engine clock */
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000195 radeon_set_engine_clock(rdev, rdev->pm.requested_clock_mode->sclk);
Alex Deucher516d0e42009-12-23 14:28:05 -0500196 /* set memory clock */
197
198 rdev->pm.current_power_state = rdev->pm.requested_power_state;
Rafał Miłecki9038dfd2010-02-20 23:15:04 +0000199 rdev->pm.current_clock_mode = rdev->pm.requested_clock_mode;
Alex Deucher516d0e42009-12-23 14:28:05 -0500200}
201
Rafał Miłecki74338742009-11-03 00:53:02 +0100202int radeon_pm_init(struct radeon_device *rdev)
203{
Rafał Miłeckic913e232009-12-22 23:02:16 +0100204 rdev->pm.state = PM_STATE_DISABLED;
205 rdev->pm.planned_action = PM_ACTION_NONE;
206 rdev->pm.downclocked = false;
Rafał Miłeckic913e232009-12-22 23:02:16 +0100207
Alex Deucher56278a82009-12-28 13:58:44 -0500208 if (rdev->bios) {
209 if (rdev->is_atom_bios)
210 radeon_atombios_get_power_modes(rdev);
211 else
212 radeon_combios_get_power_modes(rdev);
213 radeon_print_power_mode_info(rdev);
214 }
215
Rafał Miłecki74338742009-11-03 00:53:02 +0100216 if (radeon_debugfs_pm_init(rdev)) {
Rafał Miłeckic142c3e2009-11-06 11:38:34 +0100217 DRM_ERROR("Failed to register debugfs file for PM!\n");
Rafał Miłecki74338742009-11-03 00:53:02 +0100218 }
219
Rafał Miłeckic913e232009-12-22 23:02:16 +0100220 INIT_DELAYED_WORK(&rdev->pm.idle_work, radeon_pm_idle_work_handler);
221
222 if (radeon_dynpm != -1 && radeon_dynpm) {
223 rdev->pm.state = PM_STATE_PAUSED;
224 DRM_INFO("radeon: dynamic power management enabled\n");
225 }
226
227 DRM_INFO("radeon: power management initialized\n");
228
Rafał Miłecki74338742009-11-03 00:53:02 +0100229 return 0;
230}
231
Rafał Miłeckic913e232009-12-22 23:02:16 +0100232void radeon_pm_compute_clocks(struct radeon_device *rdev)
233{
234 struct drm_device *ddev = rdev->ddev;
235 struct drm_connector *connector;
236 struct radeon_crtc *radeon_crtc;
237 int count = 0;
238
239 if (rdev->pm.state == PM_STATE_DISABLED)
240 return;
241
242 mutex_lock(&rdev->pm.mutex);
243
244 rdev->pm.active_crtcs = 0;
245 list_for_each_entry(connector,
246 &ddev->mode_config.connector_list, head) {
247 if (connector->encoder &&
248 connector->dpms != DRM_MODE_DPMS_OFF) {
249 radeon_crtc = to_radeon_crtc(connector->encoder->crtc);
250 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
251 ++count;
252 }
253 }
254
255 if (count > 1) {
256 if (rdev->pm.state == PM_STATE_ACTIVE) {
Rafał Miłeckic913e232009-12-22 23:02:16 +0100257 cancel_delayed_work(&rdev->pm.idle_work);
258
259 rdev->pm.state = PM_STATE_PAUSED;
260 rdev->pm.planned_action = PM_ACTION_UPCLOCK;
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100261 if (rdev->pm.downclocked)
Rafał Miłeckic913e232009-12-22 23:02:16 +0100262 radeon_pm_set_clocks(rdev);
263
264 DRM_DEBUG("radeon: dynamic power management deactivated\n");
Rafał Miłeckic913e232009-12-22 23:02:16 +0100265 }
266 } else if (count == 1) {
Rafał Miłeckic913e232009-12-22 23:02:16 +0100267 /* TODO: Increase clocks if needed for current mode */
268
269 if (rdev->pm.state == PM_STATE_MINIMUM) {
270 rdev->pm.state = PM_STATE_ACTIVE;
271 rdev->pm.planned_action = PM_ACTION_UPCLOCK;
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100272 radeon_pm_set_clocks(rdev);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100273
274 queue_delayed_work(rdev->wq, &rdev->pm.idle_work,
275 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
276 }
277 else if (rdev->pm.state == PM_STATE_PAUSED) {
278 rdev->pm.state = PM_STATE_ACTIVE;
279 queue_delayed_work(rdev->wq, &rdev->pm.idle_work,
280 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
281 DRM_DEBUG("radeon: dynamic power management activated\n");
282 }
Rafał Miłeckic913e232009-12-22 23:02:16 +0100283 }
284 else { /* count == 0 */
285 if (rdev->pm.state != PM_STATE_MINIMUM) {
286 cancel_delayed_work(&rdev->pm.idle_work);
287
288 rdev->pm.state = PM_STATE_MINIMUM;
289 rdev->pm.planned_action = PM_ACTION_MINIMUM;
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100290 radeon_pm_set_clocks(rdev);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100291 }
Rafał Miłeckic913e232009-12-22 23:02:16 +0100292 }
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100293
294 mutex_unlock(&rdev->pm.mutex);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100295}
296
Dave Airlief7352612010-02-18 15:58:36 +1000297static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish)
298{
299 u32 stat_crtc1 = 0, stat_crtc2 = 0;
300 bool in_vbl = true;
301
302 if (ASIC_IS_AVIVO(rdev)) {
303 if (rdev->pm.active_crtcs & (1 << 0)) {
304 stat_crtc1 = RREG32(D1CRTC_STATUS);
305 if (!(stat_crtc1 & 1))
306 in_vbl = false;
307 }
308 if (rdev->pm.active_crtcs & (1 << 1)) {
309 stat_crtc2 = RREG32(D2CRTC_STATUS);
310 if (!(stat_crtc2 & 1))
311 in_vbl = false;
312 }
313 }
314 if (in_vbl == false)
315 DRM_INFO("not in vbl for pm change %08x %08x at %s\n", stat_crtc1,
316 stat_crtc2, finish ? "exit" : "entry");
317 return in_vbl;
318}
Rafał Miłeckic913e232009-12-22 23:02:16 +0100319static void radeon_pm_set_clocks_locked(struct radeon_device *rdev)
320{
321 /*radeon_fence_wait_last(rdev);*/
322 switch (rdev->pm.planned_action) {
323 case PM_ACTION_UPCLOCK:
Rafał Miłeckic913e232009-12-22 23:02:16 +0100324 rdev->pm.downclocked = false;
325 break;
326 case PM_ACTION_DOWNCLOCK:
Rafał Miłeckic913e232009-12-22 23:02:16 +0100327 rdev->pm.downclocked = true;
328 break;
329 case PM_ACTION_MINIMUM:
Rafał Miłeckic913e232009-12-22 23:02:16 +0100330 break;
331 case PM_ACTION_NONE:
332 DRM_ERROR("%s: PM_ACTION_NONE\n", __func__);
333 break;
334 }
Dave Airlief7352612010-02-18 15:58:36 +1000335
336 /* check if we are in vblank */
337 radeon_pm_debug_check_in_vbl(rdev, false);
Alex Deucher530079a2009-12-23 14:39:36 -0500338 radeon_set_power_state(rdev);
Dave Airlief7352612010-02-18 15:58:36 +1000339 radeon_pm_debug_check_in_vbl(rdev, true);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100340 rdev->pm.planned_action = PM_ACTION_NONE;
341}
342
343static void radeon_pm_set_clocks(struct radeon_device *rdev)
344{
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100345 radeon_get_power_state(rdev, rdev->pm.planned_action);
346 mutex_lock(&rdev->cp.mutex);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100347
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100348 if (rdev->pm.active_crtcs & (1 << 0)) {
349 rdev->pm.req_vblank |= (1 << 0);
350 drm_vblank_get(rdev->ddev, 0);
351 }
352 if (rdev->pm.active_crtcs & (1 << 1)) {
353 rdev->pm.req_vblank |= (1 << 1);
354 drm_vblank_get(rdev->ddev, 1);
355 }
356 if (rdev->pm.active_crtcs)
357 wait_event_interruptible_timeout(
358 rdev->irq.vblank_queue, 0,
359 msecs_to_jiffies(RADEON_WAIT_VBLANK_TIMEOUT));
360 if (rdev->pm.req_vblank & (1 << 0)) {
361 rdev->pm.req_vblank &= ~(1 << 0);
362 drm_vblank_put(rdev->ddev, 0);
363 }
364 if (rdev->pm.req_vblank & (1 << 1)) {
365 rdev->pm.req_vblank &= ~(1 << 1);
366 drm_vblank_put(rdev->ddev, 1);
367 }
368
369 radeon_pm_set_clocks_locked(rdev);
370 mutex_unlock(&rdev->cp.mutex);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100371}
372
373static void radeon_pm_idle_work_handler(struct work_struct *work)
374{
375 struct radeon_device *rdev;
376 rdev = container_of(work, struct radeon_device,
377 pm.idle_work.work);
378
379 mutex_lock(&rdev->pm.mutex);
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100380 if (rdev->pm.state == PM_STATE_ACTIVE) {
Rafał Miłeckic913e232009-12-22 23:02:16 +0100381 unsigned long irq_flags;
382 int not_processed = 0;
383
384 read_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
385 if (!list_empty(&rdev->fence_drv.emited)) {
386 struct list_head *ptr;
387 list_for_each(ptr, &rdev->fence_drv.emited) {
388 /* count up to 3, that's enought info */
389 if (++not_processed >= 3)
390 break;
391 }
392 }
393 read_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
394
395 if (not_processed >= 3) { /* should upclock */
396 if (rdev->pm.planned_action == PM_ACTION_DOWNCLOCK) {
397 rdev->pm.planned_action = PM_ACTION_NONE;
398 } else if (rdev->pm.planned_action == PM_ACTION_NONE &&
399 rdev->pm.downclocked) {
400 rdev->pm.planned_action =
401 PM_ACTION_UPCLOCK;
402 rdev->pm.action_timeout = jiffies +
403 msecs_to_jiffies(RADEON_RECLOCK_DELAY_MS);
404 }
405 } else if (not_processed == 0) { /* should downclock */
406 if (rdev->pm.planned_action == PM_ACTION_UPCLOCK) {
407 rdev->pm.planned_action = PM_ACTION_NONE;
408 } else if (rdev->pm.planned_action == PM_ACTION_NONE &&
409 !rdev->pm.downclocked) {
410 rdev->pm.planned_action =
411 PM_ACTION_DOWNCLOCK;
412 rdev->pm.action_timeout = jiffies +
413 msecs_to_jiffies(RADEON_RECLOCK_DELAY_MS);
414 }
415 }
416
417 if (rdev->pm.planned_action != PM_ACTION_NONE &&
Rafał Miłecki73a6d3f2010-01-08 00:22:47 +0100418 jiffies > rdev->pm.action_timeout) {
419 radeon_pm_set_clocks(rdev);
Rafał Miłeckic913e232009-12-22 23:02:16 +0100420 }
421 }
422 mutex_unlock(&rdev->pm.mutex);
423
424 queue_delayed_work(rdev->wq, &rdev->pm.idle_work,
425 msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
426}
427
Rafał Miłecki74338742009-11-03 00:53:02 +0100428/*
429 * Debugfs info
430 */
431#if defined(CONFIG_DEBUG_FS)
432
433static int radeon_debugfs_pm_info(struct seq_file *m, void *data)
434{
435 struct drm_info_node *node = (struct drm_info_node *) m->private;
436 struct drm_device *dev = node->minor->dev;
437 struct radeon_device *rdev = dev->dev_private;
438
Rafał Miłeckic913e232009-12-22 23:02:16 +0100439 seq_printf(m, "state: %s\n", pm_state_names[rdev->pm.state]);
Rafał Miłecki62340772009-12-15 21:46:58 +0100440 seq_printf(m, "default engine clock: %u0 kHz\n", rdev->clock.default_sclk);
441 seq_printf(m, "current engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev));
442 seq_printf(m, "default memory clock: %u0 kHz\n", rdev->clock.default_mclk);
443 if (rdev->asic->get_memory_clock)
444 seq_printf(m, "current memory clock: %u0 kHz\n", radeon_get_memory_clock(rdev));
Rafał Miłeckiaa5120d2010-02-18 20:24:28 +0000445 if (rdev->asic->get_pcie_lanes)
446 seq_printf(m, "PCIE lanes: %d\n", radeon_get_pcie_lanes(rdev));
Rafał Miłecki74338742009-11-03 00:53:02 +0100447
448 return 0;
449}
450
451static struct drm_info_list radeon_pm_info_list[] = {
452 {"radeon_pm_info", radeon_debugfs_pm_info, 0, NULL},
453};
454#endif
455
Rafał Miłeckic913e232009-12-22 23:02:16 +0100456static int radeon_debugfs_pm_init(struct radeon_device *rdev)
Rafał Miłecki74338742009-11-03 00:53:02 +0100457{
458#if defined(CONFIG_DEBUG_FS)
459 return radeon_debugfs_add_files(rdev, radeon_pm_info_list, ARRAY_SIZE(radeon_pm_info_list));
460#else
461 return 0;
462#endif
463}