Subversion Repositories Kolibri OS

Rev

Rev 6660 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6660 Rev 6937
Line 131... Line 131...
131
/* Skylake H and S */
131
/* Skylake H and S */
132
static const struct ddi_buf_trans skl_ddi_translations_dp[] = {
132
static const struct ddi_buf_trans skl_ddi_translations_dp[] = {
133
	{ 0x00002016, 0x000000A0, 0x0 },
133
	{ 0x00002016, 0x000000A0, 0x0 },
134
	{ 0x00005012, 0x0000009B, 0x0 },
134
	{ 0x00005012, 0x0000009B, 0x0 },
135
	{ 0x00007011, 0x00000088, 0x0 },
135
	{ 0x00007011, 0x00000088, 0x0 },
136
	{ 0x00009010, 0x000000C7, 0x0 },
136
	{ 0x80009010, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
137
	{ 0x00002016, 0x0000009B, 0x0 },
137
	{ 0x00002016, 0x0000009B, 0x0 },
138
	{ 0x00005012, 0x00000088, 0x0 },
138
	{ 0x00005012, 0x00000088, 0x0 },
139
	{ 0x00007011, 0x000000C7, 0x0 },
139
	{ 0x80007011, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
140
	{ 0x00002016, 0x000000DF, 0x0 },
140
	{ 0x00002016, 0x000000DF, 0x0 },
141
	{ 0x00005012, 0x000000C7, 0x0 },
141
	{ 0x80005012, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
142
};
142
};
Line 143... Line 143...
143
 
143
 
144
/* Skylake U */
144
/* Skylake U */
145
static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = {
145
static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = {
146
	{ 0x0000201B, 0x000000A2, 0x0 },
146
	{ 0x0000201B, 0x000000A2, 0x0 },
147
	{ 0x00005012, 0x00000088, 0x0 },
147
	{ 0x00005012, 0x00000088, 0x0 },
148
	{ 0x00007011, 0x00000087, 0x0 },
148
	{ 0x00007011, 0x00000087, 0x0 },
149
	{ 0x80009010, 0x000000C7, 0x1 },	/* Uses I_boost level 0x1 */
149
	{ 0x80009010, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
150
	{ 0x0000201B, 0x0000009D, 0x0 },
150
	{ 0x0000201B, 0x0000009D, 0x0 },
151
	{ 0x00005012, 0x000000C7, 0x0 },
151
	{ 0x80005012, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
152
	{ 0x00007011, 0x000000C7, 0x0 },
152
	{ 0x80007011, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
153
	{ 0x00002016, 0x00000088, 0x0 },
153
	{ 0x00002016, 0x00000088, 0x0 },
154
	{ 0x00005012, 0x000000C7, 0x0 },
154
	{ 0x80005012, 0x000000C0, 0x1 },	/* Uses I_boost level 0x1 */
Line 155... Line 155...
155
};
155
};
156
 
156
 
157
/* Skylake Y */
157
/* Skylake Y */
158
static const struct ddi_buf_trans skl_y_ddi_translations_dp[] = {
158
static const struct ddi_buf_trans skl_y_ddi_translations_dp[] = {
159
	{ 0x00000018, 0x000000A2, 0x0 },
159
	{ 0x00000018, 0x000000A2, 0x0 },
160
	{ 0x00005012, 0x00000088, 0x0 },
160
	{ 0x00005012, 0x00000088, 0x0 },
161
	{ 0x00007011, 0x00000087, 0x0 },
161
	{ 0x00007011, 0x00000087, 0x0 },
162
	{ 0x80009010, 0x000000C7, 0x3 },	/* Uses I_boost level 0x3 */
162
	{ 0x80009010, 0x000000C0, 0x3 },	/* Uses I_boost level 0x3 */
163
	{ 0x00000018, 0x0000009D, 0x0 },
163
	{ 0x00000018, 0x0000009D, 0x0 },
164
	{ 0x00005012, 0x000000C7, 0x0 },
164
	{ 0x80005012, 0x000000C0, 0x3 },	/* Uses I_boost level 0x3 */
165
	{ 0x00007011, 0x000000C7, 0x0 },
165
	{ 0x80007011, 0x000000C0, 0x3 },	/* Uses I_boost level 0x3 */
166
	{ 0x00000018, 0x00000088, 0x0 },
166
	{ 0x00000018, 0x00000088, 0x0 },
Line 167... Line 167...
167
	{ 0x00005012, 0x000000C7, 0x0 },
167
	{ 0x80005012, 0x000000C0, 0x3 },	/* Uses I_boost level 0x3 */
168
};
168
};
169
 
169
 
Line 343... Line 343...
343
}
343
}
Line 344... Line 344...
344
 
344
 
345
static bool
345
static bool
346
intel_dig_port_supports_hdmi(const struct intel_digital_port *intel_dig_port)
346
intel_dig_port_supports_hdmi(const struct intel_digital_port *intel_dig_port)
347
{
347
{
348
	return intel_dig_port->hdmi.hdmi_reg;
348
	return i915_mmio_reg_valid(intel_dig_port->hdmi.hdmi_reg);
Line 349... Line 349...
349
}
349
}
350
 
350
 
351
static const struct ddi_buf_trans *skl_get_buf_trans_dp(struct drm_device *dev,
351
static const struct ddi_buf_trans *skl_get_buf_trans_dp(struct drm_device *dev,
352
							int *n_entries)
352
							int *n_entries)
Line 353... Line 353...
353
{
353
{
354
	const struct ddi_buf_trans *ddi_translations;
354
	const struct ddi_buf_trans *ddi_translations;
355
 
355
 
356
	if (IS_SKL_ULX(dev)) {
356
	if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) {
357
		ddi_translations = skl_y_ddi_translations_dp;
357
		ddi_translations = skl_y_ddi_translations_dp;
358
		*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
358
		*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
359
	} else if (IS_SKL_ULT(dev)) {
359
	} else if (IS_SKL_ULT(dev) || IS_KBL_ULT(dev)) {
360
		ddi_translations = skl_u_ddi_translations_dp;
360
		ddi_translations = skl_u_ddi_translations_dp;
361
		*n_entries = ARRAY_SIZE(skl_u_ddi_translations_dp);
361
		*n_entries = ARRAY_SIZE(skl_u_ddi_translations_dp);
Line 371... Line 371...
371
							 int *n_entries)
371
							 int *n_entries)
372
{
372
{
373
	struct drm_i915_private *dev_priv = dev->dev_private;
373
	struct drm_i915_private *dev_priv = dev->dev_private;
374
	const struct ddi_buf_trans *ddi_translations;
374
	const struct ddi_buf_trans *ddi_translations;
Line 375... Line 375...
375
 
375
 
376
	if (IS_SKL_ULX(dev)) {
376
	if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) {
377
		if (dev_priv->edp_low_vswing) {
377
		if (dev_priv->edp_low_vswing) {
378
			ddi_translations = skl_y_ddi_translations_edp;
378
			ddi_translations = skl_y_ddi_translations_edp;
379
			*n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp);
379
			*n_entries = ARRAY_SIZE(skl_y_ddi_translations_edp);
380
		} else {
380
		} else {
381
			ddi_translations = skl_y_ddi_translations_dp;
381
			ddi_translations = skl_y_ddi_translations_dp;
382
			*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
382
			*n_entries = ARRAY_SIZE(skl_y_ddi_translations_dp);
383
		}
383
		}
384
	} else if (IS_SKL_ULT(dev)) {
384
	} else if (IS_SKL_ULT(dev) || IS_KBL_ULT(dev)) {
385
		if (dev_priv->edp_low_vswing) {
385
		if (dev_priv->edp_low_vswing) {
386
			ddi_translations = skl_u_ddi_translations_edp;
386
			ddi_translations = skl_u_ddi_translations_edp;
387
			*n_entries = ARRAY_SIZE(skl_u_ddi_translations_edp);
387
			*n_entries = ARRAY_SIZE(skl_u_ddi_translations_edp);
388
		} else {
388
		} else {
Line 406... Line 406...
406
skl_get_buf_trans_hdmi(struct drm_device *dev,
406
skl_get_buf_trans_hdmi(struct drm_device *dev,
407
		       int *n_entries)
407
		       int *n_entries)
408
{
408
{
409
	const struct ddi_buf_trans *ddi_translations;
409
	const struct ddi_buf_trans *ddi_translations;
Line 410... Line 410...
410
 
410
 
411
	if (IS_SKL_ULX(dev)) {
411
	if (IS_SKL_ULX(dev) || IS_KBL_ULX(dev)) {
412
		ddi_translations = skl_y_ddi_translations_hdmi;
412
		ddi_translations = skl_y_ddi_translations_hdmi;
413
		*n_entries = ARRAY_SIZE(skl_y_ddi_translations_hdmi);
413
		*n_entries = ARRAY_SIZE(skl_y_ddi_translations_hdmi);
414
	} else {
414
	} else {
415
		ddi_translations = skl_ddi_translations_hdmi;
415
		ddi_translations = skl_ddi_translations_hdmi;
Line 446... Line 446...
446
 
446
 
447
		/* Vswing programming for HDMI */
447
		/* Vswing programming for HDMI */
448
		bxt_ddi_vswing_sequence(dev, hdmi_level, port,
448
		bxt_ddi_vswing_sequence(dev, hdmi_level, port,
449
					INTEL_OUTPUT_HDMI);
449
					INTEL_OUTPUT_HDMI);
450
		return;
450
		return;
451
	} else if (IS_SKYLAKE(dev)) {
451
	} else if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) {
452
		ddi_translations_fdi = NULL;
452
		ddi_translations_fdi = NULL;
453
		ddi_translations_dp =
453
		ddi_translations_dp =
454
				skl_get_buf_trans_dp(dev, &n_dp_entries);
454
				skl_get_buf_trans_dp(dev, &n_dp_entries);
455
		ddi_translations_edp =
455
		ddi_translations_edp =
Line 582... Line 582...
582
}
582
}
Line 583... Line 583...
583
 
583
 
584
static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
584
static void intel_wait_ddi_buf_idle(struct drm_i915_private *dev_priv,
585
				    enum port port)
585
				    enum port port)
586
{
586
{
587
	uint32_t reg = DDI_BUF_CTL(port);
587
	i915_reg_t reg = DDI_BUF_CTL(port);
Line 588... Line 588...
588
	int i;
588
	int i;
589
 
589
 
590
	for (i = 0; i < 16; i++) {
590
	for (i = 0; i < 16; i++) {
Line 681... Line 681...
681
		udelay(5);
681
		udelay(5);
Line 682... Line 682...
682
 
682
 
683
		temp = I915_READ(DP_TP_STATUS(PORT_E));
683
		temp = I915_READ(DP_TP_STATUS(PORT_E));
684
		if (temp & DP_TP_STATUS_AUTOTRAIN_DONE) {
684
		if (temp & DP_TP_STATUS_AUTOTRAIN_DONE) {
-
 
685
			DRM_DEBUG_KMS("FDI link training done on step %d\n", i);
-
 
686
			break;
Line -... Line 687...
-
 
687
		}
685
			DRM_DEBUG_KMS("FDI link training done on step %d\n", i);
688
 
686
 
689
		/*
687
			/* Enable normal pixel sending for FDI */
690
		 * Leave things enabled even if we failed to train FDI.
688
			I915_WRITE(DP_TP_CTL(PORT_E),
691
		 * Results in less fireworks from the state checker.
689
				   DP_TP_CTL_FDI_AUTOTRAIN |
692
		 */
690
				   DP_TP_CTL_LINK_TRAIN_NORMAL |
-
 
691
				   DP_TP_CTL_ENHANCED_FRAME_ENABLE |
-
 
692
				   DP_TP_CTL_ENABLE);
693
		if (i == ARRAY_SIZE(hsw_ddi_translations_fdi) * 2 - 1) {
693
 
694
			DRM_ERROR("FDI link training failed!\n");
Line 694... Line 695...
694
			return;
695
			break;
695
		}
696
		}
696
 
697
 
Line 718... Line 719...
718
		temp |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2);
719
		temp |= FDI_RX_PWRDN_LANE1_VAL(2) | FDI_RX_PWRDN_LANE0_VAL(2);
719
		I915_WRITE(FDI_RX_MISC(PIPE_A), temp);
720
		I915_WRITE(FDI_RX_MISC(PIPE_A), temp);
720
		POSTING_READ(FDI_RX_MISC(PIPE_A));
721
		POSTING_READ(FDI_RX_MISC(PIPE_A));
721
	}
722
	}
Line 722... Line 723...
722
 
723
 
-
 
724
	/* Enable normal pixel sending for FDI */
-
 
725
	I915_WRITE(DP_TP_CTL(PORT_E),
-
 
726
		   DP_TP_CTL_FDI_AUTOTRAIN |
-
 
727
		   DP_TP_CTL_LINK_TRAIN_NORMAL |
-
 
728
		   DP_TP_CTL_ENHANCED_FRAME_ENABLE |
723
	DRM_ERROR("FDI link training failed!\n");
729
		   DP_TP_CTL_ENABLE);
Line 724... Line 730...
724
}
730
}
725
 
731
 
726
void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder)
732
void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder)
Line 937... Line 943...
937
		}
943
		}
938
	}
944
	}
939
	/* Otherwise a < c && b >= d, do nothing */
945
	/* Otherwise a < c && b >= d, do nothing */
940
}
946
}
Line 941... Line 947...
941
 
