Rev 4539 | Rev 5060 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4539 | Rev 4560 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | 0x00FFFFFF, 0x0005000A, |
40 | 0x00FFFFFF, 0x0005000A, |
41 | 0x00D75FFF, 0x000C0004, |
41 | 0x00D75FFF, 0x000C0004, |
42 | 0x80C30FFF, 0x000B0000, |
42 | 0x80C30FFF, 0x000B0000, |
43 | 0x00FFFFFF, 0x00040006, |
43 | 0x00FFFFFF, 0x00040006, |
44 | 0x80D75FFF, 0x000B0000, |
44 | 0x80D75FFF, 0x000B0000, |
45 | 0x00FFFFFF, 0x00040006 /* HDMI parameters */ |
- | |
46 | }; |
45 | }; |
Line 47... | Line 46... | ||
47 | 46 | ||
48 | static const u32 hsw_ddi_translations_fdi[] = { |
47 | static const u32 hsw_ddi_translations_fdi[] = { |
49 | 0x00FFFFFF, 0x0007000E, /* FDI parameters */ |
48 | 0x00FFFFFF, 0x0007000E, /* FDI parameters */ |
Line 53... | Line 52... | ||
53 | 0x00FFFFFF, 0x000F000A, |
52 | 0x00FFFFFF, 0x000F000A, |
54 | 0x00D75FFF, 0x00160004, |
53 | 0x00D75FFF, 0x00160004, |
55 | 0x00C30FFF, 0x001E0000, |
54 | 0x00C30FFF, 0x001E0000, |
56 | 0x00FFFFFF, 0x00060006, |
55 | 0x00FFFFFF, 0x00060006, |
57 | 0x00D75FFF, 0x001E0000, |
56 | 0x00D75FFF, 0x001E0000, |
58 | 0x00FFFFFF, 0x00040006 /* HDMI parameters */ |
- | |
59 | }; |
57 | }; |
Line -... | Line 58... | ||
- | 58 | ||
- | 59 | static const u32 hsw_ddi_translations_hdmi[] = { |
|
- | 60 | /* Idx NT mV diff T mV diff db */ |
|
- | 61 | 0x00FFFFFF, 0x0006000E, /* 0: 400 400 0 */ |
|
- | 62 | 0x00E79FFF, 0x000E000C, /* 1: 400 500 2 */ |
|
- | 63 | 0x00D75FFF, 0x0005000A, /* 2: 400 600 3.5 */ |
|
- | 64 | 0x00FFFFFF, 0x0005000A, /* 3: 600 600 0 */ |
|
- | 65 | 0x00E79FFF, 0x001D0007, /* 4: 600 750 2 */ |
|
- | 66 | 0x00D75FFF, 0x000C0004, /* 5: 600 900 3.5 */ |
|
- | 67 | 0x00FFFFFF, 0x00040006, /* 6: 800 800 0 */ |
|
- | 68 | 0x80E79FFF, 0x00030002, /* 7: 800 1000 2 */ |
|
- | 69 | 0x00FFFFFF, 0x00140005, /* 8: 850 850 0 */ |
|
- | 70 | 0x00FFFFFF, 0x000C0004, /* 9: 900 900 0 */ |
|
- | 71 | 0x00FFFFFF, 0x001C0003, /* 10: 950 950 0 */ |
|
- | 72 | 0x80FFFFFF, 0x00030002, /* 11: 1000 1000 0 */ |
|
- | 73 | }; |
|
- | 74 | ||
- | 75 | static const u32 bdw_ddi_translations_edp[] = { |
|
- | 76 | 0x00FFFFFF, 0x00000012, /* eDP parameters */ |
|
- | 77 | 0x00EBAFFF, 0x00020011, |
|
- | 78 | 0x00C71FFF, 0x0006000F, |
|
- | 79 | 0x00FFFFFF, 0x00020011, |
|
- | 80 | 0x00DB6FFF, 0x0005000F, |
|
- | 81 | 0x00BEEFFF, 0x000A000C, |
|
- | 82 | 0x00FFFFFF, 0x0005000F, |
|
- | 83 | 0x00DB6FFF, 0x000A000C, |
|
- | 84 | 0x00FFFFFF, 0x000A000C, |
|
- | 85 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
|
- | 86 | }; |
|
- | 87 | ||
- | 88 | static const u32 bdw_ddi_translations_dp[] = { |
|
- | 89 | 0x00FFFFFF, 0x0007000E, /* DP parameters */ |
|
- | 90 | 0x00D75FFF, 0x000E000A, |
|
- | 91 | 0x00BEFFFF, 0x00140006, |
|
- | 92 | 0x00FFFFFF, 0x000E000A, |
|
- | 93 | 0x00D75FFF, 0x00180004, |
|
- | 94 | 0x80CB2FFF, 0x001B0002, |
|
- | 95 | 0x00F7DFFF, 0x00180004, |
|
- | 96 | 0x80D75FFF, 0x001B0002, |
|
- | 97 | 0x80FFFFFF, 0x001B0002, |
|
- | 98 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
|
- | 99 | }; |
|
- | 100 | ||
- | 101 | static const u32 bdw_ddi_translations_fdi[] = { |
|
- | 102 | 0x00FFFFFF, 0x0001000E, /* FDI parameters */ |
|
- | 103 | 0x00D75FFF, 0x0004000A, |
|
- | 104 | 0x00C30FFF, 0x00070006, |
|
- | 105 | 0x00AAAFFF, 0x000C0000, |
|
- | 106 | 0x00FFFFFF, 0x0004000A, |
|
- | 107 | 0x00D75FFF, 0x00090004, |
|
- | 108 | 0x00C30FFF, 0x000C0000, |
|
- | 109 | 0x00FFFFFF, 0x00070006, |
|
- | 110 | 0x00D75FFF, 0x000C0000, |
|
- | 111 | 0x00FFFFFF, 0x00140006 /* HDMI parameters 800mV 0dB*/ |
|
- | 112 | }; |
|
60 | 113 | ||
61 | static enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) |
114 | enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder) |
62 | { |
115 | { |
63 | struct drm_encoder *encoder = &intel_encoder->base; |
116 | struct drm_encoder *encoder = &intel_encoder->base; |
Line 64... | Line 117... | ||
64 | int type = intel_encoder->type; |
117 | int type = intel_encoder->type; |
Line 76... | Line 129... | ||
76 | DRM_ERROR("Invalid DDI encoder type %d\n", type); |
129 | DRM_ERROR("Invalid DDI encoder type %d\n", type); |
77 | BUG(); |
130 | BUG(); |
78 | } |
131 | } |
79 | } |
132 | } |
Line -... | Line 133... | ||
- | 133 | ||
80 | 134 | /* |
|
81 | /* On Haswell, DDI port buffers must be programmed with correct values |
135 | * Starting with Haswell, DDI port buffers must be programmed with correct |
82 | * in advance. The buffer values are different for FDI and DP modes, |
136 | * values in advance. The buffer values are different for FDI and DP modes, |
83 | * but the HDMI/DVI fields are shared among those. So we program the DDI |
137 | * but the HDMI/DVI fields are shared among those. So we program the DDI |
84 | * in either FDI or DP modes only, as HDMI connections will work with both |
138 | * in either FDI or DP modes only, as HDMI connections will work with both |
85 | * of those |
139 | * of those |
86 | */ |
140 | */ |
87 | static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) |
141 | static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port) |
88 | { |
142 | { |
89 | struct drm_i915_private *dev_priv = dev->dev_private; |
143 | struct drm_i915_private *dev_priv = dev->dev_private; |
90 | u32 reg; |
144 | u32 reg; |
- | 145 | int i; |
|
91 | int i; |
146 | int hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; |
92 | const u32 *ddi_translations = (port == PORT_E) ? |
147 | const u32 *ddi_translations_fdi; |
93 | hsw_ddi_translations_fdi : |
148 | const u32 *ddi_translations_dp; |
- | 149 | const u32 *ddi_translations_edp; |
|
- | 150 | const u32 *ddi_translations; |
|
- | 151 | ||
- | 152 | if (IS_BROADWELL(dev)) { |
|
- | 153 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
|
- | 154 | ddi_translations_dp = bdw_ddi_translations_dp; |
|
- | 155 | ddi_translations_edp = bdw_ddi_translations_edp; |
|
- | 156 | } else if (IS_HASWELL(dev)) { |
|
- | 157 | ddi_translations_fdi = hsw_ddi_translations_fdi; |
|
- | 158 | ddi_translations_dp = hsw_ddi_translations_dp; |
|
- | 159 | ddi_translations_edp = hsw_ddi_translations_dp; |
|
- | 160 | } else { |
|
- | 161 | WARN(1, "ddi translation table missing\n"); |
|
- | 162 | ddi_translations_edp = bdw_ddi_translations_dp; |
|
- | 163 | ddi_translations_fdi = bdw_ddi_translations_fdi; |
|
- | 164 | ddi_translations_dp = bdw_ddi_translations_dp; |
|
- | 165 | } |
|
- | 166 | ||
- | 167 | switch (port) { |
|
- | 168 | case PORT_A: |
|
- | 169 | ddi_translations = ddi_translations_edp; |
|
- | 170 | break; |
|
- | 171 | case PORT_B: |
|
- | 172 | case PORT_C: |
|
- | 173 | ddi_translations = ddi_translations_dp; |
|
- | 174 | break; |
|
- | 175 | case PORT_D: |
|
- | 176 | if (intel_dp_is_edp(dev, PORT_D)) |
|
- | 177 | ddi_translations = ddi_translations_edp; |
|
- | 178 | else |
|
- | 179 | ddi_translations = ddi_translations_dp; |
|
- | 180 | break; |
|
- | 181 | case PORT_E: |
|
- | 182 | ddi_translations = ddi_translations_fdi; |
|
- | 183 | break; |
|
- | 184 | default: |
|
- | 185 | BUG(); |
|
Line 94... | Line 186... | ||
94 | hsw_ddi_translations_dp; |
186 | } |
95 | 187 | ||
96 | for (i = 0, reg = DDI_BUF_TRANS(port); |
188 | for (i = 0, reg = DDI_BUF_TRANS(port); |
97 | i < ARRAY_SIZE(hsw_ddi_translations_fdi); i++) { |
189 | i < ARRAY_SIZE(hsw_ddi_translations_fdi); i++) { |
98 | I915_WRITE(reg, ddi_translations[i]); |
190 | I915_WRITE(reg, ddi_translations[i]); |
- | 191 | reg += 4; |
|
- | 192 | } |
|
- | 193 | /* Entry 9 is for HDMI: */ |
|
- | 194 | for (i = 0; i < 2; i++) { |
|
- | 195 | I915_WRITE(reg, hsw_ddi_translations_hdmi[hdmi_level * 2 + i]); |
|
99 | reg += 4; |
196 | reg += 4; |
Line 100... | Line 197... | ||
100 | } |
197 | } |
101 | } |
198 | } |
102 | 199 | ||
Line 294... | Line 391... | ||
294 | 391 | ||
295 | /* write eld */ |
392 | /* write eld */ |
296 | DRM_DEBUG_DRIVER("DP audio: write eld information\n"); |
393 | DRM_DEBUG_DRIVER("DP audio: write eld information\n"); |
297 | intel_write_eld(&encoder->base, adjusted_mode); |
394 | intel_write_eld(&encoder->base, adjusted_mode); |
298 | } |
- | |
299 | - | ||
300 | intel_dp_init_link_config(intel_dp); |
- | |
301 | 395 | } |
|
302 | } else if (type == INTEL_OUTPUT_HDMI) { |
396 | } else if (type == INTEL_OUTPUT_HDMI) { |
Line 303... | Line 397... | ||
303 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
397 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
304 | 398 | ||
Line 600... | Line 694... | ||
600 | } |
694 | } |
Line 601... | Line 695... | ||
601 | 695 | ||
602 | *n2_out = best.n2; |
696 | *n2_out = best.n2; |
603 | *p_out = best.p; |
697 | *p_out = best.p; |
604 | *r2_out = best.r2; |
- | |
605 | - | ||
606 | DRM_DEBUG_KMS("WRPLL: %dHz refresh rate with p=%d, n2=%d r2=%d\n", |
- | |
607 | clock, *p_out, *n2_out, *r2_out); |
698 | *r2_out = best.r2; |
Line -... | Line 699... | ||
- | 699 | } |
|
- | 700 | ||
- | 701 | /* |
|
- | 702 | * Tries to find a PLL for the CRTC. If it finds, it increases the refcount and |
|
- | 703 | * stores it in intel_crtc->ddi_pll_sel, so other mode sets won't be able to |
|
- | 704 | * steal the selected PLL. You need to call intel_ddi_pll_enable to actually |
|
608 | } |
705 | * enable the PLL. |
609 | 706 | */ |
|
610 | bool intel_ddi_pll_mode_set(struct drm_crtc *crtc) |
707 | bool intel_ddi_pll_select(struct intel_crtc *intel_crtc) |
611 | { |
708 | { |
612 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
709 | struct drm_crtc *crtc = &intel_crtc->base; |
613 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
710 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
614 | struct drm_encoder *encoder = &intel_encoder->base; |
711 | struct drm_encoder *encoder = &intel_encoder->base; |
615 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
712 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
616 | struct intel_ddi_plls *plls = &dev_priv->ddi_plls; |
713 | struct intel_ddi_plls *plls = &dev_priv->ddi_plls; |
617 | int type = intel_encoder->type; |
- | |
618 | enum pipe pipe = intel_crtc->pipe; |
714 | int type = intel_encoder->type; |
Line 619... | Line -... | ||
619 | uint32_t reg, val; |
- | |
620 | int clock = intel_crtc->config.port_clock; |
- | |
621 | 715 | enum pipe pipe = intel_crtc->pipe; |
|
Line 622... | Line 716... | ||
622 | /* TODO: reuse PLLs when possible (compare values) */ |
716 | int clock = intel_crtc->config.port_clock; |
623 | 717 | ||
Line 640... | Line 734... | ||
640 | DRM_ERROR("Link bandwidth %d unsupported\n", |
734 | DRM_ERROR("Link bandwidth %d unsupported\n", |
641 | intel_dp->link_bw); |
735 | intel_dp->link_bw); |
642 | return false; |
736 | return false; |
643 | } |
737 | } |
Line 644... | Line -... | ||
644 | - | ||
645 | /* We don't need to turn any PLL on because we'll use LCPLL. */ |
- | |
646 | return true; |
- | |
647 | 738 | ||
- | 739 | } else if (type == INTEL_OUTPUT_HDMI) { |
|
648 | } else if (type == INTEL_OUTPUT_HDMI) { |
740 | uint32_t reg, val; |
Line -... | Line 741... | ||
- | 741 | unsigned p, n2, r2; |
|
- | 742 | ||
- | 743 | intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
|
- | 744 | ||
- | 745 | val = WRPLL_PLL_ENABLE | WRPLL_PLL_SELECT_LCPLL_2700 | |
|
- | 746 | WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | |
|
- | 747 | WRPLL_DIVIDER_POST(p); |
|
- | 748 | ||
- | 749 | if (val == I915_READ(WRPLL_CTL1)) { |
|
- | 750 | DRM_DEBUG_KMS("Reusing WRPLL 1 on pipe %c\n", |
|
- | 751 | pipe_name(pipe)); |
|
- | 752 | reg = WRPLL_CTL1; |
|
- | 753 | } else if (val == I915_READ(WRPLL_CTL2)) { |
|
- | 754 | DRM_DEBUG_KMS("Reusing WRPLL 2 on pipe %c\n", |
|
649 | unsigned p, n2, r2; |
755 | pipe_name(pipe)); |
650 | 756 | reg = WRPLL_CTL2; |
|
651 | if (plls->wrpll1_refcount == 0) { |
757 | } else if (plls->wrpll1_refcount == 0) { |
652 | DRM_DEBUG_KMS("Using WRPLL 1 on pipe %c\n", |
- | |
653 | pipe_name(pipe)); |
758 | DRM_DEBUG_KMS("Using WRPLL 1 on pipe %c\n", |
654 | plls->wrpll1_refcount++; |
- | |
655 | reg = WRPLL_CTL1; |
759 | pipe_name(pipe)); |
656 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL1; |
760 | reg = WRPLL_CTL1; |
657 | } else if (plls->wrpll2_refcount == 0) { |
761 | } else if (plls->wrpll2_refcount == 0) { |
658 | DRM_DEBUG_KMS("Using WRPLL 2 on pipe %c\n", |
- | |
659 | pipe_name(pipe)); |
762 | DRM_DEBUG_KMS("Using WRPLL 2 on pipe %c\n", |
660 | plls->wrpll2_refcount++; |
- | |
661 | reg = WRPLL_CTL2; |
763 | pipe_name(pipe)); |
662 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL2; |
764 | reg = WRPLL_CTL2; |
663 | } else { |
765 | } else { |
664 | DRM_ERROR("No WRPLLs available!\n"); |
766 | DRM_ERROR("No WRPLLs available!\n"); |
Line 665... | Line 767... | ||
665 | return false; |
767 | return false; |
666 | } |
768 | } |
Line -... | Line 769... | ||
- | 769 | ||
667 | 770 | DRM_DEBUG_KMS("WRPLL: %dKHz refresh rate with p=%d, n2=%d r2=%d\n", |
|
668 | WARN(I915_READ(reg) & WRPLL_PLL_ENABLE, |
- | |
669 | "WRPLL already enabled\n"); |
771 | clock, p, n2, r2); |
- | 772 | ||
670 | 773 | if (reg == WRPLL_CTL1) { |
|
671 | intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
774 | plls->wrpll1_refcount++; |
- | 775 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL1; |
|
Line 672... | Line 776... | ||
672 | 776 | } else { |
|
673 | val = WRPLL_PLL_ENABLE | WRPLL_PLL_SELECT_LCPLL_2700 | |
777 | plls->wrpll2_refcount++; |
674 | WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) | |
778 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_WRPLL2; |
675 | WRPLL_DIVIDER_POST(p); |
779 | } |
676 | 780 | ||
677 | } else if (type == INTEL_OUTPUT_ANALOG) { |
- | |
678 | if (plls->spll_refcount == 0) { |
781 | } else if (type == INTEL_OUTPUT_ANALOG) { |
679 | DRM_DEBUG_KMS("Using SPLL on pipe %c\n", |
782 | if (plls->spll_refcount == 0) { |
680 | pipe_name(pipe)); |
783 | DRM_DEBUG_KMS("Using SPLL on pipe %c\n", |
681 | plls->spll_refcount++; |
784 | pipe_name(pipe)); |
682 | reg = SPLL_CTL; |
785 | plls->spll_refcount++; |
Line 683... | Line -... | ||
683 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_SPLL; |
- | |
684 | } else { |
- | |
685 | DRM_ERROR("SPLL already in use\n"); |
- | |
686 | return false; |
- | |
687 | } |
- | |
688 | 786 | intel_crtc->ddi_pll_sel = PORT_CLK_SEL_SPLL; |
|
689 | WARN(I915_READ(reg) & SPLL_PLL_ENABLE, |
787 | } else { |
690 | "SPLL already enabled\n"); |
788 | DRM_ERROR("SPLL already in use\n"); |
691 | 789 | return false; |
|
Line 692... | Line -... | ||
692 | val = SPLL_PLL_ENABLE | SPLL_PLL_FREQ_1350MHz | SPLL_PLL_SSC; |
- | |
693 | - | ||
694 | } else { |
- | |
695 | WARN(1, "Invalid DDI encoder type %d\n", type); |
790 | } |
696 | return false; |
791 | |
Line -... | Line 792... | ||
- | 792 | } else { |
|
- | 793 | WARN(1, "Invalid DDI encoder type %d\n", type); |
|
- | 794 | return false; |
|
- | 795 | } |
|
- | 796 | ||
- | 797 | return true; |
|
- | 798 | } |
|
- | 799 | ||
- | 800 | /* |
|
- | 801 | * To be called after intel_ddi_pll_select(). That one selects the PLL to be |
|
- | 802 | * used, this one actually enables the PLL. |
|
- | 803 | */ |
|
- | 804 | void intel_ddi_pll_enable(struct intel_crtc *crtc) |
|
- | 805 | { |
|
- | 806 | struct drm_device *dev = crtc->base.dev; |
|
- | 807 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 808 | struct intel_ddi_plls *plls = &dev_priv->ddi_plls; |
|
- | 809 | int clock = crtc->config.port_clock; |
|
- | 810 | uint32_t reg, cur_val, new_val; |
|
- | 811 | int refcount; |
|
- | 812 | const char *pll_name; |
|
- | 813 | uint32_t enable_bit = (1 << 31); |
|
- | 814 | unsigned int p, n2, r2; |
|
- | 815 | ||
- | 816 | BUILD_BUG_ON(enable_bit != SPLL_PLL_ENABLE); |
|
- | 817 | BUILD_BUG_ON(enable_bit != WRPLL_PLL_ENABLE); |
|
- | 818 | ||
- | 819 | switch (crtc->ddi_pll_sel) { |
|
- | 820 | case PORT_CLK_SEL_LCPLL_2700: |
|
- | 821 | case PORT_CLK_SEL_LCPLL_1350: |
|
- | 822 | case PORT_CLK_SEL_LCPLL_810: |
|
- | 823 | /* |
|
- | 824 | * LCPLL should always be enabled at this point of the mode set |
|
- | 825 | * sequence, so nothing to do. |
|
- | 826 | */ |
|
- | 827 | return; |
|
- | 828 | ||
- | 829 | case PORT_CLK_SEL_SPLL: |
|
- | 830 | pll_name = "SPLL"; |
|
- | 831 | reg = SPLL_CTL; |
|
- | 832 | refcount = plls->spll_refcount; |
|
- | 833 | new_val = SPLL_PLL_ENABLE | SPLL_PLL_FREQ_1350MHz | |
|
- | 834 | SPLL_PLL_SSC; |
|
- | 835 | break; |
|
- | 836 | ||
- | 837 | case PORT_CLK_SEL_WRPLL1: |
|
- | 838 | case PORT_CLK_SEL_WRPLL2: |
|
- | 839 | if (crtc->ddi_pll_sel == PORT_CLK_SEL_WRPLL1) { |
|
- | 840 | pll_name = "WRPLL1"; |
|
- | 841 | reg = WRPLL_CTL1; |
|
- | 842 | refcount = plls->wrpll1_refcount; |
|
- | 843 | } else { |
|
- | 844 | pll_name = "WRPLL2"; |
|
- | 845 | reg = WRPLL_CTL2; |
|
- | 846 | refcount = plls->wrpll2_refcount; |
|
- | 847 | } |
|
- | 848 | ||
- | 849 | intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p); |
|
- | 850 | ||
- | 851 | new_val = WRPLL_PLL_ENABLE | WRPLL_PLL_SELECT_LCPLL_2700 | |
|
- | 852 | WRPLL_DIVIDER_REFERENCE(r2) | |
|
- | 853 | WRPLL_DIVIDER_FEEDBACK(n2) | WRPLL_DIVIDER_POST(p); |
|
- | 854 | ||
- | 855 | break; |
|
- | 856 | ||
- | 857 | case PORT_CLK_SEL_NONE: |
|
- | 858 | WARN(1, "Bad selected pll: PORT_CLK_SEL_NONE\n"); |
|
- | 859 | return; |
|
- | 860 | default: |
|
- | 861 | WARN(1, "Bad selected pll: 0x%08x\n", crtc->ddi_pll_sel); |
|
- | 862 | return; |
|
- | 863 | } |
|
- | 864 | ||
- | 865 | cur_val = I915_READ(reg); |
|
- | 866 | ||
- | 867 | WARN(refcount < 1, "Bad %s refcount: %d\n", pll_name, refcount); |
|
- | 868 | if (refcount == 1) { |
|
- | 869 | WARN(cur_val & enable_bit, "%s already enabled\n", pll_name); |
|
697 | } |
870 | I915_WRITE(reg, new_val); |
698 | 871 | POSTING_READ(reg); |
|
699 | I915_WRITE(reg, val); |
872 | udelay(20); |
700 | udelay(20); |
873 | } else { |
701 | 874 | WARN((cur_val & enable_bit) == 0, "%s disabled\n", pll_name); |
|
Line 737... | Line 910... | ||
737 | void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) |
910 | void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) |
738 | { |
911 | { |
739 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
912 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
740 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
913 | struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); |
741 | struct drm_encoder *encoder = &intel_encoder->base; |
914 | struct drm_encoder *encoder = &intel_encoder->base; |
- | 915 | struct drm_device *dev = crtc->dev; |
|
742 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; |
916 | struct drm_i915_private *dev_priv = dev->dev_private; |
743 | enum pipe pipe = intel_crtc->pipe; |
917 | enum pipe pipe = intel_crtc->pipe; |
744 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
918 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
745 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
919 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
746 | int type = intel_encoder->type; |
920 | int type = intel_encoder->type; |
747 | uint32_t temp; |
921 | uint32_t temp; |
Line 765... | Line 939... | ||
765 | break; |
939 | break; |
766 | default: |
940 | default: |
767 | BUG(); |
941 | BUG(); |
768 | } |
942 | } |
Line 769... | Line 943... | ||
769 | 943 | ||
770 | if (crtc->mode.flags & DRM_MODE_FLAG_PVSYNC) |
944 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_PVSYNC) |
771 | temp |= TRANS_DDI_PVSYNC; |
945 | temp |= TRANS_DDI_PVSYNC; |
772 | if (crtc->mode.flags & DRM_MODE_FLAG_PHSYNC) |
946 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_PHSYNC) |
Line 773... | Line 947... | ||
773 | temp |= TRANS_DDI_PHSYNC; |
947 | temp |= TRANS_DDI_PHSYNC; |
774 | 948 | ||
775 | if (cpu_transcoder == TRANSCODER_EDP) { |
949 | if (cpu_transcoder == TRANSCODER_EDP) { |
776 | switch (pipe) { |
950 | switch (pipe) { |
777 | case PIPE_A: |
951 | case PIPE_A: |
778 | /* Can only use the always-on power well for eDP when |
952 | /* On Haswell, can only use the always-on power well for |
- | 953 | * eDP when not using the panel fitter, and when not |
|
779 | * not using the panel fitter, and when not using motion |
954 | * using motion blur mitigation (which we don't |
780 | * blur mitigation (which we don't support). */ |
955 | * support). */ |
781 | if (intel_crtc->config.pch_pfit.enabled) |
956 | if (IS_HASWELL(dev) && intel_crtc->config.pch_pfit.enabled) |
782 | temp |= TRANS_DDI_EDP_INPUT_A_ONOFF; |
957 | temp |= TRANS_DDI_EDP_INPUT_A_ONOFF; |
783 | else |
958 | else |
784 | temp |= TRANS_DDI_EDP_INPUT_A_ON; |
959 | temp |= TRANS_DDI_EDP_INPUT_A_ON; |
Line 1023... | Line 1198... | ||
1023 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1198 | enum port port = intel_ddi_get_encoder_port(intel_encoder); |
1024 | int type = intel_encoder->type; |
1199 | int type = intel_encoder->type; |
Line 1025... | Line 1200... | ||
1025 | 1200 | ||
1026 | if (type == INTEL_OUTPUT_EDP) { |
1201 | if (type == INTEL_OUTPUT_EDP) { |
1027 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
- | |
1028 | ironlake_edp_panel_vdd_on(intel_dp); |
1202 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1029 | ironlake_edp_panel_on(intel_dp); |
- | |
1030 | ironlake_edp_panel_vdd_off(intel_dp, true); |
1203 | ironlake_edp_panel_on(intel_dp); |
Line 1031... | Line 1204... | ||
1031 | } |
1204 | } |
1032 | 1205 | ||
Line 1066... | Line 1239... | ||
1066 | I915_WRITE(DP_TP_CTL(port), val); |
1239 | I915_WRITE(DP_TP_CTL(port), val); |
Line 1067... | Line 1240... | ||
1067 | 1240 | ||
1068 | if (wait) |
1241 | if (wait) |
Line 1069... | Line 1242... | ||
1069 | intel_wait_ddi_buf_idle(dev_priv, port); |
1242 | intel_wait_ddi_buf_idle(dev_priv, port); |
1070 | 1243 | ||
1071 | if (type == INTEL_OUTPUT_EDP) { |
1244 | if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { |
1072 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1245 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); |
1073 | ironlake_edp_panel_vdd_on(intel_dp); |
1246 | intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); |
Line 1074... | Line 1247... | ||
1074 | ironlake_edp_panel_off(intel_dp); |
1247 | ironlake_edp_panel_off(intel_dp); |
1075 | } |
1248 | } |
Line 1143... | Line 1316... | ||
1143 | } |
1316 | } |
1144 | } |
1317 | } |
Line 1145... | Line 1318... | ||
1145 | 1318 | ||
1146 | int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) |
1319 | int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv) |
- | 1320 | { |
|
1147 | { |
1321 | struct drm_device *dev = dev_priv->dev; |
- | 1322 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
|
Line 1148... | Line 1323... | ||
1148 | uint32_t lcpll = I915_READ(LCPLL_CTL); |
1323 | uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK; |
1149 | 1324 | ||
1150 | if (lcpll & LCPLL_CD_SOURCE_FCLK) |
1325 | if (lcpll & LCPLL_CD_SOURCE_FCLK) { |
1151 | return 800000; |
1326 | return 800000; |
1152 | else if (I915_READ(HSW_FUSE_STRAP) & HSW_CDCLK_LIMIT) |
1327 | } else if (I915_READ(HSW_FUSE_STRAP) & HSW_CDCLK_LIMIT) { |
1153 | return 450000; |
1328 | return 450000; |
1154 | else if ((lcpll & LCPLL_CLK_FREQ_MASK) == LCPLL_CLK_FREQ_450) |
1329 | } else if (freq == LCPLL_CLK_FREQ_450) { |
- | 1330 | return 450000; |
|
1155 | return 450000; |
1331 | } else if (IS_HASWELL(dev)) { |
1156 | else if (IS_ULT(dev_priv->dev)) |
1332 | if (IS_ULT(dev)) |
1157 | return 337500; |
1333 | return 337500; |
- | 1334 | else |
|
- | 1335 | return 540000; |
|
- | 1336 | } else { |
|
- | 1337 | if (freq == LCPLL_CLK_FREQ_54O_BDW) |
|
- | 1338 | return 540000; |
|
- | 1339 | else if (freq == LCPLL_CLK_FREQ_337_5_BDW) |
|
- | 1340 | return 337500; |
|
- | 1341 | else |
|
1158 | else |
1342 | return 675000; |
Line 1159... | Line 1343... | ||
1159 | return 540000; |
1343 | } |
1160 | } |
1344 | } |
1161 | 1345 | ||
Line 1206... | Line 1390... | ||
1206 | intel_wait_ddi_buf_idle(dev_priv, port); |
1390 | intel_wait_ddi_buf_idle(dev_priv, port); |
1207 | } |
1391 | } |
Line 1208... | Line 1392... | ||
1208 | 1392 | ||
1209 | val = DP_TP_CTL_ENABLE | DP_TP_CTL_MODE_SST | |
1393 | val = DP_TP_CTL_ENABLE | DP_TP_CTL_MODE_SST | |
1210 | DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE; |
1394 | DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE; |
1211 | if (intel_dp->link_configuration[1] & DP_LANE_COUNT_ENHANCED_FRAME_EN) |
1395 | if (drm_dp_enhanced_frame_cap(intel_dp->dpcd)) |
1212 | val |= DP_TP_CTL_ENHANCED_FRAME_ENABLE; |
1396 | val |= DP_TP_CTL_ENHANCED_FRAME_ENABLE; |
1213 | I915_WRITE(DP_TP_CTL(port), val); |
1397 | I915_WRITE(DP_TP_CTL(port), val); |
Line 1214... | Line 1398... | ||
1214 | POSTING_READ(DP_TP_CTL(port)); |
1398 | POSTING_READ(DP_TP_CTL(port)); |
Line 1290... | Line 1474... | ||
1290 | break; |
1474 | break; |
1291 | default: |
1475 | default: |
1292 | break; |
1476 | break; |
1293 | } |
1477 | } |
Line -... | Line 1478... | ||
- | 1478 | ||
- | 1479 | switch (temp & TRANS_DDI_MODE_SELECT_MASK) { |
|
- | 1480 | case TRANS_DDI_MODE_SELECT_HDMI: |
|
- | 1481 | case TRANS_DDI_MODE_SELECT_DVI: |
|
- | 1482 | case TRANS_DDI_MODE_SELECT_FDI: |
|
- | 1483 | break; |
|
- | 1484 | case TRANS_DDI_MODE_SELECT_DP_SST: |
|
- | 1485 | case TRANS_DDI_MODE_SELECT_DP_MST: |
|
- | 1486 | pipe_config->has_dp_encoder = true; |
|
- | 1487 | intel_dp_get_m_n(intel_crtc, pipe_config); |
|
- | 1488 | break; |
|
- | 1489 | default: |
|
- | 1490 | break; |
|
- | 1491 | } |
|
1294 | 1492 | ||
1295 | if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp && |
1493 | if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp && |
1296 | pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) { |
1494 | pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) { |
1297 | /* |
1495 | /* |
1298 | * This is a big fat ugly hack. |
1496 | * This is a big fat ugly hack. |
Line 1338... | Line 1536... | ||
1338 | 1536 | ||
1339 | static const struct drm_encoder_funcs intel_ddi_funcs = { |
1537 | static const struct drm_encoder_funcs intel_ddi_funcs = { |
1340 | .destroy = intel_ddi_destroy, |
1538 | .destroy = intel_ddi_destroy, |
Line -... | Line 1539... | ||
- | 1539 | }; |
|
- | 1540 | ||
- | 1541 | static struct intel_connector * |
|
- | 1542 | intel_ddi_init_dp_connector(struct intel_digital_port *intel_dig_port) |
|
- | 1543 | { |
|
- | 1544 | struct intel_connector *connector; |
|
- | 1545 | enum port port = intel_dig_port->port; |
|
- | 1546 | ||
- | 1547 | connector = kzalloc(sizeof(*connector), GFP_KERNEL); |
|
- | 1548 | if (!connector) |
|
- | 1549 | return NULL; |
|
- | 1550 | ||
- | 1551 | intel_dig_port->dp.output_reg = DDI_BUF_CTL(port); |
|
- | 1552 | if (!intel_dp_init_connector(intel_dig_port, connector)) { |
|
- | 1553 | kfree(connector); |
|
- | 1554 | return NULL; |
|
- | 1555 | } |
|
- | 1556 | ||
- | 1557 | return connector; |
|
- | 1558 | } |
|
- | 1559 | ||
- | 1560 | static struct intel_connector * |
|
- | 1561 | intel_ddi_init_hdmi_connector(struct intel_digital_port *intel_dig_port) |
|
- | 1562 | { |
|
- | 1563 | struct intel_connector *connector; |
|
- | 1564 | enum port port = intel_dig_port->port; |
|
- | 1565 | ||
- | 1566 | connector = kzalloc(sizeof(*connector), GFP_KERNEL); |
|
- | 1567 | if (!connector) |
|
- | 1568 | return NULL; |
|
- | 1569 | ||
- | 1570 | intel_dig_port->hdmi.hdmi_reg = DDI_BUF_CTL(port); |
|
- | 1571 | intel_hdmi_init_connector(intel_dig_port, connector); |
|
- | 1572 | ||
- | 1573 | return connector; |
|
1341 | }; |
1574 | } |
1342 | 1575 | ||
1343 | void intel_ddi_init(struct drm_device *dev, enum port port) |
1576 | void intel_ddi_init(struct drm_device *dev, enum port port) |
1344 | { |
1577 | { |
1345 | struct drm_i915_private *dev_priv = dev->dev_private; |
1578 | struct drm_i915_private *dev_priv = dev->dev_private; |
1346 | struct intel_digital_port *intel_dig_port; |
1579 | struct intel_digital_port *intel_dig_port; |
1347 | struct intel_encoder *intel_encoder; |
1580 | struct intel_encoder *intel_encoder; |
1348 | struct drm_encoder *encoder; |
1581 | struct drm_encoder *encoder; |
- | 1582 | struct intel_connector *hdmi_connector = NULL; |
|
Line -... | Line 1583... | ||
- | 1583 | struct intel_connector *dp_connector = NULL; |
|
- | 1584 | bool init_hdmi, init_dp; |
|
1349 | struct intel_connector *hdmi_connector = NULL; |
1585 | |
1350 | struct intel_connector *dp_connector = NULL; |
1586 | init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi || |
- | 1587 | dev_priv->vbt.ddi_port_info[port].supports_hdmi); |
|
- | 1588 | init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp; |
|
- | 1589 | if (!init_dp && !init_hdmi) { |
|
1351 | 1590 | DRM_DEBUG_KMS("VBT says port %c is not DVI/HDMI/DP compatible\n", |
|
- | 1591 | port_name(port)); |
|
Line 1352... | Line 1592... | ||
1352 | intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); |
1592 | init_hdmi = true; |
1353 | if (!intel_dig_port) |
- | |
1354 | return; |
1593 | init_dp = true; |
1355 | 1594 | } |
|
1356 | dp_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
- | |
Line 1357... | Line 1595... | ||
1357 | if (!dp_connector) { |
1595 | |
1358 | kfree(intel_dig_port); |
1596 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
Line 1359... | Line 1597... | ||
1359 | return; |
1597 | if (!intel_dig_port) |
Line 1376... | Line 1614... | ||
1376 | 1614 | ||
1377 | intel_dig_port->port = port; |
1615 | intel_dig_port->port = port; |
1378 | intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & |
1616 | intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & |
1379 | (DDI_BUF_PORT_REVERSAL | |
1617 | (DDI_BUF_PORT_REVERSAL | |
1380 | DDI_A_4_LANES); |
- | |
Line 1381... | Line 1618... | ||
1381 | intel_dig_port->dp.output_reg = DDI_BUF_CTL(port); |
1618 | DDI_A_4_LANES); |
1382 | 1619 | ||
1383 | intel_encoder->type = INTEL_OUTPUT_UNKNOWN; |
1620 | intel_encoder->type = INTEL_OUTPUT_UNKNOWN; |
1384 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
1621 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
Line 1385... | Line -... | ||
1385 | intel_encoder->cloneable = false; |
- | |
1386 | intel_encoder->hot_plug = intel_ddi_hot_plug; |
- | |
1387 | 1622 | intel_encoder->cloneable = false; |
|
1388 | if (!intel_dp_init_connector(intel_dig_port, dp_connector)) { |
1623 | intel_encoder->hot_plug = intel_ddi_hot_plug; |
1389 | drm_encoder_cleanup(encoder); |
- | |
1390 | kfree(intel_dig_port); |
- | |
Line -... | Line 1624... | ||
- | 1624 | ||
- | 1625 | if (init_dp) |
|
1391 | kfree(dp_connector); |
1626 | dp_connector = intel_ddi_init_dp_connector(intel_dig_port); |
1392 | return; |
1627 | |
1393 | } |
- | |
1394 | - | ||
1395 | if (intel_encoder->type != INTEL_OUTPUT_EDP) { |
- | |
1396 | hdmi_connector = kzalloc(sizeof(struct intel_connector), |
- | |
Line 1397... | Line 1628... | ||
1397 | GFP_KERNEL); |
1628 | /* In theory we don't need the encoder->type check, but leave it just in |
- | 1629 | * case we have some really bad VBTs... */ |
|
1398 | if (!hdmi_connector) { |
1630 | if (intel_encoder->type != INTEL_OUTPUT_EDP && init_hdmi) |
1399 | return; |
1631 | hdmi_connector = intel_ddi_init_hdmi_connector(intel_dig_port); |
1400 | } |
1632 |