blob: 6646fa2adc38255190e3e2009479842b245528ad [file] [log] [blame]
Thierry Redingdec72732013-09-03 08:45:46 +02001/*
2 * Copyright (C) 2013 NVIDIA Corporation
3 *
Thierry Reding9a2ac2d2014-02-11 15:52:01 +01004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
Thierry Redingdec72732013-09-03 08:45:46 +02007 */
8
9#include <linux/clk.h>
10#include <linux/debugfs.h>
11#include <linux/host1x.h>
12#include <linux/module.h>
13#include <linux/of.h>
Thierry Redinge94236c2014-10-07 16:10:24 +020014#include <linux/of_platform.h>
Thierry Redingdec72732013-09-03 08:45:46 +020015#include <linux/platform_device.h>
16#include <linux/reset.h>
17
Thierry Reding3b077af2014-03-14 14:07:50 +010018#include <linux/regulator/consumer.h>
19
Thierry Redingdec72732013-09-03 08:45:46 +020020#include <drm/drm_mipi_dsi.h>
21#include <drm/drm_panel.h>
22
23#include <video/mipi_display.h>
24
25#include "dc.h"
26#include "drm.h"
27#include "dsi.h"
28#include "mipi-phy.h"
29
Thierry Redingdec72732013-09-03 08:45:46 +020030struct tegra_dsi {
31 struct host1x_client client;
32 struct tegra_output output;
33 struct device *dev;
34
35 void __iomem *regs;
36
37 struct reset_control *rst;
38 struct clk *clk_parent;
39 struct clk *clk_lp;
40 struct clk *clk;
41
42 struct drm_info_list *debugfs_files;
43 struct drm_minor *minor;
44 struct dentry *debugfs;
45
Thierry Reding17297a22014-03-14 14:13:15 +010046 unsigned long flags;
Thierry Redingdec72732013-09-03 08:45:46 +020047 enum mipi_dsi_pixel_format format;
48 unsigned int lanes;
49
50 struct tegra_mipi_device *mipi;
51 struct mipi_dsi_host host;
Thierry Reding3b077af2014-03-14 14:07:50 +010052
53 struct regulator *vdd;
Thierry Reding334ae6b2014-03-14 14:15:10 +010054 bool enabled;
Thierry Reding976cebc2014-08-06 09:14:28 +020055
56 unsigned int video_fifo_depth;
57 unsigned int host_fifo_depth;
Thierry Redinge94236c2014-10-07 16:10:24 +020058
59 /* for ganged-mode support */
60 struct tegra_dsi *master;
61 struct tegra_dsi *slave;
Thierry Redingdec72732013-09-03 08:45:46 +020062};
63
64static inline struct tegra_dsi *
65host1x_client_to_dsi(struct host1x_client *client)
66{
67 return container_of(client, struct tegra_dsi, client);
68}
69
70static inline struct tegra_dsi *host_to_tegra(struct mipi_dsi_host *host)
71{
72 return container_of(host, struct tegra_dsi, host);
73}
74
75static inline struct tegra_dsi *to_dsi(struct tegra_output *output)
76{
77 return container_of(output, struct tegra_dsi, output);
78}
79
80static inline unsigned long tegra_dsi_readl(struct tegra_dsi *dsi,
81 unsigned long reg)
82{
83 return readl(dsi->regs + (reg << 2));
84}
85
86static inline void tegra_dsi_writel(struct tegra_dsi *dsi, unsigned long value,
87 unsigned long reg)
88{
89 writel(value, dsi->regs + (reg << 2));
90}
91
92static int tegra_dsi_show_regs(struct seq_file *s, void *data)
93{
94 struct drm_info_node *node = s->private;
95 struct tegra_dsi *dsi = node->info_ent->data;
96
97#define DUMP_REG(name) \
98 seq_printf(s, "%-32s %#05x %08lx\n", #name, name, \
99 tegra_dsi_readl(dsi, name))
100
101 DUMP_REG(DSI_INCR_SYNCPT);
102 DUMP_REG(DSI_INCR_SYNCPT_CONTROL);
103 DUMP_REG(DSI_INCR_SYNCPT_ERROR);
104 DUMP_REG(DSI_CTXSW);
105 DUMP_REG(DSI_RD_DATA);
106 DUMP_REG(DSI_WR_DATA);
107 DUMP_REG(DSI_POWER_CONTROL);
108 DUMP_REG(DSI_INT_ENABLE);
109 DUMP_REG(DSI_INT_STATUS);
110 DUMP_REG(DSI_INT_MASK);
111 DUMP_REG(DSI_HOST_CONTROL);
112 DUMP_REG(DSI_CONTROL);
113 DUMP_REG(DSI_SOL_DELAY);
114 DUMP_REG(DSI_MAX_THRESHOLD);
115 DUMP_REG(DSI_TRIGGER);
116 DUMP_REG(DSI_TX_CRC);
117 DUMP_REG(DSI_STATUS);
118
119 DUMP_REG(DSI_INIT_SEQ_CONTROL);
120 DUMP_REG(DSI_INIT_SEQ_DATA_0);
121 DUMP_REG(DSI_INIT_SEQ_DATA_1);
122 DUMP_REG(DSI_INIT_SEQ_DATA_2);
123 DUMP_REG(DSI_INIT_SEQ_DATA_3);
124 DUMP_REG(DSI_INIT_SEQ_DATA_4);
125 DUMP_REG(DSI_INIT_SEQ_DATA_5);
126 DUMP_REG(DSI_INIT_SEQ_DATA_6);
127 DUMP_REG(DSI_INIT_SEQ_DATA_7);
128
129 DUMP_REG(DSI_PKT_SEQ_0_LO);
130 DUMP_REG(DSI_PKT_SEQ_0_HI);
131 DUMP_REG(DSI_PKT_SEQ_1_LO);
132 DUMP_REG(DSI_PKT_SEQ_1_HI);
133 DUMP_REG(DSI_PKT_SEQ_2_LO);
134 DUMP_REG(DSI_PKT_SEQ_2_HI);
135 DUMP_REG(DSI_PKT_SEQ_3_LO);
136 DUMP_REG(DSI_PKT_SEQ_3_HI);
137 DUMP_REG(DSI_PKT_SEQ_4_LO);
138 DUMP_REG(DSI_PKT_SEQ_4_HI);
139 DUMP_REG(DSI_PKT_SEQ_5_LO);
140 DUMP_REG(DSI_PKT_SEQ_5_HI);
141
142 DUMP_REG(DSI_DCS_CMDS);
143
144 DUMP_REG(DSI_PKT_LEN_0_1);
145 DUMP_REG(DSI_PKT_LEN_2_3);
146 DUMP_REG(DSI_PKT_LEN_4_5);
147 DUMP_REG(DSI_PKT_LEN_6_7);
148
149 DUMP_REG(DSI_PHY_TIMING_0);
150 DUMP_REG(DSI_PHY_TIMING_1);
151 DUMP_REG(DSI_PHY_TIMING_2);
152 DUMP_REG(DSI_BTA_TIMING);
153
154 DUMP_REG(DSI_TIMEOUT_0);
155 DUMP_REG(DSI_TIMEOUT_1);
156 DUMP_REG(DSI_TO_TALLY);
157
158 DUMP_REG(DSI_PAD_CONTROL_0);
159 DUMP_REG(DSI_PAD_CONTROL_CD);
160 DUMP_REG(DSI_PAD_CD_STATUS);
161 DUMP_REG(DSI_VIDEO_MODE_CONTROL);
162 DUMP_REG(DSI_PAD_CONTROL_1);
163 DUMP_REG(DSI_PAD_CONTROL_2);
164 DUMP_REG(DSI_PAD_CONTROL_3);
165 DUMP_REG(DSI_PAD_CONTROL_4);
166
167 DUMP_REG(DSI_GANGED_MODE_CONTROL);
168 DUMP_REG(DSI_GANGED_MODE_START);
169 DUMP_REG(DSI_GANGED_MODE_SIZE);
170
171 DUMP_REG(DSI_RAW_DATA_BYTE_COUNT);
172 DUMP_REG(DSI_ULTRA_LOW_POWER_CONTROL);
173
174 DUMP_REG(DSI_INIT_SEQ_DATA_8);
175 DUMP_REG(DSI_INIT_SEQ_DATA_9);
176 DUMP_REG(DSI_INIT_SEQ_DATA_10);
177 DUMP_REG(DSI_INIT_SEQ_DATA_11);
178 DUMP_REG(DSI_INIT_SEQ_DATA_12);
179 DUMP_REG(DSI_INIT_SEQ_DATA_13);
180 DUMP_REG(DSI_INIT_SEQ_DATA_14);
181 DUMP_REG(DSI_INIT_SEQ_DATA_15);
182
183#undef DUMP_REG
184
185 return 0;
186}
187
188static struct drm_info_list debugfs_files[] = {
189 { "regs", tegra_dsi_show_regs, 0, NULL },
190};
191
192static int tegra_dsi_debugfs_init(struct tegra_dsi *dsi,
193 struct drm_minor *minor)
194{
195 const char *name = dev_name(dsi->dev);
196 unsigned int i;
197 int err;
198
199 dsi->debugfs = debugfs_create_dir(name, minor->debugfs_root);
200 if (!dsi->debugfs)
201 return -ENOMEM;
202
203 dsi->debugfs_files = kmemdup(debugfs_files, sizeof(debugfs_files),
204 GFP_KERNEL);
205 if (!dsi->debugfs_files) {
206 err = -ENOMEM;
207 goto remove;
208 }
209
210 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
211 dsi->debugfs_files[i].data = dsi;
212
213 err = drm_debugfs_create_files(dsi->debugfs_files,
214 ARRAY_SIZE(debugfs_files),
215 dsi->debugfs, minor);
216 if (err < 0)
217 goto free;
218
219 dsi->minor = minor;
220
221 return 0;
222
223free:
224 kfree(dsi->debugfs_files);
225 dsi->debugfs_files = NULL;
226remove:
227 debugfs_remove(dsi->debugfs);
228 dsi->debugfs = NULL;
229
230 return err;
231}
232
233static int tegra_dsi_debugfs_exit(struct tegra_dsi *dsi)
234{
235 drm_debugfs_remove_files(dsi->debugfs_files, ARRAY_SIZE(debugfs_files),
236 dsi->minor);
237 dsi->minor = NULL;
238
239 kfree(dsi->debugfs_files);
240 dsi->debugfs_files = NULL;
241
242 debugfs_remove(dsi->debugfs);
243 dsi->debugfs = NULL;
244
245 return 0;
246}
247
248#define PKT_ID0(id) ((((id) & 0x3f) << 3) | (1 << 9))
249#define PKT_LEN0(len) (((len) & 0x07) << 0)
250#define PKT_ID1(id) ((((id) & 0x3f) << 13) | (1 << 19))
251#define PKT_LEN1(len) (((len) & 0x07) << 10)
252#define PKT_ID2(id) ((((id) & 0x3f) << 23) | (1 << 29))
253#define PKT_LEN2(len) (((len) & 0x07) << 20)
254
255#define PKT_LP (1 << 30)
256#define NUM_PKT_SEQ 12
257
Thierry Reding17297a22014-03-14 14:13:15 +0100258/*
259 * non-burst mode with sync pulses
260 */
261static const u32 pkt_seq_video_non_burst_sync_pulses[NUM_PKT_SEQ] = {
Thierry Redingdec72732013-09-03 08:45:46 +0200262 [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
263 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
264 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
265 PKT_LP,
266 [ 1] = 0,
267 [ 2] = PKT_ID0(MIPI_DSI_V_SYNC_END) | PKT_LEN0(0) |
268 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
269 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
270 PKT_LP,
271 [ 3] = 0,
272 [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
273 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
274 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
275 PKT_LP,
276 [ 5] = 0,
277 [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
278 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
279 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
280 [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
281 PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
282 PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
283 [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
284 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
285 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
286 PKT_LP,
287 [ 9] = 0,
288 [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
289 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
290 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
291 [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
292 PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
293 PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
294};
295
Thierry Reding17297a22014-03-14 14:13:15 +0100296/*
297 * non-burst mode with sync events
298 */
299static const u32 pkt_seq_video_non_burst_sync_events[NUM_PKT_SEQ] = {
300 [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
301 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
302 PKT_LP,
303 [ 1] = 0,
304 [ 2] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
305 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
306 PKT_LP,
307 [ 3] = 0,
308 [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
309 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
310 PKT_LP,
311 [ 5] = 0,
312 [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
313 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
314 PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
315 [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
316 [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
317 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
318 PKT_LP,
319 [ 9] = 0,
320 [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
321 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
322 PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
323 [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
324};
325
Thierry Reding337b4432014-11-13 15:02:46 +0100326static const u32 pkt_seq_command_mode[NUM_PKT_SEQ] = {
327 [ 0] = 0,
328 [ 1] = 0,
329 [ 2] = 0,
330 [ 3] = 0,
331 [ 4] = 0,
332 [ 5] = 0,
333 [ 6] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(3) | PKT_LP,
334 [ 7] = 0,
335 [ 8] = 0,
336 [ 9] = 0,
337 [10] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(5) | PKT_LP,
338 [11] = 0,
339};
340
Thierry Redingdec72732013-09-03 08:45:46 +0200341static int tegra_dsi_set_phy_timing(struct tegra_dsi *dsi)
342{
343 struct mipi_dphy_timing timing;
344 unsigned long value, period;
345 long rate;
346 int err;
347
348 rate = clk_get_rate(dsi->clk);
349 if (rate < 0)
350 return rate;
351
352 period = DIV_ROUND_CLOSEST(1000000000UL, rate * 2);
353
354 err = mipi_dphy_timing_get_default(&timing, period);
355 if (err < 0)
356 return err;
357
358 err = mipi_dphy_timing_validate(&timing, period);
359 if (err < 0) {
360 dev_err(dsi->dev, "failed to validate D-PHY timing: %d\n", err);
361 return err;
362 }
363
364 /*
365 * The D-PHY timing fields below are expressed in byte-clock cycles,
366 * so multiply the period by 8.
367 */
368 period *= 8;
369
370 value = DSI_TIMING_FIELD(timing.hsexit, period, 1) << 24 |
371 DSI_TIMING_FIELD(timing.hstrail, period, 0) << 16 |
372 DSI_TIMING_FIELD(timing.hszero, period, 3) << 8 |
373 DSI_TIMING_FIELD(timing.hsprepare, period, 1);
374 tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_0);
375
376 value = DSI_TIMING_FIELD(timing.clktrail, period, 1) << 24 |
377 DSI_TIMING_FIELD(timing.clkpost, period, 1) << 16 |
378 DSI_TIMING_FIELD(timing.clkzero, period, 1) << 8 |
379 DSI_TIMING_FIELD(timing.lpx, period, 1);
380 tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_1);
381
382 value = DSI_TIMING_FIELD(timing.clkprepare, period, 1) << 16 |
383 DSI_TIMING_FIELD(timing.clkpre, period, 1) << 8 |
384 DSI_TIMING_FIELD(0xff * period, period, 0) << 0;
385 tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_2);
386
387 value = DSI_TIMING_FIELD(timing.taget, period, 1) << 16 |
388 DSI_TIMING_FIELD(timing.tasure, period, 1) << 8 |
389 DSI_TIMING_FIELD(timing.tago, period, 1);
390 tegra_dsi_writel(dsi, value, DSI_BTA_TIMING);
391
392 return 0;
393}
394
395static int tegra_dsi_get_muldiv(enum mipi_dsi_pixel_format format,
396 unsigned int *mulp, unsigned int *divp)
397{
398 switch (format) {
399 case MIPI_DSI_FMT_RGB666_PACKED:
400 case MIPI_DSI_FMT_RGB888:
401 *mulp = 3;
402 *divp = 1;
403 break;
404
405 case MIPI_DSI_FMT_RGB565:
406 *mulp = 2;
407 *divp = 1;
408 break;
409
410 case MIPI_DSI_FMT_RGB666:
411 *mulp = 9;
412 *divp = 4;
413 break;
414
415 default:
416 return -EINVAL;
417 }
418
419 return 0;
420}
421
Thierry Redingf7d68892014-03-13 08:50:39 +0100422static int tegra_dsi_get_format(enum mipi_dsi_pixel_format format,
423 enum tegra_dsi_format *fmt)
424{
425 switch (format) {
426 case MIPI_DSI_FMT_RGB888:
427 *fmt = TEGRA_DSI_FORMAT_24P;
428 break;
429
430 case MIPI_DSI_FMT_RGB666:
431 *fmt = TEGRA_DSI_FORMAT_18NP;
432 break;
433
434 case MIPI_DSI_FMT_RGB666_PACKED:
435 *fmt = TEGRA_DSI_FORMAT_18P;
436 break;
437
438 case MIPI_DSI_FMT_RGB565:
439 *fmt = TEGRA_DSI_FORMAT_16P;
440 break;
441
442 default:
443 return -EINVAL;
444 }
445
446 return 0;
447}
448
Thierry Redinge94236c2014-10-07 16:10:24 +0200449static void tegra_dsi_ganged_enable(struct tegra_dsi *dsi, unsigned int start,
450 unsigned int size)
451{
452 u32 value;
453
454 tegra_dsi_writel(dsi, start, DSI_GANGED_MODE_START);
455 tegra_dsi_writel(dsi, size << 16 | size, DSI_GANGED_MODE_SIZE);
456
457 value = DSI_GANGED_MODE_CONTROL_ENABLE;
458 tegra_dsi_writel(dsi, value, DSI_GANGED_MODE_CONTROL);
459}
460
Thierry Reding563eff12014-11-13 14:44:27 +0100461static void tegra_dsi_enable(struct tegra_dsi *dsi)
Thierry Redingdec72732013-09-03 08:45:46 +0200462{
Thierry Reding563eff12014-11-13 14:44:27 +0100463 u32 value;
Thierry Redingdec72732013-09-03 08:45:46 +0200464
Thierry Reding563eff12014-11-13 14:44:27 +0100465 value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
466 value |= DSI_POWER_CONTROL_ENABLE;
467 tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
Thierry Redinge94236c2014-10-07 16:10:24 +0200468
469 if (dsi->slave)
470 tegra_dsi_enable(dsi->slave);
471}
472
473static unsigned int tegra_dsi_get_lanes(struct tegra_dsi *dsi)
474{
475 if (dsi->master)
476 return dsi->master->lanes + dsi->lanes;
477
478 if (dsi->slave)
479 return dsi->lanes + dsi->slave->lanes;
480
481 return dsi->lanes;
Thierry Reding563eff12014-11-13 14:44:27 +0100482}
483
484static int tegra_dsi_configure(struct tegra_dsi *dsi, unsigned int pipe,
485 const struct drm_display_mode *mode)
486{
487 unsigned int hact, hsw, hbp, hfp, i, mul, div;
488 enum tegra_dsi_format format;
489 const u32 *pkt_seq;
490 u32 value;
491 int err;
Thierry Reding334ae6b2014-03-14 14:15:10 +0100492
Thierry Reding17297a22014-03-14 14:13:15 +0100493 if (dsi->flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
494 DRM_DEBUG_KMS("Non-burst video mode with sync pulses\n");
495 pkt_seq = pkt_seq_video_non_burst_sync_pulses;
Thierry Reding337b4432014-11-13 15:02:46 +0100496 } else if (dsi->flags & MIPI_DSI_MODE_VIDEO) {
Thierry Reding17297a22014-03-14 14:13:15 +0100497 DRM_DEBUG_KMS("Non-burst video mode with sync events\n");
498 pkt_seq = pkt_seq_video_non_burst_sync_events;
Thierry Reding337b4432014-11-13 15:02:46 +0100499 } else {
500 DRM_DEBUG_KMS("Command mode\n");
501 pkt_seq = pkt_seq_command_mode;
Thierry Reding17297a22014-03-14 14:13:15 +0100502 }
503
Thierry Redingdec72732013-09-03 08:45:46 +0200504 err = tegra_dsi_get_muldiv(dsi->format, &mul, &div);
505 if (err < 0)
506 return err;
507
Thierry Redingf7d68892014-03-13 08:50:39 +0100508 err = tegra_dsi_get_format(dsi->format, &format);
509 if (err < 0)
510 return err;
511
Thierry Redingf7d68892014-03-13 08:50:39 +0100512 value = DSI_CONTROL_CHANNEL(0) | DSI_CONTROL_FORMAT(format) |
Thierry Redingdec72732013-09-03 08:45:46 +0200513 DSI_CONTROL_LANES(dsi->lanes - 1) |
Thierry Reding563eff12014-11-13 14:44:27 +0100514 DSI_CONTROL_SOURCE(pipe);
Thierry Redingdec72732013-09-03 08:45:46 +0200515 tegra_dsi_writel(dsi, value, DSI_CONTROL);
516
Thierry Reding976cebc2014-08-06 09:14:28 +0200517 tegra_dsi_writel(dsi, dsi->video_fifo_depth, DSI_MAX_THRESHOLD);
Thierry Redingdec72732013-09-03 08:45:46 +0200518
Thierry Reding563eff12014-11-13 14:44:27 +0100519 value = DSI_HOST_CONTROL_HS;
Thierry Redingdec72732013-09-03 08:45:46 +0200520 tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
521
522 value = tegra_dsi_readl(dsi, DSI_CONTROL);
Thierry Reding563eff12014-11-13 14:44:27 +0100523
Alexandre Courbot0c6b1e42014-07-08 21:32:13 +0900524 if (dsi->flags & MIPI_DSI_CLOCK_NON_CONTINUOUS)
525 value |= DSI_CONTROL_HS_CLK_CTRL;
Thierry Reding563eff12014-11-13 14:44:27 +0100526
Thierry Redingdec72732013-09-03 08:45:46 +0200527 value &= ~DSI_CONTROL_TX_TRIG(3);
Thierry Reding337b4432014-11-13 15:02:46 +0100528
529 /* enable DCS commands for command mode */
530 if (dsi->flags & MIPI_DSI_MODE_VIDEO)
531 value &= ~DSI_CONTROL_DCS_ENABLE;
532 else
533 value |= DSI_CONTROL_DCS_ENABLE;
534
Thierry Redingdec72732013-09-03 08:45:46 +0200535 value |= DSI_CONTROL_VIDEO_ENABLE;
536 value &= ~DSI_CONTROL_HOST_ENABLE;
537 tegra_dsi_writel(dsi, value, DSI_CONTROL);
538
539 err = tegra_dsi_set_phy_timing(dsi);
540 if (err < 0)
541 return err;
542
543 for (i = 0; i < NUM_PKT_SEQ; i++)
544 tegra_dsi_writel(dsi, pkt_seq[i], DSI_PKT_SEQ_0_LO + i);
545
Thierry Reding337b4432014-11-13 15:02:46 +0100546 if (dsi->flags & MIPI_DSI_MODE_VIDEO) {
547 /* horizontal active pixels */
548 hact = mode->hdisplay * mul / div;
Thierry Redingdec72732013-09-03 08:45:46 +0200549
Thierry Reding337b4432014-11-13 15:02:46 +0100550 /* horizontal sync width */
551 hsw = (mode->hsync_end - mode->hsync_start) * mul / div;
552 hsw -= 10;
Thierry Redingdec72732013-09-03 08:45:46 +0200553
Thierry Reding337b4432014-11-13 15:02:46 +0100554 /* horizontal back porch */
555 hbp = (mode->htotal - mode->hsync_end) * mul / div;
556 hbp -= 14;
Thierry Redingdec72732013-09-03 08:45:46 +0200557
Thierry Reding337b4432014-11-13 15:02:46 +0100558 /* horizontal front porch */
559 hfp = (mode->hsync_start - mode->hdisplay) * mul / div;
560 hfp -= 8;
Thierry Redingdec72732013-09-03 08:45:46 +0200561
Thierry Reding337b4432014-11-13 15:02:46 +0100562 tegra_dsi_writel(dsi, hsw << 16 | 0, DSI_PKT_LEN_0_1);
563 tegra_dsi_writel(dsi, hact << 16 | hbp, DSI_PKT_LEN_2_3);
564 tegra_dsi_writel(dsi, hfp, DSI_PKT_LEN_4_5);
565 tegra_dsi_writel(dsi, 0x0f0f << 16, DSI_PKT_LEN_6_7);
Thierry Redingdec72732013-09-03 08:45:46 +0200566
Thierry Reding337b4432014-11-13 15:02:46 +0100567 /* set SOL delay (for non-burst mode only) */
568 tegra_dsi_writel(dsi, 8 * mul / div, DSI_SOL_DELAY);
Thierry Redinge94236c2014-10-07 16:10:24 +0200569
570 /* TODO: implement ganged mode */
Thierry Reding337b4432014-11-13 15:02:46 +0100571 } else {
572 u16 bytes;
573
Thierry Redinge94236c2014-10-07 16:10:24 +0200574 if (dsi->master || dsi->slave) {
575 /*
576 * For ganged mode, assume symmetric left-right mode.
577 */
578 bytes = 1 + (mode->hdisplay / 2) * mul / div;
579 } else {
580 /* 1 byte (DCS command) + pixel data */
581 bytes = 1 + mode->hdisplay * mul / div;
582 }
Thierry Reding337b4432014-11-13 15:02:46 +0100583
584 tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_0_1);
585 tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_2_3);
586 tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_4_5);
587 tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_6_7);
588
589 value = MIPI_DCS_WRITE_MEMORY_START << 8 |
590 MIPI_DCS_WRITE_MEMORY_CONTINUE;
591 tegra_dsi_writel(dsi, value, DSI_DCS_CMDS);
592
Thierry Redinge94236c2014-10-07 16:10:24 +0200593 /* set SOL delay */
594 if (dsi->master || dsi->slave) {
595 unsigned int lanes = tegra_dsi_get_lanes(dsi);
596 unsigned long delay, bclk, bclk_ganged;
597
598 /* SOL to valid, valid to FIFO and FIFO write delay */
599 delay = 4 + 4 + 2;
600 delay = DIV_ROUND_UP(delay * mul, div * lanes);
601 /* FIFO read delay */
602 delay = delay + 6;
603
604 bclk = DIV_ROUND_UP(mode->htotal * mul, div * lanes);
605 bclk_ganged = DIV_ROUND_UP(bclk * lanes / 2, lanes);
606 value = bclk - bclk_ganged + delay + 20;
607 } else {
608 /* TODO: revisit for non-ganged mode */
609 value = 8 * mul / div;
610 }
Thierry Reding337b4432014-11-13 15:02:46 +0100611
612 tegra_dsi_writel(dsi, value, DSI_SOL_DELAY);
613 }
Thierry Redingdec72732013-09-03 08:45:46 +0200614
Thierry Redinge94236c2014-10-07 16:10:24 +0200615 if (dsi->slave) {
616 err = tegra_dsi_configure(dsi->slave, pipe, mode);
617 if (err < 0)
618 return err;
619
620 /*
621 * TODO: Support modes other than symmetrical left-right
622 * split.
623 */
624 tegra_dsi_ganged_enable(dsi, 0, mode->hdisplay / 2);
625 tegra_dsi_ganged_enable(dsi->slave, mode->hdisplay / 2,
626 mode->hdisplay / 2);
627 }
628
Thierry Reding563eff12014-11-13 14:44:27 +0100629 return 0;
630}
631
632static int tegra_output_dsi_enable(struct tegra_output *output)
633{
634 struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc);
635 const struct drm_display_mode *mode = &dc->base.mode;
636 struct tegra_dsi *dsi = to_dsi(output);
637 u32 value;
638 int err;
639
640 if (dsi->enabled)
641 return 0;
642
643 err = tegra_dsi_configure(dsi, dc->pipe, mode);
644 if (err < 0)
645 return err;
646
Thierry Redingdec72732013-09-03 08:45:46 +0200647 /* enable display controller */
648 value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
649 value |= DSI_ENABLE;
650 tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
651
Thierry Redingdec72732013-09-03 08:45:46 +0200652 value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
653 value &= ~DISP_CTRL_MODE_MASK;
654 value |= DISP_CTRL_MODE_C_DISPLAY;
655 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
656
Thierry Reding72d30282013-12-12 11:06:55 +0100657 value = tegra_dc_readl(dc, DC_CMD_DISPLAY_POWER_CONTROL);
658 value |= PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
659 PW4_ENABLE | PM0_ENABLE | PM1_ENABLE;
660 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_POWER_CONTROL);
661
Thierry Redingdec72732013-09-03 08:45:46 +0200662 tegra_dc_writel(dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
663 tegra_dc_writel(dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
664
665 /* enable DSI controller */
Thierry Reding563eff12014-11-13 14:44:27 +0100666 tegra_dsi_enable(dsi);
Thierry Redingdec72732013-09-03 08:45:46 +0200667
Thierry Reding334ae6b2014-03-14 14:15:10 +0100668 dsi->enabled = true;
669
Thierry Redingdec72732013-09-03 08:45:46 +0200670 return 0;
671}
672
Thierry Reding563eff12014-11-13 14:44:27 +0100673static int tegra_dsi_wait_idle(struct tegra_dsi *dsi, unsigned long timeout)
674{
675 u32 value;
676
677 timeout = jiffies + msecs_to_jiffies(timeout);
678
679 while (time_before(jiffies, timeout)) {
680 value = tegra_dsi_readl(dsi, DSI_STATUS);
681 if (value & DSI_STATUS_IDLE)
682 return 0;
683
684 usleep_range(1000, 2000);
685 }
686
687 return -ETIMEDOUT;
688}
689
690static void tegra_dsi_video_disable(struct tegra_dsi *dsi)
691{
692 u32 value;
693
694 value = tegra_dsi_readl(dsi, DSI_CONTROL);
695 value &= ~DSI_CONTROL_VIDEO_ENABLE;
696 tegra_dsi_writel(dsi, value, DSI_CONTROL);
Thierry Redinge94236c2014-10-07 16:10:24 +0200697
698 if (dsi->slave)
699 tegra_dsi_video_disable(dsi->slave);
700}
701
702static void tegra_dsi_ganged_disable(struct tegra_dsi *dsi)
703{
704 tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_START);
705 tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_SIZE);
706 tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_CONTROL);
Thierry Reding563eff12014-11-13 14:44:27 +0100707}
708
709static void tegra_dsi_disable(struct tegra_dsi *dsi)
710{
711 u32 value;
712
Thierry Redinge94236c2014-10-07 16:10:24 +0200713 if (dsi->slave) {
714 tegra_dsi_ganged_disable(dsi->slave);
715 tegra_dsi_ganged_disable(dsi);
716 }
717
Thierry Reding563eff12014-11-13 14:44:27 +0100718 value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
719 value &= ~DSI_POWER_CONTROL_ENABLE;
720 tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
721
Thierry Redinge94236c2014-10-07 16:10:24 +0200722 if (dsi->slave)
723 tegra_dsi_disable(dsi->slave);
724
Thierry Reding563eff12014-11-13 14:44:27 +0100725 usleep_range(5000, 10000);
726}
727
Thierry Redingdec72732013-09-03 08:45:46 +0200728static int tegra_output_dsi_disable(struct tegra_output *output)
729{
730 struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc);
731 struct tegra_dsi *dsi = to_dsi(output);
732 unsigned long value;
Thierry Reding563eff12014-11-13 14:44:27 +0100733 int err;
Thierry Redingdec72732013-09-03 08:45:46 +0200734
Thierry Reding334ae6b2014-03-14 14:15:10 +0100735 if (!dsi->enabled)
736 return 0;
737
Thierry Reding563eff12014-11-13 14:44:27 +0100738 tegra_dsi_video_disable(dsi);
Thierry Redingdec72732013-09-03 08:45:46 +0200739
740 /*
Thierry Reding72d30282013-12-12 11:06:55 +0100741 * The following accesses registers of the display controller, so make
742 * sure it's only executed when the output is attached to one.
Thierry Redingdec72732013-09-03 08:45:46 +0200743 */
744 if (dc) {
Thierry Reding72d30282013-12-12 11:06:55 +0100745 value = tegra_dc_readl(dc, DC_CMD_DISPLAY_POWER_CONTROL);
746 value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
747 PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
748 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_POWER_CONTROL);
749
Thierry Redingdec72732013-09-03 08:45:46 +0200750 value = tegra_dc_readl(dc, DC_CMD_DISPLAY_COMMAND);
751 value &= ~DISP_CTRL_MODE_MASK;
752 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_COMMAND);
753
754 value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
755 value &= ~DSI_ENABLE;
756 tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
Thierry Reding72d30282013-12-12 11:06:55 +0100757
758 tegra_dc_writel(dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
759 tegra_dc_writel(dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
Thierry Redingdec72732013-09-03 08:45:46 +0200760 }
761
Thierry Reding563eff12014-11-13 14:44:27 +0100762 err = tegra_dsi_wait_idle(dsi, 100);
763 if (err < 0)
764 dev_dbg(dsi->dev, "failed to idle DSI: %d\n", err);
765
766 tegra_dsi_disable(dsi);
767
Thierry Reding334ae6b2014-03-14 14:15:10 +0100768 dsi->enabled = false;
769
Thierry Redingdec72732013-09-03 08:45:46 +0200770 return 0;
771}
772
Thierry Reding3f6b4062014-11-13 14:50:33 +0100773static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,
774 unsigned int vrefresh)
775{
776 unsigned int timeout;
777 u32 value;
778
779 /* one frame high-speed transmission timeout */
780 timeout = (bclk / vrefresh) / 512;
781 value = DSI_TIMEOUT_LRX(0x2000) | DSI_TIMEOUT_HTX(timeout);
782 tegra_dsi_writel(dsi, value, DSI_TIMEOUT_0);
783
784 /* 2 ms peripheral timeout for panel */
785 timeout = 2 * bclk / 512 * 1000;
786 value = DSI_TIMEOUT_PR(timeout) | DSI_TIMEOUT_TA(0x2000);
787 tegra_dsi_writel(dsi, value, DSI_TIMEOUT_1);
788
789 value = DSI_TALLY_TA(0) | DSI_TALLY_LRX(0) | DSI_TALLY_HTX(0);
790 tegra_dsi_writel(dsi, value, DSI_TO_TALLY);
Thierry Redinge94236c2014-10-07 16:10:24 +0200791
792 if (dsi->slave)
793 tegra_dsi_set_timeout(dsi->slave, bclk, vrefresh);
Thierry Reding3f6b4062014-11-13 14:50:33 +0100794}
795
Thierry Redingdec72732013-09-03 08:45:46 +0200796static int tegra_output_dsi_setup_clock(struct tegra_output *output,
Thierry Reding91eded92014-03-26 13:32:21 +0100797 struct clk *clk, unsigned long pclk,
798 unsigned int *divp)
Thierry Redingdec72732013-09-03 08:45:46 +0200799{
800 struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc);
801 struct drm_display_mode *mode = &dc->base.mode;
Thierry Redingdec72732013-09-03 08:45:46 +0200802 struct tegra_dsi *dsi = to_dsi(output);
Thierry Redinge94236c2014-10-07 16:10:24 +0200803 unsigned int mul, div, vrefresh, lanes;
Thierry Reding3f6b4062014-11-13 14:50:33 +0100804 unsigned long bclk, plld;
Thierry Redingdec72732013-09-03 08:45:46 +0200805 int err;
806
Thierry Redinge94236c2014-10-07 16:10:24 +0200807 lanes = tegra_dsi_get_lanes(dsi);
808
Thierry Redingdec72732013-09-03 08:45:46 +0200809 err = tegra_dsi_get_muldiv(dsi->format, &mul, &div);
810 if (err < 0)
811 return err;
812
Thierry Redinge94236c2014-10-07 16:10:24 +0200813 DRM_DEBUG_KMS("mul: %u, div: %u, lanes: %u\n", mul, div, lanes);
Thierry Redingdec72732013-09-03 08:45:46 +0200814 vrefresh = drm_mode_vrefresh(mode);
Thierry Reding91eded92014-03-26 13:32:21 +0100815 DRM_DEBUG_KMS("vrefresh: %u\n", vrefresh);
Thierry Redingdec72732013-09-03 08:45:46 +0200816
Thierry Reding91eded92014-03-26 13:32:21 +0100817 /* compute byte clock */
Thierry Redinge94236c2014-10-07 16:10:24 +0200818 bclk = (pclk * mul) / (div * lanes);
Thierry Reding91eded92014-03-26 13:32:21 +0100819
820 /*
821 * Compute bit clock and round up to the next MHz.
822 */
823 plld = DIV_ROUND_UP(bclk * 8, 1000000) * 1000000;
824
825 /*
826 * We divide the frequency by two here, but we make up for that by
827 * setting the shift clock divider (further below) to half of the
828 * correct value.
829 */
830 plld /= 2;
Thierry Redingdec72732013-09-03 08:45:46 +0200831
832 err = clk_set_parent(clk, dsi->clk_parent);
833 if (err < 0) {
834 dev_err(dsi->dev, "failed to set parent clock: %d\n", err);
835 return err;
836 }
837
Thierry Reding91eded92014-03-26 13:32:21 +0100838 err = clk_set_rate(dsi->clk_parent, plld);
Thierry Redingdec72732013-09-03 08:45:46 +0200839 if (err < 0) {
840 dev_err(dsi->dev, "failed to set base clock rate to %lu Hz\n",
Thierry Reding91eded92014-03-26 13:32:21 +0100841 plld);
Thierry Redingdec72732013-09-03 08:45:46 +0200842 return err;
843 }
844
845 /*
Thierry Reding91eded92014-03-26 13:32:21 +0100846 * Derive pixel clock from bit clock using the shift clock divider.
847 * Note that this is only half of what we would expect, but we need
848 * that to make up for the fact that we divided the bit clock by a
849 * factor of two above.
850 *
851 * It's not clear exactly why this is necessary, but the display is
852 * not working properly otherwise. Perhaps the PLLs cannot generate
853 * frequencies sufficiently high.
854 */
Thierry Redinge94236c2014-10-07 16:10:24 +0200855 *divp = ((8 * mul) / (div * lanes)) - 2;
Thierry Reding91eded92014-03-26 13:32:21 +0100856
857 /*
Thierry Redingdec72732013-09-03 08:45:46 +0200858 * XXX: Move the below somewhere else so that we don't need to have
859 * access to the vrefresh in this function?
860 */
Thierry Reding3f6b4062014-11-13 14:50:33 +0100861 tegra_dsi_set_timeout(dsi, bclk, vrefresh);
Thierry Redingdec72732013-09-03 08:45:46 +0200862
863 return 0;
864}
865
866static int tegra_output_dsi_check_mode(struct tegra_output *output,
867 struct drm_display_mode *mode,
868 enum drm_mode_status *status)
869{
870 /*
871 * FIXME: For now, always assume that the mode is okay.
872 */
873
874 *status = MODE_OK;
875
876 return 0;
877}
878
879static const struct tegra_output_ops dsi_ops = {
880 .enable = tegra_output_dsi_enable,
881 .disable = tegra_output_dsi_disable,
882 .setup_clock = tegra_output_dsi_setup_clock,
883 .check_mode = tegra_output_dsi_check_mode,
884};
885
886static int tegra_dsi_pad_enable(struct tegra_dsi *dsi)
887{
888 unsigned long value;
889
890 value = DSI_PAD_CONTROL_VS1_PULLDN(0) | DSI_PAD_CONTROL_VS1_PDIO(0);
891 tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_0);
892
893 return 0;
894}
895
896static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)
897{
Thierry Reding183ef282014-11-13 14:27:29 +0100898 u32 value;
Thierry Redingdec72732013-09-03 08:45:46 +0200899
900 tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_0);
901 tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_1);
902 tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_2);
903 tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_3);
904 tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_4);
905
906 /* start calibration */
907 tegra_dsi_pad_enable(dsi);
908
909 value = DSI_PAD_SLEW_UP(0x7) | DSI_PAD_SLEW_DN(0x7) |
910 DSI_PAD_LP_UP(0x1) | DSI_PAD_LP_DN(0x1) |
911 DSI_PAD_OUT_CLK(0x0);
912 tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_2);
913
914 return tegra_mipi_calibrate(dsi->mipi);
915}
916
917static int tegra_dsi_init(struct host1x_client *client)
918{
Thierry Reding9910f5c2014-05-22 09:57:15 +0200919 struct drm_device *drm = dev_get_drvdata(client->parent);
Thierry Redingdec72732013-09-03 08:45:46 +0200920 struct tegra_dsi *dsi = host1x_client_to_dsi(client);
Thierry Redingdec72732013-09-03 08:45:46 +0200921 int err;
922
Thierry Redinge94236c2014-10-07 16:10:24 +0200923 /* Gangsters must not register their own outputs. */
924 if (!dsi->master) {
925 dsi->output.type = TEGRA_OUTPUT_DSI;
926 dsi->output.dev = client->dev;
927 dsi->output.ops = &dsi_ops;
Thierry Redingdec72732013-09-03 08:45:46 +0200928
Thierry Redinge94236c2014-10-07 16:10:24 +0200929 err = tegra_output_init(drm, &dsi->output);
930 if (err < 0) {
931 dev_err(client->dev, "output setup failed: %d\n", err);
932 return err;
933 }
Thierry Redingdec72732013-09-03 08:45:46 +0200934 }
935
936 if (IS_ENABLED(CONFIG_DEBUG_FS)) {
Thierry Reding9910f5c2014-05-22 09:57:15 +0200937 err = tegra_dsi_debugfs_init(dsi, drm->primary);
Thierry Redingdec72732013-09-03 08:45:46 +0200938 if (err < 0)
939 dev_err(dsi->dev, "debugfs setup failed: %d\n", err);
940 }
941
Thierry Redingdec72732013-09-03 08:45:46 +0200942 return 0;
943}
944
945static int tegra_dsi_exit(struct host1x_client *client)
946{
947 struct tegra_dsi *dsi = host1x_client_to_dsi(client);
948 int err;
949
950 if (IS_ENABLED(CONFIG_DEBUG_FS)) {
951 err = tegra_dsi_debugfs_exit(dsi);
952 if (err < 0)
953 dev_err(dsi->dev, "debugfs cleanup failed: %d\n", err);
954 }
955
Thierry Redinge94236c2014-10-07 16:10:24 +0200956 if (!dsi->master) {
957 err = tegra_output_disable(&dsi->output);
958 if (err < 0) {
959 dev_err(client->dev, "output failed to disable: %d\n",
960 err);
961 return err;
962 }
Thierry Redingdec72732013-09-03 08:45:46 +0200963
Thierry Redinge94236c2014-10-07 16:10:24 +0200964 err = tegra_output_exit(&dsi->output);
965 if (err < 0) {
966 dev_err(client->dev, "output cleanup failed: %d\n",
967 err);
968 return err;
969 }
Thierry Redingdec72732013-09-03 08:45:46 +0200970 }
971
972 return 0;
973}
974
975static const struct host1x_client_ops dsi_client_ops = {
976 .init = tegra_dsi_init,
977 .exit = tegra_dsi_exit,
978};
979
980static int tegra_dsi_setup_clocks(struct tegra_dsi *dsi)
981{
982 struct clk *parent;
983 int err;
984
985 parent = clk_get_parent(dsi->clk);
986 if (!parent)
987 return -EINVAL;
988
989 err = clk_set_parent(parent, dsi->clk_parent);
990 if (err < 0)
991 return err;
992
993 return 0;
994}
995
Thierry Reding0fffdf62014-11-07 17:25:26 +0100996static const char * const error_report[16] = {
997 "SoT Error",
998 "SoT Sync Error",
999 "EoT Sync Error",
1000 "Escape Mode Entry Command Error",
1001 "Low-Power Transmit Sync Error",
1002 "Peripheral Timeout Error",
1003 "False Control Error",
1004 "Contention Detected",
1005 "ECC Error, single-bit",
1006 "ECC Error, multi-bit",
1007 "Checksum Error",
1008 "DSI Data Type Not Recognized",
1009 "DSI VC ID Invalid",
1010 "Invalid Transmission Length",
1011 "Reserved",
1012 "DSI Protocol Violation",
1013};
1014
1015static ssize_t tegra_dsi_read_response(struct tegra_dsi *dsi,
1016 const struct mipi_dsi_msg *msg,
1017 size_t count)
1018{
1019 u8 *rx = msg->rx_buf;
1020 unsigned int i, j, k;
1021 size_t size = 0;
1022 u16 errors;
1023 u32 value;
1024
1025 /* read and parse packet header */
1026 value = tegra_dsi_readl(dsi, DSI_RD_DATA);
1027
1028 switch (value & 0x3f) {
1029 case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT:
1030 errors = (value >> 8) & 0xffff;
1031 dev_dbg(dsi->dev, "Acknowledge and error report: %04x\n",
1032 errors);
1033 for (i = 0; i < ARRAY_SIZE(error_report); i++)
1034 if (errors & BIT(i))
1035 dev_dbg(dsi->dev, " %2u: %s\n", i,
1036 error_report[i]);
1037 break;
1038
1039 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
1040 rx[0] = (value >> 8) & 0xff;
1041 size = 1;
1042 break;
1043
1044 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE:
1045 rx[0] = (value >> 8) & 0xff;
1046 rx[1] = (value >> 16) & 0xff;
1047 size = 2;
1048 break;
1049
1050 case MIPI_DSI_RX_DCS_LONG_READ_RESPONSE:
1051 size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
1052 break;
1053
1054 case MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE:
1055 size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
1056 break;
1057
1058 default:
1059 dev_err(dsi->dev, "unhandled response type: %02x\n",
1060 value & 0x3f);
1061 return -EPROTO;
1062 }
1063
1064 size = min(size, msg->rx_len);
1065
1066 if (msg->rx_buf && size > 0) {
1067 for (i = 0, j = 0; i < count - 1; i++, j += 4) {
1068 u8 *rx = msg->rx_buf + j;
1069
1070 value = tegra_dsi_readl(dsi, DSI_RD_DATA);
1071
1072 for (k = 0; k < 4 && (j + k) < msg->rx_len; k++)
1073 rx[j + k] = (value >> (k << 3)) & 0xff;
1074 }
1075 }
1076
1077 return size;
1078}
1079
1080static int tegra_dsi_transmit(struct tegra_dsi *dsi, unsigned long timeout)
1081{
1082 tegra_dsi_writel(dsi, DSI_TRIGGER_HOST, DSI_TRIGGER);
1083
1084 timeout = jiffies + msecs_to_jiffies(timeout);
1085
1086 while (time_before(jiffies, timeout)) {
1087 u32 value = tegra_dsi_readl(dsi, DSI_TRIGGER);
1088 if ((value & DSI_TRIGGER_HOST) == 0)
1089 return 0;
1090
1091 usleep_range(1000, 2000);
1092 }
1093
1094 DRM_DEBUG_KMS("timeout waiting for transmission to complete\n");
1095 return -ETIMEDOUT;
1096}
1097
1098static int tegra_dsi_wait_for_response(struct tegra_dsi *dsi,
1099 unsigned long timeout)
1100{
1101 timeout = jiffies + msecs_to_jiffies(250);
1102
1103 while (time_before(jiffies, timeout)) {
1104 u32 value = tegra_dsi_readl(dsi, DSI_STATUS);
1105 u8 count = value & 0x1f;
1106
1107 if (count > 0)
1108 return count;
1109
1110 usleep_range(1000, 2000);
1111 }
1112
1113 DRM_DEBUG_KMS("peripheral returned no data\n");
1114 return -ETIMEDOUT;
1115}
1116
1117static void tegra_dsi_writesl(struct tegra_dsi *dsi, unsigned long offset,
1118 const void *buffer, size_t size)
1119{
1120 const u8 *buf = buffer;
1121 size_t i, j;
1122 u32 value;
1123
1124 for (j = 0; j < size; j += 4) {
1125 value = 0;
1126
1127 for (i = 0; i < 4 && j + i < size; i++)
1128 value |= buf[j + i] << (i << 3);
1129
1130 tegra_dsi_writel(dsi, value, DSI_WR_DATA);
1131 }
1132}
1133
1134static ssize_t tegra_dsi_host_transfer(struct mipi_dsi_host *host,
1135 const struct mipi_dsi_msg *msg)
1136{
1137 struct tegra_dsi *dsi = host_to_tegra(host);
1138 struct mipi_dsi_packet packet;
1139 const u8 *header;
1140 size_t count;
1141 ssize_t err;
1142 u32 value;
1143
1144 err = mipi_dsi_create_packet(&packet, msg);
1145 if (err < 0)
1146 return err;
1147
1148 header = packet.header;
1149
1150 /* maximum FIFO depth is 1920 words */
1151 if (packet.size > dsi->video_fifo_depth * 4)
1152 return -ENOSPC;
1153
1154 /* reset underflow/overflow flags */
1155 value = tegra_dsi_readl(dsi, DSI_STATUS);
1156 if (value & (DSI_STATUS_UNDERFLOW | DSI_STATUS_OVERFLOW)) {
1157 value = DSI_HOST_CONTROL_FIFO_RESET;
1158 tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
1159 usleep_range(10, 20);
1160 }
1161
1162 value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
1163 value |= DSI_POWER_CONTROL_ENABLE;
1164 tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
1165
1166 usleep_range(5000, 10000);
1167
1168 value = DSI_HOST_CONTROL_CRC_RESET | DSI_HOST_CONTROL_TX_TRIG_HOST |
1169 DSI_HOST_CONTROL_CS | DSI_HOST_CONTROL_ECC;
1170
1171 if ((msg->flags & MIPI_DSI_MSG_USE_LPM) == 0)
1172 value |= DSI_HOST_CONTROL_HS;
1173
1174 /*
1175 * The host FIFO has a maximum of 64 words, so larger transmissions
1176 * need to use the video FIFO.
1177 */
1178 if (packet.size > dsi->host_fifo_depth * 4)
1179 value |= DSI_HOST_CONTROL_FIFO_SEL;
1180
1181 tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
1182
1183 /*
1184 * For reads and messages with explicitly requested ACK, generate a
1185 * BTA sequence after the transmission of the packet.
1186 */
1187 if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
1188 (msg->rx_buf && msg->rx_len > 0)) {
1189 value = tegra_dsi_readl(dsi, DSI_HOST_CONTROL);
1190 value |= DSI_HOST_CONTROL_PKT_BTA;
1191 tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
1192 }
1193
1194 value = DSI_CONTROL_LANES(0) | DSI_CONTROL_HOST_ENABLE;
1195 tegra_dsi_writel(dsi, value, DSI_CONTROL);
1196
1197 /* write packet header, ECC is generated by hardware */
1198 value = header[2] << 16 | header[1] << 8 | header[0];
1199 tegra_dsi_writel(dsi, value, DSI_WR_DATA);
1200
1201 /* write payload (if any) */
1202 if (packet.payload_length > 0)
1203 tegra_dsi_writesl(dsi, DSI_WR_DATA, packet.payload,
1204 packet.payload_length);
1205
1206 err = tegra_dsi_transmit(dsi, 250);
1207 if (err < 0)
1208 return err;
1209
1210 if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
1211 (msg->rx_buf && msg->rx_len > 0)) {
1212 err = tegra_dsi_wait_for_response(dsi, 250);
1213 if (err < 0)
1214 return err;
1215
1216 count = err;
1217
1218 value = tegra_dsi_readl(dsi, DSI_RD_DATA);
1219 switch (value) {
1220 case 0x84:
1221 /*
1222 dev_dbg(dsi->dev, "ACK\n");
1223 */
1224 break;
1225
1226 case 0x87:
1227 /*
1228 dev_dbg(dsi->dev, "ESCAPE\n");
1229 */
1230 break;
1231
1232 default:
1233 dev_err(dsi->dev, "unknown status: %08x\n", value);
1234 break;
1235 }
1236
1237 if (count > 1) {
1238 err = tegra_dsi_read_response(dsi, msg, count);
1239 if (err < 0)
1240 dev_err(dsi->dev,
1241 "failed to parse response: %zd\n",
1242 err);
1243 else {
1244 /*
1245 * For read commands, return the number of
1246 * bytes returned by the peripheral.
1247 */
1248 count = err;
1249 }
1250 }
1251 } else {
1252 /*
1253 * For write commands, we have transmitted the 4-byte header
1254 * plus the variable-length payload.
1255 */
1256 count = 4 + packet.payload_length;
1257 }
1258
1259 return count;
1260}
1261
Thierry Redinge94236c2014-10-07 16:10:24 +02001262static int tegra_dsi_ganged_setup(struct tegra_dsi *dsi)
1263{
1264 struct clk *parent;
1265 int err;
1266
1267 /* make sure both DSI controllers share the same PLL */
1268 parent = clk_get_parent(dsi->slave->clk);
1269 if (!parent)
1270 return -EINVAL;
1271
1272 err = clk_set_parent(parent, dsi->clk_parent);
1273 if (err < 0)
1274 return err;
1275
1276 return 0;
1277}
1278
Thierry Redingdec72732013-09-03 08:45:46 +02001279static int tegra_dsi_host_attach(struct mipi_dsi_host *host,
1280 struct mipi_dsi_device *device)
1281{
1282 struct tegra_dsi *dsi = host_to_tegra(host);
Thierry Redingdec72732013-09-03 08:45:46 +02001283
Thierry Reding17297a22014-03-14 14:13:15 +01001284 dsi->flags = device->mode_flags;
Thierry Redingdec72732013-09-03 08:45:46 +02001285 dsi->format = device->format;
1286 dsi->lanes = device->lanes;
1287
Thierry Redinge94236c2014-10-07 16:10:24 +02001288 if (dsi->slave) {
1289 int err;
1290
1291 dev_dbg(dsi->dev, "attaching dual-channel device %s\n",
1292 dev_name(&device->dev));
1293
1294 err = tegra_dsi_ganged_setup(dsi);
1295 if (err < 0) {
1296 dev_err(dsi->dev, "failed to set up ganged mode: %d\n",
1297 err);
1298 return err;
1299 }
1300 }
1301
1302 /*
1303 * Slaves don't have a panel associated with them, so they provide
1304 * merely the second channel.
1305 */
1306 if (!dsi->master) {
1307 struct tegra_output *output = &dsi->output;
1308
1309 output->panel = of_drm_find_panel(device->dev.of_node);
1310 if (output->panel && output->connector.dev) {
1311 drm_panel_attach(output->panel, &output->connector);
Thierry Redingdec72732013-09-03 08:45:46 +02001312 drm_helper_hpd_irq_event(output->connector.dev);
Thierry Redinge94236c2014-10-07 16:10:24 +02001313 }
Thierry Redingdec72732013-09-03 08:45:46 +02001314 }
1315
1316 return 0;
1317}
1318
1319static int tegra_dsi_host_detach(struct mipi_dsi_host *host,
1320 struct mipi_dsi_device *device)
1321{
1322 struct tegra_dsi *dsi = host_to_tegra(host);
1323 struct tegra_output *output = &dsi->output;
1324
1325 if (output->panel && &device->dev == output->panel->dev) {
Thierry Redingba3df972014-11-13 14:54:01 +01001326 output->panel = NULL;
1327
Thierry Redingdec72732013-09-03 08:45:46 +02001328 if (output->connector.dev)
1329 drm_helper_hpd_irq_event(output->connector.dev);
Thierry Redingdec72732013-09-03 08:45:46 +02001330 }
1331
1332 return 0;
1333}
1334
1335static const struct mipi_dsi_host_ops tegra_dsi_host_ops = {
1336 .attach = tegra_dsi_host_attach,
1337 .detach = tegra_dsi_host_detach,
Thierry Reding0fffdf62014-11-07 17:25:26 +01001338 .transfer = tegra_dsi_host_transfer,
Thierry Redingdec72732013-09-03 08:45:46 +02001339};
1340
Thierry Redinge94236c2014-10-07 16:10:24 +02001341static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi)
1342{
1343 struct device_node *np;
1344
1345 np = of_parse_phandle(dsi->dev->of_node, "nvidia,ganged-mode", 0);
1346 if (np) {
1347 struct platform_device *gangster = of_find_device_by_node(np);
1348
1349 dsi->slave = platform_get_drvdata(gangster);
1350 of_node_put(np);
1351
1352 if (!dsi->slave)
1353 return -EPROBE_DEFER;
1354
1355 dsi->slave->master = dsi;
1356 }
1357
1358 return 0;
1359}
1360
Thierry Redingdec72732013-09-03 08:45:46 +02001361static int tegra_dsi_probe(struct platform_device *pdev)
1362{
1363 struct tegra_dsi *dsi;
1364 struct resource *regs;
1365 int err;
1366
1367 dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
1368 if (!dsi)
1369 return -ENOMEM;
1370
1371 dsi->output.dev = dsi->dev = &pdev->dev;
Thierry Reding976cebc2014-08-06 09:14:28 +02001372 dsi->video_fifo_depth = 1920;
1373 dsi->host_fifo_depth = 64;
Thierry Redingdec72732013-09-03 08:45:46 +02001374
Thierry Redinge94236c2014-10-07 16:10:24 +02001375 err = tegra_dsi_ganged_probe(dsi);
1376 if (err < 0)
1377 return err;
1378
Thierry Redingdec72732013-09-03 08:45:46 +02001379 err = tegra_output_probe(&dsi->output);
1380 if (err < 0)
1381 return err;
1382
Thierry Redingba3df972014-11-13 14:54:01 +01001383 dsi->output.connector.polled = DRM_CONNECTOR_POLL_HPD;
1384
Thierry Redingdec72732013-09-03 08:45:46 +02001385 /*
1386 * Assume these values by default. When a DSI peripheral driver
1387 * attaches to the DSI host, the parameters will be taken from
1388 * the attached device.
1389 */
Thierry Reding17297a22014-03-14 14:13:15 +01001390 dsi->flags = MIPI_DSI_MODE_VIDEO;
Thierry Redingdec72732013-09-03 08:45:46 +02001391 dsi->format = MIPI_DSI_FMT_RGB888;
1392 dsi->lanes = 4;
1393
1394 dsi->rst = devm_reset_control_get(&pdev->dev, "dsi");
1395 if (IS_ERR(dsi->rst))
1396 return PTR_ERR(dsi->rst);
1397
Thierry Reding183ef282014-11-13 14:27:29 +01001398 err = reset_control_deassert(dsi->rst);
1399 if (err < 0) {
1400 dev_err(&pdev->dev, "failed to bring DSI out of reset: %d\n",
1401 err);
1402 return err;
1403 }
1404
Thierry Redingdec72732013-09-03 08:45:46 +02001405 dsi->clk = devm_clk_get(&pdev->dev, NULL);
1406 if (IS_ERR(dsi->clk)) {
1407 dev_err(&pdev->dev, "cannot get DSI clock\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001408 err = PTR_ERR(dsi->clk);
1409 goto reset;
Thierry Redingdec72732013-09-03 08:45:46 +02001410 }
1411
1412 err = clk_prepare_enable(dsi->clk);
1413 if (err < 0) {
1414 dev_err(&pdev->dev, "cannot enable DSI clock\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001415 goto reset;
Thierry Redingdec72732013-09-03 08:45:46 +02001416 }
1417
1418 dsi->clk_lp = devm_clk_get(&pdev->dev, "lp");
1419 if (IS_ERR(dsi->clk_lp)) {
1420 dev_err(&pdev->dev, "cannot get low-power clock\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001421 err = PTR_ERR(dsi->clk_lp);
1422 goto disable_clk;
Thierry Redingdec72732013-09-03 08:45:46 +02001423 }
1424
1425 err = clk_prepare_enable(dsi->clk_lp);
1426 if (err < 0) {
1427 dev_err(&pdev->dev, "cannot enable low-power clock\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001428 goto disable_clk;
Thierry Redingdec72732013-09-03 08:45:46 +02001429 }
1430
1431 dsi->clk_parent = devm_clk_get(&pdev->dev, "parent");
1432 if (IS_ERR(dsi->clk_parent)) {
1433 dev_err(&pdev->dev, "cannot get parent clock\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001434 err = PTR_ERR(dsi->clk_parent);
1435 goto disable_clk_lp;
Thierry Redingdec72732013-09-03 08:45:46 +02001436 }
1437
Thierry Reding3b077af2014-03-14 14:07:50 +01001438 dsi->vdd = devm_regulator_get(&pdev->dev, "avdd-dsi-csi");
1439 if (IS_ERR(dsi->vdd)) {
1440 dev_err(&pdev->dev, "cannot get VDD supply\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001441 err = PTR_ERR(dsi->vdd);
1442 goto disable_clk_lp;
Thierry Reding3b077af2014-03-14 14:07:50 +01001443 }
1444
1445 err = regulator_enable(dsi->vdd);
1446 if (err < 0) {
1447 dev_err(&pdev->dev, "cannot enable VDD supply\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001448 goto disable_clk_lp;
Thierry Reding3b077af2014-03-14 14:07:50 +01001449 }
1450
Thierry Redingdec72732013-09-03 08:45:46 +02001451 err = tegra_dsi_setup_clocks(dsi);
1452 if (err < 0) {
1453 dev_err(&pdev->dev, "cannot setup clocks\n");
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001454 goto disable_vdd;
Thierry Redingdec72732013-09-03 08:45:46 +02001455 }
1456
1457 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1458 dsi->regs = devm_ioremap_resource(&pdev->dev, regs);
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001459 if (IS_ERR(dsi->regs)) {
1460 err = PTR_ERR(dsi->regs);
1461 goto disable_vdd;
1462 }
Thierry Redingdec72732013-09-03 08:45:46 +02001463
Thierry Redingdec72732013-09-03 08:45:46 +02001464 dsi->mipi = tegra_mipi_request(&pdev->dev);
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001465 if (IS_ERR(dsi->mipi)) {
1466 err = PTR_ERR(dsi->mipi);
1467 goto disable_vdd;
1468 }
Thierry Redingdec72732013-09-03 08:45:46 +02001469
Thierry Reding183ef282014-11-13 14:27:29 +01001470 err = tegra_dsi_pad_calibrate(dsi);
1471 if (err < 0) {
1472 dev_err(dsi->dev, "MIPI calibration failed: %d\n", err);
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001473 goto mipi_free;
Thierry Reding183ef282014-11-13 14:27:29 +01001474 }
1475
Thierry Redingdec72732013-09-03 08:45:46 +02001476 dsi->host.ops = &tegra_dsi_host_ops;
1477 dsi->host.dev = &pdev->dev;
1478
1479 err = mipi_dsi_host_register(&dsi->host);
1480 if (err < 0) {
1481 dev_err(&pdev->dev, "failed to register DSI host: %d\n", err);
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001482 goto mipi_free;
Thierry Redingdec72732013-09-03 08:45:46 +02001483 }
1484
1485 INIT_LIST_HEAD(&dsi->client.list);
1486 dsi->client.ops = &dsi_client_ops;
1487 dsi->client.dev = &pdev->dev;
1488
1489 err = host1x_client_register(&dsi->client);
1490 if (err < 0) {
1491 dev_err(&pdev->dev, "failed to register host1x client: %d\n",
1492 err);
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001493 goto unregister;
Thierry Redingdec72732013-09-03 08:45:46 +02001494 }
1495
1496 platform_set_drvdata(pdev, dsi);
1497
1498 return 0;
Thierry Redingd2d0a9d2014-11-13 14:58:27 +01001499
1500unregister:
1501 mipi_dsi_host_unregister(&dsi->host);
1502mipi_free:
1503 tegra_mipi_free(dsi->mipi);
1504disable_vdd:
1505 regulator_disable(dsi->vdd);
1506disable_clk_lp:
1507 clk_disable_unprepare(dsi->clk_lp);
1508disable_clk:
1509 clk_disable_unprepare(dsi->clk);
1510reset:
1511 reset_control_assert(dsi->rst);
1512 return err;
Thierry Redingdec72732013-09-03 08:45:46 +02001513}
1514
1515static int tegra_dsi_remove(struct platform_device *pdev)
1516{
1517 struct tegra_dsi *dsi = platform_get_drvdata(pdev);
1518 int err;
1519
1520 err = host1x_client_unregister(&dsi->client);
1521 if (err < 0) {
1522 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n",
1523 err);
1524 return err;
1525 }
1526
1527 mipi_dsi_host_unregister(&dsi->host);
1528 tegra_mipi_free(dsi->mipi);
1529
Thierry Reding3b077af2014-03-14 14:07:50 +01001530 regulator_disable(dsi->vdd);
Thierry Redingdec72732013-09-03 08:45:46 +02001531 clk_disable_unprepare(dsi->clk_lp);
1532 clk_disable_unprepare(dsi->clk);
Thierry Redingcb825d82014-03-14 14:25:43 +01001533 reset_control_assert(dsi->rst);
Thierry Redingdec72732013-09-03 08:45:46 +02001534
1535 err = tegra_output_remove(&dsi->output);
1536 if (err < 0) {
1537 dev_err(&pdev->dev, "failed to remove output: %d\n", err);
1538 return err;
1539 }
1540
1541 return 0;
1542}
1543
1544static const struct of_device_id tegra_dsi_of_match[] = {
1545 { .compatible = "nvidia,tegra114-dsi", },
1546 { },
1547};
Stephen Warrenef707282014-06-18 16:21:55 -06001548MODULE_DEVICE_TABLE(of, tegra_dsi_of_match);
Thierry Redingdec72732013-09-03 08:45:46 +02001549
1550struct platform_driver tegra_dsi_driver = {
1551 .driver = {
1552 .name = "tegra-dsi",
1553 .of_match_table = tegra_dsi_of_match,
1554 },
1555 .probe = tegra_dsi_probe,
1556 .remove = tegra_dsi_remove,
1557};