947
 
-
 
948
static int hsw_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv,
942
static int hsw_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv, int reg)
949
				   i915_reg_t reg)
943
{
950
{
944
	int refclk = LC_FREQ;
951
	int refclk = LC_FREQ;
945
	int n, p, r;
952
	int n, p, r;
Line 973... Line 980...
973
}
980
}
Line 974... Line 981...
974
 
981
 
975
static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
982
static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
976
			       uint32_t dpll)
983
			       uint32_t dpll)
977
{
984
{
978
	uint32_t cfgcr1_reg, cfgcr2_reg;
985
	i915_reg_t cfgcr1_reg, cfgcr2_reg;
979
	uint32_t cfgcr1_val, cfgcr2_val;
986
	uint32_t cfgcr1_val, cfgcr2_val;
Line 980... Line 987...
980
	uint32_t p0, p1, p2, dco_freq;
987
	uint32_t p0, p1, p2, dco_freq;
981
 
988
 
Line 1118... Line 1125...
1118
		break;
1125
		break;
1119
	case PORT_CLK_SEL_LCPLL_2700:
1126
	case PORT_CLK_SEL_LCPLL_2700:
1120
		link_clock = 270000;
1127
		link_clock = 270000;
1121
		break;
1128
		break;
1122
	case PORT_CLK_SEL_WRPLL1:
1129
	case PORT_CLK_SEL_WRPLL1:
1123
		link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL1);
1130
		link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL(0));
