]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/gpu/drm/i915/intel_bios.c
drm/i915/bios: add support for MIPI sequence block v3
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / i915 / intel_bios.c
index ce82f9c7df2460b049b279957a8db78965b4f49c..15ba52bd25380e312876ba350cdc861c04b1102d 100644 (file)
  *    Eric Anholt <eric@anholt.net>
  *
  */
-#include <linux/dmi.h>
+
 #include <drm/drm_dp_helper.h>
 #include <drm/drmP.h>
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 #include "intel_bios.h"
 
+/**
+ * DOC: Video BIOS Table (VBT)
+ *
+ * The Video BIOS Table, or VBT, provides platform and board specific
+ * configuration information to the driver that is not discoverable or available
+ * through other means. The configuration is mostly related to display
+ * hardware. The VBT is available via the ACPI OpRegion or, on older systems, in
+ * the PCI ROM.
+ *
+ * The VBT consists of a VBT Header (defined as &struct vbt_header), a BDB
+ * Header (&struct bdb_header), and a number of BIOS Data Blocks (BDB) that
+ * contain the actual configuration information. The VBT Header, and thus the
+ * VBT, begins with "$VBT" signature. The VBT Header contains the offset of the
+ * BDB Header. The data blocks are concatenated after the BDB Header. The data
+ * blocks have a 1-byte Block ID, 2-byte Block Size, and Block Size bytes of
+ * data. (Block 53, the MIPI Sequence Block is an exception.)
+ *
+ * The driver parses the VBT during load. The relevant information is stored in
+ * driver private data for ease of use, and the actual VBT is not read after
+ * that.
+ */
+
 #define        SLAVE_ADDR1     0x70
 #define        SLAVE_ADDR2     0x72
 
 static int panel_type;
 
+/* Get BDB block size given a pointer to Block ID. */
+static u32 _get_blocksize(const u8 *block_base)
+{
+       /* The MIPI Sequence Block v3+ has a separate size field. */
+       if (*block_base == BDB_MIPI_SEQUENCE && *(block_base + 3) >= 3)
+               return *((const u32 *)(block_base + 4));
+       else
+               return *((const u16 *)(block_base + 1));
+}
+
+/* Get BDB block size give a pointer to data after Block ID and Block Size. */
+static u32 get_blocksize(const void *block_data)
+{
+       return _get_blocksize(block_data - 3);
+}
+
 static const void *
 find_section(const void *_bdb, int section_id)
 {
@@ -52,14 +90,8 @@ find_section(const void *_bdb, int section_id)
        /* walk the sections looking for section_id */
        while (index + 3 < total) {
                current_id = *(base + index);
-               index++;
-
-               current_size = *((const u16 *)(base + index));
-               index += 2;
-
-               /* The MIPI Sequence Block v3+ has a separate size field. */
-               if (current_id == BDB_MIPI_SEQUENCE && *(base + index) >= 3)
-                       current_size = *((const u32 *)(base + index + 1));
+               current_size = _get_blocksize(base + index);
+               index += 3;
 
                if (index + current_size > total)
                        return NULL;
@@ -73,16 +105,6 @@ find_section(const void *_bdb, int section_id)
        return NULL;
 }
 
-static u16
-get_blocksize(const void *p)
-{
-       u16 *block_ptr, block_size;
-
-       block_ptr = (u16 *)((char *)p - 2);
-       block_size = *block_ptr;
-       return block_size;
-}
-
 static void
 fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
                        const struct lvds_dvo_timing *dvo_timing)
@@ -332,10 +354,10 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
        drm_mode_debug_printmodeline(panel_fixed_mode);
 }
 
