Subversion Repositories Kolibri OS

Rev

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

Rev 6084 Rev 6937
Line 58... Line 58...
58
 
58
 
59
	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
59
	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
60
		DRM_ERROR("DPI FIFOs are not empty\n");
60
		DRM_ERROR("DPI FIFOs are not empty\n");
Line 61... Line 61...
61
}
61
}
-
 
62
 
62
 
63
static void write_data(struct drm_i915_private *dev_priv,
63
static void write_data(struct drm_i915_private *dev_priv, u32 reg,
64
		       i915_reg_t reg,
64
		       const u8 *data, u32 len)
65
		       const u8 *data, u32 len)
Line 65... Line 66...
65
{
66
{
Line 73... Line 74...
73
 
74
 
74
		I915_WRITE(reg, val);
75
		I915_WRITE(reg, val);
75
	}
76
	}
Line 76... Line 77...
76
}
77
}
-
 
78
 
77
 
79
static void read_data(struct drm_i915_private *dev_priv,
78
static void read_data(struct drm_i915_private *dev_priv, u32 reg,
80
		      i915_reg_t reg,
79
		      u8 *data, u32 len)
81
		      u8 *data, u32 len)
Line 80... Line 82...
80
{
82
{
Line 96... Line 98...
96
	struct drm_i915_private *dev_priv = dev->dev_private;
98
	struct drm_i915_private *dev_priv = dev->dev_private;
97
	enum port port = intel_dsi_host->port;
99
	enum port port = intel_dsi_host->port;
98
	struct mipi_dsi_packet packet;
100
	struct mipi_dsi_packet packet;
99
	ssize_t ret;
101
	ssize_t ret;
100
	const u8 *header, *data;
102
	const u8 *header, *data;
-
 
103
	i915_reg_t data_reg, ctrl_reg;
101
	u32 data_reg, data_mask, ctrl_reg, ctrl_mask;
104
	u32 data_mask, ctrl_mask;
Line 102... Line 105...
102
 
105
 
103
	ret = mipi_dsi_create_packet(&packet, msg);
106
	ret = mipi_dsi_create_packet(&packet, msg);
104
	if (ret < 0)
107
	if (ret < 0)
Line 261... Line 264...
261
{
264
{
262
	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
265
	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
263
}
266
}
Line 264... Line 267...
264
 
267
 
265
static bool intel_dsi_compute_config(struct intel_encoder *encoder,
268
static bool intel_dsi_compute_config(struct intel_encoder *encoder,
266
				     struct intel_crtc_state *config)
269
				     struct intel_crtc_state *pipe_config)
267
{
270
{
268
	struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
271
	struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
269
						   base);
272
						   base);
270
	struct intel_connector *intel_connector = intel_dsi->attached_connector;
273
	struct intel_connector *intel_connector = intel_dsi->attached_connector;
271
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
274
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
Line 272... Line 275...
272
	struct drm_display_mode *adjusted_mode = &config->base.adjusted_mode;
275
	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
Line -... Line 276...
-
 
276
 
-
 
277
	DRM_DEBUG_KMS("\n");
273
 
278
 
274
	DRM_DEBUG_KMS("\n");
279
	pipe_config->has_dsi_encoder = true;
Line 275... Line 280...
275
 
280
 
276
	if (fixed_mode)
281
	if (fixed_mode)
Line 362... Line 367...
362
 
367
 
363
static void intel_dsi_device_ready(struct intel_encoder *encoder)
368
static void intel_dsi_device_ready(struct intel_encoder *encoder)
364
{
369
{
Line 365... Line 370...
365
	struct drm_device *dev = encoder->base.dev;
370
	struct drm_device *dev = encoder->base.dev;
366
 
371
 
367
	if (IS_VALLEYVIEW(dev))
372
	if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
368
		vlv_dsi_device_ready(encoder);
373
		vlv_dsi_device_ready(encoder);
369
	else if (IS_BROXTON(dev))
374
	else if (IS_BROXTON(dev))
Line 375... Line 380...
375
	struct drm_device *dev = encoder->base.dev;
380
	struct drm_device *dev = encoder->base.dev;
376
	struct drm_i915_private *dev_priv = dev->dev_private;
381
	struct drm_i915_private *dev_priv = dev->dev_private;
377
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
382
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
378
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
383
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
379
	enum port port;
384
	enum port port;
380
	u32 temp;
-
 
381
	u32 port_ctrl;
-
 
Line 382... Line 385...
382
 
385
 
-
 
386
	if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
-
 
387
	u32 temp;
383
	if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
388
 
384
		temp = I915_READ(VLV_CHICKEN_3);
389
		temp = I915_READ(VLV_CHICKEN_3);
385
		temp &= ~PIXEL_OVERLAP_CNT_MASK |
390
		temp &= ~PIXEL_OVERLAP_CNT_MASK |
386
					intel_dsi->pixel_overlap <<
391
					intel_dsi->pixel_overlap <<
387
					PIXEL_OVERLAP_CNT_SHIFT;
392
					PIXEL_OVERLAP_CNT_SHIFT;
388
		I915_WRITE(VLV_CHICKEN_3, temp);
393
		I915_WRITE(VLV_CHICKEN_3, temp);
Line 389... Line 394...
389
	}
394
	}
390
 
395
 
391
	for_each_dsi_port(port, intel_dsi->ports) {
396
	for_each_dsi_port(port, intel_dsi->ports) {
-
 
397
		i915_reg_t port_ctrl = IS_BROXTON(dev) ?
Line 392... Line 398...
392
		port_ctrl = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
398
			BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
Line 393... Line 399...
393
						MIPI_PORT_CTRL(port);
399
		u32 temp;
394
 
400
 
Line 414... Line 420...
414
{
420
{
415
	struct drm_device *dev = encoder->base.dev;
421
	struct drm_device *dev = encoder->base.dev;
416
	struct drm_i915_private *dev_priv = dev->dev_private;
422
	struct drm_i915_private *dev_priv = dev->dev_private;
417
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
423
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
418
	enum port port;
424
	enum port port;
419
	u32 temp;
-
 
420
	u32 port_ctrl;
-
 
Line 421... Line 425...
421
 
425
 
-
 
426
	for_each_dsi_port(port, intel_dsi->ports) {
-
 
427
		i915_reg_t port_ctrl = IS_BROXTON(dev) ?
-
 
428
			BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
-
 
429
	u32 temp;
422
	for_each_dsi_port(port, intel_dsi->ports) {
430
 
423
		/* de-assert ip_tg_enable signal */
-
 
424
		port_ctrl = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
-
 
425
						MIPI_PORT_CTRL(port);
431
		/* de-assert ip_tg_enable signal */
426
		temp = I915_READ(port_ctrl);
432
		temp = I915_READ(port_ctrl);
427
		I915_WRITE(port_ctrl, temp & ~DPI_ENABLE);
433
		I915_WRITE(port_ctrl, temp & ~DPI_ENABLE);
428
		POSTING_READ(port_ctrl);
434
		POSTING_READ(port_ctrl);
429
	}
435
	}
Line 456... Line 462...
456
	}
462
	}
Line 457... Line 463...
457
 
463
 
458
	intel_panel_enable_backlight(intel_dsi->attached_connector);
464
	intel_panel_enable_backlight(intel_dsi->attached_connector);
Line -... Line 465...
-
 
465
}
-
 
466
 
459
}
467
static void intel_dsi_prepare(struct intel_encoder *intel_encoder);
460
 
468
 
461
static void intel_dsi_pre_enable(struct intel_encoder *encoder)
469
static void intel_dsi_pre_enable(struct intel_encoder *encoder)
462
{
470
{
463
	struct drm_device *dev = encoder->base.dev;
471
	struct drm_device *dev = encoder->base.dev;
Line 468... Line 476...
468
	enum port port;
476
	enum port port;
469
	u32 tmp;
477
	u32 tmp;
Line 470... Line 478...
470
 
478
 
Line -... Line 479...
-
 
479
	DRM_DEBUG_KMS("\n");
-
 
480
 
-
 
481
	intel_dsi_prepare(encoder);
471
	DRM_DEBUG_KMS("\n");
482
	intel_enable_dsi_pll(encoder);
472
 
483
 
473
	/* Panel Enable over CRC PMIC */
484
	/* Panel Enable over CRC PMIC */
Line 474... Line 485...
474
	if (intel_dsi->gpio_panel)
485
	if (intel_dsi->gpio_panel)
Line 475... Line 486...
475
		gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
486
		gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
476
 
487
 
477
	msleep(intel_dsi->panel_on_delay);
488
	msleep(intel_dsi->panel_on_delay);
478
 
489
 
479
	if (IS_VALLEYVIEW(dev)) {
490
	if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
480
		/*
491
		/*
Line 578... Line 589...
578
{
589
{
579
	struct drm_device *dev = encoder->base.dev;
590
	struct drm_device *dev = encoder->base.dev;
580
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
591
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
581
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
592
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
582
	enum port port;
593
	enum port port;
583
	u32 val;
-
 
584
	u32 port_ctrl = 0;
-
 
Line 585... Line 594...
585
 
594
 
586
	DRM_DEBUG_KMS("\n");
595
	DRM_DEBUG_KMS("\n");
-
 
596
	for_each_dsi_port(port, intel_dsi->ports) {
-
 
597
		/* Common bit for both MIPI Port A & MIPI Port C on VLV/CHV */
-
 
598
		i915_reg_t port_ctrl = IS_BROXTON(dev) ?
-
 
599
			BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(PORT_A);
Line 587... Line 600...
587
	for_each_dsi_port(port, intel_dsi->ports) {
600
		u32 val;
588
 
601
 
589
		I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
602
		I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
Line 596... Line 609...
596
 
609
 
597
		I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
610
		I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
598
							ULPS_STATE_ENTER);
611
							ULPS_STATE_ENTER);
Line 599... Line -...
599
		usleep_range(2000, 2500);
-
 
600
 
-
 
601
		if (IS_BROXTON(dev))
-
 
602
			port_ctrl = BXT_MIPI_PORT_CTRL(port);
-
 
603
		else if (IS_VALLEYVIEW(dev))
-
 
604
			/* Common bit for both MIPI Port A & MIPI Port C */
-
 
605
			port_ctrl = MIPI_PORT_CTRL(PORT_A);
612
		usleep_range(2000, 2500);
606
 
613
 
607
		/* Wait till Clock lanes are in LP-00 state for MIPI Port A
614
		/* Wait till Clock lanes are in LP-00 state for MIPI Port A
608
		 * only. MIPI Port C has no similar bit for checking
615
		 * only. MIPI Port C has no similar bit for checking
609
		 */
616
		 */
Line 654... Line 661...
654
{
661
{
655
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
662
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
656
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
663
	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
657
	struct drm_device *dev = encoder->base.dev;
664
	struct drm_device *dev = encoder->base.dev;
658
	enum intel_display_power_domain power_domain;
665
	enum intel_display_power_domain power_domain;
659
	u32 dpi_enabled, func, ctrl_reg;
-
 
660
	enum port port;
666
	enum port port;
-
 
667
	bool ret;
Line 661... Line 668...
661
 
668
 
Line 662... Line 669...
662
	DRM_DEBUG_KMS("\n");
669
	DRM_DEBUG_KMS("\n");
663
 
670
 
664
	power_domain = intel_display_port_power_domain(encoder);
671
	power_domain = intel_display_port_power_domain(encoder);
Line -... Line 672...
-
 
672
	if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
-
 
673
		return false;
665
	if (!intel_display_power_is_enabled(dev_priv, power_domain))
674
 
666
		return false;
675
	ret = false;
-
 
676
 
-
 
677
	/* XXX: this only works for one DSI output */
-
 
678
	for_each_dsi_port(port, intel_dsi->ports) {
-
 
679
		i915_reg_t ctrl_reg = IS_BROXTON(dev) ?
667
 
680
			BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
668
	/* XXX: this only works for one DSI output */
-
 
669
	for_each_dsi_port(port, intel_dsi->ports) {
-
 
670
		func = I915_READ(MIPI_DSI_FUNC_PRG(port));
681
		u32 dpi_enabled, func;
Line 671... Line 682...
671
		ctrl_reg = IS_BROXTON(dev) ? BXT_MIPI_PORT_CTRL(port) :
682
 
672
						MIPI_PORT_CTRL(port);
683
		func = I915_READ(MIPI_DSI_FUNC_PRG(port));
673
		dpi_enabled = I915_READ(ctrl_reg) & DPI_ENABLE;
684
		dpi_enabled = I915_READ(ctrl_reg) & DPI_ENABLE;
674
 
685
 
675
		/* Due to some hardware limitations on BYT, MIPI Port C DPI
686
		/* Due to some hardware limitations on BYT, MIPI Port C DPI
676
		 * Enable bit does not get set. To check whether DSI Port C
-
 
677
		 * was enabled in BIOS, check the Pipe B enable bit
687
		 * Enable bit does not get set. To check whether DSI Port C
678
		 */
688
		 * was enabled in BIOS, check the Pipe B enable bit
Line 679... Line 689...
679
		if (IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) &&
689
		 */
680
		    (port == PORT_C))
690
		if (IS_VALLEYVIEW(dev) && port == PORT_C)
681
			dpi_enabled = I915_READ(PIPECONF(PIPE_B)) &
691
			dpi_enabled = I915_READ(PIPECONF(PIPE_B)) &
682
							PIPECONF_ENABLE;
692
							PIPECONF_ENABLE;
-
 
693
 
-
 
694
		if (dpi_enabled || (func & CMD_MODE_DATA_WIDTH_MASK)) {
683
 
695
			if (I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY) {
684
		if (dpi_enabled || (func & CMD_MODE_DATA_WIDTH_MASK)) {
696
				*pipe = port == PORT_A ? PIPE_A : PIPE_B;
685
			if (I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY) {
697
				ret = true;
-
 
698
 
-
 
699
				goto out;
Line 686... Line 700...
686
				*pipe = port == PORT_A ? PIPE_A : PIPE_B;
700
			}
687
				return true;
701
		}
Line 688... Line 702...
688
			}
702
	}
689
		}
703
out:
690
	}
704
	intel_display_power_put(dev_priv, power_domain);
691
 
705
 
692
	return false;
706
	return ret;
Line -... Line 707...
-
 
707
}
-
 
708
 
693
}
709
static void intel_dsi_get_config(struct intel_encoder *encoder,
694
 
710
				 struct intel_crtc_state *pipe_config)
695
static void intel_dsi_get_config(struct intel_encoder *encoder,
711
{
696
				 struct intel_crtc_state *pipe_config)
712
	u32 pclk = 0;
697
{
713
	DRM_DEBUG_KMS("\n");
Line 698... Line 714...
698
	u32 pclk = 0;
714
 
699
	DRM_DEBUG_KMS("\n");
715
	pipe_config->has_dsi_encoder = true;
700
 
716
 
-
 
717
	/*
701
	/*
718
	 * DPLL_MD is not used in case of DSI, reading will get some default value
Line 702... Line 719...
702
	 * DPLL_MD is not used in case of DSI, reading will get some default value
719
	 * set dpll_md = 0
703
	 * set dpll_md = 0
720
	 */
Line 857... Line 874...
857
		if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
874
		if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
858
			mode_hdisplay += intel_dsi->pixel_overlap;
875
			mode_hdisplay += intel_dsi->pixel_overlap;
859
	}
876
	}
Line 860... Line 877...
860
 
877
 
861
	for_each_dsi_port(port, intel_dsi->ports) {
878
	for_each_dsi_port(port, intel_dsi->ports) {
862
		if (IS_VALLEYVIEW(dev)) {
879
		if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
863
			/*
880
			/*
864
			 * escape clock divider, 20MHz, shared for A and C.
881
			 * escape clock divider, 20MHz, shared for A and C.
865
			 * device ready must be off when doing this! txclkesc?
882
			 * device ready must be off when doing this! txclkesc?
866
			 */
883
			 */
Line 873... Line 890...
873
			tmp = I915_READ(MIPI_CTRL(port));
890
			tmp = I915_READ(MIPI_CTRL(port));
874
			tmp &= ~READ_REQUEST_PRIORITY_MASK;
891
			tmp &= ~READ_REQUEST_PRIORITY_MASK;
875
			I915_WRITE(MIPI_CTRL(port), tmp |
892
			I915_WRITE(MIPI_CTRL(port), tmp |
876
					READ_REQUEST_PRIORITY_HIGH);
893
					READ_REQUEST_PRIORITY_HIGH);
877
		} else if (IS_BROXTON(dev)) {
894
		} else if (IS_BROXTON(dev)) {
878
			/*
-
 
879
			 * FIXME:
-
 
880
			 * BXT can connect any PIPE to any MIPI port.
-
 
881
			 * Select the pipe based on the MIPI port read from
895
			enum pipe pipe = intel_crtc->pipe;
882
			 * VBT for now. Pick PIPE A for MIPI port A and C
-
 
883
			 * for port C.
-
 
884
			 */
896
 
885
			tmp = I915_READ(MIPI_CTRL(port));
897
			tmp = I915_READ(MIPI_CTRL(port));
886
			tmp &= ~BXT_PIPE_SELECT_MASK;
898
			tmp &= ~BXT_PIPE_SELECT_MASK;
Line 887... Line -...
887
 
-
 
888
			if (port == PORT_A)
-
 
889
				tmp |= BXT_PIPE_SELECT_A;
-
 
890
			else if (port == PORT_C)
899
 
891
				tmp |= BXT_PIPE_SELECT_C;
-
 
892
 
900
			tmp |= BXT_PIPE_SELECT(pipe);
893
			I915_WRITE(MIPI_CTRL(port), tmp);
901
			I915_WRITE(MIPI_CTRL(port), tmp);
Line 894... Line 902...
894
		}
902
		}
895
 
903
 
Line 1023... Line 1031...
1023
				IP_TG_CONFIG |
1031
				IP_TG_CONFIG |
1024
				RANDOM_DPI_DISPLAY_RESOLUTION);
1032
				RANDOM_DPI_DISPLAY_RESOLUTION);
1025
	}
1033
	}