1124
		break;
1131
		break;
1125
	case PORT_CLK_SEL_WRPLL2:
1132
	case PORT_CLK_SEL_WRPLL2:
1126
		link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL2);
1133
		link_clock = hsw_ddi_calc_wrpll_link(dev_priv, WRPLL_CTL(1));
1127
		break;
1134
		break;
1128
	case PORT_CLK_SEL_SPLL:
1135
	case PORT_CLK_SEL_SPLL:
1129
		pll = I915_READ(SPLL_CTL) & SPLL_PLL_FREQ_MASK;
1136
		pll = I915_READ(SPLL_CTL) & SPLL_PLL_FREQ_MASK;
1130
		if (pll == SPLL_PLL_FREQ_810MHz)
1137
		if (pll == SPLL_PLL_FREQ_810MHz)
1131
			link_clock = 81000;
1138
			link_clock = 81000;
Line 1190... Line 1197...
1190
{
1197
{
1191
	struct drm_device *dev = encoder->base.dev;
1198
	struct drm_device *dev = encoder->base.dev;
Line 1192... Line 1199...
1192
 
1199
 
1193
	if (INTEL_INFO(dev)->gen <= 8)
1200
	if (INTEL_INFO(dev)->gen <= 8)
1194
		hsw_ddi_clock_get(encoder, pipe_config);
1201
		hsw_ddi_clock_get(encoder, pipe_config);
1195
	else if (IS_SKYLAKE(dev))
1202
	else if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
1196
		skl_ddi_clock_get(encoder, pipe_config);
1203
		skl_ddi_clock_get(encoder, pipe_config);
1197
	else if (IS_BROXTON(dev))
1204
	else if (IS_BROXTON(dev))
1198
		bxt_ddi_clock_get(encoder, pipe_config);
1205
		bxt_ddi_clock_get(encoder, pipe_config);
Line 1787... Line 1794...
1787
{
1794
{
1788
	struct drm_device *dev = intel_crtc->base.dev;
1795
	struct drm_device *dev = intel_crtc->base.dev;
1789
	struct intel_encoder *intel_encoder =
1796
	struct intel_encoder *intel_encoder =
1790
		intel_ddi_get_crtc_new_encoder(crtc_state);
1797
		intel_ddi_get_crtc_new_encoder(crtc_state);
Line 1791... Line 1798...
1791
 
1798
 
1792
	if (IS_SKYLAKE(dev))
1799
	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
1793
		return skl_ddi_pll_select(intel_crtc, crtc_state,
1800
		return skl_ddi_pll_select(intel_crtc, crtc_state,
1794
					  intel_encoder);
1801
					  intel_encoder);
1795
	else if (IS_BROXTON(dev))
1802
	else if (IS_BROXTON(dev))
1796
		return bxt_ddi_pll_select(intel_crtc, crtc_state,
1803
		return bxt_ddi_pll_select(intel_crtc, crtc_state,
Line 1949... Line 1956...
1949
}
1956
}
Line 1950... Line 1957...
1950
 
1957
 
1951
void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
1958
void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
1952
				       enum transcoder cpu_transcoder)
1959
				       enum transcoder cpu_transcoder)
1953
{
1960
{
1954
	uint32_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder);
1961
	i915_reg_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder);
Line 1955... Line 1962...
1955
	uint32_t val = I915_READ(reg);
1962
	uint32_t val = I915_READ(reg);
1956
 
1963
 
1957
	val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK | TRANS_DDI_DP_VC_PAYLOAD_ALLOC);
1964
	val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK | TRANS_DDI_DP_VC_PAYLOAD_ALLOC);
Line 1968... Line 1975...
1968
	enum port port = intel_ddi_get_encoder_port(intel_encoder);
1975
	enum port port = intel_ddi_get_encoder_port(intel_encoder);
1969
	enum pipe pipe = 0;
1976
	enum pipe pipe = 0;
1970
	enum transcoder cpu_transcoder;
1977
	enum transcoder cpu_transcoder;
1971
	enum intel_display_power_domain power_domain;
1978
	enum intel_display_power_domain power_domain;
