| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright © 2013 Intel Corporation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a | 
					
						
							|  |  |  |  * copy of this software and associated documentation files (the "Software"), | 
					
						
							|  |  |  |  * to deal in the Software without restriction, including without limitation | 
					
						
							|  |  |  |  * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
					
						
							|  |  |  |  * and/or sell copies of the Software, and to permit persons to whom the | 
					
						
							|  |  |  |  * Software is furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice (including the next | 
					
						
							|  |  |  |  * paragraph) shall be included in all copies or substantial portions of the | 
					
						
							|  |  |  |  * Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 
					
						
							|  |  |  |  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 
					
						
							|  |  |  |  * DEALINGS IN THE SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _INTEL_DSI_H
 | 
					
						
							|  |  |  | #define _INTEL_DSI_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <drm/drm_crtc.h>
 | 
					
						
							| 
									
										
										
										
											2015-01-16 14:27:23 +02:00
										 |  |  | #include <drm/drm_mipi_dsi.h>
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | #include "intel_drv.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-02 18:02:36 +03:00
										 |  |  | #define INTEL_DSI_VIDEO_MODE	0
 | 
					
						
							|  |  |  | #define INTEL_DSI_COMMAND_MODE	1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 14:13:41 +05:30
										 |  |  | /* Dual Link support */ | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_NONE		0
 | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_FRONT_BACK	1
 | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_PIXEL_ALT		2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-16 14:27:23 +02:00
										 |  |  | struct intel_dsi_host; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | struct intel_dsi { | 
					
						
							|  |  |  | 	struct intel_encoder base; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-16 14:27:23 +02:00
										 |  |  | 	struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS]; | 
					
						
							| 
									
										
										
										
											2019-01-14 14:21:24 +00:00
										 |  |  | 	intel_wakeref_t io_wakeref[I915_MAX_PORTS]; | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 14:32:09 +05:30
										 |  |  | 	/* GPIO Desc for CRC based Panel control */ | 
					
						
							|  |  |  | 	struct gpio_desc *gpio_panel; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	struct intel_connector *attached_connector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 16:54:22 +02:00
										 |  |  | 	/* bit mask of ports being driven */ | 
					
						
							|  |  |  | 	u16 ports; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	/* if true, use HS mode, otherwise LP */ | 
					
						
							|  |  |  | 	bool hs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* virtual channel */ | 
					
						
							|  |  |  | 	int channel; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:24 +05:30
										 |  |  | 	/* Video mode or command mode */ | 
					
						
							|  |  |  | 	u16 operation_mode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	/* number of DSI lanes */ | 
					
						
							|  |  |  | 	unsigned int lane_count; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 12:21:40 +02:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * video mode pixel format | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * XXX: consolidate on .format in struct mipi_dsi_device. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	enum mipi_dsi_pixel_format pixel_format; | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* video mode format for MIPI_VIDEO_MODE_FORMAT register */ | 
					
						
							|  |  |  | 	u32 video_mode_format; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* eot for MIPI_EOT_DISABLE register */ | 
					
						
							| 
									
										
										
										
											2014-04-09 13:59:33 +05:30
										 |  |  | 	u8 eotp_pkt; | 
					
						
							|  |  |  | 	u8 clock_stop; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 13:59:33 +05:30
										 |  |  | 	u8 escape_clk_div; | 
					
						
							| 
									
										
										
										
											2014-12-05 14:09:28 +05:30
										 |  |  | 	u8 dual_link; | 
					
						
							| 
									
										
										
										
											2016-04-26 16:14:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	u16 dcs_backlight_ports; | 
					
						
							| 
									
										
										
										
											2016-04-26 16:14:26 +03:00
										 |  |  | 	u16 dcs_cabc_ports; | 
					
						
							| 
									
										
										
										
											2016-04-26 16:14:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:59 +03:00
										 |  |  | 	/* RGB or BGR */ | 
					
						
							|  |  |  | 	bool bgr_enabled; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 14:13:41 +05:30
										 |  |  | 	u8 pixel_overlap; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 	u32 port_bits; | 
					
						
							|  |  |  | 	u32 bw_timer; | 
					
						
							|  |  |  | 	u32 dphy_reg; | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* data lanes dphy timing */ | 
					
						
							|  |  |  | 	u32 dphy_data_lane_reg; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 	u32 video_frmt_cfg_bits; | 
					
						
							|  |  |  | 	u16 lp_byte_clk; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* timeouts in byte clocks */ | 
					
						
							| 
									
										
										
										
											2018-10-30 13:56:22 +02:00
										 |  |  | 	u16 hs_tx_timeout; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 	u16 lp_rx_timeout; | 
					
						
							|  |  |  | 	u16 turn_arnd_val; | 
					
						
							|  |  |  | 	u16 rst_timer_val; | 
					
						
							|  |  |  | 	u16 hs_to_lp_count; | 
					
						
							|  |  |  | 	u16 clk_lp_to_hs_count; | 
					
						
							|  |  |  | 	u16 clk_hs_to_lp_count; | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:25 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	u16 init_count; | 
					
						
							| 
									
										
										
										
											2014-07-30 20:34:57 +05:30
										 |  |  | 	u32 pclk; | 
					
						
							|  |  |  | 	u16 burst_mode_ratio; | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:26 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* all delays in ms */ | 
					
						
							|  |  |  | 	u16 backlight_off_delay; | 
					
						
							|  |  |  | 	u16 backlight_on_delay; | 
					
						
							|  |  |  | 	u16 panel_on_delay; | 
					
						
							|  |  |  | 	u16 panel_off_delay; | 
					
						
							|  |  |  | 	u16 panel_pwr_cycle_delay; | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-16 14:27:23 +02:00
										 |  |  | struct intel_dsi_host { | 
					
						
							|  |  |  | 	struct mipi_dsi_host base; | 
					
						
							|  |  |  | 	struct intel_dsi *intel_dsi; | 
					
						
							|  |  |  | 	enum port port; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* our little hack */ | 
					
						
							|  |  |  | 	struct mipi_dsi_device *device; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline struct intel_dsi_host *to_intel_dsi_host(struct mipi_dsi_host *h) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return container_of(h, struct intel_dsi_host, base); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 21:51:09 +02:00
										 |  |  | #define for_each_dsi_port(__port, __ports_mask) for_each_port_masked(__port, __ports_mask)
 | 
					
						
							| 
									
										
										
										
											2014-11-14 16:54:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return container_of(encoder, struct intel_dsi, base.base); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:53 +03:00
										 |  |  | static inline bool is_vid_mode(struct intel_dsi *intel_dsi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline bool is_cmd_mode(struct intel_dsi *intel_dsi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-29 16:12:17 +02:00
										 |  |  | static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return enc_to_intel_dsi(&encoder->base)->ports; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-29 15:29:23 +03:00
										 |  |  | /* icl_dsi.c */ | 
					
						
							|  |  |  | void icl_dsi_init(struct drm_i915_private *dev_priv); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:50 +03:00
										 |  |  | /* intel_dsi.c */ | 
					
						
							|  |  |  | int intel_dsi_bitrate(const struct intel_dsi *intel_dsi); | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:52 +03:00
										 |  |  | int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi); | 
					
						
							| 
									
										
										
										
											2018-10-22 17:20:15 +03:00
										 |  |  | enum drm_panel_orientation | 
					
						
							|  |  |  | intel_dsi_get_panel_orientation(struct intel_connector *connector); | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:50 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:07 +03:00
										 |  |  | /* vlv_dsi.c */ | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:08 +03:00
										 |  |  | void vlv_dsi_wait_for_fifo_empty(struct intel_dsi *intel_dsi, enum port port); | 
					
						
							| 
									
										
										
										
											2017-03-06 16:31:30 +02:00
										 |  |  | enum mipi_dsi_pixel_format pixel_format_from_register_bits(u32 fmt); | 
					
						
							| 
									
										
										
										
											2018-10-30 13:56:08 +02:00
										 |  |  | int intel_dsi_get_modes(struct drm_connector *connector); | 
					
						
							|  |  |  | enum drm_mode_status intel_dsi_mode_valid(struct drm_connector *connector, | 
					
						
							|  |  |  | 					  struct drm_display_mode *mode); | 
					
						
							| 
									
										
										
										
											2018-10-30 13:56:07 +02:00
										 |  |  | struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi, | 
					
						
							|  |  |  | 					   const struct mipi_dsi_host_ops *funcs, | 
					
						
							|  |  |  | 					   enum port port); | 
					
						
							| 
									
										
										
										
											2019-04-29 15:29:23 +03:00
										 |  |  | void vlv_dsi_init(struct drm_i915_private *dev_priv); | 
					
						
							| 
									
										
										
										
											2017-02-28 11:26:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:07 +03:00
										 |  |  | /* vlv_dsi_pll.c */ | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:08 +03:00
										 |  |  | int vlv_dsi_pll_compute(struct intel_encoder *encoder, | 
					
						
							|  |  |  | 			struct intel_crtc_state *config); | 
					
						
							|  |  |  | void vlv_dsi_pll_enable(struct intel_encoder *encoder, | 
					
						
							|  |  |  | 			const struct intel_crtc_state *config); | 
					
						
							|  |  |  | void vlv_dsi_pll_disable(struct intel_encoder *encoder); | 
					
						
							| 
									
										
										
										
											2018-12-01 12:31:45 +01:00
										 |  |  | u32 vlv_dsi_get_pclk(struct intel_encoder *encoder, | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:08 +03:00
										 |  |  | 		     struct intel_crtc_state *config); | 
					
						
							|  |  |  | void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool bxt_dsi_pll_is_enabled(struct drm_i915_private *dev_priv); | 
					
						
							|  |  |  | int bxt_dsi_pll_compute(struct intel_encoder *encoder, | 
					
						
							|  |  |  | 			struct intel_crtc_state *config); | 
					
						
							|  |  |  | void bxt_dsi_pll_enable(struct intel_encoder *encoder, | 
					
						
							|  |  |  | 			const struct intel_crtc_state *config); | 
					
						
							|  |  |  | void bxt_dsi_pll_disable(struct intel_encoder *encoder); | 
					
						
							| 
									
										
										
										
											2018-12-01 12:31:45 +01:00
										 |  |  | u32 bxt_dsi_get_pclk(struct intel_encoder *encoder, | 
					
						
							| 
									
										
										
										
											2018-07-05 16:25:08 +03:00
										 |  |  | 		     struct intel_crtc_state *config); | 
					
						
							|  |  |  | void bxt_dsi_reset_clocks(struct intel_encoder *encoder, enum port port); | 
					
						
							| 
									
										
										
										
											2013-08-27 23:40:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 16:31:30 +02:00
										 |  |  | /* intel_dsi_vbt.c */ | 
					
						
							| 
									
										
										
										
											2017-03-06 16:31:26 +02:00
										 |  |  | bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id); | 
					
						
							| 
									
										
										
										
											2017-03-06 16:31:27 +02:00
										 |  |  | void intel_dsi_vbt_exec_sequence(struct intel_dsi *intel_dsi, | 
					
						
							|  |  |  | 				 enum mipi_seq seq_id); | 
					
						
							| 
									
										
										
										
											2018-10-15 17:27:53 +03:00
										 |  |  | void intel_dsi_msleep(struct intel_dsi *intel_dsi, int msec); | 
					
						
							| 
									
										
										
										
											2019-06-05 20:17:34 +02:00
										 |  |  | void intel_dsi_log_params(struct intel_dsi *intel_dsi); | 
					
						
							| 
									
										
										
										
											2014-05-23 21:35:27 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | #endif /* _INTEL_DSI_H */
 |