blob: 97a3040290285f97f0bebd5c83a70ba3ebf35047 [file] [log] [blame]
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2013 NVIDIA Corporation
4 * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
5 */
6
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03007#include <dm.h>
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +02008#include <clk.h>
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03009#include <log.h>
10#include <misc.h>
11#include <mipi_display.h>
12#include <mipi_dsi.h>
13#include <backlight.h>
14#include <panel.h>
Svyatoslav Ryhelfe0a53a2024-01-23 19:16:30 +020015#include <reset.h>
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030016#include <linux/delay.h>
17#include <linux/err.h>
Igor Prusovc3421ea2023-11-09 20:10:04 +030018#include <linux/time.h>
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030019#include <power/regulator.h>
20
21#include <asm/gpio.h>
22#include <asm/io.h>
23#include <asm/arch/clock.h>
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +030024#include <asm/arch-tegra/clk_rst.h>
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030025
Svyatoslav Ryhel75fec412024-01-23 19:16:18 +020026#include "tegra-dc.h"
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +020027#include "tegra-dsi.h"
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030028#include "mipi-phy.h"
29
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +020030/* List of supported DSI bridges */
31enum {
32 DSI_V0,
33 DSI_V1,
34};
35
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030036struct tegra_dsi_priv {
37 struct mipi_dsi_host host;
38 struct mipi_dsi_device device;
39 struct mipi_dphy_timing dphy_timing;
40
41 struct udevice *panel;
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +020042 struct udevice *mipi;
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030043 struct display_timing timing;
44
45 struct dsi_ctlr *dsi;
46 struct udevice *avdd;
47
48 enum tegra_dsi_format format;
49
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +020050 struct clk *clk;
51 struct clk *clk_parent;
52
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030053 int video_fifo_depth;
54 int host_fifo_depth;
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +020055
56 u32 version;
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +030057
58 /* for ganged-mode support */
59 struct udevice *master;
60 struct udevice *slave;
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +030061};
62
63static void tegra_dc_enable_controller(struct udevice *dev)
64{
65 struct tegra_dc_plat *dc_plat = dev_get_plat(dev);
66 struct dc_ctlr *dc = dc_plat->dc;
67 u32 value;
68
69 value = readl(&dc->disp.disp_win_opt);
70 value |= DSI_ENABLE;
71 writel(value, &dc->disp.disp_win_opt);
72
73 writel(GENERAL_UPDATE, &dc->cmd.state_ctrl);
74 writel(GENERAL_ACT_REQ, &dc->cmd.state_ctrl);
75}
76
77static const char * const error_report[16] = {
78 "SoT Error",
79 "SoT Sync Error",
80 "EoT Sync Error",
81 "Escape Mode Entry Command Error",
82 "Low-Power Transmit Sync Error",
83 "Peripheral Timeout Error",
84 "False Control Error",
85 "Contention Detected",
86 "ECC Error, single-bit",
87 "ECC Error, multi-bit",
88 "Checksum Error",
89 "DSI Data Type Not Recognized",
90 "DSI VC ID Invalid",
91 "Invalid Transmission Length",
92 "Reserved",
93 "DSI Protocol Violation",
94};
95
96static ssize_t tegra_dsi_read_response(struct dsi_misc_reg *misc,
97 const struct mipi_dsi_msg *msg,
98 size_t count)
99{
100 u8 *rx = msg->rx_buf;
101 unsigned int i, j, k;
102 size_t size = 0;
103 u16 errors;
104 u32 value;
105
106 /* read and parse packet header */
107 value = readl(&misc->dsi_rd_data);
108
109 switch (value & 0x3f) {
110 case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT:
111 errors = (value >> 8) & 0xffff;
112 printf("%s: Acknowledge and error report: %04x\n",
113 __func__, errors);
114 for (i = 0; i < ARRAY_SIZE(error_report); i++)
115 if (errors & BIT(i))
116 printf("%s: %2u: %s\n", __func__, i,
117 error_report[i]);
118 break;
119
120 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
121 rx[0] = (value >> 8) & 0xff;
122 size = 1;
123 break;
124
125 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE:
126 rx[0] = (value >> 8) & 0xff;
127 rx[1] = (value >> 16) & 0xff;
128 size = 2;
129 break;
130
131 case MIPI_DSI_RX_DCS_LONG_READ_RESPONSE:
132 size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
133 break;
134
135 case MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE:
136 size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
137 break;
138
139 default:
140 printf("%s: unhandled response type: %02x\n",
141 __func__, value & 0x3f);
142 return -EPROTO;
143 }
144
145 size = min(size, msg->rx_len);
146
147 if (msg->rx_buf && size > 0) {
148 for (i = 0, j = 0; i < count - 1; i++, j += 4) {
149 u8 *rx = msg->rx_buf + j;
150
151 value = readl(&misc->dsi_rd_data);
152
153 for (k = 0; k < 4 && (j + k) < msg->rx_len; k++)
154 rx[j + k] = (value >> (k << 3)) & 0xff;
155 }
156 }
157
158 return size;
159}
160
161static int tegra_dsi_transmit(struct dsi_misc_reg *misc,
162 unsigned long timeout)
163{
164 writel(DSI_TRIGGER_HOST, &misc->dsi_trigger);
165
166 while (timeout--) {
167 u32 value = readl(&misc->dsi_trigger);
168
169 if ((value & DSI_TRIGGER_HOST) == 0)
170 return 0;
171
172 udelay(1000);
173 }
174
175 debug("timeout waiting for transmission to complete\n");
176 return -ETIMEDOUT;
177}
178
179static int tegra_dsi_wait_for_response(struct dsi_misc_reg *misc,
180 unsigned long timeout)
181{
182 while (timeout--) {
183 u32 value = readl(&misc->dsi_status);
184 u8 count = value & 0x1f;
185
186 if (count > 0)
187 return count;
188
189 udelay(1000);
190 }
191
192 debug("peripheral returned no data\n");
193 return -ETIMEDOUT;
194}
195
196static void tegra_dsi_writesl(struct dsi_misc_reg *misc,
197 const void *buffer, size_t size)
198{
199 const u8 *buf = buffer;
200 size_t i, j;
201 u32 value;
202
203 for (j = 0; j < size; j += 4) {
204 value = 0;
205
206 for (i = 0; i < 4 && j + i < size; i++)
207 value |= buf[j + i] << (i << 3);
208
209 writel(value, &misc->dsi_wr_data);
210 }
211}
212
213static ssize_t tegra_dsi_host_transfer(struct mipi_dsi_host *host,
214 const struct mipi_dsi_msg *msg)
215{
216 struct udevice *dev = (struct udevice *)host->dev;
217 struct tegra_dsi_priv *priv = dev_get_priv(dev);
218 struct dsi_misc_reg *misc = &priv->dsi->misc;
219 struct mipi_dsi_packet packet;
220 const u8 *header;
221 size_t count;
222 ssize_t err;
223 u32 value;
224
225 err = mipi_dsi_create_packet(&packet, msg);
226 if (err < 0)
227 return err;
228
229 header = packet.header;
230
231 /* maximum FIFO depth is 1920 words */
232 if (packet.size > priv->video_fifo_depth * 4)
233 return -ENOSPC;
234
235 /* reset underflow/overflow flags */
236 value = readl(&misc->dsi_status);
237 if (value & (DSI_STATUS_UNDERFLOW | DSI_STATUS_OVERFLOW)) {
238 value = DSI_HOST_CONTROL_FIFO_RESET;
239 writel(value, &misc->host_dsi_ctrl);
240 udelay(10);
241 }
242
243 value = readl(&misc->dsi_pwr_ctrl);
244 value |= DSI_POWER_CONTROL_ENABLE;
245 writel(value, &misc->dsi_pwr_ctrl);
246
247 mdelay(5);
248
249 value = DSI_HOST_CONTROL_CRC_RESET | DSI_HOST_CONTROL_TX_TRIG_HOST |
250 DSI_HOST_CONTROL_CS | DSI_HOST_CONTROL_ECC;
251
252 /*
253 * The host FIFO has a maximum of 64 words, so larger transmissions
254 * need to use the video FIFO.
255 */
256 if (packet.size > priv->host_fifo_depth * 4)
257 value |= DSI_HOST_CONTROL_FIFO_SEL;
258
259 writel(value, &misc->host_dsi_ctrl);
260
261 /*
262 * For reads and messages with explicitly requested ACK, generate a
263 * BTA sequence after the transmission of the packet.
264 */
265 if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
266 (msg->rx_buf && msg->rx_len > 0)) {
267 value = readl(&misc->host_dsi_ctrl);
268 value |= DSI_HOST_CONTROL_PKT_BTA;
269 writel(value, &misc->host_dsi_ctrl);
270 }
271
272 value = DSI_CONTROL_LANES(0) | DSI_CONTROL_HOST_ENABLE;
273 writel(value, &misc->dsi_ctrl);
274
275 /* write packet header, ECC is generated by hardware */
276 value = header[2] << 16 | header[1] << 8 | header[0];
277 writel(value, &misc->dsi_wr_data);
278
279 /* write payload (if any) */
280 if (packet.payload_length > 0)
281 tegra_dsi_writesl(misc, packet.payload,
282 packet.payload_length);
283
284 err = tegra_dsi_transmit(misc, 250);
285 if (err < 0)
286 return err;
287
288 if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
289 (msg->rx_buf && msg->rx_len > 0)) {
290 err = tegra_dsi_wait_for_response(misc, 250);
291 if (err < 0)
292 return err;
293
294 count = err;
295
296 value = readl(&misc->dsi_rd_data);
297 switch (value) {
298 case 0x84:
299 debug("%s: ACK\n", __func__);
300 break;
301
302 case 0x87:
303 debug("%s: ESCAPE\n", __func__);
304 break;
305
306 default:
307 printf("%s: unknown status: %08x\n", __func__, value);
308 break;
309 }
310
311 if (count > 1) {
312 err = tegra_dsi_read_response(misc, msg, count);
313 if (err < 0) {
314 printf("%s: failed to parse response: %zd\n",
315 __func__, err);
316 } else {
317 /*
318 * For read commands, return the number of
319 * bytes returned by the peripheral.
320 */
321 count = err;
322 }
323 }
324 } else {
325 /*
326 * For write commands, we have transmitted the 4-byte header
327 * plus the variable-length payload.
328 */
329 count = 4 + packet.payload_length;
330 }
331
332 return count;
333}
334
335struct mipi_dsi_host_ops tegra_dsi_bridge_host_ops = {
336 .transfer = tegra_dsi_host_transfer,
337};
338
339#define PKT_ID0(id) ((((id) & 0x3f) << 3) | (1 << 9))
340#define PKT_LEN0(len) (((len) & 0x07) << 0)
341#define PKT_ID1(id) ((((id) & 0x3f) << 13) | (1 << 19))
342#define PKT_LEN1(len) (((len) & 0x07) << 10)
343#define PKT_ID2(id) ((((id) & 0x3f) << 23) | (1 << 29))
344#define PKT_LEN2(len) (((len) & 0x07) << 20)
345
346#define PKT_LP BIT(30)
347#define NUM_PKT_SEQ 12
348
349/*
350 * non-burst mode with sync pulses
351 */
352static const u32 pkt_seq_video_non_burst_sync_pulses[NUM_PKT_SEQ] = {
353 [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
354 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
355 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
356 PKT_LP,
357 [ 1] = 0,
358 [ 2] = PKT_ID0(MIPI_DSI_V_SYNC_END) | PKT_LEN0(0) |
359 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
360 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
361 PKT_LP,
362 [ 3] = 0,
363 [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
364 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
365 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
366 PKT_LP,
367 [ 5] = 0,
368 [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
369 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
370 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
371 [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
372 PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
373 PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
374 [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
375 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
376 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
377 PKT_LP,
378 [ 9] = 0,
379 [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
380 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
381 PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
382 [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
383 PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
384 PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
385};
386
387/*
388 * non-burst mode with sync events
389 */
390static const u32 pkt_seq_video_non_burst_sync_events[NUM_PKT_SEQ] = {
391 [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
392 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
393 PKT_LP,
394 [ 1] = 0,
395 [ 2] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
396 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
397 PKT_LP,
398 [ 3] = 0,
399 [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
400 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
401 PKT_LP,
402 [ 5] = 0,
403 [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
404 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
405 PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
406 [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
407 [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
408 PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
409 PKT_LP,
410 [ 9] = 0,
411 [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
412 PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
413 PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
414 [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
415};
416
417static const u32 pkt_seq_command_mode[NUM_PKT_SEQ] = {
418 [ 0] = 0,
419 [ 1] = 0,
420 [ 2] = 0,
421 [ 3] = 0,
422 [ 4] = 0,
423 [ 5] = 0,
424 [ 6] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(3) | PKT_LP,
425 [ 7] = 0,
426 [ 8] = 0,
427 [ 9] = 0,
428 [10] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(5) | PKT_LP,
429 [11] = 0,
430};
431
432static void tegra_dsi_get_muldiv(enum mipi_dsi_pixel_format format,
433 unsigned int *mulp, unsigned int *divp)
434{
435 switch (format) {
436 case MIPI_DSI_FMT_RGB666_PACKED:
437 case MIPI_DSI_FMT_RGB888:
438 *mulp = 3;
439 *divp = 1;
440 break;
441
442 case MIPI_DSI_FMT_RGB565:
443 *mulp = 2;
444 *divp = 1;
445 break;
446
447 case MIPI_DSI_FMT_RGB666:
448 *mulp = 9;
449 *divp = 4;
450 break;
451
452 default:
453 break;
454 }
455}
456
457static int tegra_dsi_get_format(enum mipi_dsi_pixel_format format,
458 enum tegra_dsi_format *fmt)
459{
460 switch (format) {
461 case MIPI_DSI_FMT_RGB888:
462 *fmt = TEGRA_DSI_FORMAT_24P;
463 break;
464
465 case MIPI_DSI_FMT_RGB666:
466 *fmt = TEGRA_DSI_FORMAT_18NP;
467 break;
468
469 case MIPI_DSI_FMT_RGB666_PACKED:
470 *fmt = TEGRA_DSI_FORMAT_18P;
471 break;
472
473 case MIPI_DSI_FMT_RGB565:
474 *fmt = TEGRA_DSI_FORMAT_16P;
475 break;
476
477 default:
478 return -EINVAL;
479 }
480
481 return 0;
482}
483
484static void tegra_dsi_pad_calibrate(struct dsi_pad_ctrl_reg *pad)
485{
486 u32 value;
487
488 /* start calibration */
489 value = DSI_PAD_CONTROL_PAD_LPUPADJ(0x1) |
490 DSI_PAD_CONTROL_PAD_LPDNADJ(0x1) |
491 DSI_PAD_CONTROL_PAD_PREEMP_EN(0x1) |
492 DSI_PAD_CONTROL_PAD_SLEWDNADJ(0x6) |
493 DSI_PAD_CONTROL_PAD_SLEWUPADJ(0x6) |
494 DSI_PAD_CONTROL_PAD_PDIO(0) |
495 DSI_PAD_CONTROL_PAD_PDIO_CLK(0) |
496 DSI_PAD_CONTROL_PAD_PULLDN_ENAB(0);
497 writel(value, &pad->pad_ctrl);
498
499 clock_enable(PERIPH_ID_VI);
500 clock_enable(PERIPH_ID_CSI);
501 udelay(2);
502 reset_set_enable(PERIPH_ID_VI, 0);
503 reset_set_enable(PERIPH_ID_CSI, 0);
504
505 value = MIPI_CAL_TERMOSA(0x4);
506 writel(value, TEGRA_VI_BASE + (CSI_CILA_MIPI_CAL_CONFIG_0 << 2));
507
508 value = MIPI_CAL_TERMOSB(0x4);
509 writel(value, TEGRA_VI_BASE + (CSI_CILB_MIPI_CAL_CONFIG_0 << 2));
510
511 value = MIPI_CAL_HSPUOSD(0x3) | MIPI_CAL_HSPDOSD(0x4);
512 writel(value, TEGRA_VI_BASE + (CSI_DSI_MIPI_CAL_CONFIG << 2));
513
514 value = PAD_DRIV_DN_REF(0x5) | PAD_DRIV_UP_REF(0x7);
515 writel(value, TEGRA_VI_BASE + (CSI_MIPIBIAS_PAD_CONFIG << 2));
516
517 value = PAD_CIL_PDVREG(0x0);
518 writel(value, TEGRA_VI_BASE + (CSI_CIL_PAD_CONFIG << 2));
519}
520
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +0200521static void tegra_dsi_mipi_calibrate(struct tegra_dsi_priv *priv)
522{
523 struct dsi_pad_ctrl_reg *pad = &priv->dsi->pad;
524 u32 value;
525 int ret;
526
527 ret = misc_set_enabled(priv->mipi, true);
528 if (ret)
529 log_debug("%s: failed to enable MIPI calibration: %d\n",
530 __func__, ret);
531
532 writel(0, &pad->pad_ctrl);
533 writel(0, &pad->pad_ctrl_1);
534 writel(0, &pad->pad_ctrl_2);
535 writel(0, &pad->pad_ctrl_3);
536 writel(0, &pad->pad_ctrl_4);
537
538 /* DSI pad enable */
539 value = DSI_PAD_CONTROL_VS1_PULLDN(0) | DSI_PAD_CONTROL_VS1_PDIO(0);
540 writel(value, &pad->pad_ctrl);
541
542 value = DSI_PAD_SLEW_UP(0x7) | DSI_PAD_SLEW_DN(0x7) |
543 DSI_PAD_LP_UP(0x1) | DSI_PAD_LP_DN(0x1) |
544 DSI_PAD_OUT_CLK(0x0);
545 writel(value, &pad->pad_ctrl_2);
546
547 value = DSI_PAD_PREEMP_PD_CLK(0x3) | DSI_PAD_PREEMP_PU_CLK(0x3) |
548 DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3);
549 writel(value, &pad->pad_ctrl_3);
550
551 ret = misc_write(priv->mipi, 0, NULL, 0);
552 if (ret)
553 log_debug("%s: MIPI calibration failed %d\n", __func__, ret);
554}
555
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300556static void tegra_dsi_set_timeout(struct dsi_timeout_reg *rtimeout,
557 unsigned long bclk,
558 unsigned int vrefresh)
559{
560 unsigned int timeout;
561 u32 value;
562
563 /* one frame high-speed transmission timeout */
564 timeout = (bclk / vrefresh) / 512;
565 value = DSI_TIMEOUT_LRX(0x2000) | DSI_TIMEOUT_HTX(timeout);
566 writel(value, &rtimeout->dsi_timeout_0);
567
568 /* 2 ms peripheral timeout for panel */
569 timeout = 2 * bclk / 512 * 1000;
570 value = DSI_TIMEOUT_PR(timeout) | DSI_TIMEOUT_TA(0x2000);
571 writel(value, &rtimeout->dsi_timeout_1);
572
573 value = DSI_TALLY_TA(0) | DSI_TALLY_LRX(0) | DSI_TALLY_HTX(0);
574 writel(value, &rtimeout->dsi_to_tally);
575}
576
577static void tegra_dsi_set_phy_timing(struct dsi_timing_reg *ptiming,
578 unsigned long period,
579 const struct mipi_dphy_timing *dphy_timing)
580{
581 u32 value;
582
583 value = DSI_TIMING_FIELD(dphy_timing->hsexit, period, 1) << 24 |
584 DSI_TIMING_FIELD(dphy_timing->hstrail, period, 0) << 16 |
585 DSI_TIMING_FIELD(dphy_timing->hszero, period, 3) << 8 |
586 DSI_TIMING_FIELD(dphy_timing->hsprepare, period, 1);
587 writel(value, &ptiming->dsi_phy_timing_0);
588
589 value = DSI_TIMING_FIELD(dphy_timing->clktrail, period, 1) << 24 |
590 DSI_TIMING_FIELD(dphy_timing->clkpost, period, 1) << 16 |
591 DSI_TIMING_FIELD(dphy_timing->clkzero, period, 1) << 8 |
592 DSI_TIMING_FIELD(dphy_timing->lpx, period, 1);
593 writel(value, &ptiming->dsi_phy_timing_1);
594
595 value = DSI_TIMING_FIELD(dphy_timing->clkprepare, period, 1) << 16 |
596 DSI_TIMING_FIELD(dphy_timing->clkpre, period, 1) << 8 |
597 DSI_TIMING_FIELD(0xff * period, period, 0) << 0;
598 writel(value, &ptiming->dsi_phy_timing_2);
599
600 value = DSI_TIMING_FIELD(dphy_timing->taget, period, 1) << 16 |
601 DSI_TIMING_FIELD(dphy_timing->tasure, period, 1) << 8 |
602 DSI_TIMING_FIELD(dphy_timing->tago, period, 1);
603 writel(value, &ptiming->dsi_bta_timing);
604}
605
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300606static void tegra_dsi_ganged_enable(struct udevice *dev, unsigned int start,
607 unsigned int size)
608{
609 struct tegra_dsi_priv *priv = dev_get_priv(dev);
610 struct dsi_ganged_mode_reg *ganged = &priv->dsi->ganged;
611
612 writel(start, &ganged->ganged_mode_start);
613 writel(size << 16 | size, &ganged->ganged_mode_size);
614 writel(DSI_GANGED_MODE_CONTROL_ENABLE, &ganged->ganged_mode_ctrl);
615}
616
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300617static void tegra_dsi_configure(struct udevice *dev,
618 unsigned long mode_flags)
619{
620 struct tegra_dsi_priv *priv = dev_get_priv(dev);
621 struct mipi_dsi_device *device = &priv->device;
622 struct display_timing *timing = &priv->timing;
623
624 struct dsi_misc_reg *misc = &priv->dsi->misc;
625 struct dsi_pkt_seq_reg *pkt = &priv->dsi->pkt;
626 struct dsi_pkt_len_reg *len = &priv->dsi->len;
627
628 unsigned int hact, hsw, hbp, hfp, i, mul, div;
629 const u32 *pkt_seq;
630 u32 value;
631
632 tegra_dsi_get_muldiv(device->format, &mul, &div);
633
634 if (mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
635 printf("[DSI] Non-burst video mode with sync pulses\n");
636 pkt_seq = pkt_seq_video_non_burst_sync_pulses;
637 } else if (mode_flags & MIPI_DSI_MODE_VIDEO) {
638 printf("[DSI] Non-burst video mode with sync events\n");
639 pkt_seq = pkt_seq_video_non_burst_sync_events;
640 } else {
641 printf("[DSI] Command mode\n");
642 pkt_seq = pkt_seq_command_mode;
643 }
644
645 value = DSI_CONTROL_CHANNEL(0) |
646 DSI_CONTROL_FORMAT(priv->format) |
647 DSI_CONTROL_LANES(device->lanes - 1) |
648 DSI_CONTROL_SOURCE(0);
649 writel(value, &misc->dsi_ctrl);
650
651 writel(priv->video_fifo_depth, &misc->dsi_max_threshold);
652
653 value = DSI_HOST_CONTROL_HS;
654 writel(value, &misc->host_dsi_ctrl);
655
656 value = readl(&misc->dsi_ctrl);
657
658 if (mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS)
659 value |= DSI_CONTROL_HS_CLK_CTRL;
660
661 value &= ~DSI_CONTROL_TX_TRIG(3);
662
663 /* enable DCS commands for command mode */
664 if (mode_flags & MIPI_DSI_MODE_VIDEO)
665 value &= ~DSI_CONTROL_DCS_ENABLE;
666 else
667 value |= DSI_CONTROL_DCS_ENABLE;
668
669 value |= DSI_CONTROL_VIDEO_ENABLE;
670 value &= ~DSI_CONTROL_HOST_ENABLE;
671 writel(value, &misc->dsi_ctrl);
672
673 for (i = 0; i < NUM_PKT_SEQ; i++)
674 writel(pkt_seq[i], &pkt->dsi_pkt_seq_0_lo + i);
675
676 if (mode_flags & MIPI_DSI_MODE_VIDEO) {
677 /* horizontal active pixels */
678 hact = timing->hactive.typ * mul / div;
679
680 /* horizontal sync width */
681 hsw = timing->hsync_len.typ * mul / div;
682
683 /* horizontal back porch */
684 hbp = timing->hback_porch.typ * mul / div;
685
686 if ((mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) == 0)
687 hbp += hsw;
688
689 /* horizontal front porch */
690 hfp = timing->hfront_porch.typ * mul / div;
691
692 /* subtract packet overhead */
693 hsw -= 10;
694 hbp -= 14;
695 hfp -= 8;
696
697 writel(hsw << 16 | 0, &len->dsi_pkt_len_0_1);
698 writel(hact << 16 | hbp, &len->dsi_pkt_len_2_3);
699 writel(hfp, &len->dsi_pkt_len_4_5);
700 writel(0x0f0f << 16, &len->dsi_pkt_len_6_7);
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300701
702 /* set SOL delay (for non-burst mode only) */
703 writel(8 * mul / div, &misc->dsi_sol_delay);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300704 } else {
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300705 if (priv->master || priv->slave) {
706 /*
707 * For ganged mode, assume symmetric left-right mode.
708 */
709 value = 1 + (timing->hactive.typ / 2) * mul / div;
710 } else {
711 /* 1 byte (DCS command) + pixel data */
712 value = 1 + timing->hactive.typ * mul / div;
713 }
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300714
715 writel(0, &len->dsi_pkt_len_0_1);
716 writel(value << 16, &len->dsi_pkt_len_2_3);
717 writel(value << 16, &len->dsi_pkt_len_4_5);
718 writel(0, &len->dsi_pkt_len_6_7);
719
720 value = MIPI_DCS_WRITE_MEMORY_START << 8 |
721 MIPI_DCS_WRITE_MEMORY_CONTINUE;
722 writel(value, &len->dsi_dcs_cmds);
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300723
724 /* set SOL delay */
725 if (priv->master || priv->slave) {
726 unsigned long delay, bclk, bclk_ganged;
727 unsigned int lanes = device->lanes;
728 unsigned long htotal = timing->hactive.typ + timing->hfront_porch.typ +
729 timing->hback_porch.typ + timing->hsync_len.typ;
730
731 /* SOL to valid, valid to FIFO and FIFO write delay */
732 delay = 4 + 4 + 2;
733 delay = DIV_ROUND_UP(delay * mul, div * lanes);
734 /* FIFO read delay */
735 delay = delay + 6;
736
737 bclk = DIV_ROUND_UP(htotal * mul, div * lanes);
738 bclk_ganged = DIV_ROUND_UP(bclk * lanes / 2, lanes);
739 value = bclk - bclk_ganged + delay + 20;
740 } else {
741 /* TODO: revisit for non-ganged mode */
742 value = 8 * mul / div;
743 }
744
745 writel(value, &misc->dsi_sol_delay);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300746 }
747
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300748 if (priv->slave) {
749 /*
750 * TODO: Support modes other than symmetrical left-right
751 * split.
752 */
753 tegra_dsi_ganged_enable(dev, 0, timing->hactive.typ / 2);
754 tegra_dsi_ganged_enable(priv->slave, timing->hactive.typ / 2,
755 timing->hactive.typ / 2);
756 }
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300757}
758
759static int tegra_dsi_encoder_enable(struct udevice *dev)
760{
761 struct tegra_dsi_priv *priv = dev_get_priv(dev);
762 struct mipi_dsi_device *device = &priv->device;
763 struct display_timing *timing = &priv->timing;
764 struct dsi_misc_reg *misc = &priv->dsi->misc;
765 unsigned int mul, div;
766 unsigned long bclk, plld, period;
767 u32 value;
768 int ret;
769
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +0200770 /* If for some reasone DSI is enabled then it needs to
771 * be disabled in order for the panel initialization
772 * commands to be properly sent.
773 */
774 value = readl(&misc->dsi_pwr_ctrl);
775
776 if (value & DSI_POWER_CONTROL_ENABLE) {
777 value = readl(&misc->dsi_pwr_ctrl);
778 value &= ~DSI_POWER_CONTROL_ENABLE;
779 writel(value, &misc->dsi_pwr_ctrl);
780 }
781
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300782 /* Disable interrupt */
783 writel(0, &misc->int_enable);
784
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +0200785 if (priv->version)
786 tegra_dsi_mipi_calibrate(priv);
787 else
788 tegra_dsi_pad_calibrate(&priv->dsi->pad);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300789
790 tegra_dsi_get_muldiv(device->format, &mul, &div);
791
792 /* compute byte clock */
793 bclk = (timing->pixelclock.typ * mul) / (div * device->lanes);
794
795 tegra_dsi_set_timeout(&priv->dsi->timeout, bclk, 60);
796
797 /*
798 * Compute bit clock and round up to the next MHz.
799 */
800 plld = DIV_ROUND_UP(bclk * 8, USEC_PER_SEC) * USEC_PER_SEC;
801 period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, plld);
802
803 ret = mipi_dphy_timing_get_default(&priv->dphy_timing, period);
804 if (ret < 0) {
805 printf("%s: failed to get D-PHY timing: %d\n", __func__, ret);
806 return ret;
807 }
808
809 ret = mipi_dphy_timing_validate(&priv->dphy_timing, period);
810 if (ret < 0) {
811 printf("%s: failed to validate D-PHY timing: %d\n", __func__, ret);
812 return ret;
813 }
814
815 /*
816 * The D-PHY timing fields are expressed in byte-clock cycles, so
817 * multiply the period by 8.
818 */
819 tegra_dsi_set_phy_timing(&priv->dsi->ptiming,
820 period * 8, &priv->dphy_timing);
821
822 /* Perform panel HW setup */
823 ret = panel_enable_backlight(priv->panel);
824 if (ret)
825 return ret;
826
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300827 tegra_dsi_configure(dev, device->mode_flags);
828
829 tegra_dc_enable_controller(dev);
830
831 /* enable DSI controller */
832 value = readl(&misc->dsi_pwr_ctrl);
833 value |= DSI_POWER_CONTROL_ENABLE;
834 writel(value, &misc->dsi_pwr_ctrl);
835
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300836 if (priv->slave)
837 tegra_dsi_encoder_enable(priv->slave);
838
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300839 return 0;
840}
841
842static int tegra_dsi_bridge_set_panel(struct udevice *dev, int percent)
843{
Jonas Schwöbeldea5d962024-01-23 19:16:33 +0200844 struct tegra_dsi_priv *priv = dev_get_priv(dev);
845
846 /* Turn on/off backlight */
847 return panel_set_backlight(priv->panel, percent);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300848}
849
850static int tegra_dsi_panel_timings(struct udevice *dev,
851 struct display_timing *timing)
852{
853 struct tegra_dsi_priv *priv = dev_get_priv(dev);
854
855 memcpy(timing, &priv->timing, sizeof(*timing));
856
857 return 0;
858}
859
860static void tegra_dsi_init_clocks(struct udevice *dev)
861{
862 struct tegra_dsi_priv *priv = dev_get_priv(dev);
Svyatoslav Ryheld16c1052024-01-23 19:16:23 +0200863 struct tegra_dc_plat *dc_plat = dev_get_plat(dev);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300864 struct mipi_dsi_device *device = &priv->device;
865 unsigned int mul, div;
866 unsigned long bclk, plld;
867
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200868 /* Switch parents of DSI clocks in case of not standard parent */
869 if (priv->clk->id == PERIPH_ID_DSI &&
870 priv->clk_parent->id == CLOCK_ID_DISPLAY2) {
871 /* Change DSIA clock parent to PLLD2 */
872 struct clk_rst_ctlr *clkrst =
873 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
874
875 /* DSIA_CLK_SRC */
876 setbits_le32(&clkrst->crc_pll[CLOCK_ID_DISPLAY].pll_base,
877 BIT(25));
878 }
879
880 if (priv->clk->id == PERIPH_ID_DSIB &&
881 priv->clk_parent->id == CLOCK_ID_DISPLAY) {
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300882 /* Change DSIB clock parent to match DSIA */
883 struct clk_rst_ctlr *clkrst =
884 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
885
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200886 /* DSIB_CLK_SRC */
887 clrbits_le32(&clkrst->plld2.pll_base, BIT(25));
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300888 }
889
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300890 tegra_dsi_get_muldiv(device->format, &mul, &div);
891
892 bclk = (priv->timing.pixelclock.typ * mul) /
893 (div * device->lanes);
894
895 plld = DIV_ROUND_UP(bclk * 8, USEC_PER_SEC);
896
Svyatoslav Ryheld16c1052024-01-23 19:16:23 +0200897 dc_plat->scdiv = ((plld * USEC_PER_SEC +
898 priv->timing.pixelclock.typ / 2) /
899 priv->timing.pixelclock.typ) - 2;
900
901 /*
902 * BUG: If DISP1 is a PLLD/D2 child, it cannot go over 370MHz. The
903 * cause of this is not quite clear. This can be overcomed by
904 * halving the PLLD/D2 if the target rate is > 800MHz. This way
905 * DISP1 and DSI clocks will be equal.
906 */
907 if (plld > 800)
908 plld /= 2;
909
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300910 switch (clock_get_osc_freq()) {
911 case CLOCK_OSC_FREQ_12_0: /* OSC is 12Mhz */
912 case CLOCK_OSC_FREQ_48_0: /* OSC is 48Mhz */
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200913 clock_set_rate(priv->clk_parent->id, plld, 12, 0, 8);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300914 break;
915
916 case CLOCK_OSC_FREQ_26_0: /* OSC is 26Mhz */
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200917 clock_set_rate(priv->clk_parent->id, plld, 26, 0, 8);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300918 break;
919
920 case CLOCK_OSC_FREQ_13_0: /* OSC is 13Mhz */
921 case CLOCK_OSC_FREQ_16_8: /* OSC is 16.8Mhz */
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200922 clock_set_rate(priv->clk_parent->id, plld, 13, 0, 8);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300923 break;
924
925 case CLOCK_OSC_FREQ_19_2:
926 case CLOCK_OSC_FREQ_38_4:
927 default:
928 /*
929 * These are not supported.
930 */
931 break;
932 }
933
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200934 clk_enable(priv->clk);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300935}
936
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300937static int tegra_dsi_ganged_probe(struct udevice *dev)
938{
939 struct tegra_dsi_priv *mpriv = dev_get_priv(dev);
940 struct udevice *gangster;
941
942 uclass_get_device_by_phandle(UCLASS_PANEL, dev,
943 "nvidia,ganged-mode", &gangster);
944 if (gangster) {
945 /* Ganged mode is set */
946 struct tegra_dsi_priv *spriv = dev_get_priv(gangster);
947
948 mpriv->slave = gangster;
949 spriv->master = dev;
950 }
951
952 return 0;
953}
954
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300955static int tegra_dsi_bridge_probe(struct udevice *dev)
956{
957 struct tegra_dsi_priv *priv = dev_get_priv(dev);
958 struct mipi_dsi_device *device = &priv->device;
959 struct mipi_dsi_panel_plat *mipi_plat;
Svyatoslav Ryhelfe0a53a2024-01-23 19:16:30 +0200960 struct reset_ctl reset_ctl;
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300961 int ret;
962
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +0200963 priv->version = dev_get_driver_data(dev);
964
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300965 priv->dsi = (struct dsi_ctlr *)dev_read_addr_ptr(dev);
966 if (!priv->dsi) {
967 printf("%s: No display controller address\n", __func__);
968 return -EINVAL;
969 }
970
Svyatoslav Ryhel71f2c362024-11-24 14:26:08 +0200971 priv->clk = devm_clk_get(dev, NULL);
972 if (IS_ERR(priv->clk)) {
973 log_debug("%s: Could not get DSI clock: %ld\n",
974 __func__, PTR_ERR(priv->clk));
975 return PTR_ERR(priv->clk);
976 }
977
978 priv->clk_parent = devm_clk_get(dev, "parent");
979 if (IS_ERR(priv->clk_parent)) {
980 log_debug("%s: Could not get DSI clock parent: %ld\n",
981 __func__, PTR_ERR(priv->clk_parent));
982 return PTR_ERR(priv->clk_parent);
983 }
984
Jonas Schwöbel0cccf902024-01-23 19:16:32 +0200985 priv->video_fifo_depth = 1920;
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300986 priv->host_fifo_depth = 64;
987
Svyatoslav Ryhelab120e52024-07-30 13:35:45 +0300988 tegra_dsi_ganged_probe(dev);
989
Svyatoslav Ryhelfe0a53a2024-01-23 19:16:30 +0200990 ret = reset_get_by_name(dev, "dsi", &reset_ctl);
991 if (ret) {
992 log_debug("%s: reset_get_by_name() failed: %d\n",
993 __func__, ret);
994 return ret;
995 }
996
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +0300997 ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
998 "avdd-dsi-csi-supply", &priv->avdd);
999 if (ret)
1000 debug("%s: Cannot get avdd-dsi-csi-supply: error %d\n",
1001 __func__, ret);
1002
Svyatoslav Ryhelf6b2ab42024-11-24 09:38:03 +02001003 /* Check all DSI children */
1004 device_foreach_child(priv->panel, dev) {
1005 if (device_get_uclass_id(priv->panel) == UCLASS_PANEL)
1006 break;
1007 }
1008
1009 /* if loop exits without panel device return error */
1010 if (device_get_uclass_id(priv->panel) != UCLASS_PANEL) {
1011 log_debug("%s: panel not found, ret %d\n", __func__, ret);
1012 return -EINVAL;
1013 }
1014
1015 ret = uclass_get_device_by_ofnode(UCLASS_PANEL, dev_ofnode(priv->panel),
1016 &priv->panel);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001017 if (ret) {
Svyatoslav Ryhelf6b2ab42024-11-24 09:38:03 +02001018 log_debug("%s: Cannot get panel: error %d\n", __func__, ret);
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001019 return log_ret(ret);
1020 }
1021
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +02001022 if (priv->version) {
1023 ret = uclass_get_device_by_phandle(UCLASS_MISC, dev,
1024 "nvidia,mipi-calibrate",
1025 &priv->mipi);
1026 if (ret) {
1027 log_debug("%s: cannot get MIPI: error %d\n", __func__, ret);
1028 return ret;
1029 }
1030 }
1031
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001032 panel_get_display_timing(priv->panel, &priv->timing);
1033
1034 mipi_plat = dev_get_plat(priv->panel);
1035 mipi_plat->device = device;
1036
1037 priv->host.dev = (struct device *)dev;
1038 priv->host.ops = &tegra_dsi_bridge_host_ops;
1039
1040 device->host = &priv->host;
1041 device->lanes = mipi_plat->lanes;
1042 device->format = mipi_plat->format;
1043 device->mode_flags = mipi_plat->mode_flags;
1044
1045 tegra_dsi_get_format(device->format, &priv->format);
1046
Svyatoslav Ryhelfe0a53a2024-01-23 19:16:30 +02001047 reset_assert(&reset_ctl);
1048
Svyatoslav Ryheldaab7d92023-10-03 09:25:34 +03001049 ret = regulator_set_enable_if_allowed(priv->avdd, true);
1050 if (ret && ret != -ENOSYS)
1051 return ret;
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001052
1053 tegra_dsi_init_clocks(dev);
1054
Svyatoslav Ryhelfe0a53a2024-01-23 19:16:30 +02001055 mdelay(2);
1056 reset_deassert(&reset_ctl);
1057
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001058 return 0;
1059}
1060
1061static const struct panel_ops tegra_dsi_bridge_ops = {
1062 .enable_backlight = tegra_dsi_encoder_enable,
1063 .set_backlight = tegra_dsi_bridge_set_panel,
1064 .get_display_timing = tegra_dsi_panel_timings,
1065};
1066
1067static const struct udevice_id tegra_dsi_bridge_ids[] = {
Svyatoslav Ryhel094d4f92024-01-23 19:16:29 +02001068 { .compatible = "nvidia,tegra30-dsi", .data = DSI_V0 },
1069 { .compatible = "nvidia,tegra114-dsi", .data = DSI_V1 },
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001070 { }
1071};
1072
1073U_BOOT_DRIVER(tegra_dsi) = {
1074 .name = "tegra_dsi",
1075 .id = UCLASS_PANEL,
1076 .of_match = tegra_dsi_bridge_ids,
1077 .ops = &tegra_dsi_bridge_ops,
Svyatoslav Ryhelf6b2ab42024-11-24 09:38:03 +02001078 .bind = dm_scan_fdt_dev,
Svyatoslav Ryhelfeddf9f2023-03-27 11:11:48 +03001079 .probe = tegra_dsi_bridge_probe,
1080 .plat_auto = sizeof(struct tegra_dc_plat),
1081 .priv_auto = sizeof(struct tegra_dsi_priv),
1082};