1972
	uint32_t tmp;
1979
	uint32_t tmp;
-
 
1980
	bool ret;
Line 1973... Line 1981...
1973
 
1981
 
1974
	power_domain = intel_display_port_power_domain(intel_encoder);
1982
	power_domain = intel_display_port_power_domain(intel_encoder);
1975
	if (!intel_display_power_is_enabled(dev_priv, power_domain))
1983
	if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
Line 1976... Line 1984...
1976
		return false;
1984
		return false;
1977
 
1985
 
-
 
1986
	if (!intel_encoder->get_hw_state(intel_encoder, &pipe)) {
-
 
1987
		ret = false;
Line 1978... Line 1988...
1978
	if (!intel_encoder->get_hw_state(intel_encoder, &pipe))
1988
		goto out;
1979
		return false;
1989
	}
1980
 
1990
 
1981
	if (port == PORT_A)
1991
	if (port == PORT_A)
Line 1986... Line 1996...
1986
	tmp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
1996
	tmp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
Line 1987... Line 1997...
1987
 
1997
 
1988
	switch (tmp & TRANS_DDI_MODE_SELECT_MASK) {
1998
	switch (tmp & TRANS_DDI_MODE_SELECT_MASK) {
1989
	case TRANS_DDI_MODE_SELECT_HDMI:
1999
	case TRANS_DDI_MODE_SELECT_HDMI:
1990
	case TRANS_DDI_MODE_SELECT_DVI:
2000
	case TRANS_DDI_MODE_SELECT_DVI:
-
 
2001
		ret = type == DRM_MODE_CONNECTOR_HDMIA;
Line 1991... Line 2002...
1991
		return (type == DRM_MODE_CONNECTOR_HDMIA);
2002
		break;
1992
 
2003
 
1993
	case TRANS_DDI_MODE_SELECT_DP_SST:
-
 
1994
		if (type == DRM_MODE_CONNECTOR_eDP)
2004
	case TRANS_DDI_MODE_SELECT_DP_SST:
-
 
2005
		ret = type == DRM_MODE_CONNECTOR_eDP ||
-
 
2006
		      type == DRM_MODE_CONNECTOR_DisplayPort;
1995
			return true;
2007
		break;
1996
		return (type == DRM_MODE_CONNECTOR_DisplayPort);
2008
 
1997
	case TRANS_DDI_MODE_SELECT_DP_MST:
2009
	case TRANS_DDI_MODE_SELECT_DP_MST:
1998
		/* if the transcoder is in MST state then
2010
		/* if the transcoder is in MST state then
-
 
2011
		 * connector isn't connected */
Line 1999... Line 2012...
1999
		 * connector isn't connected */
2012
		ret = false;
2000
		return false;
2013
		break;
-
 
2014
 
Line 2001... Line 2015...
2001
 
2015
	case TRANS_DDI_MODE_SELECT_FDI:
2002
	case TRANS_DDI_MODE_SELECT_FDI:
2016
		ret = type == DRM_MODE_CONNECTOR_VGA;
-
 
2017
		break;
2003
		return (type == DRM_MODE_CONNECTOR_VGA);
2018
 
-
 
2019
	default:
-
 
2020
		ret = false;
-
 
2021
		break;
-
 
2022
	}
-
 
2023
 
2004
 
2024
out:
Line 2005... Line 2025...
2005
	default:
2025
	intel_display_power_put(dev_priv, power_domain);
2006
		return false;
2026
 
2007
	}
2027
	return ret;
Line 2014... Line 2034...
2014
	struct drm_i915_private *dev_priv = dev->dev_private;
2034
	struct drm_i915_private *dev_priv = dev->dev_private;
2015
	enum port port = intel_ddi_get_encoder_port(encoder);
2035
	enum port port = intel_ddi_get_encoder_port(encoder);
2016
	enum intel_display_power_domain power_domain;
2036
	enum intel_display_power_domain power_domain;
2017
	u32 tmp;
2037
	u32 tmp;
2018
	int i;
2038
	int i;
-
 
2039
	bool ret;
Line 2019... Line 2040...
2019
 
2040
 
2020
	power_domain = intel_display_port_power_domain(encoder);
2041
	power_domain = intel_display_port_power_domain(encoder);
2021
	if (!intel_display_power_is_enabled(dev_priv, power_domain))
2042
	if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
Line -... Line 2043...
-
 
2043
		return false;
-
 
2044
 
2022
		return false;
2045
	ret = false;
Line 2023... Line 2046...
2023
 
2046
 
2024
	tmp = I915_READ(DDI_BUF_CTL(port));
2047
	tmp = I915_READ(DDI_BUF_CTL(port));
Line 2025... Line 2048...
2025
 
2048
 
2026
	if (!(tmp & DDI_BUF_CTL_ENABLE))
2049
	if (!(tmp & DDI_BUF_CTL_ENABLE))
Line 2027... Line 2050...
2027
		return false;
2050
		goto out;
Line 2040... Line 2063...
2040
		case TRANS_DDI_EDP_INPUT_C_ONOFF:
2063
		case TRANS_DDI_EDP_INPUT_C_ONOFF:
2041
			*pipe = PIPE_C;
2064
			*pipe = PIPE_C;
2042
			break;
2065
			break;
2043
		}
2066
		}
Line 2044... Line 2067...
2044
 
2067
 
-
 
2068
		ret = true;
2045
		return true;
2069
 
-
 
2070
		goto out;
-
 
2071
	}
2046
	} else {
2072
 
2047
		for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) {
2073
		for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) {
Line 2048... Line 2074...
2048
			tmp = I915_READ(TRANS_DDI_FUNC_CTL(i));
2074
			tmp = I915_READ(TRANS_DDI_FUNC_CTL(i));
2049
 
2075
 
2050
			if ((tmp & TRANS_DDI_PORT_MASK)
2076
		if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(port)) {
2051
			    == TRANS_DDI_SELECT_PORT(port)) {
2077
			if ((tmp & TRANS_DDI_MODE_SELECT_MASK) ==
Line 2052... Line 2078...
2052
				if ((tmp & TRANS_DDI_MODE_SELECT_MASK) == TRANS_DDI_MODE_SELECT_DP_MST)
2078
			    TRANS_DDI_MODE_SELECT_DP_MST)
2053
					return false;
2079
				goto out;
-
 
2080
 
2054
 
2081
				*pipe = i;
2055
				*pipe = i;
2082
			ret = true;
2056
				return true;
2083
 
Line 2057... Line 2084...
2057
			}
2084
			goto out;
Line -... Line 2085...
-
 
2085
		}
