2 * Copyright 2012 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
30 #include <linux/math64.h>
31 #include <linux/seq_file.h>
33 #define MC_CG_ARB_FREQ_F0 0x0a
34 #define MC_CG_ARB_FREQ_F1 0x0b
35 #define MC_CG_ARB_FREQ_F2 0x0c
36 #define MC_CG_ARB_FREQ_F3 0x0d
38 #define SMC_RAM_END 0xC000
40 static const struct ni_cac_weights cac_weights_cayman_xt
=
104 { 0, 0, 0, 0, 0, 0, 0, 0 },
109 static const struct ni_cac_weights cac_weights_cayman_pro
=
173 { 0, 0, 0, 0, 0, 0, 0, 0 },
178 static const struct ni_cac_weights cac_weights_cayman_le
=
242 { 0, 0, 0, 0, 0, 0, 0, 0 },
247 #define NISLANDS_MGCG_SEQUENCE 300
249 static const u32 cayman_cgcg_cgls_default
[] =
251 0x000008f8, 0x00000010, 0xffffffff,
252 0x000008fc, 0x00000000, 0xffffffff,
253 0x000008f8, 0x00000011, 0xffffffff,
254 0x000008fc, 0x00000000, 0xffffffff,
255 0x000008f8, 0x00000012, 0xffffffff,
256 0x000008fc, 0x00000000, 0xffffffff,
257 0x000008f8, 0x00000013, 0xffffffff,
258 0x000008fc, 0x00000000, 0xffffffff,
259 0x000008f8, 0x00000014, 0xffffffff,
260 0x000008fc, 0x00000000, 0xffffffff,
261 0x000008f8, 0x00000015, 0xffffffff,
262 0x000008fc, 0x00000000, 0xffffffff,
263 0x000008f8, 0x00000016, 0xffffffff,
264 0x000008fc, 0x00000000, 0xffffffff,
265 0x000008f8, 0x00000017, 0xffffffff,
266 0x000008fc, 0x00000000, 0xffffffff,
267 0x000008f8, 0x00000018, 0xffffffff,
268 0x000008fc, 0x00000000, 0xffffffff,
269 0x000008f8, 0x00000019, 0xffffffff,
270 0x000008fc, 0x00000000, 0xffffffff,
271 0x000008f8, 0x0000001a, 0xffffffff,
272 0x000008fc, 0x00000000, 0xffffffff,
273 0x000008f8, 0x0000001b, 0xffffffff,
274 0x000008fc, 0x00000000, 0xffffffff,
275 0x000008f8, 0x00000020, 0xffffffff,
276 0x000008fc, 0x00000000, 0xffffffff,
277 0x000008f8, 0x00000021, 0xffffffff,
278 0x000008fc, 0x00000000, 0xffffffff,
279 0x000008f8, 0x00000022, 0xffffffff,
280 0x000008fc, 0x00000000, 0xffffffff,
281 0x000008f8, 0x00000023, 0xffffffff,
282 0x000008fc, 0x00000000, 0xffffffff,
283 0x000008f8, 0x00000024, 0xffffffff,
284 0x000008fc, 0x00000000, 0xffffffff,
285 0x000008f8, 0x00000025, 0xffffffff,
286 0x000008fc, 0x00000000, 0xffffffff,
287 0x000008f8, 0x00000026, 0xffffffff,
288 0x000008fc, 0x00000000, 0xffffffff,
289 0x000008f8, 0x00000027, 0xffffffff,
290 0x000008fc, 0x00000000, 0xffffffff,
291 0x000008f8, 0x00000028, 0xffffffff,
292 0x000008fc, 0x00000000, 0xffffffff,
293 0x000008f8, 0x00000029, 0xffffffff,
294 0x000008fc, 0x00000000, 0xffffffff,
295 0x000008f8, 0x0000002a, 0xffffffff,
296 0x000008fc, 0x00000000, 0xffffffff,
297 0x000008f8, 0x0000002b, 0xffffffff,
298 0x000008fc, 0x00000000, 0xffffffff
300 #define CAYMAN_CGCG_CGLS_DEFAULT_LENGTH sizeof(cayman_cgcg_cgls_default) / (3 * sizeof(u32))
302 static const u32 cayman_cgcg_cgls_disable
[] =
304 0x000008f8, 0x00000010, 0xffffffff,
305 0x000008fc, 0xffffffff, 0xffffffff,
306 0x000008f8, 0x00000011, 0xffffffff,
307 0x000008fc, 0xffffffff, 0xffffffff,
308 0x000008f8, 0x00000012, 0xffffffff,
309 0x000008fc, 0xffffffff, 0xffffffff,
310 0x000008f8, 0x00000013, 0xffffffff,
311 0x000008fc, 0xffffffff, 0xffffffff,
312 0x000008f8, 0x00000014, 0xffffffff,
313 0x000008fc, 0xffffffff, 0xffffffff,
314 0x000008f8, 0x00000015, 0xffffffff,
315 0x000008fc, 0xffffffff, 0xffffffff,
316 0x000008f8, 0x00000016, 0xffffffff,
317 0x000008fc, 0xffffffff, 0xffffffff,
318 0x000008f8, 0x00000017, 0xffffffff,
319 0x000008fc, 0xffffffff, 0xffffffff,
320 0x000008f8, 0x00000018, 0xffffffff,
321 0x000008fc, 0xffffffff, 0xffffffff,
322 0x000008f8, 0x00000019, 0xffffffff,
323 0x000008fc, 0xffffffff, 0xffffffff,
324 0x000008f8, 0x0000001a, 0xffffffff,
325 0x000008fc, 0xffffffff, 0xffffffff,
326 0x000008f8, 0x0000001b, 0xffffffff,
327 0x000008fc, 0xffffffff, 0xffffffff,
328 0x000008f8, 0x00000020, 0xffffffff,
329 0x000008fc, 0x00000000, 0xffffffff,
330 0x000008f8, 0x00000021, 0xffffffff,
331 0x000008fc, 0x00000000, 0xffffffff,
332 0x000008f8, 0x00000022, 0xffffffff,
333 0x000008fc, 0x00000000, 0xffffffff,
334 0x000008f8, 0x00000023, 0xffffffff,
335 0x000008fc, 0x00000000, 0xffffffff,
336 0x000008f8, 0x00000024, 0xffffffff,
337 0x000008fc, 0x00000000, 0xffffffff,
338 0x000008f8, 0x00000025, 0xffffffff,
339 0x000008fc, 0x00000000, 0xffffffff,
340 0x000008f8, 0x00000026, 0xffffffff,
341 0x000008fc, 0x00000000, 0xffffffff,
342 0x000008f8, 0x00000027, 0xffffffff,
343 0x000008fc, 0x00000000, 0xffffffff,
344 0x000008f8, 0x00000028, 0xffffffff,
345 0x000008fc, 0x00000000, 0xffffffff,
346 0x000008f8, 0x00000029, 0xffffffff,
347 0x000008fc, 0x00000000, 0xffffffff,
348 0x000008f8, 0x0000002a, 0xffffffff,
349 0x000008fc, 0x00000000, 0xffffffff,
350 0x000008f8, 0x0000002b, 0xffffffff,
351 0x000008fc, 0x00000000, 0xffffffff,
352 0x00000644, 0x000f7902, 0x001f4180,
353 0x00000644, 0x000f3802, 0x001f4180
355 #define CAYMAN_CGCG_CGLS_DISABLE_LENGTH sizeof(cayman_cgcg_cgls_disable) / (3 * sizeof(u32))
357 static const u32 cayman_cgcg_cgls_enable
[] =
359 0x00000644, 0x000f7882, 0x001f4080,
360 0x000008f8, 0x00000010, 0xffffffff,
361 0x000008fc, 0x00000000, 0xffffffff,
362 0x000008f8, 0x00000011, 0xffffffff,
363 0x000008fc, 0x00000000, 0xffffffff,
364 0x000008f8, 0x00000012, 0xffffffff,
365 0x000008fc, 0x00000000, 0xffffffff,
366 0x000008f8, 0x00000013, 0xffffffff,
367 0x000008fc, 0x00000000, 0xffffffff,
368 0x000008f8, 0x00000014, 0xffffffff,
369 0x000008fc, 0x00000000, 0xffffffff,
370 0x000008f8, 0x00000015, 0xffffffff,
371 0x000008fc, 0x00000000, 0xffffffff,
372 0x000008f8, 0x00000016, 0xffffffff,
373 0x000008fc, 0x00000000, 0xffffffff,
374 0x000008f8, 0x00000017, 0xffffffff,
375 0x000008fc, 0x00000000, 0xffffffff,
376 0x000008f8, 0x00000018, 0xffffffff,
377 0x000008fc, 0x00000000, 0xffffffff,
378 0x000008f8, 0x00000019, 0xffffffff,
379 0x000008fc, 0x00000000, 0xffffffff,
380 0x000008f8, 0x0000001a, 0xffffffff,
381 0x000008fc, 0x00000000, 0xffffffff,
382 0x000008f8, 0x0000001b, 0xffffffff,
383 0x000008fc, 0x00000000, 0xffffffff,
384 0x000008f8, 0x00000020, 0xffffffff,
385 0x000008fc, 0xffffffff, 0xffffffff,
386 0x000008f8, 0x00000021, 0xffffffff,
387 0x000008fc, 0xffffffff, 0xffffffff,
388 0x000008f8, 0x00000022, 0xffffffff,
389 0x000008fc, 0xffffffff, 0xffffffff,
390 0x000008f8, 0x00000023, 0xffffffff,
391 0x000008fc, 0xffffffff, 0xffffffff,
392 0x000008f8, 0x00000024, 0xffffffff,
393 0x000008fc, 0xffffffff, 0xffffffff,
394 0x000008f8, 0x00000025, 0xffffffff,
395 0x000008fc, 0xffffffff, 0xffffffff,
396 0x000008f8, 0x00000026, 0xffffffff,
397 0x000008fc, 0xffffffff, 0xffffffff,
398 0x000008f8, 0x00000027, 0xffffffff,
399 0x000008fc, 0xffffffff, 0xffffffff,
400 0x000008f8, 0x00000028, 0xffffffff,
401 0x000008fc, 0xffffffff, 0xffffffff,
402 0x000008f8, 0x00000029, 0xffffffff,
403 0x000008fc, 0xffffffff, 0xffffffff,
404 0x000008f8, 0x0000002a, 0xffffffff,
405 0x000008fc, 0xffffffff, 0xffffffff,
406 0x000008f8, 0x0000002b, 0xffffffff,
407 0x000008fc, 0xffffffff, 0xffffffff
409 #define CAYMAN_CGCG_CGLS_ENABLE_LENGTH sizeof(cayman_cgcg_cgls_enable) / (3 * sizeof(u32))
411 static const u32 cayman_mgcg_default
[] =
413 0x0000802c, 0xc0000000, 0xffffffff,
414 0x00003fc4, 0xc0000000, 0xffffffff,
415 0x00005448, 0x00000100, 0xffffffff,
416 0x000055e4, 0x00000100, 0xffffffff,
417 0x0000160c, 0x00000100, 0xffffffff,
418 0x00008984, 0x06000100, 0xffffffff,
419 0x0000c164, 0x00000100, 0xffffffff,
420 0x00008a18, 0x00000100, 0xffffffff,
421 0x0000897c, 0x06000100, 0xffffffff,
422 0x00008b28, 0x00000100, 0xffffffff,
423 0x00009144, 0x00800200, 0xffffffff,
424 0x00009a60, 0x00000100, 0xffffffff,
425 0x00009868, 0x00000100, 0xffffffff,
426 0x00008d58, 0x00000100, 0xffffffff,
427 0x00009510, 0x00000100, 0xffffffff,
428 0x0000949c, 0x00000100, 0xffffffff,
429 0x00009654, 0x00000100, 0xffffffff,
430 0x00009030, 0x00000100, 0xffffffff,
431 0x00009034, 0x00000100, 0xffffffff,
432 0x00009038, 0x00000100, 0xffffffff,
433 0x0000903c, 0x00000100, 0xffffffff,
434 0x00009040, 0x00000100, 0xffffffff,
435 0x0000a200, 0x00000100, 0xffffffff,
436 0x0000a204, 0x00000100, 0xffffffff,
437 0x0000a208, 0x00000100, 0xffffffff,
438 0x0000a20c, 0x00000100, 0xffffffff,
439 0x00009744, 0x00000100, 0xffffffff,
440 0x00003f80, 0x00000100, 0xffffffff,
441 0x0000a210, 0x00000100, 0xffffffff,
442 0x0000a214, 0x00000100, 0xffffffff,
443 0x000004d8, 0x00000100, 0xffffffff,
444 0x00009664, 0x00000100, 0xffffffff,
445 0x00009698, 0x00000100, 0xffffffff,
446 0x000004d4, 0x00000200, 0xffffffff,
447 0x000004d0, 0x00000000, 0xffffffff,
448 0x000030cc, 0x00000104, 0xffffffff,
449 0x0000d0c0, 0x00000100, 0xffffffff,
450 0x0000d8c0, 0x00000100, 0xffffffff,
451 0x0000802c, 0x40000000, 0xffffffff,
452 0x00003fc4, 0x40000000, 0xffffffff,
453 0x0000915c, 0x00010000, 0xffffffff,
454 0x00009160, 0x00030002, 0xffffffff,
455 0x00009164, 0x00050004, 0xffffffff,
456 0x00009168, 0x00070006, 0xffffffff,
457 0x00009178, 0x00070000, 0xffffffff,
458 0x0000917c, 0x00030002, 0xffffffff,
459 0x00009180, 0x00050004, 0xffffffff,
460 0x0000918c, 0x00010006, 0xffffffff,
461 0x00009190, 0x00090008, 0xffffffff,
462 0x00009194, 0x00070000, 0xffffffff,
463 0x00009198, 0x00030002, 0xffffffff,
464 0x0000919c, 0x00050004, 0xffffffff,
465 0x000091a8, 0x00010006, 0xffffffff,
466 0x000091ac, 0x00090008, 0xffffffff,
467 0x000091b0, 0x00070000, 0xffffffff,
468 0x000091b4, 0x00030002, 0xffffffff,
469 0x000091b8, 0x00050004, 0xffffffff,
470 0x000091c4, 0x00010006, 0xffffffff,
471 0x000091c8, 0x00090008, 0xffffffff,
472 0x000091cc, 0x00070000, 0xffffffff,
473 0x000091d0, 0x00030002, 0xffffffff,
474 0x000091d4, 0x00050004, 0xffffffff,
475 0x000091e0, 0x00010006, 0xffffffff,
476 0x000091e4, 0x00090008, 0xffffffff,
477 0x000091e8, 0x00000000, 0xffffffff,
478 0x000091ec, 0x00070000, 0xffffffff,
479 0x000091f0, 0x00030002, 0xffffffff,
480 0x000091f4, 0x00050004, 0xffffffff,
481 0x00009200, 0x00010006, 0xffffffff,
482 0x00009204, 0x00090008, 0xffffffff,
483 0x00009208, 0x00070000, 0xffffffff,
484 0x0000920c, 0x00030002, 0xffffffff,
485 0x00009210, 0x00050004, 0xffffffff,
486 0x0000921c, 0x00010006, 0xffffffff,
487 0x00009220, 0x00090008, 0xffffffff,
488 0x00009224, 0x00070000, 0xffffffff,
489 0x00009228, 0x00030002, 0xffffffff,
490 0x0000922c, 0x00050004, 0xffffffff,
491 0x00009238, 0x00010006, 0xffffffff,
492 0x0000923c, 0x00090008, 0xffffffff,
493 0x00009240, 0x00070000, 0xffffffff,
494 0x00009244, 0x00030002, 0xffffffff,
495 0x00009248, 0x00050004, 0xffffffff,
496 0x00009254, 0x00010006, 0xffffffff,
497 0x00009258, 0x00090008, 0xffffffff,
498 0x0000925c, 0x00070000, 0xffffffff,
499 0x00009260, 0x00030002, 0xffffffff,
500 0x00009264, 0x00050004, 0xffffffff,
501 0x00009270, 0x00010006, 0xffffffff,
502 0x00009274, 0x00090008, 0xffffffff,
503 0x00009278, 0x00070000, 0xffffffff,
504 0x0000927c, 0x00030002, 0xffffffff,
505 0x00009280, 0x00050004, 0xffffffff,
506 0x0000928c, 0x00010006, 0xffffffff,
507 0x00009290, 0x00090008, 0xffffffff,
508 0x000092a8, 0x00070000, 0xffffffff,
509 0x000092ac, 0x00030002, 0xffffffff,
510 0x000092b0, 0x00050004, 0xffffffff,
511 0x000092bc, 0x00010006, 0xffffffff,
512 0x000092c0, 0x00090008, 0xffffffff,
513 0x000092c4, 0x00070000, 0xffffffff,
514 0x000092c8, 0x00030002, 0xffffffff,
515 0x000092cc, 0x00050004, 0xffffffff,
516 0x000092d8, 0x00010006, 0xffffffff,
517 0x000092dc, 0x00090008, 0xffffffff,
518 0x00009294, 0x00000000, 0xffffffff,
519 0x0000802c, 0x40010000, 0xffffffff,
520 0x00003fc4, 0x40010000, 0xffffffff,
521 0x0000915c, 0x00010000, 0xffffffff,
522 0x00009160, 0x00030002, 0xffffffff,
523 0x00009164, 0x00050004, 0xffffffff,
524 0x00009168, 0x00070006, 0xffffffff,
525 0x00009178, 0x00070000, 0xffffffff,
526 0x0000917c, 0x00030002, 0xffffffff,
527 0x00009180, 0x00050004, 0xffffffff,
528 0x0000918c, 0x00010006, 0xffffffff,
529 0x00009190, 0x00090008, 0xffffffff,
530 0x00009194, 0x00070000, 0xffffffff,
531 0x00009198, 0x00030002, 0xffffffff,
532 0x0000919c, 0x00050004, 0xffffffff,
533 0x000091a8, 0x00010006, 0xffffffff,
534 0x000091ac, 0x00090008, 0xffffffff,
535 0x000091b0, 0x00070000, 0xffffffff,
536 0x000091b4, 0x00030002, 0xffffffff,
537 0x000091b8, 0x00050004, 0xffffffff,
538 0x000091c4, 0x00010006, 0xffffffff,
539 0x000091c8, 0x00090008, 0xffffffff,
540 0x000091cc, 0x00070000, 0xffffffff,
541 0x000091d0, 0x00030002, 0xffffffff,
542 0x000091d4, 0x00050004, 0xffffffff,
543 0x000091e0, 0x00010006, 0xffffffff,
544 0x000091e4, 0x00090008, 0xffffffff,
545 0x000091e8, 0x00000000, 0xffffffff,
546 0x000091ec, 0x00070000, 0xffffffff,
547 0x000091f0, 0x00030002, 0xffffffff,
548 0x000091f4, 0x00050004, 0xffffffff,
549 0x00009200, 0x00010006, 0xffffffff,
550 0x00009204, 0x00090008, 0xffffffff,
551 0x00009208, 0x00070000, 0xffffffff,
552 0x0000920c, 0x00030002, 0xffffffff,
553 0x00009210, 0x00050004, 0xffffffff,
554 0x0000921c, 0x00010006, 0xffffffff,
555 0x00009220, 0x00090008, 0xffffffff,
556 0x00009224, 0x00070000, 0xffffffff,
557 0x00009228, 0x00030002, 0xffffffff,
558 0x0000922c, 0x00050004, 0xffffffff,
559 0x00009238, 0x00010006, 0xffffffff,
560 0x0000923c, 0x00090008, 0xffffffff,
561 0x00009240, 0x00070000, 0xffffffff,
562 0x00009244, 0x00030002, 0xffffffff,
563 0x00009248, 0x00050004, 0xffffffff,
564 0x00009254, 0x00010006, 0xffffffff,
565 0x00009258, 0x00090008, 0xffffffff,
566 0x0000925c, 0x00070000, 0xffffffff,
567 0x00009260, 0x00030002, 0xffffffff,
568 0x00009264, 0x00050004, 0xffffffff,
569 0x00009270, 0x00010006, 0xffffffff,
570 0x00009274, 0x00090008, 0xffffffff,
571 0x00009278, 0x00070000, 0xffffffff,
572 0x0000927c, 0x00030002, 0xffffffff,
573 0x00009280, 0x00050004, 0xffffffff,
574 0x0000928c, 0x00010006, 0xffffffff,
575 0x00009290, 0x00090008, 0xffffffff,
576 0x000092a8, 0x00070000, 0xffffffff,
577 0x000092ac, 0x00030002, 0xffffffff,
578 0x000092b0, 0x00050004, 0xffffffff,
579 0x000092bc, 0x00010006, 0xffffffff,
580 0x000092c0, 0x00090008, 0xffffffff,
581 0x000092c4, 0x00070000, 0xffffffff,
582 0x000092c8, 0x00030002, 0xffffffff,
583 0x000092cc, 0x00050004, 0xffffffff,
584 0x000092d8, 0x00010006, 0xffffffff,
585 0x000092dc, 0x00090008, 0xffffffff,
586 0x00009294, 0x00000000, 0xffffffff,
587 0x0000802c, 0xc0000000, 0xffffffff,
588 0x00003fc4, 0xc0000000, 0xffffffff,
589 0x000008f8, 0x00000010, 0xffffffff,
590 0x000008fc, 0x00000000, 0xffffffff,
591 0x000008f8, 0x00000011, 0xffffffff,
592 0x000008fc, 0x00000000, 0xffffffff,
593 0x000008f8, 0x00000012, 0xffffffff,
594 0x000008fc, 0x00000000, 0xffffffff,
595 0x000008f8, 0x00000013, 0xffffffff,
596 0x000008fc, 0x00000000, 0xffffffff,
597 0x000008f8, 0x00000014, 0xffffffff,
598 0x000008fc, 0x00000000, 0xffffffff,
599 0x000008f8, 0x00000015, 0xffffffff,
600 0x000008fc, 0x00000000, 0xffffffff,
601 0x000008f8, 0x00000016, 0xffffffff,
602 0x000008fc, 0x00000000, 0xffffffff,
603 0x000008f8, 0x00000017, 0xffffffff,
604 0x000008fc, 0x00000000, 0xffffffff,
605 0x000008f8, 0x00000018, 0xffffffff,
606 0x000008fc, 0x00000000, 0xffffffff,
607 0x000008f8, 0x00000019, 0xffffffff,
608 0x000008fc, 0x00000000, 0xffffffff,
609 0x000008f8, 0x0000001a, 0xffffffff,
610 0x000008fc, 0x00000000, 0xffffffff,
611 0x000008f8, 0x0000001b, 0xffffffff,
612 0x000008fc, 0x00000000, 0xffffffff
614 #define CAYMAN_MGCG_DEFAULT_LENGTH sizeof(cayman_mgcg_default) / (3 * sizeof(u32))
616 static const u32 cayman_mgcg_disable
[] =
618 0x0000802c, 0xc0000000, 0xffffffff,
619 0x000008f8, 0x00000000, 0xffffffff,
620 0x000008fc, 0xffffffff, 0xffffffff,
621 0x000008f8, 0x00000001, 0xffffffff,
622 0x000008fc, 0xffffffff, 0xffffffff,
623 0x000008f8, 0x00000002, 0xffffffff,
624 0x000008fc, 0xffffffff, 0xffffffff,
625 0x000008f8, 0x00000003, 0xffffffff,
626 0x000008fc, 0xffffffff, 0xffffffff,
627 0x00009150, 0x00600000, 0xffffffff
629 #define CAYMAN_MGCG_DISABLE_LENGTH sizeof(cayman_mgcg_disable) / (3 * sizeof(u32))
631 static const u32 cayman_mgcg_enable
[] =
633 0x0000802c, 0xc0000000, 0xffffffff,
634 0x000008f8, 0x00000000, 0xffffffff,
635 0x000008fc, 0x00000000, 0xffffffff,
636 0x000008f8, 0x00000001, 0xffffffff,
637 0x000008fc, 0x00000000, 0xffffffff,
638 0x000008f8, 0x00000002, 0xffffffff,
639 0x000008fc, 0x00600000, 0xffffffff,
640 0x000008f8, 0x00000003, 0xffffffff,
641 0x000008fc, 0x00000000, 0xffffffff,
642 0x00009150, 0x96944200, 0xffffffff
645 #define CAYMAN_MGCG_ENABLE_LENGTH sizeof(cayman_mgcg_enable) / (3 * sizeof(u32))
647 #define NISLANDS_SYSLS_SEQUENCE 100
649 static const u32 cayman_sysls_default
[] =
651 /* Register, Value, Mask bits */
652 0x000055e8, 0x00000000, 0xffffffff,
653 0x0000d0bc, 0x00000000, 0xffffffff,
654 0x0000d8bc, 0x00000000, 0xffffffff,
655 0x000015c0, 0x000c1401, 0xffffffff,
656 0x0000264c, 0x000c0400, 0xffffffff,
657 0x00002648, 0x000c0400, 0xffffffff,
658 0x00002650, 0x000c0400, 0xffffffff,
659 0x000020b8, 0x000c0400, 0xffffffff,
660 0x000020bc, 0x000c0400, 0xffffffff,
661 0x000020c0, 0x000c0c80, 0xffffffff,
662 0x0000f4a0, 0x000000c0, 0xffffffff,
663 0x0000f4a4, 0x00680fff, 0xffffffff,
664 0x00002f50, 0x00000404, 0xffffffff,
665 0x000004c8, 0x00000001, 0xffffffff,
666 0x000064ec, 0x00000000, 0xffffffff,
667 0x00000c7c, 0x00000000, 0xffffffff,
668 0x00008dfc, 0x00000000, 0xffffffff
670 #define CAYMAN_SYSLS_DEFAULT_LENGTH sizeof(cayman_sysls_default) / (3 * sizeof(u32))
672 static const u32 cayman_sysls_disable
[] =
674 /* Register, Value, Mask bits */
675 0x0000d0c0, 0x00000000, 0xffffffff,
676 0x0000d8c0, 0x00000000, 0xffffffff,
677 0x000055e8, 0x00000000, 0xffffffff,
678 0x0000d0bc, 0x00000000, 0xffffffff,
679 0x0000d8bc, 0x00000000, 0xffffffff,
680 0x000015c0, 0x00041401, 0xffffffff,
681 0x0000264c, 0x00040400, 0xffffffff,
682 0x00002648, 0x00040400, 0xffffffff,
683 0x00002650, 0x00040400, 0xffffffff,
684 0x000020b8, 0x00040400, 0xffffffff,
685 0x000020bc, 0x00040400, 0xffffffff,
686 0x000020c0, 0x00040c80, 0xffffffff,
687 0x0000f4a0, 0x000000c0, 0xffffffff,
688 0x0000f4a4, 0x00680000, 0xffffffff,
689 0x00002f50, 0x00000404, 0xffffffff,
690 0x000004c8, 0x00000001, 0xffffffff,
691 0x000064ec, 0x00007ffd, 0xffffffff,
692 0x00000c7c, 0x0000ff00, 0xffffffff,
693 0x00008dfc, 0x0000007f, 0xffffffff
695 #define CAYMAN_SYSLS_DISABLE_LENGTH sizeof(cayman_sysls_disable) / (3 * sizeof(u32))
697 static const u32 cayman_sysls_enable
[] =
699 /* Register, Value, Mask bits */
700 0x000055e8, 0x00000001, 0xffffffff,
701 0x0000d0bc, 0x00000100, 0xffffffff,
702 0x0000d8bc, 0x00000100, 0xffffffff,
703 0x000015c0, 0x000c1401, 0xffffffff,
704 0x0000264c, 0x000c0400, 0xffffffff,
705 0x00002648, 0x000c0400, 0xffffffff,
706 0x00002650, 0x000c0400, 0xffffffff,
707 0x000020b8, 0x000c0400, 0xffffffff,
708 0x000020bc, 0x000c0400, 0xffffffff,
709 0x000020c0, 0x000c0c80, 0xffffffff,
710 0x0000f4a0, 0x000000c0, 0xffffffff,
711 0x0000f4a4, 0x00680fff, 0xffffffff,
712 0x00002f50, 0x00000903, 0xffffffff,
713 0x000004c8, 0x00000000, 0xffffffff,
714 0x000064ec, 0x00000000, 0xffffffff,
715 0x00000c7c, 0x00000000, 0xffffffff,
716 0x00008dfc, 0x00000000, 0xffffffff
718 #define CAYMAN_SYSLS_ENABLE_LENGTH sizeof(cayman_sysls_enable) / (3 * sizeof(u32))
720 struct rv7xx_power_info
*rv770_get_pi(struct radeon_device
*rdev
);
721 struct evergreen_power_info
*evergreen_get_pi(struct radeon_device
*rdev
);
723 struct ni_power_info
*ni_get_pi(struct radeon_device
*rdev
)
725 struct ni_power_info
*pi
= rdev
->pm
.dpm
.priv
;
730 struct ni_ps
*ni_get_ps(struct radeon_ps
*rps
)
732 struct ni_ps
*ps
= rps
->ps_priv
;
737 static void ni_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients
*coeff
,
742 s64 kt
, kv
, leakage_w
, i_leakage
, vddc
, temperature
;
744 i_leakage
= div64_s64(drm_int2fixp(ileakage
), 1000);
745 vddc
= div64_s64(drm_int2fixp(v
), 1000);
746 temperature
= div64_s64(drm_int2fixp(t
), 1000);
748 kt
= drm_fixp_mul(div64_s64(drm_int2fixp(coeff
->at
), 1000),
749 drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff
->bt
), 1000), temperature
)));
750 kv
= drm_fixp_mul(div64_s64(drm_int2fixp(coeff
->av
), 1000),
751 drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff
->bv
), 1000), vddc
)));
753 leakage_w
= drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage
, kt
), kv
), vddc
);
755 *leakage
= drm_fixp2int(leakage_w
* 1000);
758 static void ni_calculate_leakage_for_v_and_t(struct radeon_device
*rdev
,
759 const struct ni_leakage_coeffients
*coeff
,
765 ni_calculate_leakage_for_v_and_t_formula(coeff
, v
, t
, i_leakage
, leakage
);
768 bool ni_dpm_vblank_too_short(struct radeon_device
*rdev
)
770 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
771 u32 vblank_time
= r600_dpm_get_vblank_time(rdev
);
772 /* we never hit the non-gddr5 limit so disable it */
773 u32 switch_limit
= pi
->mem_gddr5
? 450 : 0;
775 if (vblank_time
< switch_limit
)
782 static void ni_apply_state_adjust_rules(struct radeon_device
*rdev
,
783 struct radeon_ps
*rps
)
785 struct ni_ps
*ps
= ni_get_ps(rps
);
786 struct radeon_clock_and_voltage_limits
*max_limits
;
787 bool disable_mclk_switching
;
790 u32 max_sclk_vddc
, max_mclk_vddci
, max_mclk_vddc
;
793 if ((rdev
->pm
.dpm
.new_active_crtc_count
> 1) ||
794 ni_dpm_vblank_too_short(rdev
))
795 disable_mclk_switching
= true;
797 disable_mclk_switching
= false;
799 if (rdev
->pm
.dpm
.ac_power
)
800 max_limits
= &rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
;
802 max_limits
= &rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_dc
;
804 if (rdev
->pm
.dpm
.ac_power
== false) {
805 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
806 if (ps
->performance_levels
[i
].mclk
> max_limits
->mclk
)
807 ps
->performance_levels
[i
].mclk
= max_limits
->mclk
;
808 if (ps
->performance_levels
[i
].sclk
> max_limits
->sclk
)
809 ps
->performance_levels
[i
].sclk
= max_limits
->sclk
;
810 if (ps
->performance_levels
[i
].vddc
> max_limits
->vddc
)
811 ps
->performance_levels
[i
].vddc
= max_limits
->vddc
;
812 if (ps
->performance_levels
[i
].vddci
> max_limits
->vddci
)
813 ps
->performance_levels
[i
].vddci
= max_limits
->vddci
;
817 /* limit clocks to max supported clocks based on voltage dependency tables */
818 btc_get_max_clock_from_voltage_dependency_table(&rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_sclk
,
820 btc_get_max_clock_from_voltage_dependency_table(&rdev
->pm
.dpm
.dyn_state
.vddci_dependency_on_mclk
,
822 btc_get_max_clock_from_voltage_dependency_table(&rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_mclk
,
825 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
827 if (ps
->performance_levels
[i
].sclk
> max_sclk_vddc
)
828 ps
->performance_levels
[i
].sclk
= max_sclk_vddc
;
830 if (max_mclk_vddci
) {
831 if (ps
->performance_levels
[i
].mclk
> max_mclk_vddci
)
832 ps
->performance_levels
[i
].mclk
= max_mclk_vddci
;
835 if (ps
->performance_levels
[i
].mclk
> max_mclk_vddc
)
836 ps
->performance_levels
[i
].mclk
= max_mclk_vddc
;
840 /* XXX validate the min clocks required for display */
842 if (disable_mclk_switching
) {
843 mclk
= ps
->performance_levels
[ps
->performance_level_count
- 1].mclk
;
844 sclk
= ps
->performance_levels
[0].sclk
;
845 vddc
= ps
->performance_levels
[0].vddc
;
846 vddci
= ps
->performance_levels
[ps
->performance_level_count
- 1].vddci
;
848 sclk
= ps
->performance_levels
[0].sclk
;
849 mclk
= ps
->performance_levels
[0].mclk
;
850 vddc
= ps
->performance_levels
[0].vddc
;
851 vddci
= ps
->performance_levels
[0].vddci
;
854 /* adjusted low state */
855 ps
->performance_levels
[0].sclk
= sclk
;
856 ps
->performance_levels
[0].mclk
= mclk
;
857 ps
->performance_levels
[0].vddc
= vddc
;
858 ps
->performance_levels
[0].vddci
= vddci
;
860 btc_skip_blacklist_clocks(rdev
, max_limits
->sclk
, max_limits
->mclk
,
861 &ps
->performance_levels
[0].sclk
,
862 &ps
->performance_levels
[0].mclk
);
864 for (i
= 1; i
< ps
->performance_level_count
; i
++) {
865 if (ps
->performance_levels
[i
].sclk
< ps
->performance_levels
[i
- 1].sclk
)
866 ps
->performance_levels
[i
].sclk
= ps
->performance_levels
[i
- 1].sclk
;
867 if (ps
->performance_levels
[i
].vddc
< ps
->performance_levels
[i
- 1].vddc
)
868 ps
->performance_levels
[i
].vddc
= ps
->performance_levels
[i
- 1].vddc
;
871 if (disable_mclk_switching
) {
872 mclk
= ps
->performance_levels
[0].mclk
;
873 for (i
= 1; i
< ps
->performance_level_count
; i
++) {
874 if (mclk
< ps
->performance_levels
[i
].mclk
)
875 mclk
= ps
->performance_levels
[i
].mclk
;
877 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
878 ps
->performance_levels
[i
].mclk
= mclk
;
879 ps
->performance_levels
[i
].vddci
= vddci
;
882 for (i
= 1; i
< ps
->performance_level_count
; i
++) {
883 if (ps
->performance_levels
[i
].mclk
< ps
->performance_levels
[i
- 1].mclk
)
884 ps
->performance_levels
[i
].mclk
= ps
->performance_levels
[i
- 1].mclk
;
885 if (ps
->performance_levels
[i
].vddci
< ps
->performance_levels
[i
- 1].vddci
)
886 ps
->performance_levels
[i
].vddci
= ps
->performance_levels
[i
- 1].vddci
;
890 for (i
= 1; i
< ps
->performance_level_count
; i
++)
891 btc_skip_blacklist_clocks(rdev
, max_limits
->sclk
, max_limits
->mclk
,
892 &ps
->performance_levels
[i
].sclk
,
893 &ps
->performance_levels
[i
].mclk
);
895 for (i
= 0; i
< ps
->performance_level_count
; i
++)
896 btc_adjust_clock_combinations(rdev
, max_limits
,
897 &ps
->performance_levels
[i
]);
899 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
900 btc_apply_voltage_dependency_rules(&rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_sclk
,
901 ps
->performance_levels
[i
].sclk
,
902 max_limits
->vddc
, &ps
->performance_levels
[i
].vddc
);
903 btc_apply_voltage_dependency_rules(&rdev
->pm
.dpm
.dyn_state
.vddci_dependency_on_mclk
,
904 ps
->performance_levels
[i
].mclk
,
905 max_limits
->vddci
, &ps
->performance_levels
[i
].vddci
);
906 btc_apply_voltage_dependency_rules(&rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_mclk
,
907 ps
->performance_levels
[i
].mclk
,
908 max_limits
->vddc
, &ps
->performance_levels
[i
].vddc
);
909 btc_apply_voltage_dependency_rules(&rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
,
910 rdev
->clock
.current_dispclk
,
911 max_limits
->vddc
, &ps
->performance_levels
[i
].vddc
);
914 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
915 btc_apply_voltage_delta_rules(rdev
,
916 max_limits
->vddc
, max_limits
->vddci
,
917 &ps
->performance_levels
[i
].vddc
,
918 &ps
->performance_levels
[i
].vddci
);
921 ps
->dc_compatible
= true;
922 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
923 if (ps
->performance_levels
[i
].vddc
> rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_dc
.vddc
)
924 ps
->dc_compatible
= false;
926 if (ps
->performance_levels
[i
].vddc
< rdev
->pm
.dpm
.dyn_state
.min_vddc_for_pcie_gen2
)
927 ps
->performance_levels
[i
].flags
&= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2
;
931 static void ni_cg_clockgating_default(struct radeon_device
*rdev
)
934 const u32
*ps
= NULL
;
936 ps
= (const u32
*)&cayman_cgcg_cgls_default
;
937 count
= CAYMAN_CGCG_CGLS_DEFAULT_LENGTH
;
939 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
942 static void ni_gfx_clockgating_enable(struct radeon_device
*rdev
,
946 const u32
*ps
= NULL
;
949 ps
= (const u32
*)&cayman_cgcg_cgls_enable
;
950 count
= CAYMAN_CGCG_CGLS_ENABLE_LENGTH
;
952 ps
= (const u32
*)&cayman_cgcg_cgls_disable
;
953 count
= CAYMAN_CGCG_CGLS_DISABLE_LENGTH
;
956 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
959 static void ni_mg_clockgating_default(struct radeon_device
*rdev
)
962 const u32
*ps
= NULL
;
964 ps
= (const u32
*)&cayman_mgcg_default
;
965 count
= CAYMAN_MGCG_DEFAULT_LENGTH
;
967 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
970 static void ni_mg_clockgating_enable(struct radeon_device
*rdev
,
974 const u32
*ps
= NULL
;
977 ps
= (const u32
*)&cayman_mgcg_enable
;
978 count
= CAYMAN_MGCG_ENABLE_LENGTH
;
980 ps
= (const u32
*)&cayman_mgcg_disable
;
981 count
= CAYMAN_MGCG_DISABLE_LENGTH
;
984 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
987 static void ni_ls_clockgating_default(struct radeon_device
*rdev
)
990 const u32
*ps
= NULL
;
992 ps
= (const u32
*)&cayman_sysls_default
;
993 count
= CAYMAN_SYSLS_DEFAULT_LENGTH
;
995 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
998 static void ni_ls_clockgating_enable(struct radeon_device
*rdev
,
1002 const u32
*ps
= NULL
;
1005 ps
= (const u32
*)&cayman_sysls_enable
;
1006 count
= CAYMAN_SYSLS_ENABLE_LENGTH
;
1008 ps
= (const u32
*)&cayman_sysls_disable
;
1009 count
= CAYMAN_SYSLS_DISABLE_LENGTH
;
1012 btc_program_mgcg_hw_sequence(rdev
, ps
, count
);
1016 static int ni_patch_single_dependency_table_based_on_leakage(struct radeon_device
*rdev
,
1017 struct radeon_clock_voltage_dependency_table
*table
)
1019 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1023 for (i
= 0; i
< table
->count
; i
++) {
1024 if (0xff01 == table
->entries
[i
].v
) {
1025 if (pi
->max_vddc
== 0)
1027 table
->entries
[i
].v
= pi
->max_vddc
;
1034 static int ni_patch_dependency_tables_based_on_leakage(struct radeon_device
*rdev
)
1038 ret
= ni_patch_single_dependency_table_based_on_leakage(rdev
,
1039 &rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_sclk
);
1041 ret
= ni_patch_single_dependency_table_based_on_leakage(rdev
,
1042 &rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_mclk
);
1046 static void ni_stop_dpm(struct radeon_device
*rdev
)
1048 WREG32_P(GENERAL_PWRMGT
, 0, ~GLOBAL_PWRMGT_EN
);
1052 static int ni_notify_hw_of_power_source(struct radeon_device
*rdev
,
1056 return (rv770_send_msg_to_smc(rdev
, PPSMC_MSG_RunningOnAC
) == PPSMC_Result_OK
) ?
1063 static PPSMC_Result
ni_send_msg_to_smc_with_parameter(struct radeon_device
*rdev
,
1064 PPSMC_Msg msg
, u32 parameter
)
1066 WREG32(SMC_SCRATCH0
, parameter
);
1067 return rv770_send_msg_to_smc(rdev
, msg
);
1070 static int ni_restrict_performance_levels_before_switch(struct radeon_device
*rdev
)
1072 if (rv770_send_msg_to_smc(rdev
, PPSMC_MSG_NoForcedLevel
) != PPSMC_Result_OK
)
1075 return (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetEnabledLevels
, 1) == PPSMC_Result_OK
) ?
1079 int ni_dpm_force_performance_level(struct radeon_device
*rdev
,
1080 enum radeon_dpm_forced_level level
)
1082 if (level
== RADEON_DPM_FORCED_LEVEL_HIGH
) {
1083 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetEnabledLevels
, 0) != PPSMC_Result_OK
)
1086 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetForcedLevels
, 1) != PPSMC_Result_OK
)
1088 } else if (level
== RADEON_DPM_FORCED_LEVEL_LOW
) {
1089 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetForcedLevels
, 0) != PPSMC_Result_OK
)
1092 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetEnabledLevels
, 1) != PPSMC_Result_OK
)
1094 } else if (level
== RADEON_DPM_FORCED_LEVEL_AUTO
) {
1095 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetForcedLevels
, 0) != PPSMC_Result_OK
)
1098 if (ni_send_msg_to_smc_with_parameter(rdev
, PPSMC_MSG_SetEnabledLevels
, 0) != PPSMC_Result_OK
)
1102 rdev
->pm
.dpm
.forced_level
= level
;
1107 static void ni_stop_smc(struct radeon_device
*rdev
)
1112 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
1113 tmp
= RREG32(LB_SYNC_RESET_SEL
) & LB_SYNC_RESET_SEL_MASK
;
1121 r7xx_stop_smc(rdev
);
1124 static int ni_process_firmware_header(struct radeon_device
*rdev
)
1126 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1127 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1128 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1132 ret
= rv770_read_smc_sram_dword(rdev
,
1133 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1134 NISLANDS_SMC_FIRMWARE_HEADER_stateTable
,
1135 &tmp
, pi
->sram_end
);
1140 pi
->state_table_start
= (u16
)tmp
;
1142 ret
= rv770_read_smc_sram_dword(rdev
,
1143 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1144 NISLANDS_SMC_FIRMWARE_HEADER_softRegisters
,
1145 &tmp
, pi
->sram_end
);
1150 pi
->soft_regs_start
= (u16
)tmp
;
1152 ret
= rv770_read_smc_sram_dword(rdev
,
1153 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1154 NISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable
,
1155 &tmp
, pi
->sram_end
);
1160 eg_pi
->mc_reg_table_start
= (u16
)tmp
;
1162 ret
= rv770_read_smc_sram_dword(rdev
,
1163 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1164 NISLANDS_SMC_FIRMWARE_HEADER_fanTable
,
1165 &tmp
, pi
->sram_end
);
1170 ni_pi
->fan_table_start
= (u16
)tmp
;
1172 ret
= rv770_read_smc_sram_dword(rdev
,
1173 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1174 NISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable
,
1175 &tmp
, pi
->sram_end
);
1180 ni_pi
->arb_table_start
= (u16
)tmp
;
1182 ret
= rv770_read_smc_sram_dword(rdev
,
1183 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1184 NISLANDS_SMC_FIRMWARE_HEADER_cacTable
,
1185 &tmp
, pi
->sram_end
);
1190 ni_pi
->cac_table_start
= (u16
)tmp
;
1192 ret
= rv770_read_smc_sram_dword(rdev
,
1193 NISLANDS_SMC_FIRMWARE_HEADER_LOCATION
+
1194 NISLANDS_SMC_FIRMWARE_HEADER_spllTable
,
1195 &tmp
, pi
->sram_end
);
1200 ni_pi
->spll_table_start
= (u16
)tmp
;
1206 static void ni_read_clock_registers(struct radeon_device
*rdev
)
1208 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1210 ni_pi
->clock_registers
.cg_spll_func_cntl
= RREG32(CG_SPLL_FUNC_CNTL
);
1211 ni_pi
->clock_registers
.cg_spll_func_cntl_2
= RREG32(CG_SPLL_FUNC_CNTL_2
);
1212 ni_pi
->clock_registers
.cg_spll_func_cntl_3
= RREG32(CG_SPLL_FUNC_CNTL_3
);
1213 ni_pi
->clock_registers
.cg_spll_func_cntl_4
= RREG32(CG_SPLL_FUNC_CNTL_4
);
1214 ni_pi
->clock_registers
.cg_spll_spread_spectrum
= RREG32(CG_SPLL_SPREAD_SPECTRUM
);
1215 ni_pi
->clock_registers
.cg_spll_spread_spectrum_2
= RREG32(CG_SPLL_SPREAD_SPECTRUM_2
);
1216 ni_pi
->clock_registers
.mpll_ad_func_cntl
= RREG32(MPLL_AD_FUNC_CNTL
);
1217 ni_pi
->clock_registers
.mpll_ad_func_cntl_2
= RREG32(MPLL_AD_FUNC_CNTL_2
);
1218 ni_pi
->clock_registers
.mpll_dq_func_cntl
= RREG32(MPLL_DQ_FUNC_CNTL
);
1219 ni_pi
->clock_registers
.mpll_dq_func_cntl_2
= RREG32(MPLL_DQ_FUNC_CNTL_2
);
1220 ni_pi
->clock_registers
.mclk_pwrmgt_cntl
= RREG32(MCLK_PWRMGT_CNTL
);
1221 ni_pi
->clock_registers
.dll_cntl
= RREG32(DLL_CNTL
);
1222 ni_pi
->clock_registers
.mpll_ss1
= RREG32(MPLL_SS1
);
1223 ni_pi
->clock_registers
.mpll_ss2
= RREG32(MPLL_SS2
);
1227 static int ni_enter_ulp_state(struct radeon_device
*rdev
)
1229 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1231 if (pi
->gfx_clock_gating
) {
1232 WREG32_P(SCLK_PWRMGT_CNTL
, 0, ~DYN_GFX_CLK_OFF_EN
);
1233 WREG32_P(SCLK_PWRMGT_CNTL
, GFX_CLK_FORCE_ON
, ~GFX_CLK_FORCE_ON
);
1234 WREG32_P(SCLK_PWRMGT_CNTL
, 0, ~GFX_CLK_FORCE_ON
);
1235 RREG32(GB_ADDR_CONFIG
);
1238 WREG32_P(SMC_MSG
, HOST_SMC_MSG(PPSMC_MSG_SwitchToMinimumPower
),
1239 ~HOST_SMC_MSG_MASK
);
1247 static void ni_program_response_times(struct radeon_device
*rdev
)
1249 u32 voltage_response_time
, backbias_response_time
, acpi_delay_time
, vbi_time_out
;
1250 u32 vddc_dly
, bb_dly
, acpi_dly
, vbi_dly
, mclk_switch_limit
;
1251 u32 reference_clock
;
1253 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_mvdd_chg_time
, 1);
1255 voltage_response_time
= (u32
)rdev
->pm
.dpm
.voltage_response_time
;
1256 backbias_response_time
= (u32
)rdev
->pm
.dpm
.backbias_response_time
;
1258 if (voltage_response_time
== 0)
1259 voltage_response_time
= 1000;
1261 if (backbias_response_time
== 0)
1262 backbias_response_time
= 1000;
1264 acpi_delay_time
= 15000;
1265 vbi_time_out
= 100000;
1267 reference_clock
= radeon_get_xclk(rdev
);
1269 vddc_dly
= (voltage_response_time
* reference_clock
) / 1600;
1270 bb_dly
= (backbias_response_time
* reference_clock
) / 1600;
1271 acpi_dly
= (acpi_delay_time
* reference_clock
) / 1600;
1272 vbi_dly
= (vbi_time_out
* reference_clock
) / 1600;
1274 mclk_switch_limit
= (460 * reference_clock
) / 100;
1276 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_delay_vreg
, vddc_dly
);
1277 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_delay_bbias
, bb_dly
);
1278 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_delay_acpi
, acpi_dly
);
1279 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_mclk_chg_timeout
, vbi_dly
);
1280 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_mc_block_delay
, 0xAA);
1281 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_mclk_switch_lim
, mclk_switch_limit
);
1284 static void ni_populate_smc_voltage_table(struct radeon_device
*rdev
,
1285 struct atom_voltage_table
*voltage_table
,
1286 NISLANDS_SMC_STATETABLE
*table
)
1290 for (i
= 0; i
< voltage_table
->count
; i
++) {
1291 table
->highSMIO
[i
] = 0;
1292 table
->lowSMIO
[i
] |= cpu_to_be32(voltage_table
->entries
[i
].smio_low
);
1296 static void ni_populate_smc_voltage_tables(struct radeon_device
*rdev
,
1297 NISLANDS_SMC_STATETABLE
*table
)
1299 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1300 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1303 if (eg_pi
->vddc_voltage_table
.count
) {
1304 ni_populate_smc_voltage_table(rdev
, &eg_pi
->vddc_voltage_table
, table
);
1305 table
->voltageMaskTable
.highMask
[NISLANDS_SMC_VOLTAGEMASK_VDDC
] = 0;
1306 table
->voltageMaskTable
.lowMask
[NISLANDS_SMC_VOLTAGEMASK_VDDC
] =
1307 cpu_to_be32(eg_pi
->vddc_voltage_table
.mask_low
);
1309 for (i
= 0; i
< eg_pi
->vddc_voltage_table
.count
; i
++) {
1310 if (pi
->max_vddc_in_table
<= eg_pi
->vddc_voltage_table
.entries
[i
].value
) {
1311 table
->maxVDDCIndexInPPTable
= i
;
1317 if (eg_pi
->vddci_voltage_table
.count
) {
1318 ni_populate_smc_voltage_table(rdev
, &eg_pi
->vddci_voltage_table
, table
);
1320 table
->voltageMaskTable
.highMask
[NISLANDS_SMC_VOLTAGEMASK_VDDCI
] = 0;
1321 table
->voltageMaskTable
.lowMask
[NISLANDS_SMC_VOLTAGEMASK_VDDCI
] =
1322 cpu_to_be32(eg_pi
->vddci_voltage_table
.mask_low
);
1326 static int ni_populate_voltage_value(struct radeon_device
*rdev
,
1327 struct atom_voltage_table
*table
,
1329 NISLANDS_SMC_VOLTAGE_VALUE
*voltage
)
1333 for (i
= 0; i
< table
->count
; i
++) {
1334 if (value
<= table
->entries
[i
].value
) {
1335 voltage
->index
= (u8
)i
;
1336 voltage
->value
= cpu_to_be16(table
->entries
[i
].value
);
1341 if (i
>= table
->count
)
1347 static void ni_populate_mvdd_value(struct radeon_device
*rdev
,
1349 NISLANDS_SMC_VOLTAGE_VALUE
*voltage
)
1351 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1352 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1354 if (!pi
->mvdd_control
) {
1355 voltage
->index
= eg_pi
->mvdd_high_index
;
1356 voltage
->value
= cpu_to_be16(MVDD_HIGH_VALUE
);
1360 if (mclk
<= pi
->mvdd_split_frequency
) {
1361 voltage
->index
= eg_pi
->mvdd_low_index
;
1362 voltage
->value
= cpu_to_be16(MVDD_LOW_VALUE
);
1364 voltage
->index
= eg_pi
->mvdd_high_index
;
1365 voltage
->value
= cpu_to_be16(MVDD_HIGH_VALUE
);
1369 static int ni_get_std_voltage_value(struct radeon_device
*rdev
,
1370 NISLANDS_SMC_VOLTAGE_VALUE
*voltage
,
1373 if (rdev
->pm
.dpm
.dyn_state
.cac_leakage_table
.entries
&&
1374 ((u32
)voltage
->index
< rdev
->pm
.dpm
.dyn_state
.cac_leakage_table
.count
))
1375 *std_voltage
= rdev
->pm
.dpm
.dyn_state
.cac_leakage_table
.entries
[voltage
->index
].vddc
;
1377 *std_voltage
= be16_to_cpu(voltage
->value
);
1382 static void ni_populate_std_voltage_value(struct radeon_device
*rdev
,
1383 u16 value
, u8 index
,
1384 NISLANDS_SMC_VOLTAGE_VALUE
*voltage
)
1386 voltage
->index
= index
;
1387 voltage
->value
= cpu_to_be16(value
);
1390 static u32
ni_get_smc_power_scaling_factor(struct radeon_device
*rdev
)
1393 u32 xclk
= radeon_get_xclk(rdev
);
1394 u32 tmp
= RREG32(CG_CAC_CTRL
) & TID_CNT_MASK
;
1396 xclk_period
= (1000000000UL / xclk
);
1397 xclk_period
/= 10000UL;
1399 return tmp
* xclk_period
;
1402 static u32
ni_scale_power_for_smc(u32 power_in_watts
, u32 scaling_factor
)
1404 return (power_in_watts
* scaling_factor
) << 2;
1407 static u32
ni_calculate_power_boost_limit(struct radeon_device
*rdev
,
1408 struct radeon_ps
*radeon_state
,
1411 struct ni_ps
*state
= ni_get_ps(radeon_state
);
1412 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1413 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1414 u32 power_boost_limit
= 0;
1417 if (ni_pi
->enable_power_containment
&&
1418 ni_pi
->use_power_boost_limit
) {
1419 NISLANDS_SMC_VOLTAGE_VALUE vddc
;
1424 if (state
->performance_level_count
< 3)
1427 ret
= ni_populate_voltage_value(rdev
, &eg_pi
->vddc_voltage_table
,
1428 state
->performance_levels
[state
->performance_level_count
- 2].vddc
,
1433 ret
= ni_get_std_voltage_value(rdev
, &vddc
, &std_vddc_med
);
1437 ret
= ni_populate_voltage_value(rdev
, &eg_pi
->vddc_voltage_table
,
1438 state
->performance_levels
[state
->performance_level_count
- 1].vddc
,
1443 ret
= ni_get_std_voltage_value(rdev
, &vddc
, &std_vddc_high
);
1447 n
= ((u64
)near_tdp_limit
* ((u64
)std_vddc_med
* (u64
)std_vddc_med
) * 90);
1448 d
= ((u64
)std_vddc_high
* (u64
)std_vddc_high
* 100);
1449 tmp
= div64_u64(n
, d
);
1453 power_boost_limit
= (u32
)tmp
;
1456 return power_boost_limit
;
1459 static int ni_calculate_adjusted_tdp_limits(struct radeon_device
*rdev
,
1460 bool adjust_polarity
,
1463 u32
*near_tdp_limit
)
1465 if (tdp_adjustment
> (u32
)rdev
->pm
.dpm
.tdp_od_limit
)
1468 if (adjust_polarity
) {
1469 *tdp_limit
= ((100 + tdp_adjustment
) * rdev
->pm
.dpm
.tdp_limit
) / 100;
1470 *near_tdp_limit
= rdev
->pm
.dpm
.near_tdp_limit
+ (*tdp_limit
- rdev
->pm
.dpm
.tdp_limit
);
1472 *tdp_limit
= ((100 - tdp_adjustment
) * rdev
->pm
.dpm
.tdp_limit
) / 100;
1473 *near_tdp_limit
= rdev
->pm
.dpm
.near_tdp_limit
- (rdev
->pm
.dpm
.tdp_limit
- *tdp_limit
);
1479 static int ni_populate_smc_tdp_limits(struct radeon_device
*rdev
,
1480 struct radeon_ps
*radeon_state
)
1482 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1483 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1485 if (ni_pi
->enable_power_containment
) {
1486 NISLANDS_SMC_STATETABLE
*smc_table
= &ni_pi
->smc_statetable
;
1487 u32 scaling_factor
= ni_get_smc_power_scaling_factor(rdev
);
1490 u32 power_boost_limit
;
1493 if (scaling_factor
== 0)
1496 memset(smc_table
, 0, sizeof(NISLANDS_SMC_STATETABLE
));
1498 ret
= ni_calculate_adjusted_tdp_limits(rdev
,
1500 rdev
->pm
.dpm
.tdp_adjustment
,
1506 power_boost_limit
= ni_calculate_power_boost_limit(rdev
, radeon_state
,
1509 smc_table
->dpm2Params
.TDPLimit
=
1510 cpu_to_be32(ni_scale_power_for_smc(tdp_limit
, scaling_factor
));
1511 smc_table
->dpm2Params
.NearTDPLimit
=
1512 cpu_to_be32(ni_scale_power_for_smc(near_tdp_limit
, scaling_factor
));
1513 smc_table
->dpm2Params
.SafePowerLimit
=
1514 cpu_to_be32(ni_scale_power_for_smc((near_tdp_limit
* NISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT
) / 100,
1516 smc_table
->dpm2Params
.PowerBoostLimit
=
1517 cpu_to_be32(ni_scale_power_for_smc(power_boost_limit
, scaling_factor
));
1519 ret
= rv770_copy_bytes_to_smc(rdev
,
1520 (u16
)(pi
->state_table_start
+ offsetof(NISLANDS_SMC_STATETABLE
, dpm2Params
) +
1521 offsetof(PP_NIslands_DPM2Parameters
, TDPLimit
)),
1522 (u8
*)(&smc_table
->dpm2Params
.TDPLimit
),
1523 sizeof(u32
) * 4, pi
->sram_end
);
1531 int ni_copy_and_switch_arb_sets(struct radeon_device
*rdev
,
1532 u32 arb_freq_src
, u32 arb_freq_dest
)
1534 u32 mc_arb_dram_timing
;
1535 u32 mc_arb_dram_timing2
;
1539 switch (arb_freq_src
) {
1540 case MC_CG_ARB_FREQ_F0
:
1541 mc_arb_dram_timing
= RREG32(MC_ARB_DRAM_TIMING
);
1542 mc_arb_dram_timing2
= RREG32(MC_ARB_DRAM_TIMING2
);
1543 burst_time
= (RREG32(MC_ARB_BURST_TIME
) & STATE0_MASK
) >> STATE0_SHIFT
;
1545 case MC_CG_ARB_FREQ_F1
:
1546 mc_arb_dram_timing
= RREG32(MC_ARB_DRAM_TIMING_1
);
1547 mc_arb_dram_timing2
= RREG32(MC_ARB_DRAM_TIMING2_1
);
1548 burst_time
= (RREG32(MC_ARB_BURST_TIME
) & STATE1_MASK
) >> STATE1_SHIFT
;
1550 case MC_CG_ARB_FREQ_F2
:
1551 mc_arb_dram_timing
= RREG32(MC_ARB_DRAM_TIMING_2
);
1552 mc_arb_dram_timing2
= RREG32(MC_ARB_DRAM_TIMING2_2
);
1553 burst_time
= (RREG32(MC_ARB_BURST_TIME
) & STATE2_MASK
) >> STATE2_SHIFT
;
1555 case MC_CG_ARB_FREQ_F3
:
1556 mc_arb_dram_timing
= RREG32(MC_ARB_DRAM_TIMING_3
);
1557 mc_arb_dram_timing2
= RREG32(MC_ARB_DRAM_TIMING2_3
);
1558 burst_time
= (RREG32(MC_ARB_BURST_TIME
) & STATE3_MASK
) >> STATE3_SHIFT
;
1564 switch (arb_freq_dest
) {
1565 case MC_CG_ARB_FREQ_F0
:
1566 WREG32(MC_ARB_DRAM_TIMING
, mc_arb_dram_timing
);
1567 WREG32(MC_ARB_DRAM_TIMING2
, mc_arb_dram_timing2
);
1568 WREG32_P(MC_ARB_BURST_TIME
, STATE0(burst_time
), ~STATE0_MASK
);
1570 case MC_CG_ARB_FREQ_F1
:
1571 WREG32(MC_ARB_DRAM_TIMING_1
, mc_arb_dram_timing
);
1572 WREG32(MC_ARB_DRAM_TIMING2_1
, mc_arb_dram_timing2
);
1573 WREG32_P(MC_ARB_BURST_TIME
, STATE1(burst_time
), ~STATE1_MASK
);
1575 case MC_CG_ARB_FREQ_F2
:
1576 WREG32(MC_ARB_DRAM_TIMING_2
, mc_arb_dram_timing
);
1577 WREG32(MC_ARB_DRAM_TIMING2_2
, mc_arb_dram_timing2
);
1578 WREG32_P(MC_ARB_BURST_TIME
, STATE2(burst_time
), ~STATE2_MASK
);
1580 case MC_CG_ARB_FREQ_F3
:
1581 WREG32(MC_ARB_DRAM_TIMING_3
, mc_arb_dram_timing
);
1582 WREG32(MC_ARB_DRAM_TIMING2_3
, mc_arb_dram_timing2
);
1583 WREG32_P(MC_ARB_BURST_TIME
, STATE3(burst_time
), ~STATE3_MASK
);
1589 mc_cg_config
= RREG32(MC_CG_CONFIG
) | 0x0000000F;
1590 WREG32(MC_CG_CONFIG
, mc_cg_config
);
1591 WREG32_P(MC_ARB_CG
, CG_ARB_REQ(arb_freq_dest
), ~CG_ARB_REQ_MASK
);
1596 static int ni_init_arb_table_index(struct radeon_device
*rdev
)
1598 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1599 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1603 ret
= rv770_read_smc_sram_dword(rdev
, ni_pi
->arb_table_start
,
1604 &tmp
, pi
->sram_end
);
1609 tmp
|= ((u32
)MC_CG_ARB_FREQ_F1
) << 24;
1611 return rv770_write_smc_sram_dword(rdev
, ni_pi
->arb_table_start
,
1615 static int ni_initial_switch_from_arb_f0_to_f1(struct radeon_device
*rdev
)
1617 return ni_copy_and_switch_arb_sets(rdev
, MC_CG_ARB_FREQ_F0
, MC_CG_ARB_FREQ_F1
);
1620 static int ni_force_switch_to_arb_f0(struct radeon_device
*rdev
)
1622 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1623 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1627 ret
= rv770_read_smc_sram_dword(rdev
, ni_pi
->arb_table_start
,
1628 &tmp
, pi
->sram_end
);
1632 tmp
= (tmp
>> 24) & 0xff;
1634 if (tmp
== MC_CG_ARB_FREQ_F0
)
1637 return ni_copy_and_switch_arb_sets(rdev
, tmp
, MC_CG_ARB_FREQ_F0
);
1640 static int ni_populate_memory_timing_parameters(struct radeon_device
*rdev
,
1641 struct rv7xx_pl
*pl
,
1642 SMC_NIslands_MCArbDramTimingRegisterSet
*arb_regs
)
1647 arb_regs
->mc_arb_rfsh_rate
=
1648 (u8
)rv770_calculate_memory_refresh_rate(rdev
, pl
->sclk
);
1651 radeon_atom_set_engine_dram_timings(rdev
,
1655 dram_timing
= RREG32(MC_ARB_DRAM_TIMING
);
1656 dram_timing2
= RREG32(MC_ARB_DRAM_TIMING2
);
1658 arb_regs
->mc_arb_dram_timing
= cpu_to_be32(dram_timing
);
1659 arb_regs
->mc_arb_dram_timing2
= cpu_to_be32(dram_timing2
);
1664 static int ni_do_program_memory_timing_parameters(struct radeon_device
*rdev
,
1665 struct radeon_ps
*radeon_state
,
1666 unsigned int first_arb_set
)
1668 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1669 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1670 struct ni_ps
*state
= ni_get_ps(radeon_state
);
1671 SMC_NIslands_MCArbDramTimingRegisterSet arb_regs
= { 0 };
1674 for (i
= 0; i
< state
->performance_level_count
; i
++) {
1675 ret
= ni_populate_memory_timing_parameters(rdev
, &state
->performance_levels
[i
], &arb_regs
);
1679 ret
= rv770_copy_bytes_to_smc(rdev
,
1680 (u16
)(ni_pi
->arb_table_start
+
1681 offsetof(SMC_NIslands_MCArbDramTimingRegisters
, data
) +
1682 sizeof(SMC_NIslands_MCArbDramTimingRegisterSet
) * (first_arb_set
+ i
)),
1684 (u16
)sizeof(SMC_NIslands_MCArbDramTimingRegisterSet
),
1692 static int ni_program_memory_timing_parameters(struct radeon_device
*rdev
,
1693 struct radeon_ps
*radeon_new_state
)
1695 return ni_do_program_memory_timing_parameters(rdev
, radeon_new_state
,
1696 NISLANDS_DRIVER_STATE_ARB_INDEX
);
1699 static void ni_populate_initial_mvdd_value(struct radeon_device
*rdev
,
1700 struct NISLANDS_SMC_VOLTAGE_VALUE
*voltage
)
1702 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1704 voltage
->index
= eg_pi
->mvdd_high_index
;
1705 voltage
->value
= cpu_to_be16(MVDD_HIGH_VALUE
);
1708 static int ni_populate_smc_initial_state(struct radeon_device
*rdev
,
1709 struct radeon_ps
*radeon_initial_state
,
1710 NISLANDS_SMC_STATETABLE
*table
)
1712 struct ni_ps
*initial_state
= ni_get_ps(radeon_initial_state
);
1713 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1714 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1715 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1719 table
->initialState
.levels
[0].mclk
.vMPLL_AD_FUNC_CNTL
=
1720 cpu_to_be32(ni_pi
->clock_registers
.mpll_ad_func_cntl
);
1721 table
->initialState
.levels
[0].mclk
.vMPLL_AD_FUNC_CNTL_2
=
1722 cpu_to_be32(ni_pi
->clock_registers
.mpll_ad_func_cntl_2
);
1723 table
->initialState
.levels
[0].mclk
.vMPLL_DQ_FUNC_CNTL
=
1724 cpu_to_be32(ni_pi
->clock_registers
.mpll_dq_func_cntl
);
1725 table
->initialState
.levels
[0].mclk
.vMPLL_DQ_FUNC_CNTL_2
=
1726 cpu_to_be32(ni_pi
->clock_registers
.mpll_dq_func_cntl_2
);
1727 table
->initialState
.levels
[0].mclk
.vMCLK_PWRMGT_CNTL
=
1728 cpu_to_be32(ni_pi
->clock_registers
.mclk_pwrmgt_cntl
);
1729 table
->initialState
.levels
[0].mclk
.vDLL_CNTL
=
1730 cpu_to_be32(ni_pi
->clock_registers
.dll_cntl
);
1731 table
->initialState
.levels
[0].mclk
.vMPLL_SS
=
1732 cpu_to_be32(ni_pi
->clock_registers
.mpll_ss1
);
1733 table
->initialState
.levels
[0].mclk
.vMPLL_SS2
=
1734 cpu_to_be32(ni_pi
->clock_registers
.mpll_ss2
);
1735 table
->initialState
.levels
[0].mclk
.mclk_value
=
1736 cpu_to_be32(initial_state
->performance_levels
[0].mclk
);
1738 table
->initialState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL
=
1739 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_func_cntl
);
1740 table
->initialState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_2
=
1741 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_func_cntl_2
);
1742 table
->initialState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_3
=
1743 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_func_cntl_3
);
1744 table
->initialState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_4
=
1745 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_func_cntl_4
);
1746 table
->initialState
.levels
[0].sclk
.vCG_SPLL_SPREAD_SPECTRUM
=
1747 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_spread_spectrum
);
1748 table
->initialState
.levels
[0].sclk
.vCG_SPLL_SPREAD_SPECTRUM_2
=
1749 cpu_to_be32(ni_pi
->clock_registers
.cg_spll_spread_spectrum_2
);
1750 table
->initialState
.levels
[0].sclk
.sclk_value
=
1751 cpu_to_be32(initial_state
->performance_levels
[0].sclk
);
1752 table
->initialState
.levels
[0].arbRefreshState
=
1753 NISLANDS_INITIAL_STATE_ARB_INDEX
;
1755 table
->initialState
.levels
[0].ACIndex
= 0;
1757 ret
= ni_populate_voltage_value(rdev
, &eg_pi
->vddc_voltage_table
,
1758 initial_state
->performance_levels
[0].vddc
,
1759 &table
->initialState
.levels
[0].vddc
);
1763 ret
= ni_get_std_voltage_value(rdev
,
1764 &table
->initialState
.levels
[0].vddc
,
1767 ni_populate_std_voltage_value(rdev
, std_vddc
,
1768 table
->initialState
.levels
[0].vddc
.index
,
1769 &table
->initialState
.levels
[0].std_vddc
);
1772 if (eg_pi
->vddci_control
)
1773 ni_populate_voltage_value(rdev
,
1774 &eg_pi
->vddci_voltage_table
,
1775 initial_state
->performance_levels
[0].vddci
,
1776 &table
->initialState
.levels
[0].vddci
);
1778 ni_populate_initial_mvdd_value(rdev
, &table
->initialState
.levels
[0].mvdd
);
1780 reg
= CG_R(0xffff) | CG_L(0);
1781 table
->initialState
.levels
[0].aT
= cpu_to_be32(reg
);
1783 table
->initialState
.levels
[0].bSP
= cpu_to_be32(pi
->dsp
);
1785 if (pi
->boot_in_gen2
)
1786 table
->initialState
.levels
[0].gen2PCIE
= 1;
1788 table
->initialState
.levels
[0].gen2PCIE
= 0;
1790 if (pi
->mem_gddr5
) {
1791 table
->initialState
.levels
[0].strobeMode
=
1792 cypress_get_strobe_mode_settings(rdev
,
1793 initial_state
->performance_levels
[0].mclk
);
1795 if (initial_state
->performance_levels
[0].mclk
> pi
->mclk_edc_enable_threshold
)
1796 table
->initialState
.levels
[0].mcFlags
= NISLANDS_SMC_MC_EDC_RD_FLAG
| NISLANDS_SMC_MC_EDC_WR_FLAG
;
1798 table
->initialState
.levels
[0].mcFlags
= 0;
1801 table
->initialState
.levelCount
= 1;
1803 table
->initialState
.flags
|= PPSMC_SWSTATE_FLAG_DC
;
1805 table
->initialState
.levels
[0].dpm2
.MaxPS
= 0;
1806 table
->initialState
.levels
[0].dpm2
.NearTDPDec
= 0;
1807 table
->initialState
.levels
[0].dpm2
.AboveSafeInc
= 0;
1808 table
->initialState
.levels
[0].dpm2
.BelowSafeInc
= 0;
1810 reg
= MIN_POWER_MASK
| MAX_POWER_MASK
;
1811 table
->initialState
.levels
[0].SQPowerThrottle
= cpu_to_be32(reg
);
1813 reg
= MAX_POWER_DELTA_MASK
| STI_SIZE_MASK
| LTI_RATIO_MASK
;
1814 table
->initialState
.levels
[0].SQPowerThrottle_2
= cpu_to_be32(reg
);
1819 static int ni_populate_smc_acpi_state(struct radeon_device
*rdev
,
1820 NISLANDS_SMC_STATETABLE
*table
)
1822 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1823 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
1824 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1825 u32 mpll_ad_func_cntl
= ni_pi
->clock_registers
.mpll_ad_func_cntl
;
1826 u32 mpll_ad_func_cntl_2
= ni_pi
->clock_registers
.mpll_ad_func_cntl_2
;
1827 u32 mpll_dq_func_cntl
= ni_pi
->clock_registers
.mpll_dq_func_cntl
;
1828 u32 mpll_dq_func_cntl_2
= ni_pi
->clock_registers
.mpll_dq_func_cntl_2
;
1829 u32 spll_func_cntl
= ni_pi
->clock_registers
.cg_spll_func_cntl
;
1830 u32 spll_func_cntl_2
= ni_pi
->clock_registers
.cg_spll_func_cntl_2
;
1831 u32 spll_func_cntl_3
= ni_pi
->clock_registers
.cg_spll_func_cntl_3
;
1832 u32 spll_func_cntl_4
= ni_pi
->clock_registers
.cg_spll_func_cntl_4
;
1833 u32 mclk_pwrmgt_cntl
= ni_pi
->clock_registers
.mclk_pwrmgt_cntl
;
1834 u32 dll_cntl
= ni_pi
->clock_registers
.dll_cntl
;
1838 table
->ACPIState
= table
->initialState
;
1840 table
->ACPIState
.flags
&= ~PPSMC_SWSTATE_FLAG_DC
;
1842 if (pi
->acpi_vddc
) {
1843 ret
= ni_populate_voltage_value(rdev
,
1844 &eg_pi
->vddc_voltage_table
,
1845 pi
->acpi_vddc
, &table
->ACPIState
.levels
[0].vddc
);
1849 ret
= ni_get_std_voltage_value(rdev
,
1850 &table
->ACPIState
.levels
[0].vddc
, &std_vddc
);
1852 ni_populate_std_voltage_value(rdev
, std_vddc
,
1853 table
->ACPIState
.levels
[0].vddc
.index
,
1854 &table
->ACPIState
.levels
[0].std_vddc
);
1857 if (pi
->pcie_gen2
) {
1858 if (pi
->acpi_pcie_gen2
)
1859 table
->ACPIState
.levels
[0].gen2PCIE
= 1;
1861 table
->ACPIState
.levels
[0].gen2PCIE
= 0;
1863 table
->ACPIState
.levels
[0].gen2PCIE
= 0;
1866 ret
= ni_populate_voltage_value(rdev
,
1867 &eg_pi
->vddc_voltage_table
,
1868 pi
->min_vddc_in_table
,
1869 &table
->ACPIState
.levels
[0].vddc
);
1873 ret
= ni_get_std_voltage_value(rdev
,
1874 &table
->ACPIState
.levels
[0].vddc
,
1877 ni_populate_std_voltage_value(rdev
, std_vddc
,
1878 table
->ACPIState
.levels
[0].vddc
.index
,
1879 &table
->ACPIState
.levels
[0].std_vddc
);
1881 table
->ACPIState
.levels
[0].gen2PCIE
= 0;
1884 if (eg_pi
->acpi_vddci
) {
1885 if (eg_pi
->vddci_control
)
1886 ni_populate_voltage_value(rdev
,
1887 &eg_pi
->vddci_voltage_table
,
1889 &table
->ACPIState
.levels
[0].vddci
);
1893 mpll_ad_func_cntl
&= ~PDNB
;
1895 mpll_ad_func_cntl_2
|= BIAS_GEN_PDNB
| RESET_EN
;
1898 mpll_dq_func_cntl
&= ~PDNB
;
1899 mpll_dq_func_cntl_2
|= BIAS_GEN_PDNB
| RESET_EN
| BYPASS
;
1902 mclk_pwrmgt_cntl
|= (MRDCKA0_RESET
|
1911 mclk_pwrmgt_cntl
&= ~(MRDCKA0_PDNB
|
1920 dll_cntl
|= (MRDCKA0_BYPASS
|
1929 spll_func_cntl_2
&= ~SCLK_MUX_SEL_MASK
;
1930 spll_func_cntl_2
|= SCLK_MUX_SEL(4);
1932 table
->ACPIState
.levels
[0].mclk
.vMPLL_AD_FUNC_CNTL
= cpu_to_be32(mpll_ad_func_cntl
);
1933 table
->ACPIState
.levels
[0].mclk
.vMPLL_AD_FUNC_CNTL_2
= cpu_to_be32(mpll_ad_func_cntl_2
);
1934 table
->ACPIState
.levels
[0].mclk
.vMPLL_DQ_FUNC_CNTL
= cpu_to_be32(mpll_dq_func_cntl
);
1935 table
->ACPIState
.levels
[0].mclk
.vMPLL_DQ_FUNC_CNTL_2
= cpu_to_be32(mpll_dq_func_cntl_2
);
1936 table
->ACPIState
.levels
[0].mclk
.vMCLK_PWRMGT_CNTL
= cpu_to_be32(mclk_pwrmgt_cntl
);
1937 table
->ACPIState
.levels
[0].mclk
.vDLL_CNTL
= cpu_to_be32(dll_cntl
);
1939 table
->ACPIState
.levels
[0].mclk
.mclk_value
= 0;
1941 table
->ACPIState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL
= cpu_to_be32(spll_func_cntl
);
1942 table
->ACPIState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_2
= cpu_to_be32(spll_func_cntl_2
);
1943 table
->ACPIState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_3
= cpu_to_be32(spll_func_cntl_3
);
1944 table
->ACPIState
.levels
[0].sclk
.vCG_SPLL_FUNC_CNTL_4
= cpu_to_be32(spll_func_cntl_4
);
1946 table
->ACPIState
.levels
[0].sclk
.sclk_value
= 0;
1948 ni_populate_mvdd_value(rdev
, 0, &table
->ACPIState
.levels
[0].mvdd
);
1950 if (eg_pi
->dynamic_ac_timing
)
1951 table
->ACPIState
.levels
[0].ACIndex
= 1;
1953 table
->ACPIState
.levels
[0].dpm2
.MaxPS
= 0;
1954 table
->ACPIState
.levels
[0].dpm2
.NearTDPDec
= 0;
1955 table
->ACPIState
.levels
[0].dpm2
.AboveSafeInc
= 0;
1956 table
->ACPIState
.levels
[0].dpm2
.BelowSafeInc
= 0;
1958 reg
= MIN_POWER_MASK
| MAX_POWER_MASK
;
1959 table
->ACPIState
.levels
[0].SQPowerThrottle
= cpu_to_be32(reg
);
1961 reg
= MAX_POWER_DELTA_MASK
| STI_SIZE_MASK
| LTI_RATIO_MASK
;
1962 table
->ACPIState
.levels
[0].SQPowerThrottle_2
= cpu_to_be32(reg
);
1967 static int ni_init_smc_table(struct radeon_device
*rdev
)
1969 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
1970 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
1972 struct radeon_ps
*radeon_boot_state
= rdev
->pm
.dpm
.boot_ps
;
1973 NISLANDS_SMC_STATETABLE
*table
= &ni_pi
->smc_statetable
;
1975 memset(table
, 0, sizeof(NISLANDS_SMC_STATETABLE
));
1977 ni_populate_smc_voltage_tables(rdev
, table
);
1979 switch (rdev
->pm
.int_thermal_type
) {
1980 case THERMAL_TYPE_NI
:
1981 case THERMAL_TYPE_EMC2103_WITH_INTERNAL
:
1982 table
->thermalProtectType
= PPSMC_THERMAL_PROTECT_TYPE_INTERNAL
;
1984 case THERMAL_TYPE_NONE
:
1985 table
->thermalProtectType
= PPSMC_THERMAL_PROTECT_TYPE_NONE
;
1988 table
->thermalProtectType
= PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL
;
1992 if (rdev
->pm
.dpm
.platform_caps
& ATOM_PP_PLATFORM_CAP_HARDWAREDC
)
1993 table
->systemFlags
|= PPSMC_SYSTEMFLAG_GPIO_DC
;
1995 if (rdev
->pm
.dpm
.platform_caps
& ATOM_PP_PLATFORM_CAP_REGULATOR_HOT
)
1996 table
->systemFlags
|= PPSMC_SYSTEMFLAG_REGULATOR_HOT
;
1998 if (rdev
->pm
.dpm
.platform_caps
& ATOM_PP_PLATFORM_CAP_STEPVDDC
)
1999 table
->systemFlags
|= PPSMC_SYSTEMFLAG_STEPVDDC
;
2002 table
->systemFlags
|= PPSMC_SYSTEMFLAG_GDDR5
;
2004 ret
= ni_populate_smc_initial_state(rdev
, radeon_boot_state
, table
);
2008 ret
= ni_populate_smc_acpi_state(rdev
, table
);
2012 table
->driverState
= table
->initialState
;
2014 table
->ULVState
= table
->initialState
;
2016 ret
= ni_do_program_memory_timing_parameters(rdev
, radeon_boot_state
,
2017 NISLANDS_INITIAL_STATE_ARB_INDEX
);
2021 return rv770_copy_bytes_to_smc(rdev
, pi
->state_table_start
, (u8
*)table
,
2022 sizeof(NISLANDS_SMC_STATETABLE
), pi
->sram_end
);
2025 static int ni_calculate_sclk_params(struct radeon_device
*rdev
,
2027 NISLANDS_SMC_SCLK_VALUE
*sclk
)
2029 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2030 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2031 struct atom_clock_dividers dividers
;
2032 u32 spll_func_cntl
= ni_pi
->clock_registers
.cg_spll_func_cntl
;
2033 u32 spll_func_cntl_2
= ni_pi
->clock_registers
.cg_spll_func_cntl_2
;
2034 u32 spll_func_cntl_3
= ni_pi
->clock_registers
.cg_spll_func_cntl_3
;
2035 u32 spll_func_cntl_4
= ni_pi
->clock_registers
.cg_spll_func_cntl_4
;
2036 u32 cg_spll_spread_spectrum
= ni_pi
->clock_registers
.cg_spll_spread_spectrum
;
2037 u32 cg_spll_spread_spectrum_2
= ni_pi
->clock_registers
.cg_spll_spread_spectrum_2
;
2039 u32 reference_clock
= rdev
->clock
.spll
.reference_freq
;
2040 u32 reference_divider
;
2044 ret
= radeon_atom_get_clock_dividers(rdev
, COMPUTE_ENGINE_PLL_PARAM
,
2045 engine_clock
, false, ÷rs
);
2049 reference_divider
= 1 + dividers
.ref_div
;
2052 tmp
= (u64
) engine_clock
* reference_divider
* dividers
.post_div
* 16834;
2053 do_div(tmp
, reference_clock
);
2056 spll_func_cntl
&= ~(SPLL_PDIV_A_MASK
| SPLL_REF_DIV_MASK
);
2057 spll_func_cntl
|= SPLL_REF_DIV(dividers
.ref_div
);
2058 spll_func_cntl
|= SPLL_PDIV_A(dividers
.post_div
);
2060 spll_func_cntl_2
&= ~SCLK_MUX_SEL_MASK
;
2061 spll_func_cntl_2
|= SCLK_MUX_SEL(2);
2063 spll_func_cntl_3
&= ~SPLL_FB_DIV_MASK
;
2064 spll_func_cntl_3
|= SPLL_FB_DIV(fbdiv
);
2065 spll_func_cntl_3
|= SPLL_DITHEN
;
2068 struct radeon_atom_ss ss
;
2069 u32 vco_freq
= engine_clock
* dividers
.post_div
;
2071 if (radeon_atombios_get_asic_ss_info(rdev
, &ss
,
2072 ASIC_INTERNAL_ENGINE_SS
, vco_freq
)) {
2073 u32 clk_s
= reference_clock
* 5 / (reference_divider
* ss
.rate
);
2074 u32 clk_v
= 4 * ss
.percentage
* fbdiv
/ (clk_s
* 10000);
2076 cg_spll_spread_spectrum
&= ~CLK_S_MASK
;
2077 cg_spll_spread_spectrum
|= CLK_S(clk_s
);
2078 cg_spll_spread_spectrum
|= SSEN
;
2080 cg_spll_spread_spectrum_2
&= ~CLK_V_MASK
;
2081 cg_spll_spread_spectrum_2
|= CLK_V(clk_v
);
2085 sclk
->sclk_value
= engine_clock
;
2086 sclk
->vCG_SPLL_FUNC_CNTL
= spll_func_cntl
;
2087 sclk
->vCG_SPLL_FUNC_CNTL_2
= spll_func_cntl_2
;
2088 sclk
->vCG_SPLL_FUNC_CNTL_3
= spll_func_cntl_3
;
2089 sclk
->vCG_SPLL_FUNC_CNTL_4
= spll_func_cntl_4
;
2090 sclk
->vCG_SPLL_SPREAD_SPECTRUM
= cg_spll_spread_spectrum
;
2091 sclk
->vCG_SPLL_SPREAD_SPECTRUM_2
= cg_spll_spread_spectrum_2
;
2096 static int ni_populate_sclk_value(struct radeon_device
*rdev
,
2098 NISLANDS_SMC_SCLK_VALUE
*sclk
)
2100 NISLANDS_SMC_SCLK_VALUE sclk_tmp
;
2103 ret
= ni_calculate_sclk_params(rdev
, engine_clock
, &sclk_tmp
);
2105 sclk
->sclk_value
= cpu_to_be32(sclk_tmp
.sclk_value
);
2106 sclk
->vCG_SPLL_FUNC_CNTL
= cpu_to_be32(sclk_tmp
.vCG_SPLL_FUNC_CNTL
);
2107 sclk
->vCG_SPLL_FUNC_CNTL_2
= cpu_to_be32(sclk_tmp
.vCG_SPLL_FUNC_CNTL_2
);
2108 sclk
->vCG_SPLL_FUNC_CNTL_3
= cpu_to_be32(sclk_tmp
.vCG_SPLL_FUNC_CNTL_3
);
2109 sclk
->vCG_SPLL_FUNC_CNTL_4
= cpu_to_be32(sclk_tmp
.vCG_SPLL_FUNC_CNTL_4
);
2110 sclk
->vCG_SPLL_SPREAD_SPECTRUM
= cpu_to_be32(sclk_tmp
.vCG_SPLL_SPREAD_SPECTRUM
);
2111 sclk
->vCG_SPLL_SPREAD_SPECTRUM_2
= cpu_to_be32(sclk_tmp
.vCG_SPLL_SPREAD_SPECTRUM_2
);
2117 static int ni_init_smc_spll_table(struct radeon_device
*rdev
)
2119 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2120 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2121 SMC_NISLANDS_SPLL_DIV_TABLE
*spll_table
;
2122 NISLANDS_SMC_SCLK_VALUE sclk_params
;
2131 if (ni_pi
->spll_table_start
== 0)
2134 spll_table
= kzalloc(sizeof(SMC_NISLANDS_SPLL_DIV_TABLE
), GFP_KERNEL
);
2135 if (spll_table
== NULL
)
2138 for (i
= 0; i
< 256; i
++) {
2139 ret
= ni_calculate_sclk_params(rdev
, sclk
, &sclk_params
);
2143 p_div
= (sclk_params
.vCG_SPLL_FUNC_CNTL
& SPLL_PDIV_A_MASK
) >> SPLL_PDIV_A_SHIFT
;
2144 fb_div
= (sclk_params
.vCG_SPLL_FUNC_CNTL_3
& SPLL_FB_DIV_MASK
) >> SPLL_FB_DIV_SHIFT
;
2145 clk_s
= (sclk_params
.vCG_SPLL_SPREAD_SPECTRUM
& CLK_S_MASK
) >> CLK_S_SHIFT
;
2146 clk_v
= (sclk_params
.vCG_SPLL_SPREAD_SPECTRUM_2
& CLK_V_MASK
) >> CLK_V_SHIFT
;
2148 fb_div
&= ~0x00001FFF;
2152 if (p_div
& ~(SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_MASK
>> SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT
))
2155 if (clk_s
& ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK
>> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT
))
2158 if (clk_s
& ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK
>> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT
))
2161 if (clk_v
& ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_MASK
>> SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT
))
2167 tmp
= ((fb_div
<< SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT
) & SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_MASK
) |
2168 ((p_div
<< SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT
) & SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_MASK
);
2169 spll_table
->freq
[i
] = cpu_to_be32(tmp
);
2171 tmp
= ((clk_v
<< SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT
) & SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_MASK
) |
2172 ((clk_s
<< SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT
) & SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK
);
2173 spll_table
->ss
[i
] = cpu_to_be32(tmp
);
2179 ret
= rv770_copy_bytes_to_smc(rdev
, ni_pi
->spll_table_start
, (u8
*)spll_table
,
2180 sizeof(SMC_NISLANDS_SPLL_DIV_TABLE
), pi
->sram_end
);
2187 static int ni_populate_mclk_value(struct radeon_device
*rdev
,
2190 NISLANDS_SMC_MCLK_VALUE
*mclk
,
2194 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2195 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2196 u32 mpll_ad_func_cntl
= ni_pi
->clock_registers
.mpll_ad_func_cntl
;
2197 u32 mpll_ad_func_cntl_2
= ni_pi
->clock_registers
.mpll_ad_func_cntl_2
;
2198 u32 mpll_dq_func_cntl
= ni_pi
->clock_registers
.mpll_dq_func_cntl
;
2199 u32 mpll_dq_func_cntl_2
= ni_pi
->clock_registers
.mpll_dq_func_cntl_2
;
2200 u32 mclk_pwrmgt_cntl
= ni_pi
->clock_registers
.mclk_pwrmgt_cntl
;
2201 u32 dll_cntl
= ni_pi
->clock_registers
.dll_cntl
;
2202 u32 mpll_ss1
= ni_pi
->clock_registers
.mpll_ss1
;
2203 u32 mpll_ss2
= ni_pi
->clock_registers
.mpll_ss2
;
2204 struct atom_clock_dividers dividers
;
2210 ret
= radeon_atom_get_clock_dividers(rdev
, COMPUTE_MEMORY_PLL_PARAM
,
2211 memory_clock
, strobe_mode
, ÷rs
);
2216 mc_seq_misc7
= RREG32(MC_SEQ_MISC7
);
2218 if (mc_seq_misc7
& 0x8000000)
2219 dividers
.post_div
= 1;
2222 ibias
= cypress_map_clkf_to_ibias(rdev
, dividers
.whole_fb_div
);
2224 mpll_ad_func_cntl
&= ~(CLKR_MASK
|
2225 YCLK_POST_DIV_MASK
|
2229 mpll_ad_func_cntl
|= CLKR(dividers
.ref_div
);
2230 mpll_ad_func_cntl
|= YCLK_POST_DIV(dividers
.post_div
);
2231 mpll_ad_func_cntl
|= CLKF(dividers
.whole_fb_div
);
2232 mpll_ad_func_cntl
|= CLKFRAC(dividers
.frac_fb_div
);
2233 mpll_ad_func_cntl
|= IBIAS(ibias
);
2235 if (dividers
.vco_mode
)
2236 mpll_ad_func_cntl_2
|= VCO_MODE
;
2238 mpll_ad_func_cntl_2
&= ~VCO_MODE
;
2240 if (pi
->mem_gddr5
) {
2241 mpll_dq_func_cntl
&= ~(CLKR_MASK
|
2242 YCLK_POST_DIV_MASK
|
2246 mpll_dq_func_cntl
|= CLKR(dividers
.ref_div
);
2247 mpll_dq_func_cntl
|= YCLK_POST_DIV(dividers
.post_div
);
2248 mpll_dq_func_cntl
|= CLKF(dividers
.whole_fb_div
);
2249 mpll_dq_func_cntl
|= CLKFRAC(dividers
.frac_fb_div
);
2250 mpll_dq_func_cntl
|= IBIAS(ibias
);
2253 mpll_dq_func_cntl
&= ~PDNB
;
2255 mpll_dq_func_cntl
|= PDNB
;
2257 if (dividers
.vco_mode
)
2258 mpll_dq_func_cntl_2
|= VCO_MODE
;
2260 mpll_dq_func_cntl_2
&= ~VCO_MODE
;
2264 struct radeon_atom_ss ss
;
2265 u32 vco_freq
= memory_clock
* dividers
.post_div
;
2267 if (radeon_atombios_get_asic_ss_info(rdev
, &ss
,
2268 ASIC_INTERNAL_MEMORY_SS
, vco_freq
)) {
2269 u32 reference_clock
= rdev
->clock
.mpll
.reference_freq
;
2270 u32 decoded_ref
= rv740_get_decoded_reference_divider(dividers
.ref_div
);
2271 u32 clk_s
= reference_clock
* 5 / (decoded_ref
* ss
.rate
);
2272 u32 clk_v
= ss
.percentage
*
2273 (0x4000 * dividers
.whole_fb_div
+ 0x800 * dividers
.frac_fb_div
) / (clk_s
* 625);
2275 mpll_ss1
&= ~CLKV_MASK
;
2276 mpll_ss1
|= CLKV(clk_v
);
2278 mpll_ss2
&= ~CLKS_MASK
;
2279 mpll_ss2
|= CLKS(clk_s
);
2283 dll_speed
= rv740_get_dll_speed(pi
->mem_gddr5
,
2286 mclk_pwrmgt_cntl
&= ~DLL_SPEED_MASK
;
2287 mclk_pwrmgt_cntl
|= DLL_SPEED(dll_speed
);
2289 mclk_pwrmgt_cntl
|= (MRDCKA0_PDNB
|
2298 mclk_pwrmgt_cntl
&= ~(MRDCKA0_PDNB
|
2308 mclk
->mclk_value
= cpu_to_be32(memory_clock
);
2309 mclk
->vMPLL_AD_FUNC_CNTL
= cpu_to_be32(mpll_ad_func_cntl
);
2310 mclk
->vMPLL_AD_FUNC_CNTL_2
= cpu_to_be32(mpll_ad_func_cntl_2
);
2311 mclk
->vMPLL_DQ_FUNC_CNTL
= cpu_to_be32(mpll_dq_func_cntl
);
2312 mclk
->vMPLL_DQ_FUNC_CNTL_2
= cpu_to_be32(mpll_dq_func_cntl_2
);
2313 mclk
->vMCLK_PWRMGT_CNTL
= cpu_to_be32(mclk_pwrmgt_cntl
);
2314 mclk
->vDLL_CNTL
= cpu_to_be32(dll_cntl
);
2315 mclk
->vMPLL_SS
= cpu_to_be32(mpll_ss1
);
2316 mclk
->vMPLL_SS2
= cpu_to_be32(mpll_ss2
);
2321 static void ni_populate_smc_sp(struct radeon_device
*rdev
,
2322 struct radeon_ps
*radeon_state
,
2323 NISLANDS_SMC_SWSTATE
*smc_state
)
2325 struct ni_ps
*ps
= ni_get_ps(radeon_state
);
2326 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2329 for (i
= 0; i
< ps
->performance_level_count
- 1; i
++)
2330 smc_state
->levels
[i
].bSP
= cpu_to_be32(pi
->dsp
);
2332 smc_state
->levels
[ps
->performance_level_count
- 1].bSP
=
2333 cpu_to_be32(pi
->psp
);
2336 static int ni_convert_power_level_to_smc(struct radeon_device
*rdev
,
2337 struct rv7xx_pl
*pl
,
2338 NISLANDS_SMC_HW_PERFORMANCE_LEVEL
*level
)
2340 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2341 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
2342 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2346 u32 tmp
= RREG32(DC_STUTTER_CNTL
);
2348 level
->gen2PCIE
= pi
->pcie_gen2
?
2349 ((pl
->flags
& ATOM_PPLIB_R600_FLAGS_PCIEGEN2
) ? 1 : 0) : 0;
2351 ret
= ni_populate_sclk_value(rdev
, pl
->sclk
, &level
->sclk
);
2356 if (pi
->mclk_stutter_mode_threshold
&&
2357 (pl
->mclk
<= pi
->mclk_stutter_mode_threshold
) &&
2358 !eg_pi
->uvd_enabled
&&
2359 (tmp
& DC_STUTTER_ENABLE_A
) &&
2360 (tmp
& DC_STUTTER_ENABLE_B
))
2361 level
->mcFlags
|= NISLANDS_SMC_MC_STUTTER_EN
;
2363 if (pi
->mem_gddr5
) {
2364 if (pl
->mclk
> pi
->mclk_edc_enable_threshold
)
2365 level
->mcFlags
|= NISLANDS_SMC_MC_EDC_RD_FLAG
;
2366 if (pl
->mclk
> eg_pi
->mclk_edc_wr_enable_threshold
)
2367 level
->mcFlags
|= NISLANDS_SMC_MC_EDC_WR_FLAG
;
2369 level
->strobeMode
= cypress_get_strobe_mode_settings(rdev
, pl
->mclk
);
2371 if (level
->strobeMode
& NISLANDS_SMC_STROBE_ENABLE
) {
2372 if (cypress_get_mclk_frequency_ratio(rdev
, pl
->mclk
, true) >=
2373 ((RREG32(MC_SEQ_MISC7
) >> 16) & 0xf))
2374 dll_state_on
= ((RREG32(MC_SEQ_MISC5
) >> 1) & 0x1) ? true : false;
2376 dll_state_on
= ((RREG32(MC_SEQ_MISC6
) >> 1) & 0x1) ? true : false;
2378 dll_state_on
= false;
2379 if (pl
->mclk
> ni_pi
->mclk_rtt_mode_threshold
)
2380 level
->mcFlags
|= NISLANDS_SMC_MC_RTT_ENABLE
;
2383 ret
= ni_populate_mclk_value(rdev
, pl
->sclk
, pl
->mclk
,
2385 (level
->strobeMode
& NISLANDS_SMC_STROBE_ENABLE
) != 0,
2388 ret
= ni_populate_mclk_value(rdev
, pl
->sclk
, pl
->mclk
, &level
->mclk
, 1, 1);
2393 ret
= ni_populate_voltage_value(rdev
, &eg_pi
->vddc_voltage_table
,
2394 pl
->vddc
, &level
->vddc
);
2398 ret
= ni_get_std_voltage_value(rdev
, &level
->vddc
, &std_vddc
);
2402 ni_populate_std_voltage_value(rdev
, std_vddc
,
2403 level
->vddc
.index
, &level
->std_vddc
);
2405 if (eg_pi
->vddci_control
) {
2406 ret
= ni_populate_voltage_value(rdev
, &eg_pi
->vddci_voltage_table
,
2407 pl
->vddci
, &level
->vddci
);
2412 ni_populate_mvdd_value(rdev
, pl
->mclk
, &level
->mvdd
);
2417 static int ni_populate_smc_t(struct radeon_device
*rdev
,
2418 struct radeon_ps
*radeon_state
,
2419 NISLANDS_SMC_SWSTATE
*smc_state
)
2421 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2422 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
2423 struct ni_ps
*state
= ni_get_ps(radeon_state
);
2429 if (state
->performance_level_count
>= 9)
2432 if (state
->performance_level_count
< 2) {
2433 a_t
= CG_R(0xffff) | CG_L(0);
2434 smc_state
->levels
[0].aT
= cpu_to_be32(a_t
);
2438 smc_state
->levels
[0].aT
= cpu_to_be32(0);
2440 for (i
= 0; i
<= state
->performance_level_count
- 2; i
++) {
2441 if (eg_pi
->uvd_enabled
)
2442 ret
= r600_calculate_at(
2443 1000 * (i
* (eg_pi
->smu_uvd_hs
? 2 : 8) + 2),
2445 state
->performance_levels
[i
+ 1].sclk
,
2446 state
->performance_levels
[i
].sclk
,
2450 ret
= r600_calculate_at(
2453 state
->performance_levels
[i
+ 1].sclk
,
2454 state
->performance_levels
[i
].sclk
,
2459 t_h
= (i
+ 1) * 1000 - 50 * R600_AH_DFLT
;
2460 t_l
= (i
+ 1) * 1000 + 50 * R600_AH_DFLT
;
2463 a_t
= be32_to_cpu(smc_state
->levels
[i
].aT
) & ~CG_R_MASK
;
2464 a_t
|= CG_R(t_l
* pi
->bsp
/ 20000);
2465 smc_state
->levels
[i
].aT
= cpu_to_be32(a_t
);
2467 high_bsp
= (i
== state
->performance_level_count
- 2) ?
2470 a_t
= CG_R(0xffff) | CG_L(t_h
* high_bsp
/ 20000);
2471 smc_state
->levels
[i
+ 1].aT
= cpu_to_be32(a_t
);
2477 static int ni_populate_power_containment_values(struct radeon_device
*rdev
,
2478 struct radeon_ps
*radeon_state
,
2479 NISLANDS_SMC_SWSTATE
*smc_state
)
2481 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2482 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
2483 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2484 struct ni_ps
*state
= ni_get_ps(radeon_state
);
2491 u32 power_boost_limit
;
2494 if (ni_pi
->enable_power_containment
== false)
2497 if (state
->performance_level_count
== 0)
2500 if (smc_state
->levelCount
!= state
->performance_level_count
)
2503 ret
= ni_calculate_adjusted_tdp_limits(rdev
,
2505 rdev
->pm
.dpm
.tdp_adjustment
,
2511 power_boost_limit
= ni_calculate_power_boost_limit(rdev
, radeon_state
, near_tdp_limit
);
2513 ret
= rv770_write_smc_sram_dword(rdev
,
2514 pi
->state_table_start
+
2515 offsetof(NISLANDS_SMC_STATETABLE
, dpm2Params
) +
2516 offsetof(PP_NIslands_DPM2Parameters
, PowerBoostLimit
),
2517 ni_scale_power_for_smc(power_boost_limit
, ni_get_smc_power_scaling_factor(rdev
)),
2520 power_boost_limit
= 0;
2522 smc_state
->levels
[0].dpm2
.MaxPS
= 0;
2523 smc_state
->levels
[0].dpm2
.NearTDPDec
= 0;
2524 smc_state
->levels
[0].dpm2
.AboveSafeInc
= 0;
2525 smc_state
->levels
[0].dpm2
.BelowSafeInc
= 0;
2526 smc_state
->levels
[0].stateFlags
|= power_boost_limit
? PPSMC_STATEFLAG_POWERBOOST
: 0;
2528 for (i
= 1; i
< state
->performance_level_count
; i
++) {
2529 prev_sclk
= state
->performance_levels
[i
-1].sclk
;
2530 max_sclk
= state
->performance_levels
[i
].sclk
;
2531 max_ps_percent
= (i
!= (state
->performance_level_count
- 1)) ?
2532 NISLANDS_DPM2_MAXPS_PERCENT_M
: NISLANDS_DPM2_MAXPS_PERCENT_H
;
2534 if (max_sclk
< prev_sclk
)
2537 if ((max_ps_percent
== 0) || (prev_sclk
== max_sclk
) || eg_pi
->uvd_enabled
)
2538 min_sclk
= max_sclk
;
2540 min_sclk
= prev_sclk
;
2542 min_sclk
= (prev_sclk
* (u32
)max_ps_percent
) / 100;
2544 if (min_sclk
< state
->performance_levels
[0].sclk
)
2545 min_sclk
= state
->performance_levels
[0].sclk
;
2550 smc_state
->levels
[i
].dpm2
.MaxPS
=
2551 (u8
)((NISLANDS_DPM2_MAX_PULSE_SKIP
* (max_sclk
- min_sclk
)) / max_sclk
);
2552 smc_state
->levels
[i
].dpm2
.NearTDPDec
= NISLANDS_DPM2_NEAR_TDP_DEC
;
2553 smc_state
->levels
[i
].dpm2
.AboveSafeInc
= NISLANDS_DPM2_ABOVE_SAFE_INC
;
2554 smc_state
->levels
[i
].dpm2
.BelowSafeInc
= NISLANDS_DPM2_BELOW_SAFE_INC
;
2555 smc_state
->levels
[i
].stateFlags
|=
2556 ((i
!= (state
->performance_level_count
- 1)) && power_boost_limit
) ?
2557 PPSMC_STATEFLAG_POWERBOOST
: 0;
2563 static int ni_populate_sq_ramping_values(struct radeon_device
*rdev
,
2564 struct radeon_ps
*radeon_state
,
2565 NISLANDS_SMC_SWSTATE
*smc_state
)
2567 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2568 struct ni_ps
*state
= ni_get_ps(radeon_state
);
2569 u32 sq_power_throttle
;
2570 u32 sq_power_throttle2
;
2571 bool enable_sq_ramping
= ni_pi
->enable_sq_ramping
;
2574 if (state
->performance_level_count
== 0)
2577 if (smc_state
->levelCount
!= state
->performance_level_count
)
2580 if (rdev
->pm
.dpm
.sq_ramping_threshold
== 0)
2583 if (NISLANDS_DPM2_SQ_RAMP_MAX_POWER
> (MAX_POWER_MASK
>> MAX_POWER_SHIFT
))
2584 enable_sq_ramping
= false;
2586 if (NISLANDS_DPM2_SQ_RAMP_MIN_POWER
> (MIN_POWER_MASK
>> MIN_POWER_SHIFT
))
2587 enable_sq_ramping
= false;
2589 if (NISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA
> (MAX_POWER_DELTA_MASK
>> MAX_POWER_DELTA_SHIFT
))
2590 enable_sq_ramping
= false;
2592 if (NISLANDS_DPM2_SQ_RAMP_STI_SIZE
> (STI_SIZE_MASK
>> STI_SIZE_SHIFT
))
2593 enable_sq_ramping
= false;
2595 if (NISLANDS_DPM2_SQ_RAMP_LTI_RATIO
> (LTI_RATIO_MASK
>> LTI_RATIO_SHIFT
))
2596 enable_sq_ramping
= false;
2598 for (i
= 0; i
< state
->performance_level_count
; i
++) {
2599 sq_power_throttle
= 0;
2600 sq_power_throttle2
= 0;
2602 if ((state
->performance_levels
[i
].sclk
>= rdev
->pm
.dpm
.sq_ramping_threshold
) &&
2603 enable_sq_ramping
) {
2604 sq_power_throttle
|= MAX_POWER(NISLANDS_DPM2_SQ_RAMP_MAX_POWER
);
2605 sq_power_throttle
|= MIN_POWER(NISLANDS_DPM2_SQ_RAMP_MIN_POWER
);
2606 sq_power_throttle2
|= MAX_POWER_DELTA(NISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA
);
2607 sq_power_throttle2
|= STI_SIZE(NISLANDS_DPM2_SQ_RAMP_STI_SIZE
);
2608 sq_power_throttle2
|= LTI_RATIO(NISLANDS_DPM2_SQ_RAMP_LTI_RATIO
);
2610 sq_power_throttle
|= MAX_POWER_MASK
| MIN_POWER_MASK
;
2611 sq_power_throttle2
|= MAX_POWER_DELTA_MASK
| STI_SIZE_MASK
| LTI_RATIO_MASK
;
2614 smc_state
->levels
[i
].SQPowerThrottle
= cpu_to_be32(sq_power_throttle
);
2615 smc_state
->levels
[i
].SQPowerThrottle_2
= cpu_to_be32(sq_power_throttle2
);
2621 static int ni_enable_power_containment(struct radeon_device
*rdev
,
2622 struct radeon_ps
*radeon_new_state
,
2625 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2626 PPSMC_Result smc_result
;
2629 if (ni_pi
->enable_power_containment
) {
2631 if (!r600_is_uvd_state(radeon_new_state
->class, radeon_new_state
->class2
)) {
2632 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_TDPClampingActive
);
2633 if (smc_result
!= PPSMC_Result_OK
) {
2635 ni_pi
->pc_enabled
= false;
2637 ni_pi
->pc_enabled
= true;
2641 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_TDPClampingInactive
);
2642 if (smc_result
!= PPSMC_Result_OK
)
2644 ni_pi
->pc_enabled
= false;
2651 static int ni_convert_power_state_to_smc(struct radeon_device
*rdev
,
2652 struct radeon_ps
*radeon_state
,
2653 NISLANDS_SMC_SWSTATE
*smc_state
)
2655 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
2656 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2657 struct ni_ps
*state
= ni_get_ps(radeon_state
);
2659 u32 threshold
= state
->performance_levels
[state
->performance_level_count
- 1].sclk
* 100 / 100;
2661 if (!(radeon_state
->caps
& ATOM_PPLIB_DISALLOW_ON_DC
))
2662 smc_state
->flags
|= PPSMC_SWSTATE_FLAG_DC
;
2664 smc_state
->levelCount
= 0;
2666 if (state
->performance_level_count
> NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE
)
2669 for (i
= 0; i
< state
->performance_level_count
; i
++) {
2670 ret
= ni_convert_power_level_to_smc(rdev
, &state
->performance_levels
[i
],
2671 &smc_state
->levels
[i
]);
2672 smc_state
->levels
[i
].arbRefreshState
=
2673 (u8
)(NISLANDS_DRIVER_STATE_ARB_INDEX
+ i
);
2678 if (ni_pi
->enable_power_containment
)
2679 smc_state
->levels
[i
].displayWatermark
=
2680 (state
->performance_levels
[i
].sclk
< threshold
) ?
2681 PPSMC_DISPLAY_WATERMARK_LOW
: PPSMC_DISPLAY_WATERMARK_HIGH
;
2683 smc_state
->levels
[i
].displayWatermark
= (i
< 2) ?
2684 PPSMC_DISPLAY_WATERMARK_LOW
: PPSMC_DISPLAY_WATERMARK_HIGH
;
2686 if (eg_pi
->dynamic_ac_timing
)
2687 smc_state
->levels
[i
].ACIndex
= NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
+ i
;
2689 smc_state
->levels
[i
].ACIndex
= 0;
2691 smc_state
->levelCount
++;
2694 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_watermark_threshold
,
2695 cpu_to_be32(threshold
/ 512));
2697 ni_populate_smc_sp(rdev
, radeon_state
, smc_state
);
2699 ret
= ni_populate_power_containment_values(rdev
, radeon_state
, smc_state
);
2701 ni_pi
->enable_power_containment
= false;
2703 ret
= ni_populate_sq_ramping_values(rdev
, radeon_state
, smc_state
);
2705 ni_pi
->enable_sq_ramping
= false;
2707 return ni_populate_smc_t(rdev
, radeon_state
, smc_state
);
2710 static int ni_upload_sw_state(struct radeon_device
*rdev
,
2711 struct radeon_ps
*radeon_new_state
)
2713 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2714 u16 address
= pi
->state_table_start
+
2715 offsetof(NISLANDS_SMC_STATETABLE
, driverState
);
2716 u16 state_size
= sizeof(NISLANDS_SMC_SWSTATE
) +
2717 ((NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE
- 1) * sizeof(NISLANDS_SMC_HW_PERFORMANCE_LEVEL
));
2719 NISLANDS_SMC_SWSTATE
*smc_state
= kzalloc(state_size
, GFP_KERNEL
);
2721 if (smc_state
== NULL
)
2724 ret
= ni_convert_power_state_to_smc(rdev
, radeon_new_state
, smc_state
);
2728 ret
= rv770_copy_bytes_to_smc(rdev
, address
, (u8
*)smc_state
, state_size
, pi
->sram_end
);
2736 static int ni_set_mc_special_registers(struct radeon_device
*rdev
,
2737 struct ni_mc_reg_table
*table
)
2739 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
2743 for (i
= 0, j
= table
->last
; i
< table
->last
; i
++) {
2744 switch (table
->mc_reg_address
[i
].s1
) {
2745 case MC_SEQ_MISC1
>> 2:
2746 if (j
>= SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2748 temp_reg
= RREG32(MC_PMG_CMD_EMRS
);
2749 table
->mc_reg_address
[j
].s1
= MC_PMG_CMD_EMRS
>> 2;
2750 table
->mc_reg_address
[j
].s0
= MC_SEQ_PMG_CMD_EMRS_LP
>> 2;
2751 for (k
= 0; k
< table
->num_entries
; k
++)
2752 table
->mc_reg_table_entry
[k
].mc_data
[j
] =
2753 ((temp_reg
& 0xffff0000)) |
2754 ((table
->mc_reg_table_entry
[k
].mc_data
[i
] & 0xffff0000) >> 16);
2756 if (j
>= SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2759 temp_reg
= RREG32(MC_PMG_CMD_MRS
);
2760 table
->mc_reg_address
[j
].s1
= MC_PMG_CMD_MRS
>> 2;
2761 table
->mc_reg_address
[j
].s0
= MC_SEQ_PMG_CMD_MRS_LP
>> 2;
2762 for(k
= 0; k
< table
->num_entries
; k
++) {
2763 table
->mc_reg_table_entry
[k
].mc_data
[j
] =
2764 (temp_reg
& 0xffff0000) |
2765 (table
->mc_reg_table_entry
[k
].mc_data
[i
] & 0x0000ffff);
2767 table
->mc_reg_table_entry
[k
].mc_data
[j
] |= 0x100;
2770 if (j
> SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2773 case MC_SEQ_RESERVE_M
>> 2:
2774 temp_reg
= RREG32(MC_PMG_CMD_MRS1
);
2775 table
->mc_reg_address
[j
].s1
= MC_PMG_CMD_MRS1
>> 2;
2776 table
->mc_reg_address
[j
].s0
= MC_SEQ_PMG_CMD_MRS1_LP
>> 2;
2777 for (k
= 0; k
< table
->num_entries
; k
++)
2778 table
->mc_reg_table_entry
[k
].mc_data
[j
] =
2779 (temp_reg
& 0xffff0000) |
2780 (table
->mc_reg_table_entry
[k
].mc_data
[i
] & 0x0000ffff);
2782 if (j
> SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2795 static bool ni_check_s0_mc_reg_index(u16 in_reg
, u16
*out_reg
)
2800 case MC_SEQ_RAS_TIMING
>> 2:
2801 *out_reg
= MC_SEQ_RAS_TIMING_LP
>> 2;
2803 case MC_SEQ_CAS_TIMING
>> 2:
2804 *out_reg
= MC_SEQ_CAS_TIMING_LP
>> 2;
2806 case MC_SEQ_MISC_TIMING
>> 2:
2807 *out_reg
= MC_SEQ_MISC_TIMING_LP
>> 2;
2809 case MC_SEQ_MISC_TIMING2
>> 2:
2810 *out_reg
= MC_SEQ_MISC_TIMING2_LP
>> 2;
2812 case MC_SEQ_RD_CTL_D0
>> 2:
2813 *out_reg
= MC_SEQ_RD_CTL_D0_LP
>> 2;
2815 case MC_SEQ_RD_CTL_D1
>> 2:
2816 *out_reg
= MC_SEQ_RD_CTL_D1_LP
>> 2;
2818 case MC_SEQ_WR_CTL_D0
>> 2:
2819 *out_reg
= MC_SEQ_WR_CTL_D0_LP
>> 2;
2821 case MC_SEQ_WR_CTL_D1
>> 2:
2822 *out_reg
= MC_SEQ_WR_CTL_D1_LP
>> 2;
2824 case MC_PMG_CMD_EMRS
>> 2:
2825 *out_reg
= MC_SEQ_PMG_CMD_EMRS_LP
>> 2;
2827 case MC_PMG_CMD_MRS
>> 2:
2828 *out_reg
= MC_SEQ_PMG_CMD_MRS_LP
>> 2;
2830 case MC_PMG_CMD_MRS1
>> 2:
2831 *out_reg
= MC_SEQ_PMG_CMD_MRS1_LP
>> 2;
2833 case MC_SEQ_PMG_TIMING
>> 2:
2834 *out_reg
= MC_SEQ_PMG_TIMING_LP
>> 2;
2836 case MC_PMG_CMD_MRS2
>> 2:
2837 *out_reg
= MC_SEQ_PMG_CMD_MRS2_LP
>> 2;
2847 static void ni_set_valid_flag(struct ni_mc_reg_table
*table
)
2851 for (i
= 0; i
< table
->last
; i
++) {
2852 for (j
= 1; j
< table
->num_entries
; j
++) {
2853 if (table
->mc_reg_table_entry
[j
-1].mc_data
[i
] != table
->mc_reg_table_entry
[j
].mc_data
[i
]) {
2854 table
->valid_flag
|= 1 << i
;
2861 static void ni_set_s0_mc_reg_index(struct ni_mc_reg_table
*table
)
2866 for (i
= 0; i
< table
->last
; i
++)
2867 table
->mc_reg_address
[i
].s0
=
2868 ni_check_s0_mc_reg_index(table
->mc_reg_address
[i
].s1
, &address
) ?
2869 address
: table
->mc_reg_address
[i
].s1
;
2872 static int ni_copy_vbios_mc_reg_table(struct atom_mc_reg_table
*table
,
2873 struct ni_mc_reg_table
*ni_table
)
2877 if (table
->last
> SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2879 if (table
->num_entries
> MAX_AC_TIMING_ENTRIES
)
2882 for (i
= 0; i
< table
->last
; i
++)
2883 ni_table
->mc_reg_address
[i
].s1
= table
->mc_reg_address
[i
].s1
;
2884 ni_table
->last
= table
->last
;
2886 for (i
= 0; i
< table
->num_entries
; i
++) {
2887 ni_table
->mc_reg_table_entry
[i
].mclk_max
=
2888 table
->mc_reg_table_entry
[i
].mclk_max
;
2889 for (j
= 0; j
< table
->last
; j
++)
2890 ni_table
->mc_reg_table_entry
[i
].mc_data
[j
] =
2891 table
->mc_reg_table_entry
[i
].mc_data
[j
];
2893 ni_table
->num_entries
= table
->num_entries
;
2898 static int ni_initialize_mc_reg_table(struct radeon_device
*rdev
)
2900 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2902 struct atom_mc_reg_table
*table
;
2903 struct ni_mc_reg_table
*ni_table
= &ni_pi
->mc_reg_table
;
2904 u8 module_index
= rv770_get_memory_module_index(rdev
);
2906 table
= kzalloc(sizeof(struct atom_mc_reg_table
), GFP_KERNEL
);
2910 WREG32(MC_SEQ_RAS_TIMING_LP
, RREG32(MC_SEQ_RAS_TIMING
));
2911 WREG32(MC_SEQ_CAS_TIMING_LP
, RREG32(MC_SEQ_CAS_TIMING
));
2912 WREG32(MC_SEQ_MISC_TIMING_LP
, RREG32(MC_SEQ_MISC_TIMING
));
2913 WREG32(MC_SEQ_MISC_TIMING2_LP
, RREG32(MC_SEQ_MISC_TIMING2
));
2914 WREG32(MC_SEQ_PMG_CMD_EMRS_LP
, RREG32(MC_PMG_CMD_EMRS
));
2915 WREG32(MC_SEQ_PMG_CMD_MRS_LP
, RREG32(MC_PMG_CMD_MRS
));
2916 WREG32(MC_SEQ_PMG_CMD_MRS1_LP
, RREG32(MC_PMG_CMD_MRS1
));
2917 WREG32(MC_SEQ_WR_CTL_D0_LP
, RREG32(MC_SEQ_WR_CTL_D0
));
2918 WREG32(MC_SEQ_WR_CTL_D1_LP
, RREG32(MC_SEQ_WR_CTL_D1
));
2919 WREG32(MC_SEQ_RD_CTL_D0_LP
, RREG32(MC_SEQ_RD_CTL_D0
));
2920 WREG32(MC_SEQ_RD_CTL_D1_LP
, RREG32(MC_SEQ_RD_CTL_D1
));
2921 WREG32(MC_SEQ_PMG_TIMING_LP
, RREG32(MC_SEQ_PMG_TIMING
));
2922 WREG32(MC_SEQ_PMG_CMD_MRS2_LP
, RREG32(MC_PMG_CMD_MRS2
));
2924 ret
= radeon_atom_init_mc_reg_table(rdev
, module_index
, table
);
2929 ret
= ni_copy_vbios_mc_reg_table(table
, ni_table
);
2934 ni_set_s0_mc_reg_index(ni_table
);
2936 ret
= ni_set_mc_special_registers(rdev
, ni_table
);
2941 ni_set_valid_flag(ni_table
);
2949 static void ni_populate_mc_reg_addresses(struct radeon_device
*rdev
,
2950 SMC_NIslands_MCRegisters
*mc_reg_table
)
2952 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2955 for (i
= 0, j
= 0; j
< ni_pi
->mc_reg_table
.last
; j
++) {
2956 if (ni_pi
->mc_reg_table
.valid_flag
& (1 << j
)) {
2957 if (i
>= SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
)
2959 mc_reg_table
->address
[i
].s0
=
2960 cpu_to_be16(ni_pi
->mc_reg_table
.mc_reg_address
[j
].s0
);
2961 mc_reg_table
->address
[i
].s1
=
2962 cpu_to_be16(ni_pi
->mc_reg_table
.mc_reg_address
[j
].s1
);
2966 mc_reg_table
->last
= (u8
)i
;
2970 static void ni_convert_mc_registers(struct ni_mc_reg_entry
*entry
,
2971 SMC_NIslands_MCRegisterSet
*data
,
2972 u32 num_entries
, u32 valid_flag
)
2976 for (i
= 0, j
= 0; j
< num_entries
; j
++) {
2977 if (valid_flag
& (1 << j
)) {
2978 data
->value
[i
] = cpu_to_be32(entry
->mc_data
[j
]);
2984 static void ni_convert_mc_reg_table_entry_to_smc(struct radeon_device
*rdev
,
2985 struct rv7xx_pl
*pl
,
2986 SMC_NIslands_MCRegisterSet
*mc_reg_table_data
)
2988 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
2991 for (i
= 0; i
< ni_pi
->mc_reg_table
.num_entries
; i
++) {
2992 if (pl
->mclk
<= ni_pi
->mc_reg_table
.mc_reg_table_entry
[i
].mclk_max
)
2996 if ((i
== ni_pi
->mc_reg_table
.num_entries
) && (i
> 0))
2999 ni_convert_mc_registers(&ni_pi
->mc_reg_table
.mc_reg_table_entry
[i
],
3001 ni_pi
->mc_reg_table
.last
,
3002 ni_pi
->mc_reg_table
.valid_flag
);
3005 static void ni_convert_mc_reg_table_to_smc(struct radeon_device
*rdev
,
3006 struct radeon_ps
*radeon_state
,
3007 SMC_NIslands_MCRegisters
*mc_reg_table
)
3009 struct ni_ps
*state
= ni_get_ps(radeon_state
);
3012 for (i
= 0; i
< state
->performance_level_count
; i
++) {
3013 ni_convert_mc_reg_table_entry_to_smc(rdev
,
3014 &state
->performance_levels
[i
],
3015 &mc_reg_table
->data
[NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
+ i
]);
3019 static int ni_populate_mc_reg_table(struct radeon_device
*rdev
,
3020 struct radeon_ps
*radeon_boot_state
)
3022 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3023 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3024 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3025 struct ni_ps
*boot_state
= ni_get_ps(radeon_boot_state
);
3026 SMC_NIslands_MCRegisters
*mc_reg_table
= &ni_pi
->smc_mc_reg_table
;
3028 memset(mc_reg_table
, 0, sizeof(SMC_NIslands_MCRegisters
));
3030 rv770_write_smc_soft_register(rdev
, NI_SMC_SOFT_REGISTER_seq_index
, 1);
3032 ni_populate_mc_reg_addresses(rdev
, mc_reg_table
);
3034 ni_convert_mc_reg_table_entry_to_smc(rdev
, &boot_state
->performance_levels
[0],
3035 &mc_reg_table
->data
[0]);
3037 ni_convert_mc_registers(&ni_pi
->mc_reg_table
.mc_reg_table_entry
[0],
3038 &mc_reg_table
->data
[1],
3039 ni_pi
->mc_reg_table
.last
,
3040 ni_pi
->mc_reg_table
.valid_flag
);
3042 ni_convert_mc_reg_table_to_smc(rdev
, radeon_boot_state
, mc_reg_table
);
3044 return rv770_copy_bytes_to_smc(rdev
, eg_pi
->mc_reg_table_start
,
3046 sizeof(SMC_NIslands_MCRegisters
),
3050 static int ni_upload_mc_reg_table(struct radeon_device
*rdev
,
3051 struct radeon_ps
*radeon_new_state
)
3053 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3054 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3055 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3056 struct ni_ps
*ni_new_state
= ni_get_ps(radeon_new_state
);
3057 SMC_NIslands_MCRegisters
*mc_reg_table
= &ni_pi
->smc_mc_reg_table
;
3060 memset(mc_reg_table
, 0, sizeof(SMC_NIslands_MCRegisters
));
3062 ni_convert_mc_reg_table_to_smc(rdev
, radeon_new_state
, mc_reg_table
);
3064 address
= eg_pi
->mc_reg_table_start
+
3065 (u16
)offsetof(SMC_NIslands_MCRegisters
, data
[NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
]);
3067 return rv770_copy_bytes_to_smc(rdev
, address
,
3068 (u8
*)&mc_reg_table
->data
[NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
],
3069 sizeof(SMC_NIslands_MCRegisterSet
) * ni_new_state
->performance_level_count
,
3073 static int ni_init_driver_calculated_leakage_table(struct radeon_device
*rdev
,
3074 PP_NIslands_CACTABLES
*cac_tables
)
3076 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3077 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3079 unsigned int i
, j
, table_size
;
3081 u32 smc_leakage
, max_leakage
= 0;
3084 table_size
= eg_pi
->vddc_voltage_table
.count
;
3086 if (SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
< table_size
)
3087 table_size
= SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
;
3089 scaling_factor
= ni_get_smc_power_scaling_factor(rdev
);
3091 for (i
= 0; i
< SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES
; i
++) {
3092 for (j
= 0; j
< table_size
; j
++) {
3093 t
= (1000 * ((i
+ 1) * 8));
3095 if (t
< ni_pi
->cac_data
.leakage_minimum_temperature
)
3096 t
= ni_pi
->cac_data
.leakage_minimum_temperature
;
3098 ni_calculate_leakage_for_v_and_t(rdev
,
3099 &ni_pi
->cac_data
.leakage_coefficients
,
3100 eg_pi
->vddc_voltage_table
.entries
[j
].value
,
3102 ni_pi
->cac_data
.i_leakage
,
3105 smc_leakage
= ni_scale_power_for_smc(leakage
, scaling_factor
) / 1000;
3106 if (smc_leakage
> max_leakage
)
3107 max_leakage
= smc_leakage
;
3109 cac_tables
->cac_lkge_lut
[i
][j
] = cpu_to_be32(smc_leakage
);
3113 for (j
= table_size
; j
< SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
; j
++) {
3114 for (i
= 0; i
< SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES
; i
++)
3115 cac_tables
->cac_lkge_lut
[i
][j
] = cpu_to_be32(max_leakage
);
3120 static int ni_init_simplified_leakage_table(struct radeon_device
*rdev
,
3121 PP_NIslands_CACTABLES
*cac_tables
)
3123 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3124 struct radeon_cac_leakage_table
*leakage_table
=
3125 &rdev
->pm
.dpm
.dyn_state
.cac_leakage_table
;
3126 u32 i
, j
, table_size
;
3127 u32 smc_leakage
, max_leakage
= 0;
3133 table_size
= leakage_table
->count
;
3135 if (eg_pi
->vddc_voltage_table
.count
!= table_size
)
3136 table_size
= (eg_pi
->vddc_voltage_table
.count
< leakage_table
->count
) ?
3137 eg_pi
->vddc_voltage_table
.count
: leakage_table
->count
;
3139 if (SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
< table_size
)
3140 table_size
= SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
;
3142 if (table_size
== 0)
3145 scaling_factor
= ni_get_smc_power_scaling_factor(rdev
);
3147 for (j
= 0; j
< table_size
; j
++) {
3148 smc_leakage
= leakage_table
->entries
[j
].leakage
;
3150 if (smc_leakage
> max_leakage
)
3151 max_leakage
= smc_leakage
;
3153 for (i
= 0; i
< SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES
; i
++)
3154 cac_tables
->cac_lkge_lut
[i
][j
] =
3155 cpu_to_be32(ni_scale_power_for_smc(smc_leakage
, scaling_factor
));
3158 for (j
= table_size
; j
< SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES
; j
++) {
3159 for (i
= 0; i
< SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES
; i
++)
3160 cac_tables
->cac_lkge_lut
[i
][j
] =
3161 cpu_to_be32(ni_scale_power_for_smc(max_leakage
, scaling_factor
));
3166 static int ni_initialize_smc_cac_tables(struct radeon_device
*rdev
)
3168 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3169 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3170 PP_NIslands_CACTABLES
*cac_tables
= NULL
;
3174 if (ni_pi
->enable_cac
== false)
3177 cac_tables
= kzalloc(sizeof(PP_NIslands_CACTABLES
), GFP_KERNEL
);
3181 reg
= RREG32(CG_CAC_CTRL
) & ~(TID_CNT_MASK
| TID_UNIT_MASK
);
3182 reg
|= (TID_CNT(ni_pi
->cac_weights
->tid_cnt
) |
3183 TID_UNIT(ni_pi
->cac_weights
->tid_unit
));
3184 WREG32(CG_CAC_CTRL
, reg
);
3186 for (i
= 0; i
< NISLANDS_DCCAC_MAX_LEVELS
; i
++)
3187 ni_pi
->dc_cac_table
[i
] = ni_pi
->cac_weights
->dc_cac
[i
];
3189 for (i
= 0; i
< SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES
; i
++)
3190 cac_tables
->cac_bif_lut
[i
] = ni_pi
->cac_weights
->pcie_cac
[i
];
3192 ni_pi
->cac_data
.i_leakage
= rdev
->pm
.dpm
.cac_leakage
;
3193 ni_pi
->cac_data
.pwr_const
= 0;
3194 ni_pi
->cac_data
.dc_cac_value
= ni_pi
->dc_cac_table
[NISLANDS_DCCAC_LEVEL_0
];
3195 ni_pi
->cac_data
.bif_cac_value
= 0;
3196 ni_pi
->cac_data
.mc_wr_weight
= ni_pi
->cac_weights
->mc_write_weight
;
3197 ni_pi
->cac_data
.mc_rd_weight
= ni_pi
->cac_weights
->mc_read_weight
;
3198 ni_pi
->cac_data
.allow_ovrflw
= 0;
3199 ni_pi
->cac_data
.l2num_win_tdp
= ni_pi
->lta_window_size
;
3200 ni_pi
->cac_data
.num_win_tdp
= 0;
3201 ni_pi
->cac_data
.lts_truncate_n
= ni_pi
->lts_truncate
;
3203 if (ni_pi
->driver_calculate_cac_leakage
)
3204 ret
= ni_init_driver_calculated_leakage_table(rdev
, cac_tables
);
3206 ret
= ni_init_simplified_leakage_table(rdev
, cac_tables
);
3211 cac_tables
->pwr_const
= cpu_to_be32(ni_pi
->cac_data
.pwr_const
);
3212 cac_tables
->dc_cacValue
= cpu_to_be32(ni_pi
->cac_data
.dc_cac_value
);
3213 cac_tables
->bif_cacValue
= cpu_to_be32(ni_pi
->cac_data
.bif_cac_value
);
3214 cac_tables
->AllowOvrflw
= ni_pi
->cac_data
.allow_ovrflw
;
3215 cac_tables
->MCWrWeight
= ni_pi
->cac_data
.mc_wr_weight
;
3216 cac_tables
->MCRdWeight
= ni_pi
->cac_data
.mc_rd_weight
;
3217 cac_tables
->numWin_TDP
= ni_pi
->cac_data
.num_win_tdp
;
3218 cac_tables
->l2numWin_TDP
= ni_pi
->cac_data
.l2num_win_tdp
;
3219 cac_tables
->lts_truncate_n
= ni_pi
->cac_data
.lts_truncate_n
;
3221 ret
= rv770_copy_bytes_to_smc(rdev
, ni_pi
->cac_table_start
, (u8
*)cac_tables
,
3222 sizeof(PP_NIslands_CACTABLES
), pi
->sram_end
);
3226 ni_pi
->enable_cac
= false;
3227 ni_pi
->enable_power_containment
= false;
3235 static int ni_initialize_hardware_cac_manager(struct radeon_device
*rdev
)
3237 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3240 if (!ni_pi
->enable_cac
||
3241 !ni_pi
->cac_configuration_required
)
3244 if (ni_pi
->cac_weights
== NULL
)
3247 reg
= RREG32_CG(CG_CAC_REGION_1_WEIGHT_0
) & ~(WEIGHT_TCP_SIG0_MASK
|
3248 WEIGHT_TCP_SIG1_MASK
|
3249 WEIGHT_TA_SIG_MASK
);
3250 reg
|= (WEIGHT_TCP_SIG0(ni_pi
->cac_weights
->weight_tcp_sig0
) |
3251 WEIGHT_TCP_SIG1(ni_pi
->cac_weights
->weight_tcp_sig1
) |
3252 WEIGHT_TA_SIG(ni_pi
->cac_weights
->weight_ta_sig
));
3253 WREG32_CG(CG_CAC_REGION_1_WEIGHT_0
, reg
);
3255 reg
= RREG32_CG(CG_CAC_REGION_1_WEIGHT_1
) & ~(WEIGHT_TCC_EN0_MASK
|
3256 WEIGHT_TCC_EN1_MASK
|
3257 WEIGHT_TCC_EN2_MASK
);
3258 reg
|= (WEIGHT_TCC_EN0(ni_pi
->cac_weights
->weight_tcc_en0
) |
3259 WEIGHT_TCC_EN1(ni_pi
->cac_weights
->weight_tcc_en1
) |
3260 WEIGHT_TCC_EN2(ni_pi
->cac_weights
->weight_tcc_en2
));
3261 WREG32_CG(CG_CAC_REGION_1_WEIGHT_1
, reg
);
3263 reg
= RREG32_CG(CG_CAC_REGION_2_WEIGHT_0
) & ~(WEIGHT_CB_EN0_MASK
|
3264 WEIGHT_CB_EN1_MASK
|
3265 WEIGHT_CB_EN2_MASK
|
3266 WEIGHT_CB_EN3_MASK
);
3267 reg
|= (WEIGHT_CB_EN0(ni_pi
->cac_weights
->weight_cb_en0
) |
3268 WEIGHT_CB_EN1(ni_pi
->cac_weights
->weight_cb_en1
) |
3269 WEIGHT_CB_EN2(ni_pi
->cac_weights
->weight_cb_en2
) |
3270 WEIGHT_CB_EN3(ni_pi
->cac_weights
->weight_cb_en3
));
3271 WREG32_CG(CG_CAC_REGION_2_WEIGHT_0
, reg
);
3273 reg
= RREG32_CG(CG_CAC_REGION_2_WEIGHT_1
) & ~(WEIGHT_DB_SIG0_MASK
|
3274 WEIGHT_DB_SIG1_MASK
|
3275 WEIGHT_DB_SIG2_MASK
|
3276 WEIGHT_DB_SIG3_MASK
);
3277 reg
|= (WEIGHT_DB_SIG0(ni_pi
->cac_weights
->weight_db_sig0
) |
3278 WEIGHT_DB_SIG1(ni_pi
->cac_weights
->weight_db_sig1
) |
3279 WEIGHT_DB_SIG2(ni_pi
->cac_weights
->weight_db_sig2
) |
3280 WEIGHT_DB_SIG3(ni_pi
->cac_weights
->weight_db_sig3
));
3281 WREG32_CG(CG_CAC_REGION_2_WEIGHT_1
, reg
);
3283 reg
= RREG32_CG(CG_CAC_REGION_2_WEIGHT_2
) & ~(WEIGHT_SXM_SIG0_MASK
|
3284 WEIGHT_SXM_SIG1_MASK
|
3285 WEIGHT_SXM_SIG2_MASK
|
3286 WEIGHT_SXS_SIG0_MASK
|
3287 WEIGHT_SXS_SIG1_MASK
);
3288 reg
|= (WEIGHT_SXM_SIG0(ni_pi
->cac_weights
->weight_sxm_sig0
) |
3289 WEIGHT_SXM_SIG1(ni_pi
->cac_weights
->weight_sxm_sig1
) |
3290 WEIGHT_SXM_SIG2(ni_pi
->cac_weights
->weight_sxm_sig2
) |
3291 WEIGHT_SXS_SIG0(ni_pi
->cac_weights
->weight_sxs_sig0
) |
3292 WEIGHT_SXS_SIG1(ni_pi
->cac_weights
->weight_sxs_sig1
));
3293 WREG32_CG(CG_CAC_REGION_2_WEIGHT_2
, reg
);
3295 reg
= RREG32_CG(CG_CAC_REGION_3_WEIGHT_0
) & ~(WEIGHT_XBR_0_MASK
|
3298 WEIGHT_SPI_SIG0_MASK
);
3299 reg
|= (WEIGHT_XBR_0(ni_pi
->cac_weights
->weight_xbr_0
) |
3300 WEIGHT_XBR_1(ni_pi
->cac_weights
->weight_xbr_1
) |
3301 WEIGHT_XBR_2(ni_pi
->cac_weights
->weight_xbr_2
) |
3302 WEIGHT_SPI_SIG0(ni_pi
->cac_weights
->weight_spi_sig0
));
3303 WREG32_CG(CG_CAC_REGION_3_WEIGHT_0
, reg
);
3305 reg
= RREG32_CG(CG_CAC_REGION_3_WEIGHT_1
) & ~(WEIGHT_SPI_SIG1_MASK
|
3306 WEIGHT_SPI_SIG2_MASK
|
3307 WEIGHT_SPI_SIG3_MASK
|
3308 WEIGHT_SPI_SIG4_MASK
|
3309 WEIGHT_SPI_SIG5_MASK
);
3310 reg
|= (WEIGHT_SPI_SIG1(ni_pi
->cac_weights
->weight_spi_sig1
) |
3311 WEIGHT_SPI_SIG2(ni_pi
->cac_weights
->weight_spi_sig2
) |
3312 WEIGHT_SPI_SIG3(ni_pi
->cac_weights
->weight_spi_sig3
) |
3313 WEIGHT_SPI_SIG4(ni_pi
->cac_weights
->weight_spi_sig4
) |
3314 WEIGHT_SPI_SIG5(ni_pi
->cac_weights
->weight_spi_sig5
));
3315 WREG32_CG(CG_CAC_REGION_3_WEIGHT_1
, reg
);
3317 reg
= RREG32_CG(CG_CAC_REGION_4_WEIGHT_0
) & ~(WEIGHT_LDS_SIG0_MASK
|
3318 WEIGHT_LDS_SIG1_MASK
|
3320 reg
|= (WEIGHT_LDS_SIG0(ni_pi
->cac_weights
->weight_lds_sig0
) |
3321 WEIGHT_LDS_SIG1(ni_pi
->cac_weights
->weight_lds_sig1
) |
3322 WEIGHT_SC(ni_pi
->cac_weights
->weight_sc
));
3323 WREG32_CG(CG_CAC_REGION_4_WEIGHT_0
, reg
);
3325 reg
= RREG32_CG(CG_CAC_REGION_4_WEIGHT_1
) & ~(WEIGHT_BIF_MASK
|
3327 WEIGHT_PA_SIG0_MASK
|
3328 WEIGHT_PA_SIG1_MASK
|
3329 WEIGHT_VGT_SIG0_MASK
);
3330 reg
|= (WEIGHT_BIF(ni_pi
->cac_weights
->weight_bif
) |
3331 WEIGHT_CP(ni_pi
->cac_weights
->weight_cp
) |
3332 WEIGHT_PA_SIG0(ni_pi
->cac_weights
->weight_pa_sig0
) |
3333 WEIGHT_PA_SIG1(ni_pi
->cac_weights
->weight_pa_sig1
) |
3334 WEIGHT_VGT_SIG0(ni_pi
->cac_weights
->weight_vgt_sig0
));
3335 WREG32_CG(CG_CAC_REGION_4_WEIGHT_1
, reg
);
3337 reg
= RREG32_CG(CG_CAC_REGION_4_WEIGHT_2
) & ~(WEIGHT_VGT_SIG1_MASK
|
3338 WEIGHT_VGT_SIG2_MASK
|
3339 WEIGHT_DC_SIG0_MASK
|
3340 WEIGHT_DC_SIG1_MASK
|
3341 WEIGHT_DC_SIG2_MASK
);
3342 reg
|= (WEIGHT_VGT_SIG1(ni_pi
->cac_weights
->weight_vgt_sig1
) |
3343 WEIGHT_VGT_SIG2(ni_pi
->cac_weights
->weight_vgt_sig2
) |
3344 WEIGHT_DC_SIG0(ni_pi
->cac_weights
->weight_dc_sig0
) |
3345 WEIGHT_DC_SIG1(ni_pi
->cac_weights
->weight_dc_sig1
) |
3346 WEIGHT_DC_SIG2(ni_pi
->cac_weights
->weight_dc_sig2
));
3347 WREG32_CG(CG_CAC_REGION_4_WEIGHT_2
, reg
);
3349 reg
= RREG32_CG(CG_CAC_REGION_4_WEIGHT_3
) & ~(WEIGHT_DC_SIG3_MASK
|
3350 WEIGHT_UVD_SIG0_MASK
|
3351 WEIGHT_UVD_SIG1_MASK
|
3352 WEIGHT_SPARE0_MASK
|
3353 WEIGHT_SPARE1_MASK
);
3354 reg
|= (WEIGHT_DC_SIG3(ni_pi
->cac_weights
->weight_dc_sig3
) |
3355 WEIGHT_UVD_SIG0(ni_pi
->cac_weights
->weight_uvd_sig0
) |
3356 WEIGHT_UVD_SIG1(ni_pi
->cac_weights
->weight_uvd_sig1
) |
3357 WEIGHT_SPARE0(ni_pi
->cac_weights
->weight_spare0
) |
3358 WEIGHT_SPARE1(ni_pi
->cac_weights
->weight_spare1
));
3359 WREG32_CG(CG_CAC_REGION_4_WEIGHT_3
, reg
);
3361 reg
= RREG32_CG(CG_CAC_REGION_5_WEIGHT_0
) & ~(WEIGHT_SQ_VSP_MASK
|
3362 WEIGHT_SQ_VSP0_MASK
);
3363 reg
|= (WEIGHT_SQ_VSP(ni_pi
->cac_weights
->weight_sq_vsp
) |
3364 WEIGHT_SQ_VSP0(ni_pi
->cac_weights
->weight_sq_vsp0
));
3365 WREG32_CG(CG_CAC_REGION_5_WEIGHT_0
, reg
);
3367 reg
= RREG32_CG(CG_CAC_REGION_5_WEIGHT_1
) & ~(WEIGHT_SQ_GPR_MASK
);
3368 reg
|= WEIGHT_SQ_GPR(ni_pi
->cac_weights
->weight_sq_gpr
);
3369 WREG32_CG(CG_CAC_REGION_5_WEIGHT_1
, reg
);
3371 reg
= RREG32_CG(CG_CAC_REGION_4_OVERRIDE_4
) & ~(OVR_MODE_SPARE_0_MASK
|
3372 OVR_VAL_SPARE_0_MASK
|
3373 OVR_MODE_SPARE_1_MASK
|
3374 OVR_VAL_SPARE_1_MASK
);
3375 reg
|= (OVR_MODE_SPARE_0(ni_pi
->cac_weights
->ovr_mode_spare_0
) |
3376 OVR_VAL_SPARE_0(ni_pi
->cac_weights
->ovr_val_spare_0
) |
3377 OVR_MODE_SPARE_1(ni_pi
->cac_weights
->ovr_mode_spare_1
) |
3378 OVR_VAL_SPARE_1(ni_pi
->cac_weights
->ovr_val_spare_1
));
3379 WREG32_CG(CG_CAC_REGION_4_OVERRIDE_4
, reg
);
3381 reg
= RREG32(SQ_CAC_THRESHOLD
) & ~(VSP_MASK
|
3384 reg
|= (VSP(ni_pi
->cac_weights
->vsp
) |
3385 VSP0(ni_pi
->cac_weights
->vsp0
) |
3386 GPR(ni_pi
->cac_weights
->gpr
));
3387 WREG32(SQ_CAC_THRESHOLD
, reg
);
3389 reg
= (MCDW_WR_ENABLE
|
3394 WREG32(MC_CG_CONFIG
, reg
);
3396 reg
= (READ_WEIGHT(ni_pi
->cac_weights
->mc_read_weight
) |
3397 WRITE_WEIGHT(ni_pi
->cac_weights
->mc_write_weight
) |
3399 WREG32(MC_CG_DATAPORT
, reg
);
3404 static int ni_enable_smc_cac(struct radeon_device
*rdev
,
3405 struct radeon_ps
*radeon_new_state
,
3408 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3410 PPSMC_Result smc_result
;
3412 if (ni_pi
->enable_cac
) {
3414 if (!r600_is_uvd_state(radeon_new_state
->class, radeon_new_state
->class2
)) {
3415 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_MSG_CollectCAC_PowerCorreln
);
3417 if (ni_pi
->support_cac_long_term_average
) {
3418 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_CACLongTermAvgEnable
);
3419 if (PPSMC_Result_OK
!= smc_result
)
3420 ni_pi
->support_cac_long_term_average
= false;
3423 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_MSG_EnableCac
);
3424 if (PPSMC_Result_OK
!= smc_result
)
3427 ni_pi
->cac_enabled
= (PPSMC_Result_OK
== smc_result
) ? true : false;
3429 } else if (ni_pi
->cac_enabled
) {
3430 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_MSG_DisableCac
);
3432 ni_pi
->cac_enabled
= false;
3434 if (ni_pi
->support_cac_long_term_average
) {
3435 smc_result
= rv770_send_msg_to_smc(rdev
, PPSMC_CACLongTermAvgDisable
);
3436 if (PPSMC_Result_OK
!= smc_result
)
3437 ni_pi
->support_cac_long_term_average
= false;
3445 static int ni_pcie_performance_request(struct radeon_device
*rdev
,
3446 u8 perf_req
, bool advertise
)
3448 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3450 #if defined(CONFIG_ACPI)
3451 if ((perf_req
== PCIE_PERF_REQ_PECI_GEN1
) ||
3452 (perf_req
== PCIE_PERF_REQ_PECI_GEN2
)) {
3453 if (eg_pi
->pcie_performance_request_registered
== false)
3454 radeon_acpi_pcie_notify_device_ready(rdev
);
3455 eg_pi
->pcie_performance_request_registered
= true;
3456 return radeon_acpi_pcie_performance_request(rdev
, perf_req
, advertise
);
3457 } else if ((perf_req
== PCIE_PERF_REQ_REMOVE_REGISTRY
) &&
3458 eg_pi
->pcie_performance_request_registered
) {
3459 eg_pi
->pcie_performance_request_registered
= false;
3460 return radeon_acpi_pcie_performance_request(rdev
, perf_req
, advertise
);
3466 static int ni_advertise_gen2_capability(struct radeon_device
*rdev
)
3468 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3471 tmp
= RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
);
3473 if ((tmp
& LC_OTHER_SIDE_EVER_SENT_GEN2
) &&
3474 (tmp
& LC_OTHER_SIDE_SUPPORTS_GEN2
))
3475 pi
->pcie_gen2
= true;
3477 pi
->pcie_gen2
= false;
3480 ni_pcie_performance_request(rdev
, PCIE_PERF_REQ_PECI_GEN2
, true);
3485 static void ni_enable_bif_dynamic_pcie_gen2(struct radeon_device
*rdev
,
3488 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3491 tmp
= RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
);
3493 if ((tmp
& LC_OTHER_SIDE_EVER_SENT_GEN2
) &&
3494 (tmp
& LC_OTHER_SIDE_SUPPORTS_GEN2
)) {
3496 if (!pi
->boot_in_gen2
) {
3497 bif
= RREG32(CG_BIF_REQ_AND_RSP
) & ~CG_CLIENT_REQ_MASK
;
3498 bif
|= CG_CLIENT_REQ(0xd);
3499 WREG32(CG_BIF_REQ_AND_RSP
, bif
);
3501 tmp
&= ~LC_HW_VOLTAGE_IF_CONTROL_MASK
;
3502 tmp
|= LC_HW_VOLTAGE_IF_CONTROL(1);
3503 tmp
|= LC_GEN2_EN_STRAP
;
3505 tmp
|= LC_CLR_FAILED_SPD_CHANGE_CNT
;
3506 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
, tmp
);
3508 tmp
&= ~LC_CLR_FAILED_SPD_CHANGE_CNT
;
3509 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
, tmp
);
3511 if (!pi
->boot_in_gen2
) {
3512 bif
= RREG32(CG_BIF_REQ_AND_RSP
) & ~CG_CLIENT_REQ_MASK
;
3513 bif
|= CG_CLIENT_REQ(0xd);
3514 WREG32(CG_BIF_REQ_AND_RSP
, bif
);
3516 tmp
&= ~LC_HW_VOLTAGE_IF_CONTROL_MASK
;
3517 tmp
&= ~LC_GEN2_EN_STRAP
;
3519 WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL
, tmp
);
3524 static void ni_enable_dynamic_pcie_gen2(struct radeon_device
*rdev
,
3527 ni_enable_bif_dynamic_pcie_gen2(rdev
, enable
);
3530 WREG32_P(GENERAL_PWRMGT
, ENABLE_GEN2PCIE
, ~ENABLE_GEN2PCIE
);
3532 WREG32_P(GENERAL_PWRMGT
, 0, ~ENABLE_GEN2PCIE
);
3535 void ni_set_uvd_clock_before_set_eng_clock(struct radeon_device
*rdev
,
3536 struct radeon_ps
*new_ps
,
3537 struct radeon_ps
*old_ps
)
3539 struct ni_ps
*new_state
= ni_get_ps(new_ps
);
3540 struct ni_ps
*current_state
= ni_get_ps(old_ps
);
3542 if ((new_ps
->vclk
== old_ps
->vclk
) &&
3543 (new_ps
->dclk
== old_ps
->dclk
))
3546 if (new_state
->performance_levels
[new_state
->performance_level_count
- 1].sclk
>=
3547 current_state
->performance_levels
[current_state
->performance_level_count
- 1].sclk
)
3550 radeon_set_uvd_clocks(rdev
, new_ps
->vclk
, new_ps
->dclk
);
3553 void ni_set_uvd_clock_after_set_eng_clock(struct radeon_device
*rdev
,
3554 struct radeon_ps
*new_ps
,
3555 struct radeon_ps
*old_ps
)
3557 struct ni_ps
*new_state
= ni_get_ps(new_ps
);
3558 struct ni_ps
*current_state
= ni_get_ps(old_ps
);
3560 if ((new_ps
->vclk
== old_ps
->vclk
) &&
3561 (new_ps
->dclk
== old_ps
->dclk
))
3564 if (new_state
->performance_levels
[new_state
->performance_level_count
- 1].sclk
<
3565 current_state
->performance_levels
[current_state
->performance_level_count
- 1].sclk
)
3568 radeon_set_uvd_clocks(rdev
, new_ps
->vclk
, new_ps
->dclk
);
3571 void ni_dpm_setup_asic(struct radeon_device
*rdev
)
3573 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3575 ni_read_clock_registers(rdev
);
3576 btc_read_arb_registers(rdev
);
3577 rv770_get_memory_type(rdev
);
3578 if (eg_pi
->pcie_performance_request
)
3579 ni_advertise_gen2_capability(rdev
);
3580 rv770_get_pcie_gen2_status(rdev
);
3581 rv770_enable_acpi_pm(rdev
);
3584 void ni_update_current_ps(struct radeon_device
*rdev
,
3585 struct radeon_ps
*rps
)
3587 struct ni_ps
*new_ps
= ni_get_ps(rps
);
3588 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3589 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3591 eg_pi
->current_rps
= *rps
;
3592 ni_pi
->current_ps
= *new_ps
;
3593 eg_pi
->current_rps
.ps_priv
= &ni_pi
->current_ps
;
3596 void ni_update_requested_ps(struct radeon_device
*rdev
,
3597 struct radeon_ps
*rps
)
3599 struct ni_ps
*new_ps
= ni_get_ps(rps
);
3600 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3601 struct ni_power_info
*ni_pi
= ni_get_pi(rdev
);
3603 eg_pi
->requested_rps
= *rps
;
3604 ni_pi
->requested_ps
= *new_ps
;
3605 eg_pi
->requested_rps
.ps_priv
= &ni_pi
->requested_ps
;
3608 int ni_dpm_enable(struct radeon_device
*rdev
)
3610 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3611 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3612 struct radeon_ps
*boot_ps
= rdev
->pm
.dpm
.boot_ps
;
3615 if (pi
->gfx_clock_gating
)
3616 ni_cg_clockgating_default(rdev
);
3617 if (btc_dpm_enabled(rdev
))
3619 if (pi
->mg_clock_gating
)
3620 ni_mg_clockgating_default(rdev
);
3621 if (eg_pi
->ls_clock_gating
)
3622 ni_ls_clockgating_default(rdev
);
3623 if (pi
->voltage_control
) {
3624 rv770_enable_voltage_control(rdev
, true);
3625 ret
= cypress_construct_voltage_tables(rdev
);
3627 DRM_ERROR("cypress_construct_voltage_tables failed\n");
3631 if (eg_pi
->dynamic_ac_timing
) {
3632 ret
= ni_initialize_mc_reg_table(rdev
);
3634 eg_pi
->dynamic_ac_timing
= false;
3637 cypress_enable_spread_spectrum(rdev
, true);
3638 if (pi
->thermal_protection
)
3639 rv770_enable_thermal_protection(rdev
, true);
3640 rv770_setup_bsp(rdev
);
3641 rv770_program_git(rdev
);
3642 rv770_program_tp(rdev
);
3643 rv770_program_tpp(rdev
);
3644 rv770_program_sstp(rdev
);
3645 cypress_enable_display_gap(rdev
);
3646 rv770_program_vc(rdev
);
3647 if (pi
->dynamic_pcie_gen2
)
3648 ni_enable_dynamic_pcie_gen2(rdev
, true);
3649 ret
= rv770_upload_firmware(rdev
);
3651 DRM_ERROR("rv770_upload_firmware failed\n");
3654 ret
= ni_process_firmware_header(rdev
);
3656 DRM_ERROR("ni_process_firmware_header failed\n");
3659 ret
= ni_initial_switch_from_arb_f0_to_f1(rdev
);
3661 DRM_ERROR("ni_initial_switch_from_arb_f0_to_f1 failed\n");
3664 ret
= ni_init_smc_table(rdev
);
3666 DRM_ERROR("ni_init_smc_table failed\n");
3669 ret
= ni_init_smc_spll_table(rdev
);
3671 DRM_ERROR("ni_init_smc_spll_table failed\n");
3674 ret
= ni_init_arb_table_index(rdev
);
3676 DRM_ERROR("ni_init_arb_table_index failed\n");
3679 if (eg_pi
->dynamic_ac_timing
) {
3680 ret
= ni_populate_mc_reg_table(rdev
, boot_ps
);
3682 DRM_ERROR("ni_populate_mc_reg_table failed\n");
3686 ret
= ni_initialize_smc_cac_tables(rdev
);
3688 DRM_ERROR("ni_initialize_smc_cac_tables failed\n");
3691 ret
= ni_initialize_hardware_cac_manager(rdev
);
3693 DRM_ERROR("ni_initialize_hardware_cac_manager failed\n");
3696 ret
= ni_populate_smc_tdp_limits(rdev
, boot_ps
);
3698 DRM_ERROR("ni_populate_smc_tdp_limits failed\n");
3701 ni_program_response_times(rdev
);
3702 r7xx_start_smc(rdev
);
3703 ret
= cypress_notify_smc_display_change(rdev
, false);
3705 DRM_ERROR("cypress_notify_smc_display_change failed\n");
3708 cypress_enable_sclk_control(rdev
, true);
3709 if (eg_pi
->memory_transition
)
3710 cypress_enable_mclk_control(rdev
, true);
3711 cypress_start_dpm(rdev
);
3712 if (pi
->gfx_clock_gating
)
3713 ni_gfx_clockgating_enable(rdev
, true);
3714 if (pi
->mg_clock_gating
)
3715 ni_mg_clockgating_enable(rdev
, true);
3716 if (eg_pi
->ls_clock_gating
)
3717 ni_ls_clockgating_enable(rdev
, true);
3719 if (rdev
->irq
.installed
&&
3720 r600_is_internal_thermal_sensor(rdev
->pm
.int_thermal_type
)) {
3721 PPSMC_Result result
;
3723 ret
= rv770_set_thermal_temperature_range(rdev
, R600_TEMP_RANGE_MIN
, 0xff * 1000);
3726 rdev
->irq
.dpm_thermal
= true;
3727 radeon_irq_set(rdev
);
3728 result
= rv770_send_msg_to_smc(rdev
, PPSMC_MSG_EnableThermalInterrupt
);
3730 if (result
!= PPSMC_Result_OK
)
3731 DRM_DEBUG_KMS("Could not enable thermal interrupts.\n");
3734 rv770_enable_auto_throttle_source(rdev
, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL
, true);
3736 ni_update_current_ps(rdev
, boot_ps
);
3741 void ni_dpm_disable(struct radeon_device
*rdev
)
3743 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3744 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3745 struct radeon_ps
*boot_ps
= rdev
->pm
.dpm
.boot_ps
;
3747 if (!btc_dpm_enabled(rdev
))
3749 rv770_clear_vc(rdev
);
3750 if (pi
->thermal_protection
)
3751 rv770_enable_thermal_protection(rdev
, false);
3752 ni_enable_power_containment(rdev
, boot_ps
, false);
3753 ni_enable_smc_cac(rdev
, boot_ps
, false);
3754 cypress_enable_spread_spectrum(rdev
, false);
3755 rv770_enable_auto_throttle_source(rdev
, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL
, false);
3756 if (pi
->dynamic_pcie_gen2
)
3757 ni_enable_dynamic_pcie_gen2(rdev
, false);
3759 if (rdev
->irq
.installed
&&
3760 r600_is_internal_thermal_sensor(rdev
->pm
.int_thermal_type
)) {
3761 rdev
->irq
.dpm_thermal
= false;
3762 radeon_irq_set(rdev
);
3765 if (pi
->gfx_clock_gating
)
3766 ni_gfx_clockgating_enable(rdev
, false);
3767 if (pi
->mg_clock_gating
)
3768 ni_mg_clockgating_enable(rdev
, false);
3769 if (eg_pi
->ls_clock_gating
)
3770 ni_ls_clockgating_enable(rdev
, false);
3772 btc_reset_to_default(rdev
);
3774 ni_force_switch_to_arb_f0(rdev
);
3776 ni_update_current_ps(rdev
, boot_ps
);
3779 static int ni_power_control_set_level(struct radeon_device
*rdev
)
3781 struct radeon_ps
*new_ps
= rdev
->pm
.dpm
.requested_ps
;
3784 ret
= ni_restrict_performance_levels_before_switch(rdev
);
3787 ret
= rv770_halt_smc(rdev
);
3790 ret
= ni_populate_smc_tdp_limits(rdev
, new_ps
);
3793 ret
= rv770_resume_smc(rdev
);
3796 ret
= rv770_set_sw_state(rdev
);
3803 int ni_dpm_pre_set_power_state(struct radeon_device
*rdev
)
3805 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3806 struct radeon_ps requested_ps
= *rdev
->pm
.dpm
.requested_ps
;
3807 struct radeon_ps
*new_ps
= &requested_ps
;
3809 ni_update_requested_ps(rdev
, new_ps
);
3811 ni_apply_state_adjust_rules(rdev
, &eg_pi
->requested_rps
);
3816 int ni_dpm_set_power_state(struct radeon_device
*rdev
)
3818 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3819 struct radeon_ps
*new_ps
= &eg_pi
->requested_rps
;
3820 struct radeon_ps
*old_ps
= &eg_pi
->current_rps
;
3823 ret
= ni_restrict_performance_levels_before_switch(rdev
);
3825 DRM_ERROR("ni_restrict_performance_levels_before_switch failed\n");
3828 ni_set_uvd_clock_before_set_eng_clock(rdev
, new_ps
, old_ps
);
3829 ret
= ni_enable_power_containment(rdev
, new_ps
, false);
3831 DRM_ERROR("ni_enable_power_containment failed\n");
3834 ret
= ni_enable_smc_cac(rdev
, new_ps
, false);
3836 DRM_ERROR("ni_enable_smc_cac failed\n");
3839 ret
= rv770_halt_smc(rdev
);
3841 DRM_ERROR("rv770_halt_smc failed\n");
3844 if (eg_pi
->smu_uvd_hs
)
3845 btc_notify_uvd_to_smc(rdev
, new_ps
);
3846 ret
= ni_upload_sw_state(rdev
, new_ps
);
3848 DRM_ERROR("ni_upload_sw_state failed\n");
3851 if (eg_pi
->dynamic_ac_timing
) {
3852 ret
= ni_upload_mc_reg_table(rdev
, new_ps
);
3854 DRM_ERROR("ni_upload_mc_reg_table failed\n");
3858 ret
= ni_program_memory_timing_parameters(rdev
, new_ps
);
3860 DRM_ERROR("ni_program_memory_timing_parameters failed\n");
3863 ret
= rv770_resume_smc(rdev
);
3865 DRM_ERROR("rv770_resume_smc failed\n");
3868 ret
= rv770_set_sw_state(rdev
);
3870 DRM_ERROR("rv770_set_sw_state failed\n");
3873 ni_set_uvd_clock_after_set_eng_clock(rdev
, new_ps
, old_ps
);
3874 ret
= ni_enable_smc_cac(rdev
, new_ps
, true);
3876 DRM_ERROR("ni_enable_smc_cac failed\n");
3879 ret
= ni_enable_power_containment(rdev
, new_ps
, true);
3881 DRM_ERROR("ni_enable_power_containment failed\n");
3886 ret
= ni_power_control_set_level(rdev
);
3888 DRM_ERROR("ni_power_control_set_level failed\n");
3895 void ni_dpm_post_set_power_state(struct radeon_device
*rdev
)
3897 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3898 struct radeon_ps
*new_ps
= &eg_pi
->requested_rps
;
3900 ni_update_current_ps(rdev
, new_ps
);
3903 void ni_dpm_reset_asic(struct radeon_device
*rdev
)
3905 ni_restrict_performance_levels_before_switch(rdev
);
3906 rv770_set_boot_state(rdev
);
3910 struct _ATOM_POWERPLAY_INFO info
;
3911 struct _ATOM_POWERPLAY_INFO_V2 info_2
;
3912 struct _ATOM_POWERPLAY_INFO_V3 info_3
;
3913 struct _ATOM_PPLIB_POWERPLAYTABLE pplib
;
3914 struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2
;
3915 struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3
;
3918 union pplib_clock_info
{
3919 struct _ATOM_PPLIB_R600_CLOCK_INFO r600
;
3920 struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780
;
3921 struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen
;
3922 struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo
;
3925 union pplib_power_state
{
3926 struct _ATOM_PPLIB_STATE v1
;
3927 struct _ATOM_PPLIB_STATE_V2 v2
;
3930 static void ni_parse_pplib_non_clock_info(struct radeon_device
*rdev
,
3931 struct radeon_ps
*rps
,
3932 struct _ATOM_PPLIB_NONCLOCK_INFO
*non_clock_info
,
3935 rps
->caps
= le32_to_cpu(non_clock_info
->ulCapsAndSettings
);
3936 rps
->class = le16_to_cpu(non_clock_info
->usClassification
);
3937 rps
->class2
= le16_to_cpu(non_clock_info
->usClassification2
);
3939 if (ATOM_PPLIB_NONCLOCKINFO_VER1
< table_rev
) {
3940 rps
->vclk
= le32_to_cpu(non_clock_info
->ulVCLK
);
3941 rps
->dclk
= le32_to_cpu(non_clock_info
->ulDCLK
);
3942 } else if (r600_is_uvd_state(rps
->class, rps
->class2
)) {
3943 rps
->vclk
= RV770_DEFAULT_VCLK_FREQ
;
3944 rps
->dclk
= RV770_DEFAULT_DCLK_FREQ
;
3950 if (rps
->class & ATOM_PPLIB_CLASSIFICATION_BOOT
)
3951 rdev
->pm
.dpm
.boot_ps
= rps
;
3952 if (rps
->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE
)
3953 rdev
->pm
.dpm
.uvd_ps
= rps
;
3956 static void ni_parse_pplib_clock_info(struct radeon_device
*rdev
,
3957 struct radeon_ps
*rps
, int index
,
3958 union pplib_clock_info
*clock_info
)
3960 struct rv7xx_power_info
*pi
= rv770_get_pi(rdev
);
3961 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
3962 struct ni_ps
*ps
= ni_get_ps(rps
);
3964 struct rv7xx_pl
*pl
= &ps
->performance_levels
[index
];
3966 ps
->performance_level_count
= index
+ 1;
3968 pl
->sclk
= le16_to_cpu(clock_info
->evergreen
.usEngineClockLow
);
3969 pl
->sclk
|= clock_info
->evergreen
.ucEngineClockHigh
<< 16;
3970 pl
->mclk
= le16_to_cpu(clock_info
->evergreen
.usMemoryClockLow
);
3971 pl
->mclk
|= clock_info
->evergreen
.ucMemoryClockHigh
<< 16;
3973 pl
->vddc
= le16_to_cpu(clock_info
->evergreen
.usVDDC
);
3974 pl
->vddci
= le16_to_cpu(clock_info
->evergreen
.usVDDCI
);
3975 pl
->flags
= le32_to_cpu(clock_info
->evergreen
.ulFlags
);
3977 /* patch up vddc if necessary */
3978 if (pl
->vddc
== 0xff01) {
3979 if (radeon_atom_get_max_vddc(rdev
, 0, 0, &vddc
) == 0)
3983 if (rps
->class & ATOM_PPLIB_CLASSIFICATION_ACPI
) {
3984 pi
->acpi_vddc
= pl
->vddc
;
3985 eg_pi
->acpi_vddci
= pl
->vddci
;
3986 if (ps
->performance_levels
[0].flags
& ATOM_PPLIB_R600_FLAGS_PCIEGEN2
)
3987 pi
->acpi_pcie_gen2
= true;
3989 pi
->acpi_pcie_gen2
= false;
3992 if (rps
->class2
& ATOM_PPLIB_CLASSIFICATION2_ULV
) {
3993 eg_pi
->ulv
.supported
= true;
3997 if (pi
->min_vddc_in_table
> pl
->vddc
)
3998 pi
->min_vddc_in_table
= pl
->vddc
;
4000 if (pi
->max_vddc_in_table
< pl
->vddc
)
4001 pi
->max_vddc_in_table
= pl
->vddc
;
4003 /* patch up boot state */
4004 if (rps
->class & ATOM_PPLIB_CLASSIFICATION_BOOT
) {
4005 u16 vddc
, vddci
, mvdd
;
4006 radeon_atombios_get_default_voltages(rdev
, &vddc
, &vddci
, &mvdd
);
4007 pl
->mclk
= rdev
->clock
.default_mclk
;
4008 pl
->sclk
= rdev
->clock
.default_sclk
;
4013 if ((rps
->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK
) ==
4014 ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE
) {
4015 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
.sclk
= pl
->sclk
;
4016 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
.mclk
= pl
->mclk
;
4017 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
.vddc
= pl
->vddc
;
4018 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
.vddci
= pl
->vddci
;
4022 static int ni_parse_power_table(struct radeon_device
*rdev
)
4024 struct radeon_mode_info
*mode_info
= &rdev
->mode_info
;
4025 struct _ATOM_PPLIB_NONCLOCK_INFO
*non_clock_info
;
4026 union pplib_power_state
*power_state
;
4028 union pplib_clock_info
*clock_info
;
4029 union power_info
*power_info
;
4030 int index
= GetIndexIntoMasterTable(DATA
, PowerPlayInfo
);
4035 if (!atom_parse_data_header(mode_info
->atom_context
, index
, NULL
,
4036 &frev
, &crev
, &data_offset
))
4038 power_info
= (union power_info
*)(mode_info
->atom_context
->bios
+ data_offset
);
4040 rdev
->pm
.dpm
.ps
= kzalloc(sizeof(struct radeon_ps
) *
4041 power_info
->pplib
.ucNumStates
, GFP_KERNEL
);
4042 if (!rdev
->pm
.dpm
.ps
)
4044 rdev
->pm
.dpm
.platform_caps
= le32_to_cpu(power_info
->pplib
.ulPlatformCaps
);
4045 rdev
->pm
.dpm
.backbias_response_time
= le16_to_cpu(power_info
->pplib
.usBackbiasTime
);
4046 rdev
->pm
.dpm
.voltage_response_time
= le16_to_cpu(power_info
->pplib
.usVoltageTime
);
4048 for (i
= 0; i
< power_info
->pplib
.ucNumStates
; i
++) {
4049 power_state
= (union pplib_power_state
*)
4050 (mode_info
->atom_context
->bios
+ data_offset
+
4051 le16_to_cpu(power_info
->pplib
.usStateArrayOffset
) +
4052 i
* power_info
->pplib
.ucStateEntrySize
);
4053 non_clock_info
= (struct _ATOM_PPLIB_NONCLOCK_INFO
*)
4054 (mode_info
->atom_context
->bios
+ data_offset
+
4055 le16_to_cpu(power_info
->pplib
.usNonClockInfoArrayOffset
) +
4056 (power_state
->v1
.ucNonClockStateIndex
*
4057 power_info
->pplib
.ucNonClockSize
));
4058 if (power_info
->pplib
.ucStateEntrySize
- 1) {
4060 ps
= kzalloc(sizeof(struct ni_ps
), GFP_KERNEL
);
4062 kfree(rdev
->pm
.dpm
.ps
);
4065 rdev
->pm
.dpm
.ps
[i
].ps_priv
= ps
;
4066 ni_parse_pplib_non_clock_info(rdev
, &rdev
->pm
.dpm
.ps
[i
],
4068 power_info
->pplib
.ucNonClockSize
);
4069 idx
= (u8
*)&power_state
->v1
.ucClockStateIndices
[0];
4070 for (j
= 0; j
< (power_info
->pplib
.ucStateEntrySize
- 1); j
++) {
4071 clock_info
= (union pplib_clock_info
*)
4072 (mode_info
->atom_context
->bios
+ data_offset
+
4073 le16_to_cpu(power_info
->pplib
.usClockInfoArrayOffset
) +
4074 (idx
[j
] * power_info
->pplib
.ucClockInfoSize
));
4075 ni_parse_pplib_clock_info(rdev
,
4076 &rdev
->pm
.dpm
.ps
[i
], j
,
4081 rdev
->pm
.dpm
.num_ps
= power_info
->pplib
.ucNumStates
;
4085 int ni_dpm_init(struct radeon_device
*rdev
)
4087 struct rv7xx_power_info
*pi
;
4088 struct evergreen_power_info
*eg_pi
;
4089 struct ni_power_info
*ni_pi
;
4090 struct atom_clock_dividers dividers
;
4093 ni_pi
= kzalloc(sizeof(struct ni_power_info
), GFP_KERNEL
);
4096 rdev
->pm
.dpm
.priv
= ni_pi
;
4100 rv770_get_max_vddc(rdev
);
4102 eg_pi
->ulv
.supported
= false;
4104 eg_pi
->acpi_vddci
= 0;
4105 pi
->min_vddc_in_table
= 0;
4106 pi
->max_vddc_in_table
= 0;
4108 ret
= ni_parse_power_table(rdev
);
4111 ret
= r600_parse_extended_power_table(rdev
);
4115 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
=
4116 kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry
), GFP_KERNEL
);
4117 if (!rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
) {
4118 r600_free_extended_power_table(rdev
);
4121 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.count
= 4;
4122 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[0].clk
= 0;
4123 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[0].v
= 0;
4124 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[1].clk
= 36000;
4125 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[1].v
= 720;
4126 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[2].clk
= 54000;
4127 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[2].v
= 810;
4128 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[3].clk
= 72000;
4129 rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
[3].v
= 900;
4131 ni_patch_dependency_tables_based_on_leakage(rdev
);
4133 if (rdev
->pm
.dpm
.voltage_response_time
== 0)
4134 rdev
->pm
.dpm
.voltage_response_time
= R600_VOLTAGERESPONSETIME_DFLT
;
4135 if (rdev
->pm
.dpm
.backbias_response_time
== 0)
4136 rdev
->pm
.dpm
.backbias_response_time
= R600_BACKBIASRESPONSETIME_DFLT
;
4138 ret
= radeon_atom_get_clock_dividers(rdev
, COMPUTE_ENGINE_PLL_PARAM
,
4139 0, false, ÷rs
);
4141 pi
->ref_div
= dividers
.ref_div
+ 1;
4143 pi
->ref_div
= R600_REFERENCEDIVIDER_DFLT
;
4145 pi
->rlp
= RV770_RLP_DFLT
;
4146 pi
->rmp
= RV770_RMP_DFLT
;
4147 pi
->lhp
= RV770_LHP_DFLT
;
4148 pi
->lmp
= RV770_LMP_DFLT
;
4150 eg_pi
->ats
[0].rlp
= RV770_RLP_DFLT
;
4151 eg_pi
->ats
[0].rmp
= RV770_RMP_DFLT
;
4152 eg_pi
->ats
[0].lhp
= RV770_LHP_DFLT
;
4153 eg_pi
->ats
[0].lmp
= RV770_LMP_DFLT
;
4155 eg_pi
->ats
[1].rlp
= BTC_RLP_UVD_DFLT
;
4156 eg_pi
->ats
[1].rmp
= BTC_RMP_UVD_DFLT
;
4157 eg_pi
->ats
[1].lhp
= BTC_LHP_UVD_DFLT
;
4158 eg_pi
->ats
[1].lmp
= BTC_LMP_UVD_DFLT
;
4160 eg_pi
->smu_uvd_hs
= true;
4162 if (rdev
->pdev
->device
== 0x6707) {
4163 pi
->mclk_strobe_mode_threshold
= 55000;
4164 pi
->mclk_edc_enable_threshold
= 55000;
4165 eg_pi
->mclk_edc_wr_enable_threshold
= 55000;
4167 pi
->mclk_strobe_mode_threshold
= 40000;
4168 pi
->mclk_edc_enable_threshold
= 40000;
4169 eg_pi
->mclk_edc_wr_enable_threshold
= 40000;
4171 ni_pi
->mclk_rtt_mode_threshold
= eg_pi
->mclk_edc_wr_enable_threshold
;
4173 pi
->voltage_control
=
4174 radeon_atom_is_voltage_gpio(rdev
, SET_VOLTAGE_TYPE_ASIC_VDDC
, 0);
4177 radeon_atom_is_voltage_gpio(rdev
, SET_VOLTAGE_TYPE_ASIC_MVDDC
, 0);
4179 eg_pi
->vddci_control
=
4180 radeon_atom_is_voltage_gpio(rdev
, SET_VOLTAGE_TYPE_ASIC_VDDCI
, 0);
4182 rv770_get_engine_memory_ss(rdev
);
4184 pi
->asi
= RV770_ASI_DFLT
;
4185 pi
->pasi
= CYPRESS_HASI_DFLT
;
4186 pi
->vrc
= CYPRESS_VRC_DFLT
;
4188 pi
->power_gating
= false;
4190 pi
->gfx_clock_gating
= true;
4192 pi
->mg_clock_gating
= true;
4193 pi
->mgcgtssm
= true;
4194 eg_pi
->ls_clock_gating
= false;
4195 eg_pi
->sclk_deep_sleep
= false;
4197 pi
->dynamic_pcie_gen2
= true;
4199 if (rdev
->pm
.int_thermal_type
!= THERMAL_TYPE_NONE
)
4200 pi
->thermal_protection
= true;
4202 pi
->thermal_protection
= false;
4204 pi
->display_gap
= true;
4210 eg_pi
->dynamic_ac_timing
= true;
4213 eg_pi
->light_sleep
= true;
4214 eg_pi
->memory_transition
= true;
4215 #if defined(CONFIG_ACPI)
4216 eg_pi
->pcie_performance_request
=
4217 radeon_acpi_is_pcie_performance_request_supported(rdev
);
4219 eg_pi
->pcie_performance_request
= false;
4222 eg_pi
->dll_default_on
= false;
4224 eg_pi
->sclk_deep_sleep
= false;
4226 pi
->mclk_stutter_mode_threshold
= 0;
4228 pi
->sram_end
= SMC_RAM_END
;
4230 rdev
->pm
.dpm
.dyn_state
.mclk_sclk_ratio
= 3;
4231 rdev
->pm
.dpm
.dyn_state
.vddc_vddci_delta
= 200;
4232 rdev
->pm
.dpm
.dyn_state
.min_vddc_for_pcie_gen2
= 900;
4233 rdev
->pm
.dpm
.dyn_state
.valid_sclk_values
.count
= ARRAY_SIZE(btc_valid_sclk
);
4234 rdev
->pm
.dpm
.dyn_state
.valid_sclk_values
.values
= btc_valid_sclk
;
4235 rdev
->pm
.dpm
.dyn_state
.valid_mclk_values
.count
= 0;
4236 rdev
->pm
.dpm
.dyn_state
.valid_mclk_values
.values
= NULL
;
4237 rdev
->pm
.dpm
.dyn_state
.sclk_mclk_delta
= 12500;
4239 ni_pi
->cac_data
.leakage_coefficients
.at
= 516;
4240 ni_pi
->cac_data
.leakage_coefficients
.bt
= 18;
4241 ni_pi
->cac_data
.leakage_coefficients
.av
= 51;
4242 ni_pi
->cac_data
.leakage_coefficients
.bv
= 2957;
4244 switch (rdev
->pdev
->device
) {
4250 ni_pi
->cac_weights
= &cac_weights_cayman_xt
;
4257 ni_pi
->cac_weights
= &cac_weights_cayman_pro
;
4264 ni_pi
->cac_weights
= &cac_weights_cayman_le
;
4268 if (ni_pi
->cac_weights
->enable_power_containment_by_default
) {
4269 ni_pi
->enable_power_containment
= true;
4270 ni_pi
->enable_cac
= true;
4271 ni_pi
->enable_sq_ramping
= true;
4273 ni_pi
->enable_power_containment
= false;
4274 ni_pi
->enable_cac
= false;
4275 ni_pi
->enable_sq_ramping
= false;
4278 ni_pi
->driver_calculate_cac_leakage
= false;
4279 ni_pi
->cac_configuration_required
= true;
4281 if (ni_pi
->cac_configuration_required
) {
4282 ni_pi
->support_cac_long_term_average
= true;
4283 ni_pi
->lta_window_size
= ni_pi
->cac_weights
->l2_lta_window_size
;
4284 ni_pi
->lts_truncate
= ni_pi
->cac_weights
->lts_truncate
;
4286 ni_pi
->support_cac_long_term_average
= false;
4287 ni_pi
->lta_window_size
= 0;
4288 ni_pi
->lts_truncate
= 0;
4291 ni_pi
->use_power_boost_limit
= true;
4293 /* make sure dc limits are valid */
4294 if ((rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_dc
.sclk
== 0) ||
4295 (rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_dc
.mclk
== 0))
4296 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_dc
=
4297 rdev
->pm
.dpm
.dyn_state
.max_clock_voltage_on_ac
;
4302 void ni_dpm_fini(struct radeon_device
*rdev
)
4306 for (i
= 0; i
< rdev
->pm
.dpm
.num_ps
; i
++) {
4307 kfree(rdev
->pm
.dpm
.ps
[i
].ps_priv
);
4309 kfree(rdev
->pm
.dpm
.ps
);
4310 kfree(rdev
->pm
.dpm
.priv
);
4311 kfree(rdev
->pm
.dpm
.dyn_state
.vddc_dependency_on_dispclk
.entries
);
4312 r600_free_extended_power_table(rdev
);
4315 void ni_dpm_print_power_state(struct radeon_device
*rdev
,
4316 struct radeon_ps
*rps
)
4318 struct ni_ps
*ps
= ni_get_ps(rps
);
4319 struct rv7xx_pl
*pl
;
4322 r600_dpm_print_class_info(rps
->class, rps
->class2
);
4323 r600_dpm_print_cap_info(rps
->caps
);
4324 printk("\tuvd vclk: %d dclk: %d\n", rps
->vclk
, rps
->dclk
);
4325 for (i
= 0; i
< ps
->performance_level_count
; i
++) {
4326 pl
= &ps
->performance_levels
[i
];
4327 if (rdev
->family
>= CHIP_TAHITI
)
4328 printk("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
4329 i
, pl
->sclk
, pl
->mclk
, pl
->vddc
, pl
->vddci
, pl
->pcie_gen
+ 1);
4331 printk("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u\n",
4332 i
, pl
->sclk
, pl
->mclk
, pl
->vddc
, pl
->vddci
);
4334 r600_dpm_print_ps_status(rdev
, rps
);
4337 void ni_dpm_debugfs_print_current_performance_level(struct radeon_device
*rdev
,
4340 struct radeon_ps
*rps
= rdev
->pm
.dpm
.current_ps
;
4341 struct ni_ps
*ps
= ni_get_ps(rps
);
4342 struct rv7xx_pl
*pl
;
4344 (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX
) & CURRENT_STATE_INDEX_MASK
) >>
4345 CURRENT_STATE_INDEX_SHIFT
;
4347 if (current_index
>= ps
->performance_level_count
) {
4348 seq_printf(m
, "invalid dpm profile %d\n", current_index
);
4350 pl
= &ps
->performance_levels
[current_index
];
4351 seq_printf(m
, "uvd vclk: %d dclk: %d\n", rps
->vclk
, rps
->dclk
);
4352 seq_printf(m
, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u\n",
4353 current_index
, pl
->sclk
, pl
->mclk
, pl
->vddc
, pl
->vddci
);
4357 u32
ni_dpm_get_sclk(struct radeon_device
*rdev
, bool low
)
4359 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
4360 struct ni_ps
*requested_state
= ni_get_ps(&eg_pi
->requested_rps
);
4363 return requested_state
->performance_levels
[0].sclk
;
4365 return requested_state
->performance_levels
[requested_state
->performance_level_count
- 1].sclk
;
4368 u32
ni_dpm_get_mclk(struct radeon_device
*rdev
, bool low
)
4370 struct evergreen_power_info
*eg_pi
= evergreen_get_pi(rdev
);
4371 struct ni_ps
*requested_state
= ni_get_ps(&eg_pi
->requested_rps
);
4374 return requested_state
->performance_levels
[0].mclk
;
4376 return requested_state
->performance_levels
[requested_state
->performance_level_count
- 1].mclk
;