aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2010-01-19 17:16:10 -0500
committerDave Airlie <airlied@redhat.com>2010-01-24 02:24:23 -0500
commitfc10332b8ac5ca32d11f898027d84c007543bd80 (patch)
tree28b24fb83e4c4bfc71286ce93f01271fa5027c95 /drivers
parenta348c84d953f61c776e53cde0a63a4e407a23c18 (diff)
drm/radeon/kms: clean up pll struct
- add a new flag for fixed post div - pull the pll flags into the struct Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c35
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c35
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h27
4 files changed, 62 insertions, 49 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 7af5c1f7b6de..7a8cdf2813dc 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -426,7 +426,11 @@ void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
426 uint32_t adjusted_clock; 426 uint32_t adjusted_clock;
427 uint32_t ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; 427 uint32_t ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0;
428 struct radeon_pll *pll; 428 struct radeon_pll *pll;
429 int pll_flags = 0; 429
430 if (radeon_crtc->crtc_id == 0)
431 pll = &rdev->clock.p1pll;
432 else
433 pll = &rdev->clock.p2pll;
430 434
431 memset(&args, 0, sizeof(args)); 435 memset(&args, 0, sizeof(args));
432 436
@@ -434,20 +438,20 @@ void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
434 if ((rdev->family == CHIP_RS600) || 438 if ((rdev->family == CHIP_RS600) ||
435 (rdev->family == CHIP_RS690) || 439 (rdev->family == CHIP_RS690) ||
436 (rdev->family == CHIP_RS740)) 440 (rdev->family == CHIP_RS740))
437 pll_flags |= (RADEON_PLL_USE_FRAC_FB_DIV | 441 pll->flags |= (RADEON_PLL_USE_FRAC_FB_DIV |
438 RADEON_PLL_PREFER_CLOSEST_LOWER); 442 RADEON_PLL_PREFER_CLOSEST_LOWER);
439 443
440 if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */ 444 if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */
441 pll_flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; 445 pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV;
442 else 446 else
443 pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV; 447 pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
444 } else { 448 } else {
445 pll_flags |= RADEON_PLL_LEGACY; 449 pll->flags |= RADEON_PLL_LEGACY;
446 450
447 if (mode->clock > 200000) /* range limits??? */ 451 if (mode->clock > 200000) /* range limits??? */
448 pll_flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; 452 pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV;
449 else 453 else
450 pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV; 454 pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
451 455
452 } 456 }
453 457
@@ -456,10 +460,10 @@ void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
456 if (!ASIC_IS_AVIVO(rdev)) { 460 if (!ASIC_IS_AVIVO(rdev)) {
457 if (encoder->encoder_type != 461 if (encoder->encoder_type !=
458 DRM_MODE_ENCODER_DAC) 462 DRM_MODE_ENCODER_DAC)
459 pll_flags |= RADEON_PLL_NO_ODD_POST_DIV; 463 pll->flags |= RADEON_PLL_NO_ODD_POST_DIV;
460 if (encoder->encoder_type == 464 if (encoder->encoder_type ==
461 DRM_MODE_ENCODER_LVDS) 465 DRM_MODE_ENCODER_LVDS)
462 pll_flags |= RADEON_PLL_USE_REF_DIV; 466 pll->flags |= RADEON_PLL_USE_REF_DIV;
463 } 467 }
464 radeon_encoder = to_radeon_encoder(encoder); 468 radeon_encoder = to_radeon_encoder(encoder);
465 break; 469 break;
@@ -494,23 +498,18 @@ void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
494 adjusted_clock = mode->clock; 498 adjusted_clock = mode->clock;
495 } 499 }
496 500
497 if (radeon_crtc->crtc_id == 0)
498 pll = &rdev->clock.p1pll;
499 else
500 pll = &rdev->clock.p2pll;
501
502 if (ASIC_IS_AVIVO(rdev)) { 501 if (ASIC_IS_AVIVO(rdev)) {
503 if (radeon_new_pll) 502 if (radeon_new_pll)
504 radeon_compute_pll_avivo(pll, adjusted_clock, &pll_clock, 503 radeon_compute_pll_avivo(pll, adjusted_clock, &pll_clock,
505 &fb_div, &frac_fb_div, 504 &fb_div, &frac_fb_div,
506 &ref_div, &post_div, pll_flags); 505 &ref_div, &post_div);
507 else 506 else
508 radeon_compute_pll(pll, adjusted_clock, &pll_clock, 507 radeon_compute_pll(pll, adjusted_clock, &pll_clock,
509 &fb_div, &frac_fb_div, 508 &fb_div, &frac_fb_div,
510 &ref_div, &post_div, pll_flags); 509 &ref_div, &post_div);
511 } else 510 } else
512 radeon_compute_pll(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, 511 radeon_compute_pll(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
513 &ref_div, &post_div, pll_flags); 512 &ref_div, &post_div);
514 513
515 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); 514 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock);
516 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, 515 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index f899320f0a6b..6a92f994cc26 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -411,11 +411,12 @@ void radeon_compute_pll(struct radeon_pll *pll,
411 uint32_t *fb_div_p, 411 uint32_t *fb_div_p,
412 uint32_t *frac_fb_div_p, 412 uint32_t *frac_fb_div_p,
413 uint32_t *ref_div_p, 413 uint32_t *ref_div_p,
414 uint32_t *post_div_p, 414 uint32_t *post_div_p)
415 int flags)
416{ 415{
417 uint32_t min_ref_div = pll->min_ref_div; 416 uint32_t min_ref_div = pll->min_ref_div;
418 uint32_t max_ref_div = pll->max_ref_div; 417 uint32_t max_ref_div = pll->max_ref_div;
418 uint32_t min_post_div = pll->min_post_div;
419 uint32_t max_post_div = pll->max_post_div;
419 uint32_t min_fractional_feed_div = 0; 420 uint32_t min_fractional_feed_div = 0;
420 uint32_t max_fractional_feed_div = 0; 421 uint32_t max_fractional_feed_div = 0;
421 uint32_t best_vco = pll->best_vco; 422 uint32_t best_vco = pll->best_vco;
@@ -431,7 +432,7 @@ void radeon_compute_pll(struct radeon_pll *pll,
431 DRM_DEBUG("PLL freq %llu %u %u\n", freq, pll->min_ref_div, pll->max_ref_div); 432 DRM_DEBUG("PLL freq %llu %u %u\n", freq, pll->min_ref_div, pll->max_ref_div);
432 freq = freq * 1000; 433 freq = freq * 1000;
433 434
434 if (flags & RADEON_PLL_USE_REF_DIV) 435 if (pll->flags & RADEON_PLL_USE_REF_DIV)
435 min_ref_div = max_ref_div = pll->reference_div; 436 min_ref_div = max_ref_div = pll->reference_div;
436 else { 437 else {
437 while (min_ref_div < max_ref_div-1) { 438 while (min_ref_div < max_ref_div-1) {
@@ -446,19 +447,22 @@ void radeon_compute_pll(struct radeon_pll *pll,
446 } 447 }
447 } 448 }
448 449
449 if (flags & RADEON_PLL_USE_FRAC_FB_DIV) { 450 if (pll->flags & RADEON_PLL_USE_POST_DIV)
451 min_post_div = max_post_div = pll->post_div;
452
453 if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV) {
450 min_fractional_feed_div = pll->min_frac_feedback_div; 454 min_fractional_feed_div = pll->min_frac_feedback_div;
451 max_fractional_feed_div = pll->max_frac_feedback_div; 455 max_fractional_feed_div = pll->max_frac_feedback_div;
452 } 456 }
453 457
454 for (post_div = pll->min_post_div; post_div <= pll->max_post_div; ++post_div) { 458 for (post_div = min_post_div; post_div <= max_post_div; ++post_div) {
455 uint32_t ref_div; 459 uint32_t ref_div;
456 460
457 if ((flags & RADEON_PLL_NO_ODD_POST_DIV) && (post_div & 1)) 461 if ((pll->flags & RADEON_PLL_NO_ODD_POST_DIV) && (post_div & 1))
458 continue; 462 continue;
459 463
460 /* legacy radeons only have a few post_divs */ 464 /* legacy radeons only have a few post_divs */
461 if (flags & RADEON_PLL_LEGACY) { 465 if (pll->flags & RADEON_PLL_LEGACY) {
462 if ((post_div == 5) || 466 if ((post_div == 5) ||
463 (post_div == 7) || 467 (post_div == 7) ||
464 (post_div == 9) || 468 (post_div == 9) ||
@@ -505,7 +509,7 @@ void radeon_compute_pll(struct radeon_pll *pll,
505 tmp += (uint64_t)pll->reference_freq * 1000 * frac_feedback_div; 509 tmp += (uint64_t)pll->reference_freq * 1000 * frac_feedback_div;
506 current_freq = radeon_div(tmp, ref_div * post_div); 510 current_freq = radeon_div(tmp, ref_div * post_div);
507 511
508 if (flags & RADEON_PLL_PREFER_CLOSEST_LOWER) { 512 if (pll->flags & RADEON_PLL_PREFER_CLOSEST_LOWER) {
509 error = freq - current_freq; 513 error = freq - current_freq;
510 error = error < 0 ? 0xffffffff : error; 514 error = error < 0 ? 0xffffffff : error;
511 } else 515 } else
@@ -532,12 +536,12 @@ void radeon_compute_pll(struct radeon_pll *pll,
532 best_freq = current_freq; 536 best_freq = current_freq;
533 best_error = error; 537 best_error = error;
534 best_vco_diff = vco_diff; 538 best_vco_diff = vco_diff;
535 } else if (((flags & RADEON_PLL_PREFER_LOW_REF_DIV) && (ref_div < best_ref_div)) || 539 } else if (((pll->flags & RADEON_PLL_PREFER_LOW_REF_DIV) && (ref_div < best_ref_div)) ||
536 ((flags & RADEON_PLL_PREFER_HIGH_REF_DIV) && (ref_div > best_ref_div)) || 540 ((pll->flags & RADEON_PLL_PREFER_HIGH_REF_DIV) && (ref_div > best_ref_div)) ||
537 ((flags & RADEON_PLL_PREFER_LOW_FB_DIV) && (feedback_div < best_feedback_div)) || 541 ((pll->flags & RADEON_PLL_PREFER_LOW_FB_DIV) && (feedback_div < best_feedback_div)) ||
538 ((flags & RADEON_PLL_PREFER_HIGH_FB_DIV) && (feedback_div > best_feedback_div)) || 542 ((pll->flags & RADEON_PLL_PREFER_HIGH_FB_DIV) && (feedback_div > best_feedback_div)) ||
539 ((flags & RADEON_PLL_PREFER_LOW_POST_DIV) && (post_div < best_post_div)) || 543 ((pll->flags & RADEON_PLL_PREFER_LOW_POST_DIV) && (post_div < best_post_div)) ||
540 ((flags & RADEON_PLL_PREFER_HIGH_POST_DIV) && (post_div > best_post_div))) { 544 ((pll->flags & RADEON_PLL_PREFER_HIGH_POST_DIV) && (post_div > best_post_div))) {
541 best_post_div = post_div; 545 best_post_div = post_div;
542 best_ref_div = ref_div; 546 best_ref_div = ref_div;
543 best_feedback_div = feedback_div; 547 best_feedback_div = feedback_div;
@@ -573,8 +577,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
573 uint32_t *fb_div_p, 577 uint32_t *fb_div_p,
574 uint32_t *frac_fb_div_p, 578 uint32_t *frac_fb_div_p,
575 uint32_t *ref_div_p, 579 uint32_t *ref_div_p,
576 uint32_t *post_div_p, 580 uint32_t *post_div_p)
577 int flags)
578{ 581{
579 fixed20_12 m, n, frac_n, p, f_vco, f_pclk, best_freq; 582 fixed20_12 m, n, frac_n, p, f_vco, f_pclk, best_freq;
580 fixed20_12 pll_out_max, pll_out_min; 583 fixed20_12 pll_out_max, pll_out_min;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 762e07b08951..b6d8081e1246 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -692,7 +692,6 @@ static void radeon_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
692 uint32_t post_divider = 0; 692 uint32_t post_divider = 0;
693 uint32_t freq = 0; 693 uint32_t freq = 0;
694 uint8_t pll_gain; 694 uint8_t pll_gain;
695 int pll_flags = RADEON_PLL_LEGACY;
696 bool use_bios_divs = false; 695 bool use_bios_divs = false;
697 /* PLL registers */ 696 /* PLL registers */
698 uint32_t pll_ref_div = 0; 697 uint32_t pll_ref_div = 0;
@@ -726,10 +725,12 @@ static void radeon_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
726 else 725 else
727 pll = &rdev->clock.p1pll; 726 pll = &rdev->clock.p1pll;
728 727
728 pll->flags = RADEON_PLL_LEGACY;
729
729 if (mode->clock > 200000) /* range limits??? */ 730 if (mode->clock > 200000) /* range limits??? */
730 pll_flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; 731 pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV;
731 else 732 else
732 pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV; 733 pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
733 734
734 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 735 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
735 if (encoder->crtc == crtc) { 736 if (encoder->crtc == crtc) {
@@ -741,7 +742,7 @@ static void radeon_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
741 } 742 }
742 743
743 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC) 744 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
744 pll_flags |= RADEON_PLL_NO_ODD_POST_DIV; 745 pll->flags |= RADEON_PLL_NO_ODD_POST_DIV;
745 if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) { 746 if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) {
746 if (!rdev->is_atom_bios) { 747 if (!rdev->is_atom_bios) {
747 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 748 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
@@ -756,7 +757,7 @@ static void radeon_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
756 } 757 }
757 } 758 }
758 } 759 }
759 pll_flags |= RADEON_PLL_USE_REF_DIV; 760 pll->flags |= RADEON_PLL_USE_REF_DIV;
760 } 761 }
761 } 762 }
762 } 763 }
@@ -766,8 +767,7 @@ static void radeon_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode)
766 if (!use_bios_divs) { 767 if (!use_bios_divs) {
767 radeon_compute_pll(pll, mode->clock, 768 radeon_compute_pll(pll, mode->clock,
768 &freq, &feedback_div, &frac_fb_div, 769 &freq, &feedback_div, &frac_fb_div,
769 &reference_div, &post_divider, 770 &reference_div, &post_divider);
770 pll_flags);
771 771
772 for (post_div = &post_divs[0]; post_div->divider; ++post_div) { 772 for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
773 if (post_div->divider == post_divider) 773 if (post_div->divider == post_divider)
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index eb19b3022b0e..96b851f92f4c 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -125,16 +125,24 @@ struct radeon_tmds_pll {
125#define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9) 125#define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9)
126#define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10) 126#define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10)
127#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11) 127#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11)
128#define RADEON_PLL_USE_POST_DIV (1 << 12)
128 129
129struct radeon_pll { 130struct radeon_pll {
130 uint16_t reference_freq; 131 /* reference frequency */
131 uint16_t reference_div; 132 uint32_t reference_freq;
133
134 /* fixed dividers */
135 uint32_t reference_div;
136 uint32_t post_div;
137
138 /* pll in/out limits */
132 uint32_t pll_in_min; 139 uint32_t pll_in_min;
133 uint32_t pll_in_max; 140 uint32_t pll_in_max;
134 uint32_t pll_out_min; 141 uint32_t pll_out_min;
135 uint32_t pll_out_max; 142 uint32_t pll_out_max;
136 uint16_t xclk; 143 uint32_t best_vco;
137 144
145 /* divider limits */
138 uint32_t min_ref_div; 146 uint32_t min_ref_div;
139 uint32_t max_ref_div; 147 uint32_t max_ref_div;
140 uint32_t min_post_div; 148 uint32_t min_post_div;
@@ -143,7 +151,12 @@ struct radeon_pll {
143 uint32_t max_feedback_div; 151 uint32_t max_feedback_div;
144 uint32_t min_frac_feedback_div; 152 uint32_t min_frac_feedback_div;
145 uint32_t max_frac_feedback_div; 153 uint32_t max_frac_feedback_div;
146 uint32_t best_vco; 154
155 /* flags for the current clock */
156 uint32_t flags;
157
158 /* pll id */
159 uint32_t id;
147}; 160};
148 161
149struct radeon_i2c_chan { 162struct radeon_i2c_chan {
@@ -417,8 +430,7 @@ extern void radeon_compute_pll(struct radeon_pll *pll,
417 uint32_t *fb_div_p, 430 uint32_t *fb_div_p,
418 uint32_t *frac_fb_div_p, 431 uint32_t *frac_fb_div_p,
419 uint32_t *ref_div_p, 432 uint32_t *ref_div_p,
420 uint32_t *post_div_p, 433 uint32_t *post_div_p);
421 int flags);
422 434
423extern void radeon_compute_pll_avivo(struct radeon_pll *pll, 435extern void radeon_compute_pll_avivo(struct radeon_pll *pll,
424 uint64_t freq, 436 uint64_t freq,
@@ -426,8 +438,7 @@ extern void radeon_compute_pll_avivo(struct radeon_pll *pll,
426 uint32_t *fb_div_p, 438 uint32_t *fb_div_p,
427 uint32_t *frac_fb_div_p, 439 uint32_t *frac_fb_div_p,
428 uint32_t *ref_div_p, 440 uint32_t *ref_div_p,
429 uint32_t *post_div_p, 441 uint32_t *post_div_p);
430 int flags);
431 442
432extern void radeon_setup_encoder_clones(struct drm_device *dev); 443extern void radeon_setup_encoder_clones(struct drm_device *dev);
433 444