-
 
2086
	}
-
 
2087
 
2058
		}
2088
	DRM_DEBUG_KMS("No pipe for ddi port %c found\n", port_name(port));
2059
	}
2089
 
Line 2060... Line 2090...
2060
 
2090
out:
2061
	DRM_DEBUG_KMS("No pipe for ddi port %c found\n", port_name(port));
2091
	intel_display_power_put(dev_priv, power_domain);
2062
 
2092
 
Line 2104... Line 2134...
2104
	if (type == INTEL_OUTPUT_DISPLAYPORT) {
2134
	if (type == INTEL_OUTPUT_DISPLAYPORT) {
2105
		if (dp_iboost) {
2135
		if (dp_iboost) {
2106
			iboost = dp_iboost;
2136
			iboost = dp_iboost;
2107
		} else {
2137
		} else {
2108
			ddi_translations = skl_get_buf_trans_dp(dev, &n_entries);
2138
			ddi_translations = skl_get_buf_trans_dp(dev, &n_entries);
2109
			iboost = ddi_translations[port].i_boost;
2139
			iboost = ddi_translations[level].i_boost;
2110
		}
2140
		}
2111
	} else if (type == INTEL_OUTPUT_EDP) {
2141
	} else if (type == INTEL_OUTPUT_EDP) {
2112
		if (dp_iboost) {
2142
		if (dp_iboost) {
2113
			iboost = dp_iboost;
2143
			iboost = dp_iboost;
2114
		} else {
2144
		} else {
2115
			ddi_translations = skl_get_buf_trans_edp(dev, &n_entries);
2145
			ddi_translations = skl_get_buf_trans_edp(dev, &n_entries);
2116
			iboost = ddi_translations[port].i_boost;
2146
			iboost = ddi_translations[level].i_boost;
2117
		}
2147
		}
2118
	} else if (type == INTEL_OUTPUT_HDMI) {
2148
	} else if (type == INTEL_OUTPUT_HDMI) {
2119
		if (hdmi_iboost) {
2149
		if (hdmi_iboost) {
2120
			iboost = hdmi_iboost;
2150
			iboost = hdmi_iboost;
2121
		} else {
2151
		} else {
2122
			ddi_translations = skl_get_buf_trans_hdmi(dev, &n_entries);
2152
			ddi_translations = skl_get_buf_trans_hdmi(dev, &n_entries);
2123
			iboost = ddi_translations[port].i_boost;
2153
			iboost = ddi_translations[level].i_boost;
2124
		}
2154
		}
2125
	} else {
2155
	} else {
2126
		return;
2156
		return;
2127
	}
2157
	}
Line 2270... Line 2300...
2270
	enum port port = dport->port;
2300
	enum port port = dport->port;
2271
	uint32_t level;
2301
	uint32_t level;
Line 2272... Line 2302...
2272
 
2302
 
Line 2273... Line 2303...
2273
	level = translate_signal_level(signal_levels);
2303
	level = translate_signal_level(signal_levels);
2274
 
2304
 
2275
	if (IS_SKYLAKE(dev))
2305
	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
2276
		skl_ddi_set_iboost(dev, level, port, encoder->type);
2306
		skl_ddi_set_iboost(dev, level, port, encoder->type);
Line 2277... Line 2307...
2277
	else if (IS_BROXTON(dev))
2307
	else if (IS_BROXTON(dev))
2278
		bxt_ddi_vswing_sequence(dev, level, port, encoder->type);
2308
		bxt_ddi_vswing_sequence(dev, level, port, encoder->type);
Line 2279... Line 2309...
2279
 
2309
 
-
 
2310
	return DDI_BUF_TRANS_SELECT(level);
2280
	return DDI_BUF_TRANS_SELECT(level);
2311
}
2281
}
-
 
2282
 
-
 
2283
static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
2312
 
2284
{
-
 
2285
	struct drm_encoder *encoder = &intel_encoder->base;
2313
void intel_ddi_clk_select(struct intel_encoder *encoder,
2286
	struct drm_device *dev = encoder->dev;
-
 
2287
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2288
	struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
-
 
2289
	enum port port = intel_ddi_get_encoder_port(intel_encoder);
-
 
2290
	int type = intel_encoder->type;
-
 
2291
	int hdmi_level;
-
 
2292
 
-
 
Line 2293... Line 2314...
2293
	if (type == INTEL_OUTPUT_EDP) {
2314
			  const struct intel_crtc_state *pipe_config)
2294
		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
2315
{
2295
		intel_edp_panel_on(intel_dp);
2316
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
Line 2296... Line 2317...
2296
	}
2317
	enum port port = intel_ddi_get_encoder_port(encoder);
2297
 
2318
 
2298
	if (IS_SKYLAKE(dev)) {
2319
	if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
2299
		uint32_t dpll = crtc->config->ddi_pll_sel;
2320
		uint32_t dpll = pipe_config->ddi_pll_sel;
2300
		uint32_t val;
2321
		uint32_t val;
2301
 
2322
 
Line 2302... Line 2323...
2302
		/*
2323
		/*
Line 2303... Line 2324...
2303
		 * DPLL0 is used for eDP and is the only "private" DPLL (as
2324
		 * DPLL0 is used for eDP and is the only "private" DPLL (as
2304
		 * opposed to shared) on SKL
2325
		 * opposed to shared) on SKL
2305
		 */
2326
		 */
2306
		if (type == INTEL_OUTPUT_EDP) {
2327
		if (encoder->type == INTEL_OUTPUT_EDP) {
Line 2307... Line 2328...
2307
			WARN_ON(dpll != SKL_DPLL0);
2328
			WARN_ON(dpll != SKL_DPLL0);
2308
 
2329
 
2309
			val = I915_READ(DPLL_CTRL1);
2330
			val = I915_READ(DPLL_CTRL1);
Line 2325... Line 2346...
2325
		val |= (DPLL_CTRL2_DDI_CLK_SEL(dpll, port) |
2346
		val |= (DPLL_CTRL2_DDI_CLK_SEL(dpll, port) |
2326
			DPLL_CTRL2_DDI_SEL_OVERRIDE(port));
2347
			DPLL_CTRL2_DDI_SEL_OVERRIDE(port));
Line 2327... Line 2348...
2327
 
2348
 
Line 2328... Line 2349...
2328
		I915_WRITE(DPLL_CTRL2, val);
2349
		I915_WRITE(DPLL_CTRL2, val);
2329
 
2350
 
2330
	} else if (INTEL_INFO(dev)->gen < 9) {
2351
	} else if (INTEL_INFO(dev_priv)->gen < 9) {
-
 
2352
		WARN_ON(pipe_config->ddi_pll_sel == PORT_CLK_SEL_NONE);
2331
		WARN_ON(crtc->config->ddi_pll_sel == PORT_CLK_SEL_NONE);
2353
		I915_WRITE(PORT_CLK_SEL(port), pipe_config->ddi_pll_sel);
Line -... Line 2354...
-
 
2354
	}
-
 
2355
}
-
 
2356
 
-
 
2357
static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder)
-
 
2358
{
-
 
2359
	struct drm_encoder *encoder = &intel_encoder->base;
-
 
2360
	struct drm_device *dev = encoder->dev;
-
 
2361
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2362
	struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
-
 
2363
	enum port port = intel_ddi_get_encoder_port(intel_encoder);
-
 
2364
	int type = intel_encoder->type;
-
 
2365
	int hdmi_level;
-
 
2366
 
-
 
2367
	if (type == INTEL_OUTPUT_EDP) {
-
 
2368
		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
-
 
2369
		intel_edp_panel_on(intel_dp);
-
 
2370
	}
2332
		I915_WRITE(PORT_CLK_SEL(port), crtc->config->ddi_pll_sel);
2371
 
2333
	}
2372
	intel_ddi_clk_select(intel_encoder, crtc->config);
Line 2334... Line 2373...
2334
 
2373
 
Line 2388... Line 2427...
2388
		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
2427
		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
2389
		intel_edp_panel_vdd_on(intel_dp);
2428
		intel_edp_panel_vdd_on(intel_dp);
2390
		intel_edp_panel_off(intel_dp);
2429
		intel_edp_panel_off(intel_dp);
2391
	}
2430
	}