-static int intel_bios_ssc_frequency(struct drm_device *dev,
+static int intel_bios_ssc_frequency(struct drm_i915_private *dev_priv,
                                    bool alternate)
 {
-       switch (INTEL_INFO(dev)->gen) {
+       switch (INTEL_INFO(dev_priv)->gen) {
        case 2:
                return alternate ? 66667 : 48000;
        case 3:
@@ -350,26 +372,29 @@ static void
 parse_general_features(struct drm_i915_private *dev_priv,
                       const struct bdb_header *bdb)
 {
-       struct drm_device *dev = dev_priv->dev;
        const struct bdb_general_features *general;
 
        general = find_section(bdb, BDB_GENERAL_FEATURES);
-       if (general) {
-               dev_priv->vbt.int_tv_support = general->int_tv_support;
+       if (!general)
+               return;
+
+       dev_priv->vbt.int_tv_support = general->int_tv_support;
+       /* int_crt_support can't be trusted on earlier platforms */
+       if (bdb->version >= 155 &&
+           (HAS_DDI(dev_priv) || IS_VALLEYVIEW(dev_priv)))
                dev_priv->vbt.int_crt_support = general->int_crt_support;
-               dev_priv->vbt.lvds_use_ssc = general->enable_ssc;
-               dev_priv->vbt.lvds_ssc_freq =
-                       intel_bios_ssc_frequency(dev, general->ssc_freq);
-               dev_priv->vbt.display_clock_mode = general->display_clock_mode;
-               dev_priv->vbt.fdi_rx_polarity_inverted = general->fdi_rx_polarity_inverted;
-               DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d fdi_rx_polarity_inverted %d\n",
-                             dev_priv->vbt.int_tv_support,
-                             dev_priv->vbt.int_crt_support,
-                             dev_priv->vbt.lvds_use_ssc,
-                             dev_priv->vbt.lvds_ssc_freq,
-                             dev_priv->vbt.display_clock_mode,
-                             dev_priv->vbt.fdi_rx_polarity_inverted);
-       }
+       dev_priv->vbt.lvds_use_ssc = general->enable_ssc;
+       dev_priv->vbt.lvds_ssc_freq =
+               intel_bios_ssc_frequency(dev_priv, general->ssc_freq);
+       dev_priv->vbt.display_clock_mode = general->display_clock_mode;
+       dev_priv->vbt.fdi_rx_polarity_inverted = general->fdi_rx_polarity_inverted;
+       DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d fdi_rx_polarity_inverted %d\n",
+                     dev_priv->vbt.int_tv_support,
+                     dev_priv->vbt.int_crt_support,
+                     dev_priv->vbt.lvds_use_ssc,
+                     dev_priv->vbt.lvds_ssc_freq,
+                     dev_priv->vbt.display_clock_mode,
+                     dev_priv->vbt.fdi_rx_polarity_inverted);
 }
 
 static void
@@ -672,84 +697,13 @@ parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
        dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time;
 }
 
-static u8 *goto_next_sequence(u8 *data, int *size)
-{
-       u16 len;
-       int tmp = *size;
-
-       if (--tmp < 0)
-               return NULL;
-
-       /* goto first element */
-       data++;
-       while (1) {
-               switch (*data) {
-               case MIPI_SEQ_ELEM_SEND_PKT:
-                       /*
-                        * skip by this element payload size
-                        * skip elem id, command flag and data type
-                        */
-                       tmp -= 5;
-                       if (tmp < 0)
-                               return NULL;
-
-                       data += 3;
-                       len = *((u16 *)data);
-
-                       tmp -= len;
-                       if (tmp < 0)
-                               return NULL;
-
-                       /* skip by len */
-                       data = data + 2 + len;
-                       break;
-               case MIPI_SEQ_ELEM_DELAY:
-                       /* skip by elem id, and delay is 4 bytes */
-                       tmp -= 5;
-                       if (tmp < 0)
-                               return NULL;
-
-                       data += 5;
-                       break;
-               case MIPI_SEQ_ELEM_GPIO:
-                       tmp -= 3;
-                       if (tmp < 0)
-                               return NULL;
-
-                       data += 3;
-                       break;
-               default:
-                       DRM_ERROR("Unknown element\n");
-                       return NULL;
-               }
-
-               /* end of sequence ? */
-               if (*data == 0)
-                       break;
-       }
-
-       /* goto next sequence or end of block byte */
-       if (--tmp < 0)
-               return NULL;
-
-       data++;
-
-       /* update amount of data left for the sequence block to be parsed */
-       *size = tmp;
-       return data;
-}
-
 static void
-parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
+parse_mipi_config(struct drm_i915_private *dev_priv,
+                 const struct bdb_header *bdb)
 {
        const struct bdb_mipi_config *start;
-       const struct bdb_mipi_sequence *sequence;
        const struct mipi_config *config;
        const struct mipi_pps_data *pps;
-       u8 *data;
-       const u8 *seq_data;
-       int i, panel_id, seq_size;
-       u16 block_size;
 
        /* parse MIPI blocks only if LFP type is MIPI */
        if (!dev_priv->vbt.has_mipi)
@@ -795,104 +749,222 @@ parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
 
        /* We have mandatory mipi config blocks. Initialize as generic panel */
        dev_priv->vbt.dsi.panel_id = MIPI_DSI_GENERIC_PANEL_ID;
+}
 
-       /* Check if we have sequence block as well */
-       sequence = find_section(bdb, BDB_MIPI_SEQUENCE);
-       if (!sequence) {
-               DRM_DEBUG_KMS("No MIPI Sequence found, parsing complete\n");
-               return;
+/* Find the sequence block and size for the given panel. */
+static const u8 *
+find_panel_sequence_block(const struct bdb_mipi_sequence *sequence,
+                         u16 panel_id, u32 *seq_size)
+{
+       u32 total = get_blocksize(sequence);
+       const u8 *data = &sequence->data[0];
+       u8 current_id;
+       u32 current_size;
+       int header_size = sequence->version >= 3 ? 5 : 3;
+       int index = 0;
+       int i;
+
+       /* skip new block size */
+       if (sequence->version >= 3)
+               data += 4;
+
+       for (i = 0; i < MAX_MIPI_CONFIGURATIONS && index < total; i++) {
+               if (index + header_size > total) {
+                       DRM_ERROR("Invalid sequence block (header)\n");
+                       return NULL;
+               }
+
+               current_id = *(data + index);
+               if (sequence->version >= 3)
+                       current_size = *((const u32 *)(data + index + 1));
+               else
+                       current_size = *((const u16 *)(data + index + 1));
+
+               index += header_size;
+
+               if (index + current_size > total) {
+                       DRM_ERROR("Invalid sequence block\n");
+                       return NULL;
+               }
+
+               if (current_id == panel_id) {
+                       *seq_size = current_size;
+                       return data + index;
+               }
+
+               index += current_size;
        }
 
-       /* Fail gracefully for forward incompatible sequence block. */
-       if (sequence->version >= 3) {
-               DRM_ERROR("Unable to parse MIPI Sequence Block v3+\n");
-               return;
+       DRM_ERROR("Sequence block detected but no valid configuration\n");
+
+       return NULL;
+}
+
+static int goto_next_sequence(const u8 *data, int index, int total)
+{
+       u16 len;
+
+       /* Skip Sequence Byte. */
+       for (index = index + 1; index < total; index += len) {
+               u8 operation_byte = *(data + index);
+               index++;
+
+               switch (operation_byte) {
+               case MIPI_SEQ_ELEM_END:
+                       return index;
+               case MIPI_SEQ_ELEM_SEND_PKT:
+                       if (index + 4 > total)
+                               return 0;
+
+                       len = *((const u16 *)(data + index + 2)) + 4;
+                       break;
+               case MIPI_SEQ_ELEM_DELAY:
+                       len = 4;
+                       break;
+               case MIPI_SEQ_ELEM_GPIO:
+                       len = 2;
+                       break;
+               case MIPI_SEQ_ELEM_I2C:
+                       if (index + 7 > total)
+                               return 0;
+                       len = *(data + index + 6) + 7;
+                       break;
+               default:
+                       DRM_ERROR("Unknown operation byte\n");
+                       return 0;
+               }
        }
 
-       DRM_DEBUG_DRIVER("Found MIPI sequence block\n");
+       return 0;
+}
 
-       block_size = get_blocksize(sequence);
+static int goto_next_sequence_v3(const u8 *data, int index, int total)
+{
+       int seq_end;
+       u16 len;
 
        /*
-        * parse the sequence block for individual sequences
+        * Could skip sequence based on Size of Sequence alone, but also do some
+        * checking on the structure.
         */
-       dev_priv->vbt.dsi.seq_version = sequence->version;
+       if (total < 5) {
+               DRM_ERROR("Too small sequence size\n");
+               return 0;
+       }
 
-       seq_data = &sequence->data[0];
+       seq_end = index + *((const u32 *)(data + 1));
+       if (seq_end > total) {
+               DRM_ERROR("Invalid sequence size\n");
+               return 0;
+       }
 
-       /*
-        * sequence block is variable length and hence we need to parse and
-        * get the sequence data for specific panel id
-        */
-       for (i = 0; i < MAX_MIPI_CONFIGURATIONS; i++) {
-               panel_id = *seq_data;
-               seq_size = *((u16 *) (seq_data + 1));
-               if (panel_id == panel_type)
-                       break;
+       /* Skip Sequence Byte and Size of Sequence. */
+       for (index = index + 5; index < total; index += len) {
+               u8 operation_byte = *(data + index);
+               index++;
 
-               /* skip the sequence including seq header of 3 bytes */
-               seq_data = seq_data + 3 + seq_size;
-               if ((seq_data - &sequence->data[0]) > block_size) {
-                       DRM_ERROR("Sequence start is beyond sequence block size, corrupted sequence block\n");
-                       return;
+               if (operation_byte == MIPI_SEQ_ELEM_END) {
+                       if (index != seq_end) {
+                               DRM_ERROR("Invalid element structure\n");
+                               return 0;
+                       }
+                       return index;
+               }
+
+               len = *(data + index);
+               index++;
+
+               /*
+                * FIXME: Would be nice to check elements like for v1/v2 in
+                * goto_next_sequence() above.
+                */
+               switch (operation_byte) {
+               case MIPI_SEQ_ELEM_SEND_PKT:
+               case MIPI_SEQ_ELEM_DELAY:
+               case MIPI_SEQ_ELEM_GPIO:
+               case MIPI_SEQ_ELEM_I2C:
+               case MIPI_SEQ_ELEM_SPI:
+               case MIPI_SEQ_ELEM_PMIC:
+                       break;
+               default:
+                       DRM_ERROR("Unknown operation byte %u\n",
+                                 operation_byte);
+                       break;
                }
        }
 
-       if (i == MAX_MIPI_CONFIGURATIONS) {
-               DRM_ERROR("Sequence block detected but no valid configuration\n");
+       return 0;
+}
+
+static void
+parse_mipi_sequence(struct drm_i915_private *dev_priv,
+                   const struct bdb_header *bdb)
+{
+       const struct bdb_mipi_sequence *sequence;
+       const u8 *seq_data;
+       u32 seq_size;
+       u8 *data;
+       int index = 0;
+
+       /* Only our generic panel driver uses the sequence block. */
+       if (dev_priv->vbt.dsi.panel_id != MIPI_DSI_GENERIC_PANEL_ID)
+               return;
+
+       sequence = find_section(bdb, BDB_MIPI_SEQUENCE);
+       if (!sequence) {
+               DRM_DEBUG_KMS("No MIPI Sequence found, parsing complete\n");
                return;
        }
 
-       /* check if found sequence is completely within the sequence block
-        * just being paranoid */
-       if (seq_size > block_size) {
-               DRM_ERROR("Corrupted sequence/size, bailing out\n");
+       /* Fail gracefully for forward incompatible sequence block. */
+       if (sequence->version >= 4) {
+               DRM_ERROR("Unable to parse MIPI Sequence Block v%u\n",
+                         sequence->version);
                return;
        }
 
-       /* skip the panel id(1 byte) and seq size(2 bytes) */
-       dev_priv->vbt.dsi.data = kmemdup(seq_data + 3, seq_size, GFP_KERNEL);
-       if (!dev_priv->vbt.dsi.data)
+       DRM_DEBUG_DRIVER("Found MIPI sequence block v%u\n", sequence->version);
+
+       seq_data = find_panel_sequence_block(sequence, panel_type, &seq_size);
+       if (!seq_data)
                return;
 
-       /*
-        * loop into the sequence data and split into multiple sequneces
-        * There are only 5 types of sequences as of now
-        */
-       data = dev_priv->vbt.dsi.data;
-       dev_priv->vbt.dsi.size = seq_size;
+       data = kmemdup(seq_data, seq_size, GFP_KERNEL);
+       if (!data)
+               return;
 
-       /* two consecutive 0x00 indicate end of all sequences */
-       while (1) {
-               int seq_id = *data;
-               if (MIPI_SEQ_MAX > seq_id && seq_id > MIPI_SEQ_UNDEFINED) {
-                       dev_priv->vbt.dsi.sequence[seq_id] = data;
-                       DRM_DEBUG_DRIVER("Found mipi sequence - %d\n", seq_id);
-               } else {
-                       DRM_ERROR("undefined sequence\n");
+       /* Parse the sequences, store pointers to each sequence. */
+       for (;;) {
+               u8 seq_id = *(data + index);
+               if (seq_id == MIPI_SEQ_END)
+                       break;
+
+               if (seq_id >= MIPI_SEQ_MAX) {
+                       DRM_ERROR("Unknown sequence %u\n", seq_id);
                        goto err;
                }
 
-               /* partial parsing to skip elements */
-               data = goto_next_sequence(data, &seq_size);
+               dev_priv->vbt.dsi.sequence[seq_id] = data + index;
 
-               if (data == NULL) {
-                       DRM_ERROR("Sequence elements going beyond block itself. Sequence block parsing failed\n");
+               if (sequence->version >= 3)
+                       index = goto_next_sequence_v3(data, index, seq_size);
+               else
+                       index = goto_next_sequence(data, index, seq_size);
+               if (!index) {
+                       DRM_ERROR("Invalid sequence %u\n", seq_id);
                        goto err;
                }
-
-               if (*data == 0)
-                       break; /* end of sequence reached */
        }
 
-       DRM_DEBUG_DRIVER("MIPI related vbt parsing complete\n");
+       dev_priv->vbt.dsi.data = data;
+       dev_priv->vbt.dsi.size = seq_size;
+       dev_priv->vbt.dsi.seq_version = sequence->version;
+
+       DRM_DEBUG_DRIVER("MIPI related VBT parsing complete\n");
        return;
-err:
-       kfree(dev_priv->vbt.dsi.data);
-       dev_priv->vbt.dsi.data = NULL;
 
-       /* error during parsing so set all pointers to null
-        * because of partial parsing */
+err:
+       kfree(data);
        memset(dev_priv->vbt.dsi.sequence, 0, sizeof(dev_priv->vbt.dsi.sequence));
 }
 
@@ -1054,10 +1126,9 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 static void parse_ddi_ports(struct drm_i915_private *dev_priv,
                            const struct bdb_header *bdb)
 {
-       struct drm_device *dev = dev_priv->dev;
        enum port port;
 
-       if (!HAS_DDI(dev))
+       if (!HAS_DDI(dev_priv))
                return;
 
        if (!dev_priv->vbt.child_dev_num)
@@ -1170,7 +1241,6 @@ parse_device_mapping(struct drm_i915_private *dev_priv,
 static void
 init_vbt_defaults(struct drm_i915_private *dev_priv)
 {
-       struct drm_device *dev = dev_priv->dev;
        enum port port;
 
        dev_priv->vbt.crt_ddc_pin = GMBUS_PIN_VGADDC;
@@ -1195,8 +1265,8 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
         * Core/SandyBridge/IvyBridge use alternative (120MHz) reference
         * clock for LVDS.
         */
-       dev_priv->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(dev,
-                       !HAS_PCH_SPLIT(dev));
+       dev_priv->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(dev_priv,
+                       !HAS_PCH_SPLIT(dev_priv));
        DRM_DEBUG_KMS("Set default to SSC at %d kHz\n", dev_priv->vbt.lvds_ssc_freq);
 
        for (port = PORT_A; port < I915_MAX_PORTS; port++) {
@@ -1211,89 +1281,80 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
        }
 }
 
-static int intel_no_opregion_vbt_callback(const struct dmi_system_id *id)
+static const struct bdb_header *get_bdb_header(const struct vbt_header *vbt)
 {
-       DRM_DEBUG_KMS("Falling back to manually reading VBT from "
-                     "VBIOS ROM for %s\n",
-                     id->ident);
-       return 1;
+       const void *_vbt = vbt;
+
+       return _vbt + vbt->bdb_offset;
 }
 
-static const struct dmi_system_id intel_no_opregion_vbt[] = {
-       {
-               .callback = intel_no_opregion_vbt_callback,
-               .ident = "ThinkCentre A57",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "97027RG"),
-               },
-       },
-       { }
-};
-
-static const struct bdb_header *validate_vbt(const void *base,
-                                            size_t size,
-                                            const void *_vbt,
-                                            const char *source)
+/**
+ * intel_bios_is_valid_vbt - does the given buffer contain a valid VBT
+ * @buf:       pointer to a buffer to validate
+ * @size:      size of the buffer
+ *
+ * Returns true on valid VBT.
+ */
+bool intel_bios_is_valid_vbt(const void *buf, size_t size)
 {
-       size_t offset = _vbt - base;
-       const struct vbt_header *vbt = _vbt;
+       const struct vbt_header *vbt = buf;
        const struct bdb_header *bdb;
 
-       if (offset + sizeof(struct vbt_header) > size) {
+       if (!vbt)
+               return false;
+
+       if (sizeof(struct vbt_header) > size) {
                DRM_DEBUG_DRIVER("VBT header incomplete\n");
-               return NULL;
+               return false;
        }
 
        if (memcmp(vbt->signature, "$VBT", 4)) {
                DRM_DEBUG_DRIVER("VBT invalid signature\n");
-               return NULL;
+               return false;
        }
 
-       offset += vbt->bdb_offset;
-       if (offset + sizeof(struct bdb_header) > size) {
+       if (vbt->bdb_offset + sizeof(struct bdb_header) > size) {
                DRM_DEBUG_DRIVER("BDB header incomplete\n");
-               return NULL;
+               return false;
        }
 
-       bdb = base + offset;
-       if (offset + bdb->bdb_size > size) {
+       bdb = get_bdb_header(vbt);
+       if (vbt->bdb_offset + bdb->bdb_size > size) {
                DRM_DEBUG_DRIVER("BDB incomplete\n");
-               return NULL;
+               return false;
        }
 
-       DRM_DEBUG_KMS("Using VBT from %s: %20s\n",
-                     source, vbt->signature);
-       return bdb;
+       return vbt;
 }
 
-static const struct bdb_header *find_vbt(void __iomem *bios, size_t size)
+static const struct vbt_header *find_vbt(void __iomem *bios, size_t size)
 {
-       const struct bdb_header *bdb = NULL;
        size_t i;
 
        /* Scour memory looking for the VBT signature. */
        for (i = 0; i + 4 < size; i++) {
-               if (ioread32(bios + i) == *((const u32 *) "$VBT")) {
-                       /*
-                        * This is the one place where we explicitly discard the
-                        * address space (__iomem) of the BIOS/VBT. From now on
-                        * everything is based on 'base', and treated as regular
-                        * memory.
-                        */
-                       void *_bios = (void __force *) bios;
+               void *vbt;
 
-                       bdb = validate_vbt(_bios, size, _bios + i, "PCI ROM");
-                       break;
-               }
+               if (ioread32(bios + i) != *((const u32 *) "$VBT"))
+                       continue;
+
+               /*
+                * This is the one place where we explicitly discard the address
+                * space (__iomem) of the BIOS/VBT.
+                */
+               vbt = (void __force *) bios + i;
+               if (intel_bios_is_valid_vbt(vbt, size - i))
+                       return vbt;
+
+               break;
        }
 
-       return bdb;
+       return NULL;
 }
 
 /**
- * intel_parse_bios - find VBT and initialize settings from the BIOS
- * @dev: DRM device
+ * intel_bios_init - find VBT and initialize settings from the BIOS
+ * @dev_priv: i915 device instance
  *
  * Loads the Video BIOS and checks that the VBT exists.  Sets scratch registers
  * to appropriate values.
@@ -1301,37 +1362,39 @@ static const struct bdb_header *find_vbt(void __iomem *bios, size_t size)
  * Returns 0 on success, nonzero on failure.
  */
 int
-intel_parse_bios(struct drm_device *dev)
+intel_bios_init(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct pci_dev *pdev = dev->pdev;
-       const struct bdb_header *bdb = NULL;
+       struct pci_dev *pdev = dev_priv->dev->pdev;
+       const struct vbt_header *vbt = dev_priv->opregion.vbt;
+       const struct bdb_header *bdb;
        u8 __iomem *bios = NULL;
 
-       if (HAS_PCH_NOP(dev))
+       if (HAS_PCH_NOP(dev_priv))
                return -ENODEV;
 
        init_vbt_defaults(dev_priv);
 
-       /* XXX Should this validation be moved to intel_opregion.c? */
-       if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt)
-               bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
-                                  dev_priv->opregion.vbt, "OpRegion");
-
-       if (bdb == NULL) {
+       if (!vbt) {
                size_t size;
 
                bios = pci_map_rom(pdev, &size);
                if (!bios)
                        return -1;
 
-               bdb = find_vbt(bios, size);
-               if (!bdb) {
+               vbt = find_vbt(bios, size);
+               if (!vbt) {
                        pci_unmap_rom(pdev, bios);
                        return -1;
                }
+
+               DRM_DEBUG_KMS("Found valid VBT in PCI ROM\n");
        }
 
+       bdb = get_bdb_header(vbt);
+
+       DRM_DEBUG_KMS("VBT signature \"%.*s\", BDB version %d\n",
+                     (int)sizeof(vbt->signature), vbt->signature, bdb->version);
+
        /* Grab useful general definitions */
        parse_general_features(dev_priv, bdb);
        parse_general_definitions(dev_priv, bdb);
@@ -1343,7 +1406,8 @@ intel_parse_bios(struct drm_device *dev)
        parse_driver_features(dev_priv, bdb);
        parse_edp(dev_priv, bdb);
        parse_psr(dev_priv, bdb);
-       parse_mipi(dev_priv, bdb);
+       parse_mipi_config(dev_priv, bdb);
+       parse_mipi_sequence(dev_priv, bdb);
        parse_ddi_ports(dev_priv, bdb);
 
        if (bios)