blob: 7158c7ce9c0941a05654261e2443bac8b2315b08 [file] [log] [blame]
Shobhit Kumar2ab8b452014-05-23 21:35:27 +05301/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Shobhit Kumar <shobhit.kumar@intel.com>
24 *
25 */
26
27#include <drm/drmP.h>
28#include <drm/drm_crtc.h>
29#include <drm/drm_edid.h>
30#include <drm/i915_drm.h>
Jani Nikula213e08a2016-12-05 09:30:34 +020031#include <linux/gpio/consumer.h>
Shobhit Kumar2ab8b452014-05-23 21:35:27 +053032#include <linux/slab.h>
33#include <video/mipi_display.h>
34#include <asm/intel-mid.h>
35#include <video/mipi_display.h>
36#include "i915_drv.h"
37#include "intel_drv.h"
38#include "intel_dsi.h"
Shobhit Kumar2ab8b452014-05-23 21:35:27 +053039
40#define MIPI_TRANSFER_MODE_SHIFT 0
41#define MIPI_VIRTUAL_CHANNEL_SHIFT 1
42#define MIPI_PORT_SHIFT 3
43
44#define PREPARE_CNT_MAX 0x3F
45#define EXIT_ZERO_CNT_MAX 0x3F
46#define CLK_ZERO_CNT_MAX 0xFF
47#define TRAIL_CNT_MAX 0x1F
48
49#define NS_KHZ_RATIO 1000000
50
Jani Nikulab0c91cd2016-04-05 22:30:49 +030051/* base offsets for gpio pads */
52#define VLV_GPIO_NC_0_HV_DDI0_HPD 0x4130
53#define VLV_GPIO_NC_1_HV_DDI0_DDC_SDA 0x4120
54#define VLV_GPIO_NC_2_HV_DDI0_DDC_SCL 0x4110
55#define VLV_GPIO_NC_3_PANEL0_VDDEN 0x4140
56#define VLV_GPIO_NC_4_PANEL0_BKLTEN 0x4150
57#define VLV_GPIO_NC_5_PANEL0_BKLTCTL 0x4160
58#define VLV_GPIO_NC_6_HV_DDI1_HPD 0x4180
59#define VLV_GPIO_NC_7_HV_DDI1_DDC_SDA 0x4190
60#define VLV_GPIO_NC_8_HV_DDI1_DDC_SCL 0x4170
61#define VLV_GPIO_NC_9_PANEL1_VDDEN 0x4100
62#define VLV_GPIO_NC_10_PANEL1_BKLTEN 0x40E0
63#define VLV_GPIO_NC_11_PANEL1_BKLTCTL 0x40F0
64
65#define VLV_GPIO_PCONF0(base_offset) (base_offset)
66#define VLV_GPIO_PAD_VAL(base_offset) ((base_offset) + 8)
Shobhit Kumar2ab8b452014-05-23 21:35:27 +053067
Jani Nikulab13d8e22016-04-07 16:36:54 +030068struct gpio_map {
Jani Nikulab0c91cd2016-04-05 22:30:49 +030069 u16 base_offset;
70 bool init;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +053071};
72
Jani Nikulab13d8e22016-04-07 16:36:54 +030073static struct gpio_map vlv_gpio_table[] = {
Jani Nikulab0c91cd2016-04-05 22:30:49 +030074 { VLV_GPIO_NC_0_HV_DDI0_HPD },
75 { VLV_GPIO_NC_1_HV_DDI0_DDC_SDA },
76 { VLV_GPIO_NC_2_HV_DDI0_DDC_SCL },
77 { VLV_GPIO_NC_3_PANEL0_VDDEN },
78 { VLV_GPIO_NC_4_PANEL0_BKLTEN },
79 { VLV_GPIO_NC_5_PANEL0_BKLTCTL },
80 { VLV_GPIO_NC_6_HV_DDI1_HPD },
81 { VLV_GPIO_NC_7_HV_DDI1_DDC_SDA },
82 { VLV_GPIO_NC_8_HV_DDI1_DDC_SCL },
83 { VLV_GPIO_NC_9_PANEL1_VDDEN },
84 { VLV_GPIO_NC_10_PANEL1_BKLTEN },
85 { VLV_GPIO_NC_11_PANEL1_BKLTCTL },
Shobhit Kumar2ab8b452014-05-23 21:35:27 +053086};
87
Jani Nikulaa0a6d4f2016-04-26 13:27:40 +030088#define CHV_GPIO_IDX_START_N 0
89#define CHV_GPIO_IDX_START_E 73
90#define CHV_GPIO_IDX_START_SW 100
91#define CHV_GPIO_IDX_START_SE 198
92
93#define CHV_VBT_MAX_PINS_PER_FMLY 15
94
95#define CHV_GPIO_PAD_CFG0(f, i) (0x4400 + (f) * 0x400 + (i) * 8)
96#define CHV_GPIO_GPIOEN (1 << 15)
97#define CHV_GPIO_GPIOCFG_GPIO (0 << 8)
98#define CHV_GPIO_GPIOCFG_GPO (1 << 8)
99#define CHV_GPIO_GPIOCFG_GPI (2 << 8)
100#define CHV_GPIO_GPIOCFG_HIZ (3 << 8)
101#define CHV_GPIO_GPIOTXSTATE(state) ((!!(state)) << 1)
102
103#define CHV_GPIO_PAD_CFG1(f, i) (0x4400 + (f) * 0x400 + (i) * 8 + 4)
104#define CHV_GPIO_CFGLOCK (1 << 31)
105
Gaurav K Singh8f4d2682014-12-04 10:58:48 +0530106static inline enum port intel_dsi_seq_port_to_port(u8 port)
107{
108 return port ? PORT_C : PORT_A;
109}
110
Jani Nikula5b48ca02015-01-16 14:27:21 +0200111static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
112 const u8 *data)
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530113{
Jani Nikula759d10c2015-01-16 14:27:24 +0200114 struct mipi_dsi_device *dsi_device;
115 u8 type, flags, seq_port;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530116 u16 len;
Gaurav K Singh8f4d2682014-12-04 10:58:48 +0530117 enum port port;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530118
Jani Nikula0b9407c32016-09-19 15:02:25 +0300119 DRM_DEBUG_KMS("\n");
120
Jani Nikula759d10c2015-01-16 14:27:24 +0200121 flags = *data++;
122 type = *data++;
123
124 len = *((u16 *) data);
125 data += 2;
126
127 seq_port = (flags >> MIPI_PORT_SHIFT) & 3;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530128
Gaurav K Singhf9150842014-12-10 22:07:40 +0530129 /* For DSI single link on Port A & C, the seq_port value which is
130 * parsed from Sequence Block#53 of VBT has been set to 0
131 * Now, read/write of packets for the DSI single link on Port A and
132 * Port C will based on the DVO port from VBT block 2.
133 */
134 if (intel_dsi->ports == (1 << PORT_C))
135 port = PORT_C;
136 else
137 port = intel_dsi_seq_port_to_port(seq_port);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530138
Jani Nikula759d10c2015-01-16 14:27:24 +0200139 dsi_device = intel_dsi->dsi_hosts[port]->device;
140 if (!dsi_device) {
141 DRM_DEBUG_KMS("no dsi device for port %c\n", port_name(port));
142 goto out;
143 }
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530144
Jani Nikula759d10c2015-01-16 14:27:24 +0200145 if ((flags >> MIPI_TRANSFER_MODE_SHIFT) & 1)
146 dsi_device->mode_flags &= ~MIPI_DSI_MODE_LPM;
147 else
148 dsi_device->mode_flags |= MIPI_DSI_MODE_LPM;
149
150 dsi_device->channel = (flags >> MIPI_VIRTUAL_CHANNEL_SHIFT) & 3;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530151
152 switch (type) {
153 case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
Jani Nikula759d10c2015-01-16 14:27:24 +0200154 mipi_dsi_generic_write(dsi_device, NULL, 0);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530155 break;
156 case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
Jani Nikula759d10c2015-01-16 14:27:24 +0200157 mipi_dsi_generic_write(dsi_device, data, 1);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530158 break;
159 case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
Jani Nikula759d10c2015-01-16 14:27:24 +0200160 mipi_dsi_generic_write(dsi_device, data, 2);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530161 break;
162 case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
163 case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
164 case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
165 DRM_DEBUG_DRIVER("Generic Read not yet implemented or used\n");
166 break;
167 case MIPI_DSI_GENERIC_LONG_WRITE:
Jani Nikula759d10c2015-01-16 14:27:24 +0200168 mipi_dsi_generic_write(dsi_device, data, len);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530169 break;
170 case MIPI_DSI_DCS_SHORT_WRITE:
Jani Nikula759d10c2015-01-16 14:27:24 +0200171 mipi_dsi_dcs_write_buffer(dsi_device, data, 1);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530172 break;
173 case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
Jani Nikula759d10c2015-01-16 14:27:24 +0200174 mipi_dsi_dcs_write_buffer(dsi_device, data, 2);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530175 break;
176 case MIPI_DSI_DCS_READ:
177 DRM_DEBUG_DRIVER("DCS Read not yet implemented or used\n");
178 break;
179 case MIPI_DSI_DCS_LONG_WRITE:
Jani Nikula759d10c2015-01-16 14:27:24 +0200180 mipi_dsi_dcs_write_buffer(dsi_device, data, len);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530181 break;
Shobhit Kumarb5fbcd982014-05-27 19:23:46 +0530182 }
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530183
Hans de Goede3870b892017-02-28 11:26:16 +0200184 wait_for_dsi_fifo_empty(intel_dsi, port);
185
Jani Nikula759d10c2015-01-16 14:27:24 +0200186out:
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530187 data += len;
188
189 return data;
190}
191
Jani Nikula5b48ca02015-01-16 14:27:21 +0200192static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530193{
Jani Nikula5b48ca02015-01-16 14:27:21 +0200194 u32 delay = *((const u32 *) data);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530195
Jani Nikula0b9407c32016-09-19 15:02:25 +0300196 DRM_DEBUG_KMS("\n");
197
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530198 usleep_range(delay, delay + 10);
199 data += 4;
200
201 return data;
202}
203
Jani Nikula515d07d2016-04-05 22:30:50 +0300204static void vlv_exec_gpio(struct drm_i915_private *dev_priv,
205 u8 gpio_source, u8 gpio_index, bool value)
206{
Jani Nikulab13d8e22016-04-07 16:36:54 +0300207 struct gpio_map *map;
Jani Nikula515d07d2016-04-05 22:30:50 +0300208 u16 pconf0, padval;
209 u32 tmp;
210 u8 port;
211
212 if (gpio_index >= ARRAY_SIZE(vlv_gpio_table)) {
213 DRM_DEBUG_KMS("unknown gpio index %u\n", gpio_index);
214 return;
215 }
216
Jani Nikulab13d8e22016-04-07 16:36:54 +0300217 map = &vlv_gpio_table[gpio_index];
218
Jani Nikula515d07d2016-04-05 22:30:50 +0300219 if (dev_priv->vbt.dsi.seq_version >= 3) {
Jani Nikula4b541ef2016-04-26 13:27:39 +0300220 /* XXX: this assumes vlv_gpio_table only has NC GPIOs. */
221 port = IOSF_PORT_GPIO_NC;
Jani Nikula515d07d2016-04-05 22:30:50 +0300222 } else {
223 if (gpio_source == 0) {
224 port = IOSF_PORT_GPIO_NC;
225 } else if (gpio_source == 1) {
Jani Nikula060d4c32016-04-07 17:26:18 +0300226 DRM_DEBUG_KMS("SC gpio not supported\n");
227 return;
Jani Nikula515d07d2016-04-05 22:30:50 +0300228 } else {
229 DRM_DEBUG_KMS("unknown gpio source %u\n", gpio_source);
230 return;
231 }
232 }
233
Jani Nikulab13d8e22016-04-07 16:36:54 +0300234 pconf0 = VLV_GPIO_PCONF0(map->base_offset);
235 padval = VLV_GPIO_PAD_VAL(map->base_offset);
Jani Nikula515d07d2016-04-05 22:30:50 +0300236
237 mutex_lock(&dev_priv->sb_lock);
Jani Nikulab13d8e22016-04-07 16:36:54 +0300238 if (!map->init) {
Jani Nikula515d07d2016-04-05 22:30:50 +0300239 /* FIXME: remove constant below */
240 vlv_iosf_sb_write(dev_priv, port, pconf0, 0x2000CC00);
Jani Nikulab13d8e22016-04-07 16:36:54 +0300241 map->init = true;
Jani Nikula515d07d2016-04-05 22:30:50 +0300242 }
243
244 tmp = 0x4 | value;
245 vlv_iosf_sb_write(dev_priv, port, padval, tmp);
246 mutex_unlock(&dev_priv->sb_lock);
247}
248
Jani Nikulaa0a6d4f2016-04-26 13:27:40 +0300249static void chv_exec_gpio(struct drm_i915_private *dev_priv,
250 u8 gpio_source, u8 gpio_index, bool value)
251{
252 u16 cfg0, cfg1;
253 u16 family_num;
254 u8 port;
255
256 if (dev_priv->vbt.dsi.seq_version >= 3) {
257 if (gpio_index >= CHV_GPIO_IDX_START_SE) {
258 /* XXX: it's unclear whether 255->57 is part of SE. */
259 gpio_index -= CHV_GPIO_IDX_START_SE;
260 port = CHV_IOSF_PORT_GPIO_SE;
261 } else if (gpio_index >= CHV_GPIO_IDX_START_SW) {
262 gpio_index -= CHV_GPIO_IDX_START_SW;
263 port = CHV_IOSF_PORT_GPIO_SW;
264 } else if (gpio_index >= CHV_GPIO_IDX_START_E) {
265 gpio_index -= CHV_GPIO_IDX_START_E;
266 port = CHV_IOSF_PORT_GPIO_E;
267 } else {
268 port = CHV_IOSF_PORT_GPIO_N;
269 }
270 } else {
271 /* XXX: The spec is unclear about CHV GPIO on seq v2 */
272 if (gpio_source != 0) {
273 DRM_DEBUG_KMS("unknown gpio source %u\n", gpio_source);
274 return;
275 }
276
277 if (gpio_index >= CHV_GPIO_IDX_START_E) {
278 DRM_DEBUG_KMS("invalid gpio index %u for GPIO N\n",
279 gpio_index);
280 return;
281 }
282
283 port = CHV_IOSF_PORT_GPIO_N;
284 }
285
286 family_num = gpio_index / CHV_VBT_MAX_PINS_PER_FMLY;
287 gpio_index = gpio_index % CHV_VBT_MAX_PINS_PER_FMLY;
288
289 cfg0 = CHV_GPIO_PAD_CFG0(family_num, gpio_index);
290 cfg1 = CHV_GPIO_PAD_CFG1(family_num, gpio_index);
291
292 mutex_lock(&dev_priv->sb_lock);
293 vlv_iosf_sb_write(dev_priv, port, cfg1, 0);
294 vlv_iosf_sb_write(dev_priv, port, cfg0,
Hans de Goedeb2b45fc2016-12-01 21:29:09 +0100295 CHV_GPIO_GPIOEN | CHV_GPIO_GPIOCFG_GPO |
296 CHV_GPIO_GPIOTXSTATE(value));
Jani Nikulaa0a6d4f2016-04-26 13:27:40 +0300297 mutex_unlock(&dev_priv->sb_lock);
298}
299
Jani Nikula213e08a2016-12-05 09:30:34 +0200300static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
301 u8 gpio_source, u8 gpio_index, bool value)
302{
303 /* XXX: this table is a quick ugly hack. */
304 static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
305 struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
306
307 if (!gpio_desc) {
308 gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
309 "panel", gpio_index,
310 value ? GPIOD_OUT_LOW :
311 GPIOD_OUT_HIGH);
312
313 if (IS_ERR_OR_NULL(gpio_desc)) {
314 DRM_ERROR("GPIO index %u request failed (%ld)\n",
315 gpio_index, PTR_ERR(gpio_desc));
316 return;
317 }
318
319 bxt_gpio_table[gpio_index] = gpio_desc;
320 }
321
322 gpiod_set_value(gpio_desc, value);
323}
324
Jani Nikula5b48ca02015-01-16 14:27:21 +0200325static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530326{
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530327 struct drm_device *dev = intel_dsi->base.base.dev;
Chris Wilsonfac5e232016-07-04 11:34:36 +0100328 struct drm_i915_private *dev_priv = to_i915(dev);
Jani Nikula213e08a2016-12-05 09:30:34 +0200329 u8 gpio_source, gpio_index = 0, gpio_number;
Jani Nikula515d07d2016-04-05 22:30:50 +0300330 bool value;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530331
Jani Nikula0b9407c32016-09-19 15:02:25 +0300332 DRM_DEBUG_KMS("\n");
333
Jani Nikula96afef12016-02-04 18:52:47 +0200334 if (dev_priv->vbt.dsi.seq_version >= 3)
Jani Nikula213e08a2016-12-05 09:30:34 +0200335 gpio_index = *data++;
Jani Nikula96afef12016-02-04 18:52:47 +0200336
Jani Nikula213e08a2016-12-05 09:30:34 +0200337 gpio_number = *data++;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530338
Jani Nikula1d96a4a2016-03-18 13:11:10 +0200339 /* gpio source in sequence v2 only */
340 if (dev_priv->vbt.dsi.seq_version == 2)
341 gpio_source = (*data >> 1) & 3;
342 else
343 gpio_source = 0;
344
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530345 /* pull up/down */
Jani Nikula515d07d2016-04-05 22:30:50 +0300346 value = *data++ & 1;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530347
Jani Nikula515d07d2016-04-05 22:30:50 +0300348 if (IS_VALLEYVIEW(dev_priv))
Jani Nikula213e08a2016-12-05 09:30:34 +0200349 vlv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
Jani Nikulaa0a6d4f2016-04-26 13:27:40 +0300350 else if (IS_CHERRYVIEW(dev_priv))
Jani Nikula213e08a2016-12-05 09:30:34 +0200351 chv_exec_gpio(dev_priv, gpio_source, gpio_number, value);
Jani Nikula515d07d2016-04-05 22:30:50 +0300352 else
Jani Nikula213e08a2016-12-05 09:30:34 +0200353 bxt_exec_gpio(dev_priv, gpio_source, gpio_index, value);
Jani Nikula96afef12016-02-04 18:52:47 +0200354
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530355 return data;
356}
357
Jani Nikula0b9407c32016-09-19 15:02:25 +0300358static const u8 *mipi_exec_i2c(struct intel_dsi *intel_dsi, const u8 *data)
Jani Nikula29bbdcb2016-01-11 15:29:08 +0200359{
Jani Nikula0b9407c32016-09-19 15:02:25 +0300360 DRM_DEBUG_KMS("Skipping I2C element execution\n");
361
Jani Nikula29bbdcb2016-01-11 15:29:08 +0200362 return data + *(data + 6) + 7;
363}
364
Jani Nikula044aad62016-09-19 15:02:26 +0300365static const u8 *mipi_exec_spi(struct intel_dsi *intel_dsi, const u8 *data)
366{
367 DRM_DEBUG_KMS("Skipping SPI element execution\n");
368
369 return data + *(data + 5) + 6;
370}
371
372static const u8 *mipi_exec_pmic(struct intel_dsi *intel_dsi, const u8 *data)
373{
374 DRM_DEBUG_KMS("Skipping PMIC element execution\n");
375
376 return data + 15;
377}
378
Jani Nikula5b48ca02015-01-16 14:27:21 +0200379typedef const u8 * (*fn_mipi_elem_exec)(struct intel_dsi *intel_dsi,
380 const u8 *data);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530381static const fn_mipi_elem_exec exec_elem[] = {
Jani Nikula28c72842015-12-21 15:10:59 +0200382 [MIPI_SEQ_ELEM_SEND_PKT] = mipi_exec_send_packet,
383 [MIPI_SEQ_ELEM_DELAY] = mipi_exec_delay,
384 [MIPI_SEQ_ELEM_GPIO] = mipi_exec_gpio,
Jani Nikula0b9407c32016-09-19 15:02:25 +0300385 [MIPI_SEQ_ELEM_I2C] = mipi_exec_i2c,
Jani Nikula044aad62016-09-19 15:02:26 +0300386 [MIPI_SEQ_ELEM_SPI] = mipi_exec_spi,
387 [MIPI_SEQ_ELEM_PMIC] = mipi_exec_pmic,
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530388};
389
390/*
391 * MIPI Sequence from VBT #53 parsing logic
392 * We have already separated each seqence during bios parsing
393 * Following is generic execution function for any sequence
394 */
395
396static const char * const seq_name[] = {
Hans de Goede2b8208a2016-12-02 16:01:28 +0100397 [MIPI_SEQ_DEASSERT_RESET] = "MIPI_SEQ_DEASSERT_RESET",
Jani Nikula5cda0d22015-12-21 15:10:58 +0200398 [MIPI_SEQ_INIT_OTP] = "MIPI_SEQ_INIT_OTP",
399 [MIPI_SEQ_DISPLAY_ON] = "MIPI_SEQ_DISPLAY_ON",
400 [MIPI_SEQ_DISPLAY_OFF] = "MIPI_SEQ_DISPLAY_OFF",
Hans de Goede2b8208a2016-12-02 16:01:28 +0100401 [MIPI_SEQ_ASSERT_RESET] = "MIPI_SEQ_ASSERT_RESET",
Jani Nikulabc95ce72016-01-05 17:08:17 +0200402 [MIPI_SEQ_BACKLIGHT_ON] = "MIPI_SEQ_BACKLIGHT_ON",
403 [MIPI_SEQ_BACKLIGHT_OFF] = "MIPI_SEQ_BACKLIGHT_OFF",
404 [MIPI_SEQ_TEAR_ON] = "MIPI_SEQ_TEAR_ON",
405 [MIPI_SEQ_TEAR_OFF] = "MIPI_SEQ_TEAR_OFF",
406 [MIPI_SEQ_POWER_ON] = "MIPI_SEQ_POWER_ON",
407 [MIPI_SEQ_POWER_OFF] = "MIPI_SEQ_POWER_OFF",
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530408};
409
Jani Nikula5cda0d22015-12-21 15:10:58 +0200410static const char *sequence_name(enum mipi_seq seq_id)
411{
412 if (seq_id < ARRAY_SIZE(seq_name) && seq_name[seq_id])
413 return seq_name[seq_id];
414 else
415 return "(unknown)";
416}
417
Jani Nikulab0dd6882017-03-06 16:31:27 +0200418void intel_dsi_vbt_exec_sequence(struct intel_dsi *intel_dsi,
Hans de Goede18a00092017-02-28 11:26:20 +0200419 enum mipi_seq seq_id)
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530420{
Jani Nikula2a33d932016-01-11 15:15:02 +0200421 struct drm_i915_private *dev_priv = to_i915(intel_dsi->base.base.dev);
Jani Nikulac67fed82015-12-21 15:11:06 +0200422 const u8 *data;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530423 fn_mipi_elem_exec mipi_elem_exec;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530424
Jani Nikulac67fed82015-12-21 15:11:06 +0200425 if (WARN_ON(seq_id >= ARRAY_SIZE(dev_priv->vbt.dsi.sequence)))
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530426 return;
427
Jani Nikulac67fed82015-12-21 15:11:06 +0200428 data = dev_priv->vbt.dsi.sequence[seq_id];
Jani Nikulaf7d3c972016-09-19 15:02:24 +0300429 if (!data)
Jani Nikulac67fed82015-12-21 15:11:06 +0200430 return;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530431
Jani Nikulac67fed82015-12-21 15:11:06 +0200432 WARN_ON(*data != seq_id);
433
434 DRM_DEBUG_KMS("Starting MIPI sequence %d - %s\n",
435 seq_id, sequence_name(seq_id));
436
437 /* Skip Sequence Byte. */
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530438 data++;
439
Jani Nikula2a33d932016-01-11 15:15:02 +0200440 /* Skip Size of Sequence. */
441 if (dev_priv->vbt.dsi.seq_version >= 3)
442 data += 4;
443
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530444 while (1) {
Jani Nikula28c72842015-12-21 15:10:59 +0200445 u8 operation_byte = *data++;
Jani Nikula40795782016-01-05 17:06:48 +0200446 u8 operation_size = 0;
447
448 if (operation_byte == MIPI_SEQ_ELEM_END)
449 break;
450
451 if (operation_byte < ARRAY_SIZE(exec_elem))
452 mipi_elem_exec = exec_elem[operation_byte];
453 else
454 mipi_elem_exec = NULL;
455
456 /* Size of Operation. */
457 if (dev_priv->vbt.dsi.seq_version >= 3)
458 operation_size = *data++;
459
460 if (mipi_elem_exec) {
Jani Nikula8e4f7682016-09-19 15:02:30 +0300461 const u8 *next = data + operation_size;
462
Jani Nikula40795782016-01-05 17:06:48 +0200463 data = mipi_elem_exec(intel_dsi, data);
Jani Nikula8e4f7682016-09-19 15:02:30 +0300464
465 /* Consistency check if we have size. */
466 if (operation_size && data != next) {
467 DRM_ERROR("Inconsistent operation size\n");
468 return;
469 }
Jani Nikula40795782016-01-05 17:06:48 +0200470 } else if (operation_size) {
471 /* We have size, skip. */
472 DRM_DEBUG_KMS("Unsupported MIPI operation byte %u\n",
473 operation_byte);
474 data += operation_size;
475 } else {
476 /* No size, can't skip without parsing. */
Jani Nikula28c72842015-12-21 15:10:59 +0200477 DRM_ERROR("Unsupported MIPI operation byte %u\n",
478 operation_byte);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530479 return;
480 }
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530481 }
482}
483
Jani Nikula3f751d62017-03-06 16:31:26 +0200484int intel_dsi_vbt_get_modes(struct intel_dsi *intel_dsi)
Jani Nikula593e0622015-01-23 15:30:56 +0200485{
Jani Nikula3f751d62017-03-06 16:31:26 +0200486 struct intel_connector *connector = intel_dsi->attached_connector;
Jani Nikula593e0622015-01-23 15:30:56 +0200487 struct drm_device *dev = intel_dsi->base.base.dev;
Chris Wilsonfac5e232016-07-04 11:34:36 +0100488 struct drm_i915_private *dev_priv = to_i915(dev);
Jani Nikula593e0622015-01-23 15:30:56 +0200489 struct drm_display_mode *mode;
490
Jani Nikula593e0622015-01-23 15:30:56 +0200491 mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
492 if (!mode)
493 return 0;
494
495 mode->type |= DRM_MODE_TYPE_PREFERRED;
496
Jani Nikula3f751d62017-03-06 16:31:26 +0200497 drm_mode_probed_add(&connector->base, mode);
Jani Nikula593e0622015-01-23 15:30:56 +0200498
499 return 1;
500}
501
Jani Nikula3f751d62017-03-06 16:31:26 +0200502bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
Jani Nikula593e0622015-01-23 15:30:56 +0200503{
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530504 struct drm_device *dev = intel_dsi->base.base.dev;
Chris Wilsonfac5e232016-07-04 11:34:36 +0100505 struct drm_i915_private *dev_priv = to_i915(dev);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530506 struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
507 struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
508 struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
Jani Nikula1e78aa02016-03-16 12:21:40 +0200509 u32 bpp;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530510 u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui;
511 u32 ui_num, ui_den;
512 u32 prepare_cnt, exit_zero_cnt, clk_zero_cnt, trail_cnt;
513 u32 ths_prepare_ns, tclk_trail_ns;
514 u32 tclk_prepare_clkzero, ths_prepare_hszero;
515 u32 lp_to_hs_switch, hs_to_lp_switch;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530516 u32 pclk, computed_ddr;
Deepak M39299832017-02-17 18:13:29 +0530517 u32 mul;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530518 u16 burst_mode_ratio;
Jani Nikula759d10c2015-01-16 14:27:24 +0200519 enum port port;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530520
521 DRM_DEBUG_KMS("\n");
522
523 intel_dsi->eotp_pkt = mipi_config->eot_pkt_disabled ? 0 : 1;
524 intel_dsi->clock_stop = mipi_config->enable_clk_stop ? 1 : 0;
525 intel_dsi->lane_count = mipi_config->lane_cnt + 1;
Ramalingam C43367ec2016-04-07 14:36:06 +0530526 intel_dsi->pixel_format =
527 pixel_format_from_register_bits(
528 mipi_config->videomode_color_format << 7);
Jani Nikula1e78aa02016-03-16 12:21:40 +0200529 bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
530
Gaurav K Singh369602d2014-12-05 14:09:28 +0530531 intel_dsi->dual_link = mipi_config->dual_link;
Gaurav K Singha9da9bc2014-12-05 14:13:41 +0530532 intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530533 intel_dsi->operation_mode = mipi_config->is_cmd_mode;
534 intel_dsi->video_mode_format = mipi_config->video_transfer_mode;
535 intel_dsi->escape_clk_div = mipi_config->byte_clk_sel;
536 intel_dsi->lp_rx_timeout = mipi_config->lp_rx_timeout;
537 intel_dsi->turn_arnd_val = mipi_config->turn_around_timeout;
538 intel_dsi->rst_timer_val = mipi_config->device_reset_timer;
539 intel_dsi->init_count = mipi_config->master_init_timer;
540 intel_dsi->bw_timer = mipi_config->dbi_bw_timer;
Shobhit Kumarb5fbcd982014-05-27 19:23:46 +0530541 intel_dsi->video_frmt_cfg_bits =
542 mipi_config->bta_enabled ? DISABLE_VIDEO_BTA : 0;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530543
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530544 pclk = mode->clock;
545
Gaurav K Singha9da9bc2014-12-05 14:13:41 +0530546 /* In dual link mode each port needs half of pixel clock */
547 if (intel_dsi->dual_link) {
548 pclk = pclk / 2;
549
550 /* we can enable pixel_overlap if needed by panel. In this
551 * case we need to increase the pixelclock for extra pixels
552 */
553 if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
554 pclk += DIV_ROUND_UP(mode->vtotal *
555 intel_dsi->pixel_overlap *
556 60, 1000);
557 }
558 }
559
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530560 /* Burst Mode Ratio
561 * Target ddr frequency from VBT / non burst ddr freq
562 * multiply by 100 to preserve remainder
563 */
564 if (intel_dsi->video_mode_format == VIDEO_MODE_BURST) {
565 if (mipi_config->target_burst_mode_freq) {
Jani Nikula1e78aa02016-03-16 12:21:40 +0200566 computed_ddr = (pclk * bpp) / intel_dsi->lane_count;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530567
568 if (mipi_config->target_burst_mode_freq <
569 computed_ddr) {
570 DRM_ERROR("Burst mode freq is less than computed\n");
Jani Nikula3f751d62017-03-06 16:31:26 +0200571 return false;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530572 }
573
574 burst_mode_ratio = DIV_ROUND_UP(
575 mipi_config->target_burst_mode_freq * 100,
576 computed_ddr);
577
578 pclk = DIV_ROUND_UP(pclk * burst_mode_ratio, 100);
579 } else {
580 DRM_ERROR("Burst mode target is not set\n");
Jani Nikula3f751d62017-03-06 16:31:26 +0200581 return false;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530582 }
583 } else
584 burst_mode_ratio = 100;
585
586 intel_dsi->burst_mode_ratio = burst_mode_ratio;
587 intel_dsi->pclk = pclk;
588
Jani Nikula1e78aa02016-03-16 12:21:40 +0200589 bitrate = (pclk * bpp) / intel_dsi->lane_count;
Shobhit Kumar7f0c8602014-07-30 20:34:57 +0530590
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530591 switch (intel_dsi->escape_clk_div) {
592 case 0:
593 tlpx_ns = 50;
594 break;
595 case 1:
596 tlpx_ns = 100;
597 break;
598
599 case 2:
600 tlpx_ns = 200;
601 break;
602 default:
603 tlpx_ns = 50;
604 break;
605 }
606
607 switch (intel_dsi->lane_count) {
608 case 1:
609 case 2:
610 extra_byte_count = 2;
611 break;
612 case 3:
613 extra_byte_count = 4;
614 break;
615 case 4:
616 default:
617 extra_byte_count = 3;
618 break;
619 }
620
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530621 /* in Kbps */
622 ui_num = NS_KHZ_RATIO;
623 ui_den = bitrate;
624
625 tclk_prepare_clkzero = mipi_config->tclk_prepare_clkzero;
626 ths_prepare_hszero = mipi_config->ths_prepare_hszero;
627
628 /*
629 * B060
630 * LP byte clock = TLPX/ (8UI)
631 */
632 intel_dsi->lp_byte_clk = DIV_ROUND_UP(tlpx_ns * ui_den, 8 * ui_num);
633
Deepak M39299832017-02-17 18:13:29 +0530634 /* DDR clock period = 2 * UI
635 * UI(sec) = 1/(bitrate * 10^3) (bitrate is in KHZ)
636 * UI(nsec) = 10^6 / bitrate
637 * DDR clock period (nsec) = 2 * UI = (2 * 10^6)/ bitrate
638 * DDR clock count = ns_value / DDR clock period
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530639 *
Deepak M39299832017-02-17 18:13:29 +0530640 * For GEMINILAKE dphy_param_reg will be programmed in terms of
641 * HS byte clock count for other platform in HS ddr clock count
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530642 */
Deepak M39299832017-02-17 18:13:29 +0530643 mul = IS_GEMINILAKE(dev_priv) ? 8 : 2;
Shobhit Kumarb5fbcd982014-05-27 19:23:46 +0530644 ths_prepare_ns = max(mipi_config->ths_prepare,
645 mipi_config->tclk_prepare);
Deepak M39299832017-02-17 18:13:29 +0530646
647 /* prepare count */
648 prepare_cnt = DIV_ROUND_UP(ths_prepare_ns * ui_den, ui_num * mul);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530649
650 /* exit zero count */
651 exit_zero_cnt = DIV_ROUND_UP(
652 (ths_prepare_hszero - ths_prepare_ns) * ui_den,
Deepak M39299832017-02-17 18:13:29 +0530653 ui_num * mul
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530654 );
655
656 /*
Chris Wilsonebe69dd2016-07-02 15:36:03 +0100657 * Exit zero is unified val ths_zero and ths_exit
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530658 * minimum value for ths_exit = 110ns
659 * min (exit_zero_cnt * 2) = 110/UI
660 * exit_zero_cnt = 55/UI
661 */
Chris Wilsonebe69dd2016-07-02 15:36:03 +0100662 if (exit_zero_cnt < (55 * ui_den / ui_num) && (55 * ui_den) % ui_num)
663 exit_zero_cnt += 1;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530664
665 /* clk zero count */
666 clk_zero_cnt = DIV_ROUND_UP(
Deepak M39299832017-02-17 18:13:29 +0530667 (tclk_prepare_clkzero - ths_prepare_ns)
668 * ui_den, ui_num * mul);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530669
670 /* trail count */
671 tclk_trail_ns = max(mipi_config->tclk_trail, mipi_config->ths_trail);
Deepak M39299832017-02-17 18:13:29 +0530672 trail_cnt = DIV_ROUND_UP(tclk_trail_ns * ui_den, ui_num * mul);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530673
674 if (prepare_cnt > PREPARE_CNT_MAX ||
675 exit_zero_cnt > EXIT_ZERO_CNT_MAX ||
676 clk_zero_cnt > CLK_ZERO_CNT_MAX ||
677 trail_cnt > TRAIL_CNT_MAX)
678 DRM_DEBUG_DRIVER("Values crossing maximum limits, restricting to max values\n");
679
680 if (prepare_cnt > PREPARE_CNT_MAX)
681 prepare_cnt = PREPARE_CNT_MAX;
682
683 if (exit_zero_cnt > EXIT_ZERO_CNT_MAX)
684 exit_zero_cnt = EXIT_ZERO_CNT_MAX;
685
686 if (clk_zero_cnt > CLK_ZERO_CNT_MAX)
687 clk_zero_cnt = CLK_ZERO_CNT_MAX;
688
689 if (trail_cnt > TRAIL_CNT_MAX)
690 trail_cnt = TRAIL_CNT_MAX;
691
692 /* B080 */
693 intel_dsi->dphy_reg = exit_zero_cnt << 24 | trail_cnt << 16 |
694 clk_zero_cnt << 8 | prepare_cnt;
695
696 /*
Madhav Chauhan1fdd7832017-05-09 18:59:24 +0530697 * LP to HS switch count = 4TLPX + PREP_COUNT * mul + EXIT_ZERO_COUNT *
698 * mul + 10UI + Extra Byte Count
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530699 *
700 * HS to LP switch count = THS-TRAIL + 2TLPX + Extra Byte Count
701 * Extra Byte Count is calculated according to number of lanes.
702 * High Low Switch Count is the Max of LP to HS and
703 * HS to LP switch count
704 *
705 */
706 tlpx_ui = DIV_ROUND_UP(tlpx_ns * ui_den, ui_num);
707
708 /* B044 */
709 /* FIXME:
710 * The comment above does not match with the code */
Madhav Chauhan1fdd7832017-05-09 18:59:24 +0530711 lp_to_hs_switch = DIV_ROUND_UP(4 * tlpx_ui + prepare_cnt * mul +
712 exit_zero_cnt * mul + 10, 8);
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530713
714 hs_to_lp_switch = DIV_ROUND_UP(mipi_config->ths_trail + 2 * tlpx_ui, 8);
715
716 intel_dsi->hs_to_lp_count = max(lp_to_hs_switch, hs_to_lp_switch);
717 intel_dsi->hs_to_lp_count += extra_byte_count;
718
719 /* B088 */
720 /* LP -> HS for clock lanes
721 * LP clk sync + LP11 + LP01 + tclk_prepare + tclk_zero +
722 * extra byte count
723 * 2TPLX + 1TLPX + 1 TPLX(in ns) + prepare_cnt * 2 + clk_zero_cnt *
724 * 2(in UI) + extra byte count
725 * In byteclks = (4TLPX + prepare_cnt * 2 + clk_zero_cnt *2 (in UI)) /
726 * 8 + extra byte count
727 */
728 intel_dsi->clk_lp_to_hs_count =
729 DIV_ROUND_UP(
730 4 * tlpx_ui + prepare_cnt * 2 +
731 clk_zero_cnt * 2,
732 8);
733
734 intel_dsi->clk_lp_to_hs_count += extra_byte_count;
735
736 /* HS->LP for Clock Lanes
737 * Low Power clock synchronisations + 1Tx byteclk + tclk_trail +
738 * Extra byte count
739 * 2TLPX + 8UI + (trail_count*2)(in UI) + Extra byte count
740 * In byteclks = (2*TLpx(in UI) + trail_count*2 +8)(in UI)/8 +
741 * Extra byte count
742 */
743 intel_dsi->clk_hs_to_lp_count =
744 DIV_ROUND_UP(2 * tlpx_ui + trail_cnt * 2 + 8,
745 8);
746 intel_dsi->clk_hs_to_lp_count += extra_byte_count;
747
Ville Syrjälä64d83e32016-12-21 16:31:14 +0200748 DRM_DEBUG_KMS("Pclk %d\n", intel_dsi->pclk);
749 DRM_DEBUG_KMS("Pixel overlap %d\n", intel_dsi->pixel_overlap);
750 DRM_DEBUG_KMS("Lane count %d\n", intel_dsi->lane_count);
751 DRM_DEBUG_KMS("DPHY param reg 0x%x\n", intel_dsi->dphy_reg);
752 DRM_DEBUG_KMS("Video mode format %s\n",
753 intel_dsi->video_mode_format == VIDEO_MODE_NON_BURST_WITH_SYNC_PULSE ?
754 "non-burst with sync pulse" :
755 intel_dsi->video_mode_format == VIDEO_MODE_NON_BURST_WITH_SYNC_EVENTS ?
756 "non-burst with sync events" :
757 intel_dsi->video_mode_format == VIDEO_MODE_BURST ?
758 "burst" : "<unknown>");
759 DRM_DEBUG_KMS("Burst mode ratio %d\n", intel_dsi->burst_mode_ratio);
760 DRM_DEBUG_KMS("Reset timer %d\n", intel_dsi->rst_timer_val);
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +0000761 DRM_DEBUG_KMS("Eot %s\n", enableddisabled(intel_dsi->eotp_pkt));
762 DRM_DEBUG_KMS("Clockstop %s\n", enableddisabled(!intel_dsi->clock_stop));
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530763 DRM_DEBUG_KMS("Mode %s\n", intel_dsi->operation_mode ? "command" : "video");
Gaurav K Singha9da9bc2014-12-05 14:13:41 +0530764 if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
765 DRM_DEBUG_KMS("Dual link: DSI_DUAL_LINK_FRONT_BACK\n");
766 else if (intel_dsi->dual_link == DSI_DUAL_LINK_PIXEL_ALT)
767 DRM_DEBUG_KMS("Dual link: DSI_DUAL_LINK_PIXEL_ALT\n");
768 else
769 DRM_DEBUG_KMS("Dual link: NONE\n");
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530770 DRM_DEBUG_KMS("Pixel Format %d\n", intel_dsi->pixel_format);
771 DRM_DEBUG_KMS("TLPX %d\n", intel_dsi->escape_clk_div);
772 DRM_DEBUG_KMS("LP RX Timeout 0x%x\n", intel_dsi->lp_rx_timeout);
773 DRM_DEBUG_KMS("Turnaround Timeout 0x%x\n", intel_dsi->turn_arnd_val);
774 DRM_DEBUG_KMS("Init Count 0x%x\n", intel_dsi->init_count);
775 DRM_DEBUG_KMS("HS to LP Count 0x%x\n", intel_dsi->hs_to_lp_count);
776 DRM_DEBUG_KMS("LP Byte Clock %d\n", intel_dsi->lp_byte_clk);
777 DRM_DEBUG_KMS("DBI BW Timer 0x%x\n", intel_dsi->bw_timer);
778 DRM_DEBUG_KMS("LP to HS Clock Count 0x%x\n", intel_dsi->clk_lp_to_hs_count);
779 DRM_DEBUG_KMS("HS to LP Clock Count 0x%x\n", intel_dsi->clk_hs_to_lp_count);
780 DRM_DEBUG_KMS("BTA %s\n",
Tvrtko Ursulin08c4d7f2016-11-17 12:30:14 +0000781 enableddisabled(!(intel_dsi->video_frmt_cfg_bits & DISABLE_VIDEO_BTA)));
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530782
783 /* delays in VBT are in unit of 100us, so need to convert
784 * here in ms
785 * Delay (100us) * 100 /1000 = Delay / 10 (ms) */
786 intel_dsi->backlight_off_delay = pps->bl_disable_delay / 10;
787 intel_dsi->backlight_on_delay = pps->bl_enable_delay / 10;
788 intel_dsi->panel_on_delay = pps->panel_on_delay / 10;
789 intel_dsi->panel_off_delay = pps->panel_off_delay / 10;
790 intel_dsi->panel_pwr_cycle_delay = pps->panel_power_cycle_delay / 10;
791
Jani Nikula759d10c2015-01-16 14:27:24 +0200792 /* a regular driver would get the device in probe */
793 for_each_dsi_port(port, intel_dsi->ports) {
794 mipi_dsi_attach(intel_dsi->dsi_hosts[port]->device);
795 }
796
Jani Nikula3f751d62017-03-06 16:31:26 +0200797 return true;
Shobhit Kumar2ab8b452014-05-23 21:35:27 +0530798}