Line 2392... Line 2431...
2392
 
2431
 
2393
	if (IS_SKYLAKE(dev))
2432
	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
2394
		I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) |
2433
		I915_WRITE(DPLL_CTRL2, (I915_READ(DPLL_CTRL2) |
2395
					DPLL_CTRL2_DDI_CLK_OFF(port)));
2434
					DPLL_CTRL2_DDI_CLK_OFF(port)));
2396
	else if (INTEL_INFO(dev)->gen < 9)
2435
	else if (INTEL_INFO(dev)->gen < 9)
2397
		I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
2436
		I915_WRITE(PORT_CLK_SEL(port), PORT_CLK_SEL_NONE);
Line 2498... Line 2537...
2498
				       struct intel_shared_dpll *pll,
2537
				       struct intel_shared_dpll *pll,
2499
				       struct intel_dpll_hw_state *hw_state)
2538
				       struct intel_dpll_hw_state *hw_state)
2500
{
2539
{
2501
	uint32_t val;
2540
	uint32_t val;
Line 2502... Line 2541...
2502
 
2541
 
2503
	if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
2542
	if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
Line 2504... Line 2543...
2504
		return false;
2543
		return false;
2505
 
2544
 
Line -... Line 2545...
-
 
2545
	val = I915_READ(WRPLL_CTL(pll->id));
-
 
2546
	hw_state->wrpll = val;
2506
	val = I915_READ(WRPLL_CTL(pll->id));
2547
 
2507
	hw_state->wrpll = val;
2548
	intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
Line 2508... Line 2549...
2508
 
2549
 
2509
	return val & WRPLL_PLL_ENABLE;
2550
	return val & WRPLL_PLL_ENABLE;
2510
}
2551
}
2511
 
2552
 
2512
static bool hsw_ddi_spll_get_hw_state(struct drm_i915_private *dev_priv,
2553
static bool hsw_ddi_spll_get_hw_state(struct drm_i915_private *dev_priv,
Line 2513... Line 2554...
2513
				      struct intel_shared_dpll *pll,
2554
				      struct intel_shared_dpll *pll,
2514
				      struct intel_dpll_hw_state *hw_state)
2555
				      struct intel_dpll_hw_state *hw_state)
Line 2515... Line 2556...
2515
{
2556
{
2516
	uint32_t val;
2557
	uint32_t val;
Line -... Line 2558...
-
 
2558
 
-
 
2559
	if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
2517
 
2560
		return false;
2518
	if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
2561
 
Line 2519... Line 2562...
2519
		return false;
2562
	val = I915_READ(SPLL_CTL);
Line 2560... Line 2603...
2560
	"DPLL 2",
2603
	"DPLL 2",
2561
	"DPLL 3",
2604
	"DPLL 3",
2562
};
2605
};
Line 2563... Line 2606...
2563
 
2606
 
2564
struct skl_dpll_regs {
2607
struct skl_dpll_regs {
2565
	u32 ctl, cfgcr1, cfgcr2;
2608
	i915_reg_t ctl, cfgcr1, cfgcr2;
Line 2566... Line 2609...
2566
};
2609
};
2567
 
2610
 
2568
/* this array is indexed by the *shared* pll id */
2611
/* this array is indexed by the *shared* pll id */
Line 2573... Line 2616...
2573
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL1),
2616
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL1),
2574
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL1),
2617
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL1),
2575
	},
2618
	},
2576
	{
2619
	{
2577
		/* DPLL 2 */
2620
		/* DPLL 2 */
2578
		.ctl = WRPLL_CTL1,
2621
		.ctl = WRPLL_CTL(0),
2579
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL2),
2622
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL2),
2580
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL2),
2623
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL2),
2581
	},
2624
	},
2582
	{
2625
	{
2583
		/* DPLL 3 */
2626
		/* DPLL 3 */
2584
		.ctl = WRPLL_CTL2,
2627
		.ctl = WRPLL_CTL(1),
2585
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL3),
2628
		.cfgcr1 = DPLL_CFGCR1(SKL_DPLL3),
2586
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL3),
2629
		.cfgcr2 = DPLL_CFGCR2(SKL_DPLL3),
2587
	},
2630
	},
2588
};
2631
};
Line 2635... Line 2678...
2635
				     struct intel_dpll_hw_state *hw_state)
