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