xref: /openbmc/linux/drivers/gpu/drm/i915/display/intel_bios.h (revision 5804c19b80bf625c6a9925317f845e497434d6d3)
1df0566a6SJani Nikula /*
25b6030daSRamalingam C  * Copyright © 2016-2019 Intel Corporation
3df0566a6SJani Nikula  *
4df0566a6SJani Nikula  * Permission is hereby granted, free of charge, to any person obtaining a
5df0566a6SJani Nikula  * copy of this software and associated documentation files (the "Software"),
6df0566a6SJani Nikula  * to deal in the Software without restriction, including without limitation
7df0566a6SJani Nikula  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8df0566a6SJani Nikula  * and/or sell copies of the Software, and to permit persons to whom the
9df0566a6SJani Nikula  * Software is furnished to do so, subject to the following conditions:
10df0566a6SJani Nikula  *
11df0566a6SJani Nikula  * The above copyright notice and this permission notice (including the next
12df0566a6SJani Nikula  * paragraph) shall be included in all copies or substantial portions of the
13df0566a6SJani Nikula  * Software.
14df0566a6SJani Nikula  *
15df0566a6SJani Nikula  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16df0566a6SJani Nikula  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17df0566a6SJani Nikula  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18df0566a6SJani Nikula  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19df0566a6SJani Nikula  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20df0566a6SJani Nikula  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21df0566a6SJani Nikula  * SOFTWARE.
22df0566a6SJani Nikula  */
23df0566a6SJani Nikula 
24df0566a6SJani Nikula /*
25df0566a6SJani Nikula  * Please use intel_vbt_defs.h for VBT private data, to hide and abstract away
26df0566a6SJani Nikula  * the VBT from the rest of the driver. Add the parsed, clean data to struct
27df0566a6SJani Nikula  * intel_vbt_data within struct drm_i915_private.
28df0566a6SJani Nikula  */
29df0566a6SJani Nikula 
30df0566a6SJani Nikula #ifndef _INTEL_BIOS_H_
31df0566a6SJani Nikula #define _INTEL_BIOS_H_
32df0566a6SJani Nikula 
33df0566a6SJani Nikula #include <linux/types.h>
34df0566a6SJani Nikula 
35c36225a1SJani Nikula struct drm_edid;
36df0566a6SJani Nikula struct drm_i915_private;
37dbc13742SJani Nikula struct intel_bios_encoder_data;
381bf2f3bfSJani Nikula struct intel_crtc_state;
391bf2f3bfSJani Nikula struct intel_encoder;
403cf05076SVille Syrjälä struct intel_panel;
41bb45217fSVille Syrjälä enum aux_ch;
425b6030daSRamalingam C enum port;
43df0566a6SJani Nikula 
44df0566a6SJani Nikula enum intel_backlight_type {
45df0566a6SJani Nikula 	INTEL_BACKLIGHT_PMIC,
46df0566a6SJani Nikula 	INTEL_BACKLIGHT_LPSS,
47df0566a6SJani Nikula 	INTEL_BACKLIGHT_DISPLAY_DDI,
48df0566a6SJani Nikula 	INTEL_BACKLIGHT_DSI_DCS,
49df0566a6SJani Nikula 	INTEL_BACKLIGHT_PANEL_DRIVER_INTERFACE,
505ccf2027SLee Shawn C 	INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE,
51df0566a6SJani Nikula };
52df0566a6SJani Nikula 
53df0566a6SJani Nikula struct edp_power_seq {
54df0566a6SJani Nikula 	u16 t1_t3;
55df0566a6SJani Nikula 	u16 t8;
56df0566a6SJani Nikula 	u16 t9;
57df0566a6SJani Nikula 	u16 t10;
58df0566a6SJani Nikula 	u16 t11_t12;
59df0566a6SJani Nikula } __packed;
60df0566a6SJani Nikula 
61df0566a6SJani Nikula /*
62df0566a6SJani Nikula  * MIPI Sequence Block definitions
63df0566a6SJani Nikula  *
64df0566a6SJani Nikula  * Note the VBT spec has AssertReset / DeassertReset swapped from their
65df0566a6SJani Nikula  * usual naming, we use the proper names here to avoid confusion when
66df0566a6SJani Nikula  * reading the code.
67df0566a6SJani Nikula  */
68df0566a6SJani Nikula enum mipi_seq {
69df0566a6SJani Nikula 	MIPI_SEQ_END = 0,
70df0566a6SJani Nikula 	MIPI_SEQ_DEASSERT_RESET,	/* Spec says MipiAssertResetPin */
71df0566a6SJani Nikula 	MIPI_SEQ_INIT_OTP,
72df0566a6SJani Nikula 	MIPI_SEQ_DISPLAY_ON,
73df0566a6SJani Nikula 	MIPI_SEQ_DISPLAY_OFF,
74df0566a6SJani Nikula 	MIPI_SEQ_ASSERT_RESET,		/* Spec says MipiDeassertResetPin */
75df0566a6SJani Nikula 	MIPI_SEQ_BACKLIGHT_ON,		/* sequence block v2+ */
76df0566a6SJani Nikula 	MIPI_SEQ_BACKLIGHT_OFF,		/* sequence block v2+ */
77df0566a6SJani Nikula 	MIPI_SEQ_TEAR_ON,		/* sequence block v2+ */
78df0566a6SJani Nikula 	MIPI_SEQ_TEAR_OFF,		/* sequence block v3+ */
79df0566a6SJani Nikula 	MIPI_SEQ_POWER_ON,		/* sequence block v3+ */
80df0566a6SJani Nikula 	MIPI_SEQ_POWER_OFF,		/* sequence block v3+ */
81df0566a6SJani Nikula 	MIPI_SEQ_MAX
82df0566a6SJani Nikula };
83df0566a6SJani Nikula 
84df0566a6SJani Nikula enum mipi_seq_element {
85df0566a6SJani Nikula 	MIPI_SEQ_ELEM_END = 0,
86df0566a6SJani Nikula 	MIPI_SEQ_ELEM_SEND_PKT,
87df0566a6SJani Nikula 	MIPI_SEQ_ELEM_DELAY,
88df0566a6SJani Nikula 	MIPI_SEQ_ELEM_GPIO,
89df0566a6SJani Nikula 	MIPI_SEQ_ELEM_I2C,		/* sequence block v2+ */
90df0566a6SJani Nikula 	MIPI_SEQ_ELEM_SPI,		/* sequence block v3+ */
91df0566a6SJani Nikula 	MIPI_SEQ_ELEM_PMIC,		/* sequence block v3+ */
92df0566a6SJani Nikula 	MIPI_SEQ_ELEM_MAX
93df0566a6SJani Nikula };
94df0566a6SJani Nikula 
95df0566a6SJani Nikula #define MIPI_DSI_UNDEFINED_PANEL_ID	0
96df0566a6SJani Nikula #define MIPI_DSI_GENERIC_PANEL_ID	1
97df0566a6SJani Nikula 
98df0566a6SJani Nikula struct mipi_config {
99df0566a6SJani Nikula 	u16 panel_id;
100df0566a6SJani Nikula 
101df0566a6SJani Nikula 	/* General Params */
102df0566a6SJani Nikula 	u32 enable_dithering:1;
103df0566a6SJani Nikula 	u32 rsvd1:1;
104df0566a6SJani Nikula 	u32 is_bridge:1;
105df0566a6SJani Nikula 
106df0566a6SJani Nikula 	u32 panel_arch_type:2;
107df0566a6SJani Nikula 	u32 is_cmd_mode:1;
108df0566a6SJani Nikula 
109df0566a6SJani Nikula #define NON_BURST_SYNC_PULSE	0x1
110df0566a6SJani Nikula #define NON_BURST_SYNC_EVENTS	0x2
111df0566a6SJani Nikula #define BURST_MODE		0x3
112df0566a6SJani Nikula 	u32 video_transfer_mode:2;
113df0566a6SJani Nikula 
114df0566a6SJani Nikula 	u32 cabc_supported:1;
115df0566a6SJani Nikula #define PPS_BLC_PMIC   0
116df0566a6SJani Nikula #define PPS_BLC_SOC    1
117df0566a6SJani Nikula 	u32 pwm_blc:1;
118df0566a6SJani Nikula 
119df0566a6SJani Nikula 	/* Bit 13:10 */
120df0566a6SJani Nikula #define PIXEL_FORMAT_RGB565			0x1
121df0566a6SJani Nikula #define PIXEL_FORMAT_RGB666			0x2
122df0566a6SJani Nikula #define PIXEL_FORMAT_RGB666_LOOSELY_PACKED	0x3
123df0566a6SJani Nikula #define PIXEL_FORMAT_RGB888			0x4
124df0566a6SJani Nikula 	u32 videomode_color_format:4;
125df0566a6SJani Nikula 
126df0566a6SJani Nikula 	/* Bit 15:14 */
127df0566a6SJani Nikula #define ENABLE_ROTATION_0	0x0
128df0566a6SJani Nikula #define ENABLE_ROTATION_90	0x1
129df0566a6SJani Nikula #define ENABLE_ROTATION_180	0x2
130df0566a6SJani Nikula #define ENABLE_ROTATION_270	0x3
131df0566a6SJani Nikula 	u32 rotation:2;
132df0566a6SJani Nikula 	u32 bta_enabled:1;
133df0566a6SJani Nikula 	u32 rsvd2:15;
134df0566a6SJani Nikula 
135df0566a6SJani Nikula 	/* 2 byte Port Description */
136df0566a6SJani Nikula #define DUAL_LINK_NOT_SUPPORTED	0
137df0566a6SJani Nikula #define DUAL_LINK_FRONT_BACK	1
138df0566a6SJani Nikula #define DUAL_LINK_PIXEL_ALT	2
139df0566a6SJani Nikula 	u16 dual_link:2;
140df0566a6SJani Nikula 	u16 lane_cnt:2;
141df0566a6SJani Nikula 	u16 pixel_overlap:3;
142df0566a6SJani Nikula 	u16 rgb_flip:1;
143df0566a6SJani Nikula #define DL_DCS_PORT_A			0x00
144df0566a6SJani Nikula #define DL_DCS_PORT_C			0x01
145df0566a6SJani Nikula #define DL_DCS_PORT_A_AND_C		0x02
146df0566a6SJani Nikula 	u16 dl_dcs_cabc_ports:2;
147df0566a6SJani Nikula 	u16 dl_dcs_backlight_ports:2;
148df0566a6SJani Nikula 	u16 rsvd3:4;
149df0566a6SJani Nikula 
150df0566a6SJani Nikula 	u16 rsvd4;
151df0566a6SJani Nikula 
152df0566a6SJani Nikula 	u8 rsvd5;
153df0566a6SJani Nikula 	u32 target_burst_mode_freq;
154df0566a6SJani Nikula 	u32 dsi_ddr_clk;
155df0566a6SJani Nikula 	u32 bridge_ref_clk;
156df0566a6SJani Nikula 
157df0566a6SJani Nikula #define  BYTE_CLK_SEL_20MHZ		0
158df0566a6SJani Nikula #define  BYTE_CLK_SEL_10MHZ		1
159df0566a6SJani Nikula #define  BYTE_CLK_SEL_5MHZ		2
160df0566a6SJani Nikula 	u8 byte_clk_sel:2;
161df0566a6SJani Nikula 
162df0566a6SJani Nikula 	u8 rsvd6:6;
163df0566a6SJani Nikula 
164df0566a6SJani Nikula 	/* DPHY Flags */
165df0566a6SJani Nikula 	u16 dphy_param_valid:1;
166df0566a6SJani Nikula 	u16 eot_pkt_disabled:1;
167df0566a6SJani Nikula 	u16 enable_clk_stop:1;
168df0566a6SJani Nikula 	u16 rsvd7:13;
169df0566a6SJani Nikula 
170df0566a6SJani Nikula 	u32 hs_tx_timeout;
171df0566a6SJani Nikula 	u32 lp_rx_timeout;
172df0566a6SJani Nikula 	u32 turn_around_timeout;
173df0566a6SJani Nikula 	u32 device_reset_timer;
174df0566a6SJani Nikula 	u32 master_init_timer;
175df0566a6SJani Nikula 	u32 dbi_bw_timer;
176df0566a6SJani Nikula 	u32 lp_byte_clk_val;
177df0566a6SJani Nikula 
178df0566a6SJani Nikula 	/*  4 byte Dphy Params */
179df0566a6SJani Nikula 	u32 prepare_cnt:6;
180df0566a6SJani Nikula 	u32 rsvd8:2;
181df0566a6SJani Nikula 	u32 clk_zero_cnt:8;
182df0566a6SJani Nikula 	u32 trail_cnt:5;
183df0566a6SJani Nikula 	u32 rsvd9:3;
184df0566a6SJani Nikula 	u32 exit_zero_cnt:6;
185df0566a6SJani Nikula 	u32 rsvd10:2;
186df0566a6SJani Nikula 
187df0566a6SJani Nikula 	u32 clk_lane_switch_cnt;
188df0566a6SJani Nikula 	u32 hl_switch_cnt;
189df0566a6SJani Nikula 
190df0566a6SJani Nikula 	u32 rsvd11[6];
191df0566a6SJani Nikula 
192df0566a6SJani Nikula 	/* timings based on dphy spec */
193df0566a6SJani Nikula 	u8 tclk_miss;
194df0566a6SJani Nikula 	u8 tclk_post;
195df0566a6SJani Nikula 	u8 rsvd12;
196df0566a6SJani Nikula 	u8 tclk_pre;
197df0566a6SJani Nikula 	u8 tclk_prepare;
198df0566a6SJani Nikula 	u8 tclk_settle;
199df0566a6SJani Nikula 	u8 tclk_term_enable;
200df0566a6SJani Nikula 	u8 tclk_trail;
201df0566a6SJani Nikula 	u16 tclk_prepare_clkzero;
202df0566a6SJani Nikula 	u8 rsvd13;
203df0566a6SJani Nikula 	u8 td_term_enable;
204df0566a6SJani Nikula 	u8 teot;
205df0566a6SJani Nikula 	u8 ths_exit;
206df0566a6SJani Nikula 	u8 ths_prepare;
207df0566a6SJani Nikula 	u16 ths_prepare_hszero;
208df0566a6SJani Nikula 	u8 rsvd14;
209df0566a6SJani Nikula 	u8 ths_settle;
210df0566a6SJani Nikula 	u8 ths_skip;
211df0566a6SJani Nikula 	u8 ths_trail;
212df0566a6SJani Nikula 	u8 tinit;
213df0566a6SJani Nikula 	u8 tlpx;
214df0566a6SJani Nikula 	u8 rsvd15[3];
215df0566a6SJani Nikula 
216df0566a6SJani Nikula 	/* GPIOs */
217df0566a6SJani Nikula 	u8 panel_enable;
218df0566a6SJani Nikula 	u8 bl_enable;
219df0566a6SJani Nikula 	u8 pwm_enable;
220df0566a6SJani Nikula 	u8 reset_r_n;
221df0566a6SJani Nikula 	u8 pwr_down_r;
222df0566a6SJani Nikula 	u8 stdby_r_n;
223df0566a6SJani Nikula 
224df0566a6SJani Nikula } __packed;
225df0566a6SJani Nikula 
226df0566a6SJani Nikula /* all delays have a unit of 100us */
227df0566a6SJani Nikula struct mipi_pps_data {
228df0566a6SJani Nikula 	u16 panel_on_delay;
229df0566a6SJani Nikula 	u16 bl_enable_delay;
230df0566a6SJani Nikula 	u16 bl_disable_delay;
231df0566a6SJani Nikula 	u16 panel_off_delay;
232df0566a6SJani Nikula 	u16 panel_power_cycle_delay;
233df0566a6SJani Nikula } __packed;
234df0566a6SJani Nikula 
235df0566a6SJani Nikula void intel_bios_init(struct drm_i915_private *dev_priv);
2363f9ffce5SVille Syrjälä void intel_bios_init_panel_early(struct drm_i915_private *dev_priv,
2373f9ffce5SVille Syrjälä 				 struct intel_panel *panel,
2383f9ffce5SVille Syrjälä 				 const struct intel_bios_encoder_data *devdata);
2393f9ffce5SVille Syrjälä void intel_bios_init_panel_late(struct drm_i915_private *dev_priv,
240c518a775SVille Syrjälä 				struct intel_panel *panel,
2416434cf63SAnimesh Manna 				const struct intel_bios_encoder_data *devdata,
242c36225a1SJani Nikula 				const struct drm_edid *drm_edid);
2433cf05076SVille Syrjälä void intel_bios_fini_panel(struct intel_panel *panel);
24478dae1acSJanusz Krzysztofik void intel_bios_driver_remove(struct drm_i915_private *dev_priv);
245df0566a6SJani Nikula bool intel_bios_is_valid_vbt(const void *buf, size_t size);
246df0566a6SJani Nikula bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv);
247df0566a6SJani Nikula bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin);
248df0566a6SJani Nikula bool intel_bios_is_port_present(struct drm_i915_private *dev_priv, enum port port);
249df0566a6SJani Nikula bool intel_bios_is_port_edp(struct drm_i915_private *dev_priv, enum port port);
250df0566a6SJani Nikula bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
2511bf2f3bfSJani Nikula bool intel_bios_get_dsc_params(struct intel_encoder *encoder,
2521bf2f3bfSJani Nikula 			       struct intel_crtc_state *crtc_state,
2531bf2f3bfSJani Nikula 			       int dsc_max_bpc);
254c5faae5aSJani Nikula bool intel_bios_port_supports_typec_usb(struct drm_i915_private *i915, enum port port);
255c5faae5aSJani Nikula bool intel_bios_port_supports_tbt(struct drm_i915_private *i915, enum port port);
256df0566a6SJani Nikula 
25745c0673aSJani Nikula const struct intel_bios_encoder_data *
25845c0673aSJani Nikula intel_bios_encoder_data_lookup(struct drm_i915_private *i915, enum port port);
25945c0673aSJani Nikula 
26045c0673aSJani Nikula bool intel_bios_encoder_supports_dvi(const struct intel_bios_encoder_data *devdata);
26145c0673aSJani Nikula bool intel_bios_encoder_supports_hdmi(const struct intel_bios_encoder_data *devdata);
26245c0673aSJani Nikula bool intel_bios_encoder_supports_dp(const struct intel_bios_encoder_data *devdata);
2639d4b7af5SVille Syrjälä bool intel_bios_encoder_supports_edp(const struct intel_bios_encoder_data *devdata);
264f08fbe6aSJani Nikula bool intel_bios_encoder_supports_typec_usb(const struct intel_bios_encoder_data *devdata);
265f08fbe6aSJani Nikula bool intel_bios_encoder_supports_tbt(const struct intel_bios_encoder_data *devdata);
266021a62a5SVille Syrjälä bool intel_bios_encoder_supports_dsi(const struct intel_bios_encoder_data *devdata);
2672bea1d7cSVille Syrjälä bool intel_bios_encoder_supports_dp_dual_mode(const struct intel_bios_encoder_data *devdata);
268db5d650fSVille Syrjälä bool intel_bios_encoder_is_lspcon(const struct intel_bios_encoder_data *devdata);
2695f42196dSVille Syrjälä bool intel_bios_encoder_lane_reversal(const struct intel_bios_encoder_data *devdata);
2709151c85cSVille Syrjälä bool intel_bios_encoder_hpd_invert(const struct intel_bios_encoder_data *devdata);
271021a62a5SVille Syrjälä enum port intel_bios_encoder_port(const struct intel_bios_encoder_data *devdata);
272bb45217fSVille Syrjälä enum aux_ch intel_bios_dp_aux_ch(const struct intel_bios_encoder_data *devdata);
27302107ef1SVille Syrjälä int intel_bios_dp_boost_level(const struct intel_bios_encoder_data *devdata);
27402107ef1SVille Syrjälä int intel_bios_dp_max_lane_count(const struct intel_bios_encoder_data *devdata);
27502107ef1SVille Syrjälä int intel_bios_dp_max_link_rate(const struct intel_bios_encoder_data *devdata);
276*7c95ec3bSVille Syrjälä bool intel_bios_dp_has_shared_aux_ch(const struct intel_bios_encoder_data *devdata);
27702107ef1SVille Syrjälä int intel_bios_hdmi_boost_level(const struct intel_bios_encoder_data *devdata);
27802107ef1SVille Syrjälä int intel_bios_hdmi_ddc_pin(const struct intel_bios_encoder_data *devdata);
27902107ef1SVille Syrjälä int intel_bios_hdmi_level_shift(const struct intel_bios_encoder_data *devdata);
28002107ef1SVille Syrjälä int intel_bios_hdmi_max_tmds_clock(const struct intel_bios_encoder_data *devdata);
28145c0673aSJani Nikula 
282021a62a5SVille Syrjälä void intel_bios_for_each_encoder(struct drm_i915_private *i915,
283021a62a5SVille Syrjälä 				 void (*func)(struct drm_i915_private *i915,
284021a62a5SVille Syrjälä 					      const struct intel_bios_encoder_data *devdata));
285021a62a5SVille Syrjälä 
286df0566a6SJani Nikula #endif /* _INTEL_BIOS_H_ */
287