2678
				     struct intel_dpll_hw_state *hw_state)
2636
{
2679
{
2637
	uint32_t val;
2680
	uint32_t val;
2638
	unsigned int dpll;
2681
	unsigned int dpll;
2639
	const struct skl_dpll_regs *regs = skl_dpll_regs;
2682
	const struct skl_dpll_regs *regs = skl_dpll_regs;
-
 
2683
	bool ret;
Line 2640... Line 2684...
2640
 
2684
 
2641
	if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
2685
	if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
Line -... Line 2686...
-
 
2686
		return false;
-
 
2687
 
2642
		return false;
2688
	ret = false;
2643
 
2689
 
Line 2644... Line 2690...
2644
	/* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
2690
	/* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
2645
	dpll = pll->id + 1;
2691
	dpll = pll->id + 1;
2646
 
2692
 
Line 2647... Line 2693...
2647
	val = I915_READ(regs[pll->id].ctl);
2693
	val = I915_READ(regs[pll->id].ctl);
2648
	if (!(val & LCPLL_PLL_ENABLE))
2694
	if (!(val & LCPLL_PLL_ENABLE))
Line 2649... Line 2695...
2649
		return false;
2695
		goto out;
2650
 
2696
 
2651
	val = I915_READ(DPLL_CTRL1);
2697
	val = I915_READ(DPLL_CTRL1);
2652
	hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f;
2698
	hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f;
2653
 
2699
 
-
 
2700
	/* avoid reading back stale values if HDMI mode is not enabled */
Line -... Line 2701...
-
 
2701
	if (val & DPLL_CTRL1_HDMI_MODE(dpll)) {
-
 
2702
		hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1);
-
 
2703
		hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2);
2654
	/* avoid reading back stale values if HDMI mode is not enabled */
2704
	}
2655
	if (val & DPLL_CTRL1_HDMI_MODE(dpll)) {
2705
	ret = true;
Line 2656... Line 2706...
2656
		hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1);
2706
 
2657
		hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2);
2707
out:
2658
	}
2708
	intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
Line 2922... Line 2972...
2922
					struct intel_shared_dpll *pll,
2972
					struct intel_shared_dpll *pll,
2923
					struct intel_dpll_hw_state *hw_state)
2973
					struct intel_dpll_hw_state *hw_state)
2924
{
2974
{
2925
	enum port port = (enum port)pll->id;	/* 1:1 port->PLL mapping */
2975
	enum port port = (enum port)pll->id;	/* 1:1 port->PLL mapping */
2926
	uint32_t val;
2976
	uint32_t val;
-
 
2977
	bool ret;
Line 2927... Line 2978...
2927
 
2978
 
2928
	if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
2979
	if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
Line -... Line 2980...
-
 
2980
		return false;
-
 
2981
 
2929
		return false;
2982
	ret = false;
2930
 
2983
 
2931
	val = I915_READ(BXT_PORT_PLL_ENABLE(port));
2984
	val = I915_READ(BXT_PORT_PLL_ENABLE(port));
Line 2932... Line 2985...
2932
	if (!(val & PORT_PLL_ENABLE))
2985
	if (!(val & PORT_PLL_ENABLE))
2933
		return false;
2986
		goto out;
Line 2934... Line 2987...
2934
 
2987
 
Line 2975... Line 3028...
2975
		DRM_DEBUG_DRIVER("lane stagger config different for lane 01 (%08x) and 23 (%08x)\n",
3028
		DRM_DEBUG_DRIVER("lane stagger config different for lane 01 (%08x) and 23 (%08x)\n",
2976
				 hw_state->pcsdw12,
3029
				 hw_state->pcsdw12,
2977
				 I915_READ(BXT_PORT_PCS_DW12_LN23(port)));
3030
				 I915_READ(BXT_PORT_PCS_DW12_LN23(port)));
2978
	hw_state->pcsdw12 &= LANE_STAGGER_MASK | LANESTAGGER_STRAP_OVRD;
3031
	hw_state->pcsdw12 &= LANE_STAGGER_MASK | LANESTAGGER_STRAP_OVRD;
Line 2979... Line 3032...
2979
 
3032
 
-
 
3033
	ret = true;
-
 
3034
 
-
 
3035
out:
-
 
3036
	intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
-
 
3037
 
2980
	return true;
3038
	return ret;
Line 2981... Line 3039...
2981
}
3039
}
2982
 
3040
 
2983
static void bxt_shared_dplls_init(struct drm_i915_private *dev_priv)
3041
static void bxt_shared_dplls_init(struct drm_i915_private *dev_priv)
Line 2999... Line 3057...
2999
void intel_ddi_pll_init(struct drm_device *dev)
3057
void intel_ddi_pll_init(struct drm_device *dev)
3000
{
3058
{
3001
	struct drm_i915_private *dev_priv = dev->dev_private;
3059
	struct drm_i915_private *dev_priv = dev->dev_private;
3002
	uint32_t val = I915_READ(LCPLL_CTL);
3060
	uint32_t val = I915_READ(LCPLL_CTL);
Line 3003... Line 3061...
3003
 
3061
 
3004
	if (IS_SKYLAKE(dev))
3062
	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
3005
		skl_shared_dplls_init(dev_priv);
3063
		skl_shared_dplls_init(dev_priv);
3006
	else if (IS_BROXTON(dev))
3064
	else if (IS_BROXTON(dev))
3007
		bxt_shared_dplls_init(dev_priv);
3065
		bxt_shared_dplls_init(dev_priv);
3008
	else
3066
	else
Line 3009... Line 3067...
3009
		hsw_shared_dplls_init(dev_priv);
3067
		hsw_shared_dplls_init(dev_priv);
3010
 
3068
 
Line 3011... Line 3069...
3011
	if (IS_SKYLAKE(dev)) {
3069
	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) {
3012
		int cdclk_freq;
3070
		int cdclk_freq;
-
 
3071
 
-
 
3072
		cdclk_freq = dev_priv->display.get_display_clock_speed(dev);
3013
 
3073
		dev_priv->skl_boot_cdclk = cdclk_freq;
3014
		cdclk_freq = dev_priv->display.get_display_clock_speed(dev);
3074
		if (skl_sanitize_cdclk(dev_priv))
3015
		dev_priv->skl_boot_cdclk = cdclk_freq;
-
 
3016
		if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
-
 
3017
			DRM_ERROR("LCPLL1 is disabled\n");
3075
			DRM_DEBUG_KMS("Sanitized cdclk programmed by pre-os\n");
3018
		else
3076
		if (!(I915_READ(LCPLL1_CTL) & LCPLL_PLL_ENABLE))
3019
			intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS);
3077
			DRM_ERROR("LCPLL1 is disabled\n");
3020
	} else if (IS_BROXTON(dev)) {
3078
	} else if (IS_BROXTON(dev)) {
3021
		broxton_init_cdclk(dev);
3079
		broxton_init_cdclk(dev);
Line 3033... Line 3091...
3033
		if (val & LCPLL_PLL_DISABLE)
3091
		if (val & LCPLL_PLL_DISABLE)
3034
			DRM_ERROR("LCPLL is disabled\n");
3092
			DRM_ERROR("LCPLL is disabled\n");
3035
	}
3093
	}