1026
}
1034
}
Line 1027... Line -...
1027
 
-
 
1028
static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
-
 
1029
{
-
 
1030
	DRM_DEBUG_KMS("\n");
-
 
1031
 
-
 
1032
	intel_dsi_prepare(encoder);
-
 
1033
	intel_enable_dsi_pll(encoder);
-
 
1034
 
-
 
1035
}
-
 
1036
 
1035
 
1037
static enum drm_connector_status
1036
static enum drm_connector_status
1038
intel_dsi_detect(struct drm_connector *connector, bool force)
1037
intel_dsi_detect(struct drm_connector *connector, bool force)
1039
{
1038
{
1040
	return connector_status_connected;
1039
	return connector_status_connected;
Line 1126... Line 1125...
1126
 
1125
 
1127
	/* There is no detection method for MIPI so rely on VBT */
1126
	/* There is no detection method for MIPI so rely on VBT */
1128
	if (!dev_priv->vbt.has_mipi)
1127
	if (!dev_priv->vbt.has_mipi)
Line 1129... Line 1128...
1129
		return;
1128
		return;
1130
 
1129
 
1131
	if (IS_VALLEYVIEW(dev)) {
1130
	if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
1132
		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
1131
		dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
1133
	} else {
1132
	} else {
1134
		DRM_ERROR("Unsupported Mipi device to reg base");
1133
		DRM_ERROR("Unsupported Mipi device to reg base");
Line 1149... Line 1148...
1149
	encoder = &intel_encoder->base;
1148
	encoder = &intel_encoder->base;
1150
	intel_dsi->attached_connector = intel_connector;
1149
	intel_dsi->attached_connector = intel_connector;
Line 1151... Line 1150...
1151
 
1150
 
Line 1152... Line 1151...
1152
	connector = &intel_connector->base;
1151
	connector = &intel_connector->base;
-
 
1152
 
Line 1153... Line -...
1153
 
-
 
1154
	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
1153
	drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI,
1155
 
-
 
1156
	/* XXX: very likely not all of these are needed */
1154
			 NULL);
1157
	intel_encoder->compute_config = intel_dsi_compute_config;
1155
 
1158
	intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable;
1156
	intel_encoder->compute_config = intel_dsi_compute_config;
1159
	intel_encoder->pre_enable = intel_dsi_pre_enable;
1157
	intel_encoder->pre_enable = intel_dsi_pre_enable;
1160
	intel_encoder->enable = intel_dsi_enable_nop;
1158
	intel_encoder->enable = intel_dsi_enable_nop;