3036
}
3094
}
Line 3037... Line 3095...
3037
 
3095
 
3038
void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder)
3096
void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp)
3039
{
3097
{
3040
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
3098
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
3041
	struct intel_dp *intel_dp = &intel_dig_port->dp;
3099
	struct drm_i915_private *dev_priv =
3042
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
3100
		to_i915(intel_dig_port->base.base.dev);
3043
	enum port port = intel_dig_port->port;
3101
	enum port port = intel_dig_port->port;
3044
	uint32_t val;
3102
	uint32_t val;
Line 3045... Line 3103...
3045
	bool wait = false;
3103
	bool wait = false;
Line 3148... Line 3206...
3148
	switch (temp & TRANS_DDI_MODE_SELECT_MASK) {
3206
	switch (temp & TRANS_DDI_MODE_SELECT_MASK) {
3149
	case TRANS_DDI_MODE_SELECT_HDMI:
3207
	case TRANS_DDI_MODE_SELECT_HDMI:
3150
		pipe_config->has_hdmi_sink = true;
3208
		pipe_config->has_hdmi_sink = true;
3151
		intel_hdmi = enc_to_intel_hdmi(&encoder->base);
3209
		intel_hdmi = enc_to_intel_hdmi(&encoder->base);
Line 3152... Line 3210...
3152
 
3210
 
3153
		if (intel_hdmi->infoframe_enabled(&encoder->base))
3211
		if (intel_hdmi->infoframe_enabled(&encoder->base, pipe_config))
3154
			pipe_config->has_infoframe = true;
3212
			pipe_config->has_infoframe = true;
3155
		break;
3213
		break;
3156
	case TRANS_DDI_MODE_SELECT_DVI:
3214
	case TRANS_DDI_MODE_SELECT_DVI:
3157
	case TRANS_DDI_MODE_SELECT_FDI:
3215
	case TRANS_DDI_MODE_SELECT_FDI:
Line 3276... Line 3334...
3276
 
3334
 
3277
	intel_encoder = &intel_dig_port->base;
3335
	intel_encoder = &intel_dig_port->base;
Line 3278... Line 3336...
3278
	encoder = &intel_encoder->base;
3336
	encoder = &intel_encoder->base;
3279
 
3337
 
Line 3280... Line 3338...
3280
	drm_encoder_init(dev, encoder, &intel_ddi_funcs,
3338
	drm_encoder_init(dev, encoder, &intel_ddi_funcs,
3281
			 DRM_MODE_ENCODER_TMDS);
3339
			 DRM_MODE_ENCODER_TMDS, NULL);
3282
 
3340
 
3283
	intel_encoder->compute_config = intel_ddi_compute_config;
3341
	intel_encoder->compute_config = intel_ddi_compute_config;
Line 3292... Line 3350...
3292
	intel_dig_port->port = port;
3350
	intel_dig_port->port = port;
3293
	intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
3351
	intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
3294
					  (DDI_BUF_PORT_REVERSAL |
3352
					  (DDI_BUF_PORT_REVERSAL |
3295
					   DDI_A_4_LANES);
3353
					   DDI_A_4_LANES);
Line -... Line 3354...
-
 
3354
 
-
 
3355
	/*
-
 
3356
	 * Bspec says that DDI_A_4_LANES is the only supported configuration
-
 
3357
	 * for Broxton.  Yet some BIOS fail to set this bit on port A if eDP
-
 
3358
	 * wasn't lit up at boot.  Force this bit on in our internal
-
 
3359
	 * configuration so that we use the proper lane count for our
-
 
3360
	 * calculations.
-
 
3361
	 */
-
 
3362
	if (IS_BROXTON(dev) && port == PORT_A) {
-
 
3363
		if (!(intel_dig_port->saved_port_bits & DDI_A_4_LANES)) {
-
 
3364
			DRM_DEBUG_KMS("BXT BIOS forgot to set DDI_A_4_LANES for port A; fixing\n");
-
 
3365
			intel_dig_port->saved_port_bits |= DDI_A_4_LANES;
-
 
3366
		}
-
 
3367
	}
3296
 
3368
 
3297
	intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
3369
	intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
3298
	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
3370
	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
Line 3299... Line 3371...
3299
	intel_encoder->cloneable = 0;
3371
	intel_encoder->cloneable = 0;
Line 3305... Line 3377...
3305
		intel_dig_port->hpd_pulse = intel_dp_hpd_pulse;
3377
		intel_dig_port->hpd_pulse = intel_dp_hpd_pulse;
3306
		/*
3378
		/*
3307
		 * On BXT A0/A1, sw needs to activate DDIA HPD logic and
3379
		 * On BXT A0/A1, sw needs to activate DDIA HPD logic and
3308
		 * interrupts to check the external panel connection.
3380
		 * interrupts to check the external panel connection.
3309
		 */
3381
		 */
3310
		if (IS_BROXTON(dev_priv) && (INTEL_REVID(dev) < BXT_REVID_B0)
3382
		if (IS_BXT_REVID(dev, 0, BXT_REVID_A1) && port == PORT_B)
3311
					 && port == PORT_B)
-
 
3312
			dev_priv->hotplug.irq_port[PORT_A] = intel_dig_port;
3383
			dev_priv->hotplug.irq_port[PORT_A] = intel_dig_port;
3313
		else
3384
		else
3314
			dev_priv->hotplug.irq_port[port] = intel_dig_port;
3385
			dev_priv->hotplug.irq_port[port] = intel_dig_port;
3315
	}
3386
	}