1 /*
2 * Copyright 2022, NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #define DT_DRV_COMPAT raydium_rm68200
8
9 #include <zephyr/drivers/display.h>
10 #include <zephyr/drivers/mipi_dsi.h>
11 #include <zephyr/drivers/gpio.h>
12 #include <zephyr/kernel.h>
13 #include <zephyr/logging/log.h>
14
15 LOG_MODULE_REGISTER(rm68200, CONFIG_DISPLAY_LOG_LEVEL);
16
17 /* DCS Commands */
18 #define DCS_CMD_PAGE 0xFE
19 #define DCS_CMD_PAGE_UCS 0x0
20 #define DCS_CMD_PAGE_SET_PAGE0 0x1
21 #define DCS_CMD_PAGE_SET_PAGE1 0x2
22 #define DCS_CMD_PAGE_SET_PAGE2 0x3
23 #define DCS_CMD_PAGE_SET_PAGE3 0x4
24
25 /* MCS Commands */
26 #define MCS_STBCTR 0x12
27 #define MCS_SGOPCTR 0x16
28 #define MCS_SDCTR 0x1A
29 #define MCS_INVCTR 0x1B
30 #define MCS_EXT_PWR_IC_TYPE 0x24
31 #define MCS_EXT_PWR_SET_AVDD 0x25
32 #define MCS_AVEE_FROM_PFM 0x26
33 #define MCS_AVDD_FROM_PFM 0x27
34 #define MCS_SETAVEE 0x29
35 #define MCS_BT2CTR 0x2B
36 #define MCS_BT3CTR 0x2F
37 #define MCS_BT4CTR 0x34
38 #define MCS_VCMCTR 0x46
39 #define MCS_SETVGMN 0x52
40 #define MCS_SETVGSN 0x53
41 #define MCS_SETVGMP 0x54
42 #define MCS_SETVGSP 0x55
43 #define MCS_SW_CTRL 0x5F
44 #define MCS_GAMMA_VP1 0x60
45 #define MCS_GAMMA_VP4 0x61
46 #define MCS_GAMMA_VP8 0x62
47 #define MCS_GAMMA_VP16 0x63
48 #define MCS_GAMMA_VP24 0x64
49 #define MCS_GAMMA_VP52 0x65
50 #define MCS_GAMMA_VP80 0x66
51 #define MCS_GAMMA_VP108 0x67
52 #define MCS_GAMMA_VP147 0x68
53 #define MCS_GAMMA_VP175 0x69
54 #define MCS_GAMMA_VP203 0x6A
55 #define MCS_GAMMA_VP231 0x6B
56 #define MCS_GAMMA_VP239 0x6C
57 #define MCS_GAMMA_VP247 0x6D
58 #define MCS_GAMMA_VP251 0x6E
59 #define MCS_GAMMA_VP255 0x6F
60 #define MCS_GAMMA_VN1 0x70
61 #define MCS_GAMMA_VN4 0x71
62 #define MCS_GAMMA_VN8 0x72
63 #define MCS_GAMMA_VN16 0x73
64 #define MCS_GAMMA_VN24 0x74
65 #define MCS_GAMMA_VN52 0x75
66 #define MCS_GAMMA_VN80 0x76
67 #define MCS_GAMMA_VN108 0x77
68 #define MCS_GAMMA_VN147 0x78
69 #define MCS_GAMMA_VN175 0x79
70 #define MCS_GAMMA_VN203 0x7A
71 #define MCS_GAMMA_VN231 0x7B
72 #define MCS_GAMMA_VN239 0x7C
73 #define MCS_GAMMA_VN247 0x7D
74 #define MCS_GAMMA_VN251 0x7E
75 #define MCS_GAMMA_VN255 0x7F
76 #define MCS_GAMMA_UPDATE 0x80
77
78 struct rm68200_config {
79 const struct device *mipi_dsi;
80 const struct gpio_dt_spec reset_gpio;
81 const struct gpio_dt_spec bl_gpio;
82 uint8_t num_of_lanes;
83 uint8_t pixel_format;
84 uint16_t panel_width;
85 uint16_t panel_height;
86 uint8_t channel;
87 };
88
rm68200_dcs_write(const struct device * dev,uint8_t cmd,uint8_t * buf,uint8_t len)89 static int rm68200_dcs_write(const struct device *dev, uint8_t cmd, uint8_t *buf,
90 uint8_t len)
91 {
92 const struct rm68200_config *config = dev->config;
93
94 return mipi_dsi_dcs_write(config->mipi_dsi, config->channel, cmd, buf, len);
95 }
96
rm68200_write(const struct device * dev,const uint16_t x,const uint16_t y,const struct display_buffer_descriptor * desc,const void * buf)97 static int rm68200_write(const struct device *dev, const uint16_t x,
98 const uint16_t y,
99 const struct display_buffer_descriptor *desc,
100 const void *buf)
101 {
102 return 0;
103 }
104
rm68200_blanking_off(const struct device * dev)105 static int rm68200_blanking_off(const struct device *dev)
106 {
107 const struct rm68200_config *config = dev->config;
108
109 if (config->bl_gpio.port != NULL) {
110 return gpio_pin_set_dt(&config->bl_gpio, 1);
111 } else {
112 return -ENOTSUP;
113 }
114 }
115
rm68200_blanking_on(const struct device * dev)116 static int rm68200_blanking_on(const struct device *dev)
117 {
118 const struct rm68200_config *config = dev->config;
119
120 if (config->bl_gpio.port != NULL) {
121 return gpio_pin_set_dt(&config->bl_gpio, 0);
122 } else {
123 return -ENOTSUP;
124 }
125 }
126
rm68200_set_pixel_format(const struct device * dev,const enum display_pixel_format pixel_format)127 static int rm68200_set_pixel_format(const struct device *dev,
128 const enum display_pixel_format pixel_format)
129 {
130 const struct rm68200_config *config = dev->config;
131
132 if (pixel_format == config->pixel_format) {
133 return 0;
134 }
135 LOG_ERR("Pixel format change not implemented");
136 return -ENOTSUP;
137 }
138
rm68200_set_orientation(const struct device * dev,const enum display_orientation orientation)139 static int rm68200_set_orientation(const struct device *dev,
140 const enum display_orientation orientation)
141 {
142 if (orientation == DISPLAY_ORIENTATION_NORMAL) {
143 return 0;
144 }
145 LOG_ERR("Changing display orientation not implemented");
146 return -ENOTSUP;
147 }
148
rm68200_get_capabilities(const struct device * dev,struct display_capabilities * capabilities)149 static void rm68200_get_capabilities(const struct device *dev,
150 struct display_capabilities *capabilities)
151 {
152 const struct rm68200_config *config = dev->config;
153
154 memset(capabilities, 0, sizeof(struct display_capabilities));
155 capabilities->x_resolution = config->panel_width;
156 capabilities->y_resolution = config->panel_height;
157 capabilities->supported_pixel_formats = config->pixel_format;
158 capabilities->current_pixel_format = config->pixel_format;
159 capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL;
160 }
161
162 static DEVICE_API(display, rm68200_api) = {
163 .blanking_on = rm68200_blanking_on,
164 .blanking_off = rm68200_blanking_off,
165 .write = rm68200_write,
166 .get_capabilities = rm68200_get_capabilities,
167 .set_pixel_format = rm68200_set_pixel_format,
168 .set_orientation = rm68200_set_orientation,
169 };
170
rm68200_init(const struct device * dev)171 static int rm68200_init(const struct device *dev)
172 {
173 const struct rm68200_config *config = dev->config;
174 uint8_t param;
175 int ret;
176 struct mipi_dsi_device mdev;
177
178 mdev.data_lanes = config->num_of_lanes;
179 mdev.pixfmt = config->pixel_format;
180 /* RM68200 runs in video mode */
181 mdev.mode_flags = MIPI_DSI_MODE_VIDEO;
182
183 ret = mipi_dsi_attach(config->mipi_dsi, config->channel, &mdev);
184 if (ret < 0) {
185 LOG_ERR("Could not attach to MIPI-DSI host");
186 return ret;
187 }
188
189 if (config->reset_gpio.port != NULL) {
190 ret = gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE);
191 if (ret < 0) {
192 LOG_ERR("Could not configure reset GPIO (%d)", ret);
193 return ret;
194 }
195
196 /* Power to the display has been enabled via the regulator fixed api during
197 * regulator init.
198 * reset:0 -> reset:1
199 */
200 gpio_pin_set_dt(&config->reset_gpio, 0);
201 /* Per datasheet, reset low pulse width should be at least 15usec */
202 k_sleep(K_USEC(50));
203 gpio_pin_set_dt(&config->reset_gpio, 1);
204 /* Per datasheet, it is necessary to wait 5msec after releasing reset */
205 k_sleep(K_MSEC(5));
206 }
207
208 param = DCS_CMD_PAGE_SET_PAGE0;
209 rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1);
210
211 param = 0xC0;
212 rm68200_dcs_write(dev, MCS_EXT_PWR_IC_TYPE, ¶m, 1);
213
214 param = 0x53;
215 rm68200_dcs_write(dev, MCS_EXT_PWR_SET_AVDD, ¶m, 1);
216
217 param = 0x00;
218 rm68200_dcs_write(dev, MCS_AVEE_FROM_PFM, ¶m, 1);
219
220 param = 0xE5;
221 rm68200_dcs_write(dev, MCS_BT2CTR, ¶m, 1);
222
223 param = 0x0A;
224 rm68200_dcs_write(dev, MCS_AVDD_FROM_PFM, ¶m, 1);
225
226 param = 0x0A;
227 rm68200_dcs_write(dev, MCS_SETAVEE, ¶m, 1);
228
229 param = 0x52;
230 rm68200_dcs_write(dev, MCS_SGOPCTR, ¶m, 1);
231
232 param = 0x53;
233 rm68200_dcs_write(dev, MCS_BT3CTR, ¶m, 1);
234
235 param = 0x5A;
236 rm68200_dcs_write(dev, MCS_BT4CTR, ¶m, 1);
237
238 param = 0x00;
239 rm68200_dcs_write(dev, MCS_INVCTR, ¶m, 1);
240
241 param = 0x0A;
242 rm68200_dcs_write(dev, MCS_STBCTR, ¶m, 1);
243
244 param = 0x06;
245 rm68200_dcs_write(dev, MCS_SDCTR, ¶m, 1);
246
247 param = 0x56;
248 rm68200_dcs_write(dev, MCS_VCMCTR, ¶m, 1);
249
250 param = 0xA0;
251 rm68200_dcs_write(dev, MCS_SETVGMN, ¶m, 1);
252
253 param = 0x00;
254 rm68200_dcs_write(dev, MCS_SETVGSN, ¶m, 1);
255
256 param = 0xA0;
257 rm68200_dcs_write(dev, MCS_SETVGMP, ¶m, 1);
258
259 param = 0x00;
260 rm68200_dcs_write(dev, MCS_SETVGSP, ¶m, 1);
261
262 param = 0x10U | (config->num_of_lanes - 1U);
263 rm68200_dcs_write(dev, MCS_SW_CTRL, ¶m, 1);
264
265 param = DCS_CMD_PAGE_SET_PAGE2;
266 rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1);
267
268 /* There is no description for the below registers in the datasheet */
269 param = 0x05;
270 rm68200_dcs_write(dev, 0x00, ¶m, 1);
271
272 param = 0x0B;
273 rm68200_dcs_write(dev, 0x02, ¶m, 1);
274
275 param = 0x0F;
276 rm68200_dcs_write(dev, 0x03, ¶m, 1);
277
278 param = 0x7D;
279 rm68200_dcs_write(dev, 0x04, ¶m, 1);
280
281 param = 0x00;
282 rm68200_dcs_write(dev, 0x05, ¶m, 1);
283
284 param = 0x50;
285 rm68200_dcs_write(dev, 0x06, ¶m, 1);
286
287 param = 0x05;
288 rm68200_dcs_write(dev, 0x07, ¶m, 1);
289
290 param = 0x16;
291 rm68200_dcs_write(dev, 0x08, ¶m, 1);
292
293 param = 0x0D;
294 rm68200_dcs_write(dev, 0x09, ¶m, 1);
295
296 param = 0x11;
297 rm68200_dcs_write(dev, 0x0A, ¶m, 1);
298
299 param = 0x7D;
300 rm68200_dcs_write(dev, 0x0B, ¶m, 1);
301
302 param = 0x00;
303 rm68200_dcs_write(dev, 0x0C, ¶m, 1);
304
305 param = 0x50;
306 rm68200_dcs_write(dev, 0x0D, ¶m, 1);
307
308 param = 0x07;
309 rm68200_dcs_write(dev, 0x0E, ¶m, 1);
310
311 param = 0x08;
312 rm68200_dcs_write(dev, 0x0F, ¶m, 1);
313
314 param = 0x01;
315 rm68200_dcs_write(dev, 0x10, ¶m, 1);
316
317 param = 0x02;
318 rm68200_dcs_write(dev, 0x11, ¶m, 1);
319
320 param = 0x00;
321 rm68200_dcs_write(dev, 0x12, ¶m, 1);
322
323 param = 0x7D;
324 rm68200_dcs_write(dev, 0x13, ¶m, 1);
325
326 param = 0x00;
327 rm68200_dcs_write(dev, 0x14, ¶m, 1);
328
329 param = 0x85;
330 rm68200_dcs_write(dev, 0x15, ¶m, 1);
331
332 param = 0x08;
333 rm68200_dcs_write(dev, 0x16, ¶m, 1);
334
335 param = 0x03;
336 rm68200_dcs_write(dev, 0x17, ¶m, 1);
337
338 param = 0x04;
339 rm68200_dcs_write(dev, 0x18, ¶m, 1);
340
341 param = 0x05;
342 rm68200_dcs_write(dev, 0x19, ¶m, 1);
343
344 param = 0x06;
345 rm68200_dcs_write(dev, 0x1A, ¶m, 1);
346
347 param = 0x00;
348 rm68200_dcs_write(dev, 0x1B, ¶m, 1);
349
350 param = 0x7D;
351 rm68200_dcs_write(dev, 0x1C, ¶m, 1);
352
353 param = 0x00;
354 rm68200_dcs_write(dev, 0x1D, ¶m, 1);
355
356 param = 0x85;
357 rm68200_dcs_write(dev, 0x1E, ¶m, 1);
358
359 param = 0x08;
360 rm68200_dcs_write(dev, 0x1F, ¶m, 1);
361
362 param = 0x00;
363 rm68200_dcs_write(dev, 0x20, ¶m, 1);
364
365 param = 0x00;
366 rm68200_dcs_write(dev, 0x21, ¶m, 1);
367
368 param = 0x00;
369 rm68200_dcs_write(dev, 0x22, ¶m, 1);
370
371 param = 0x00;
372 rm68200_dcs_write(dev, 0x23, ¶m, 1);
373
374 param = 0x00;
375 rm68200_dcs_write(dev, 0x24, ¶m, 1);
376
377 param = 0x00;
378 rm68200_dcs_write(dev, 0x25, ¶m, 1);
379
380 param = 0x00;
381 rm68200_dcs_write(dev, 0x26, ¶m, 1);
382
383 param = 0x00;
384 rm68200_dcs_write(dev, 0x27, ¶m, 1);
385
386 param = 0x00;
387 rm68200_dcs_write(dev, 0x28, ¶m, 1);
388
389 param = 0x00;
390 rm68200_dcs_write(dev, 0x29, ¶m, 1);
391
392 param = 0x07;
393 rm68200_dcs_write(dev, 0x2A, ¶m, 1);
394
395 param = 0x08;
396 rm68200_dcs_write(dev, 0x2B, ¶m, 1);
397
398 param = 0x01;
399 rm68200_dcs_write(dev, 0x2D, ¶m, 1);
400
401 param = 0x02;
402 rm68200_dcs_write(dev, 0x2F, ¶m, 1);
403
404 param = 0x00;
405 rm68200_dcs_write(dev, 0x30, ¶m, 1);
406
407 param = 0x40;
408 rm68200_dcs_write(dev, 0x31, ¶m, 1);
409
410 param = 0x05;
411 rm68200_dcs_write(dev, 0x32, ¶m, 1);
412
413 param = 0x08;
414 rm68200_dcs_write(dev, 0x33, ¶m, 1);
415
416 param = 0x54;
417 rm68200_dcs_write(dev, 0x34, ¶m, 1);
418
419 param = 0x7D;
420 rm68200_dcs_write(dev, 0x35, ¶m, 1);
421
422 param = 0x00;
423 rm68200_dcs_write(dev, 0x36, ¶m, 1);
424
425 param = 0x03;
426 rm68200_dcs_write(dev, 0x37, ¶m, 1);
427
428 param = 0x04;
429 rm68200_dcs_write(dev, 0x38, ¶m, 1);
430
431 param = 0x05;
432 rm68200_dcs_write(dev, 0x39, ¶m, 1);
433
434 param = 0x06;
435 rm68200_dcs_write(dev, 0x3A, ¶m, 1);
436
437 param = 0x00;
438 rm68200_dcs_write(dev, 0x3B, ¶m, 1);
439
440 param = 0x40;
441 rm68200_dcs_write(dev, 0x3D, ¶m, 1);
442
443 param = 0x05;
444 rm68200_dcs_write(dev, 0x3F, ¶m, 1);
445
446 param = 0x08;
447 rm68200_dcs_write(dev, 0x40, ¶m, 1);
448
449 param = 0x54;
450 rm68200_dcs_write(dev, 0x41, ¶m, 1);
451
452 param = 0x7D;
453 rm68200_dcs_write(dev, 0x42, ¶m, 1);
454
455 param = 0x00;
456 rm68200_dcs_write(dev, 0x43, ¶m, 1);
457
458 param = 0x00;
459 rm68200_dcs_write(dev, 0x44, ¶m, 1);
460
461 param = 0x00;
462 rm68200_dcs_write(dev, 0x45, ¶m, 1);
463
464 param = 0x00;
465 rm68200_dcs_write(dev, 0x46, ¶m, 1);
466
467 param = 0x00;
468 rm68200_dcs_write(dev, 0x47, ¶m, 1);
469
470 param = 0x00;
471 rm68200_dcs_write(dev, 0x48, ¶m, 1);
472
473 param = 0x00;
474 rm68200_dcs_write(dev, 0x49, ¶m, 1);
475
476 param = 0x00;
477 rm68200_dcs_write(dev, 0x4A, ¶m, 1);
478
479 param = 0x00;
480 rm68200_dcs_write(dev, 0x4B, ¶m, 1);
481
482 param = 0x00;
483 rm68200_dcs_write(dev, 0x4C, ¶m, 1);
484
485 param = 0x00;
486 rm68200_dcs_write(dev, 0x4D, ¶m, 1);
487
488 param = 0x00;
489 rm68200_dcs_write(dev, 0x4E, ¶m, 1);
490
491 param = 0x00;
492 rm68200_dcs_write(dev, 0x4F, ¶m, 1);
493
494 param = 0x00;
495 rm68200_dcs_write(dev, 0x50, ¶m, 1);
496
497 param = 0x00;
498 rm68200_dcs_write(dev, 0x51, ¶m, 1);
499
500 param = 0x00;
501 rm68200_dcs_write(dev, 0x52, ¶m, 1);
502
503 param = 0x00;
504 rm68200_dcs_write(dev, 0x53, ¶m, 1);
505
506 param = 0x00;
507 rm68200_dcs_write(dev, 0x54, ¶m, 1);
508
509 param = 0x00;
510 rm68200_dcs_write(dev, 0x55, ¶m, 1);
511
512 param = 0x00;
513 rm68200_dcs_write(dev, 0x56, ¶m, 1);
514
515 param = 0x00;
516 rm68200_dcs_write(dev, 0x58, ¶m, 1);
517
518 param = 0x00;
519 rm68200_dcs_write(dev, 0x59, ¶m, 1);
520
521 param = 0x00;
522 rm68200_dcs_write(dev, 0x5A, ¶m, 1);
523
524 param = 0x00;
525 rm68200_dcs_write(dev, 0x5B, ¶m, 1);
526
527 param = 0x00;
528 rm68200_dcs_write(dev, 0x5C, ¶m, 1);
529
530 param = 0x00;
531 rm68200_dcs_write(dev, 0x5D, ¶m, 1);
532
533 param = 0x00;
534 rm68200_dcs_write(dev, 0x5E, ¶m, 1);
535
536 param = 0x00;
537 rm68200_dcs_write(dev, 0x5F, ¶m, 1);
538
539 param = 0x00;
540 rm68200_dcs_write(dev, 0x60, ¶m, 1);
541
542 param = 0x00;
543 rm68200_dcs_write(dev, 0x61, ¶m, 1);
544
545 param = 0x00;
546 rm68200_dcs_write(dev, 0x62, ¶m, 1);
547
548 param = 0x00;
549 rm68200_dcs_write(dev, 0x63, ¶m, 1);
550
551 param = 0x00;
552 rm68200_dcs_write(dev, 0x64, ¶m, 1);
553
554 param = 0x00;
555 rm68200_dcs_write(dev, 0x65, ¶m, 1);
556
557 param = 0x00;
558 rm68200_dcs_write(dev, 0x66, ¶m, 1);
559
560 param = 0x00;
561 rm68200_dcs_write(dev, 0x67, ¶m, 1);
562
563 param = 0x00;
564 rm68200_dcs_write(dev, 0x68, ¶m, 1);
565
566 param = 0x00;
567 rm68200_dcs_write(dev, 0x69, ¶m, 1);
568
569 param = 0x00;
570 rm68200_dcs_write(dev, 0x6A, ¶m, 1);
571
572 param = 0x00;
573 rm68200_dcs_write(dev, 0x6B, ¶m, 1);
574
575 param = 0x00;
576 rm68200_dcs_write(dev, 0x6C, ¶m, 1);
577
578 param = 0x00;
579 rm68200_dcs_write(dev, 0x6D, ¶m, 1);
580
581 param = 0x00;
582 rm68200_dcs_write(dev, 0x6E, ¶m, 1);
583
584 param = 0x00;
585 rm68200_dcs_write(dev, 0x6F, ¶m, 1);
586
587 param = 0x00;
588 rm68200_dcs_write(dev, 0x70, ¶m, 1);
589
590 param = 0x00;
591 rm68200_dcs_write(dev, 0x71, ¶m, 1);
592
593 param = 0x20;
594 rm68200_dcs_write(dev, 0x72, ¶m, 1);
595
596 param = 0x00;
597 rm68200_dcs_write(dev, 0x73, ¶m, 1);
598
599 param = 0x08;
600 rm68200_dcs_write(dev, 0x74, ¶m, 1);
601
602 param = 0x08;
603 rm68200_dcs_write(dev, 0x75, ¶m, 1);
604
605 param = 0x08;
606 rm68200_dcs_write(dev, 0x76, ¶m, 1);
607
608 param = 0x08;
609 rm68200_dcs_write(dev, 0x77, ¶m, 1);
610
611 param = 0x08;
612 rm68200_dcs_write(dev, 0x78, ¶m, 1);
613
614 param = 0x08;
615 rm68200_dcs_write(dev, 0x79, ¶m, 1);
616
617 param = 0x00;
618 rm68200_dcs_write(dev, 0x7A, ¶m, 1);
619
620 param = 0x00;
621 rm68200_dcs_write(dev, 0x7B, ¶m, 1);
622
623 param = 0x00;
624 rm68200_dcs_write(dev, 0x7C, ¶m, 1);
625
626 param = 0x00;
627 rm68200_dcs_write(dev, 0x7D, ¶m, 1);
628
629 param = 0xBF;
630 rm68200_dcs_write(dev, 0x7E, ¶m, 1);
631
632 param = 0x02;
633 rm68200_dcs_write(dev, 0x7F, ¶m, 1);
634
635 param = 0x06;
636 rm68200_dcs_write(dev, 0x80, ¶m, 1);
637
638 param = 0x14;
639 rm68200_dcs_write(dev, 0x81, ¶m, 1);
640
641 param = 0x10;
642 rm68200_dcs_write(dev, 0x82, ¶m, 1);
643
644 param = 0x16;
645 rm68200_dcs_write(dev, 0x83, ¶m, 1);
646
647 param = 0x12;
648 rm68200_dcs_write(dev, 0x84, ¶m, 1);
649
650 param = 0x08;
651 rm68200_dcs_write(dev, 0x85, ¶m, 1);
652
653 param = 0x3F;
654 rm68200_dcs_write(dev, 0x86, ¶m, 1);
655
656 param = 0x3F;
657 rm68200_dcs_write(dev, 0x87, ¶m, 1);
658
659 param = 0x3F;
660 rm68200_dcs_write(dev, 0x88, ¶m, 1);
661
662 param = 0x3F;
663 rm68200_dcs_write(dev, 0x89, ¶m, 1);
664
665 param = 0x3F;
666 rm68200_dcs_write(dev, 0x8A, ¶m, 1);
667
668 param = 0x0C;
669 rm68200_dcs_write(dev, 0x8B, ¶m, 1);
670
671 param = 0x0A;
672 rm68200_dcs_write(dev, 0x8C, ¶m, 1);
673
674 param = 0x0E;
675 rm68200_dcs_write(dev, 0x8D, ¶m, 1);
676
677 param = 0x3F;
678 rm68200_dcs_write(dev, 0x8E, ¶m, 1);
679
680 param = 0x3F;
681 rm68200_dcs_write(dev, 0x8F, ¶m, 1);
682
683 param = 0x00;
684 rm68200_dcs_write(dev, 0x90, ¶m, 1);
685
686 param = 0x04;
687 rm68200_dcs_write(dev, 0x91, ¶m, 1);
688
689 param = 0x3F;
690 rm68200_dcs_write(dev, 0x92, ¶m, 1);
691
692 param = 0x3F;
693 rm68200_dcs_write(dev, 0x93, ¶m, 1);
694
695 param = 0x3F;
696 rm68200_dcs_write(dev, 0x94, ¶m, 1);
697
698 param = 0x3F;
699 rm68200_dcs_write(dev, 0x95, ¶m, 1);
700
701 param = 0x05;
702 rm68200_dcs_write(dev, 0x96, ¶m, 1);
703
704 param = 0x01;
705 rm68200_dcs_write(dev, 0x97, ¶m, 1);
706
707 param = 0x3F;
708 rm68200_dcs_write(dev, 0x98, ¶m, 1);
709
710 param = 0x3F;
711 rm68200_dcs_write(dev, 0x99, ¶m, 1);
712
713 param = 0x0F;
714 rm68200_dcs_write(dev, 0x9A, ¶m, 1);
715
716 param = 0x0B;
717 rm68200_dcs_write(dev, 0x9B, ¶m, 1);
718
719 param = 0x0D;
720 rm68200_dcs_write(dev, 0x9C, ¶m, 1);
721
722 param = 0x3F;
723 rm68200_dcs_write(dev, 0x9D, ¶m, 1);
724
725 param = 0x3F;
726 rm68200_dcs_write(dev, 0x9E, ¶m, 1);
727
728 param = 0x3F;
729 rm68200_dcs_write(dev, 0x9F, ¶m, 1);
730
731 param = 0x3F;
732 rm68200_dcs_write(dev, 0xA0, ¶m, 1);
733
734 param = 0x3F;
735 rm68200_dcs_write(dev, 0xA2, ¶m, 1);
736
737 param = 0x09;
738 rm68200_dcs_write(dev, 0xA3, ¶m, 1);
739
740 param = 0x13;
741 rm68200_dcs_write(dev, 0xA4, ¶m, 1);
742
743 param = 0x17;
744 rm68200_dcs_write(dev, 0xA5, ¶m, 1);
745
746 param = 0x11;
747 rm68200_dcs_write(dev, 0xA6, ¶m, 1);
748
749 param = 0x15;
750 rm68200_dcs_write(dev, 0xA7, ¶m, 1);
751
752 param = 0x07;
753 rm68200_dcs_write(dev, 0xA9, ¶m, 1);
754
755 param = 0x03;
756 rm68200_dcs_write(dev, 0xAA, ¶m, 1);
757
758 param = 0x3F;
759 rm68200_dcs_write(dev, 0xAB, ¶m, 1);
760
761 param = 0x3F;
762 rm68200_dcs_write(dev, 0xAC, ¶m, 1);
763
764 param = 0x05;
765 rm68200_dcs_write(dev, 0xAD, ¶m, 1);
766
767 param = 0x01;
768 rm68200_dcs_write(dev, 0xAE, ¶m, 1);
769
770 param = 0x17;
771 rm68200_dcs_write(dev, 0xAF, ¶m, 1);
772
773 param = 0x13;
774 rm68200_dcs_write(dev, 0xB0, ¶m, 1);
775
776 param = 0x15;
777 rm68200_dcs_write(dev, 0xB1, ¶m, 1);
778
779 param = 0x11;
780 rm68200_dcs_write(dev, 0xB2, ¶m, 1);
781
782 param = 0x0F;
783 rm68200_dcs_write(dev, 0xB3, ¶m, 1);
784
785 param = 0x3F;
786 rm68200_dcs_write(dev, 0xB4, ¶m, 1);
787
788 param = 0x3F;
789 rm68200_dcs_write(dev, 0xB5, ¶m, 1);
790
791 param = 0x3F;
792 rm68200_dcs_write(dev, 0xB6, ¶m, 1);
793
794 param = 0x3F;
795 rm68200_dcs_write(dev, 0xB7, ¶m, 1);
796
797 param = 0x3F;
798 rm68200_dcs_write(dev, 0xB8, ¶m, 1);
799
800 param = 0x0B;
801 rm68200_dcs_write(dev, 0xB9, ¶m, 1);
802
803 param = 0x0D;
804 rm68200_dcs_write(dev, 0xBA, ¶m, 1);
805
806 param = 0x09;
807 rm68200_dcs_write(dev, 0xBB, ¶m, 1);
808
809 param = 0x3F;
810 rm68200_dcs_write(dev, 0xBC, ¶m, 1);
811
812 param = 0x3F;
813 rm68200_dcs_write(dev, 0xBD, ¶m, 1);
814
815 param = 0x07;
816 rm68200_dcs_write(dev, 0xBE, ¶m, 1);
817
818 param = 0x03;
819 rm68200_dcs_write(dev, 0xBF, ¶m, 1);
820
821 param = 0x3F;
822 rm68200_dcs_write(dev, 0xC0, ¶m, 1);
823
824 param = 0x3F;
825 rm68200_dcs_write(dev, 0xC1, ¶m, 1);
826
827 param = 0x3F;
828 rm68200_dcs_write(dev, 0xC2, ¶m, 1);
829
830 param = 0x3F;
831 rm68200_dcs_write(dev, 0xC3, ¶m, 1);
832
833 param = 0x02;
834 rm68200_dcs_write(dev, 0xC4, ¶m, 1);
835
836 param = 0x06;
837 rm68200_dcs_write(dev, 0xC5, ¶m, 1);
838
839 param = 0x3F;
840 rm68200_dcs_write(dev, 0xC6, ¶m, 1);
841
842 param = 0x3F;
843 rm68200_dcs_write(dev, 0xC7, ¶m, 1);
844
845 param = 0x08;
846 rm68200_dcs_write(dev, 0xC8, ¶m, 1);
847
848 param = 0x0C;
849 rm68200_dcs_write(dev, 0xC9, ¶m, 1);
850
851 param = 0x0A;
852 rm68200_dcs_write(dev, 0xCA, ¶m, 1);
853
854 param = 0x3F;
855 rm68200_dcs_write(dev, 0xCB, ¶m, 1);
856
857 param = 0x3F;
858 rm68200_dcs_write(dev, 0xCC, ¶m, 1);
859
860 param = 0x3F;
861 rm68200_dcs_write(dev, 0xCD, ¶m, 1);
862
863 param = 0x3F;
864 rm68200_dcs_write(dev, 0xCE, ¶m, 1);
865
866 param = 0x3F;
867 rm68200_dcs_write(dev, 0xCF, ¶m, 1);
868
869 param = 0x0E;
870 rm68200_dcs_write(dev, 0xD0, ¶m, 1);
871
872 param = 0x10;
873 rm68200_dcs_write(dev, 0xD1, ¶m, 1);
874
875 param = 0x14;
876 rm68200_dcs_write(dev, 0xD2, ¶m, 1);
877
878 param = 0x12;
879 rm68200_dcs_write(dev, 0xD3, ¶m, 1);
880
881 param = 0x16;
882 rm68200_dcs_write(dev, 0xD4, ¶m, 1);
883
884 param = 0x00;
885 rm68200_dcs_write(dev, 0xD5, ¶m, 1);
886
887 param = 0x04;
888 rm68200_dcs_write(dev, 0xD6, ¶m, 1);
889
890 param = 0x3F;
891 rm68200_dcs_write(dev, 0xD7, ¶m, 1);
892
893 param = 0x02;
894 rm68200_dcs_write(dev, 0xDC, ¶m, 1);
895
896 param = 0x12;
897 rm68200_dcs_write(dev, 0xDE, ¶m, 1);
898
899 param = 0x0E;
900 rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1);
901
902 param = 0x75;
903 rm68200_dcs_write(dev, 0x01, ¶m, 1);
904
905 /* Gamma Settings */
906 param = DCS_CMD_PAGE_SET_PAGE3;
907 rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1);
908
909 param = 0x00;
910 rm68200_dcs_write(dev, MCS_GAMMA_VP1, ¶m, 1);
911
912 param = 0x0C;
913 rm68200_dcs_write(dev, MCS_GAMMA_VP4, ¶m, 1);
914
915 param = 0x12;
916 rm68200_dcs_write(dev, MCS_GAMMA_VP8, ¶m, 1);
917
918 param = 0x0E;
919 rm68200_dcs_write(dev, MCS_GAMMA_VP16, ¶m, 1);
920
921 param = 0x06;
922 rm68200_dcs_write(dev, MCS_GAMMA_VP24, ¶m, 1);
923
924 param = 0x12;
925 rm68200_dcs_write(dev, MCS_GAMMA_VP52, ¶m, 1);
926
927 param = 0x0E;
928 rm68200_dcs_write(dev, MCS_GAMMA_VP80, ¶m, 1);
929
930 param = 0x0B;
931 rm68200_dcs_write(dev, MCS_GAMMA_VP108, ¶m, 1);
932
933 param = 0x15;
934 rm68200_dcs_write(dev, MCS_GAMMA_VP147, ¶m, 1);
935
936 param = 0x0B;
937 rm68200_dcs_write(dev, MCS_GAMMA_VP175, ¶m, 1);
938
939 param = 0x10;
940 rm68200_dcs_write(dev, MCS_GAMMA_VP203, ¶m, 1);
941
942 param = 0x07;
943 rm68200_dcs_write(dev, MCS_GAMMA_VP231, ¶m, 1);
944
945 param = 0x0F;
946 rm68200_dcs_write(dev, MCS_GAMMA_VP239, ¶m, 1);
947
948 param = 0x12;
949 rm68200_dcs_write(dev, MCS_GAMMA_VP247, ¶m, 1);
950
951 param = 0x0C;
952 rm68200_dcs_write(dev, MCS_GAMMA_VP251, ¶m, 1);
953
954 param = 0x00;
955 rm68200_dcs_write(dev, MCS_GAMMA_VP255, ¶m, 1);
956
957 param = 0x00;
958 rm68200_dcs_write(dev, MCS_GAMMA_VN1, ¶m, 1);
959
960 param = 0x0C;
961 rm68200_dcs_write(dev, MCS_GAMMA_VN4, ¶m, 1);
962
963 param = 0x12;
964 rm68200_dcs_write(dev, MCS_GAMMA_VN8, ¶m, 1);
965
966 param = 0x0E;
967 rm68200_dcs_write(dev, MCS_GAMMA_VN16, ¶m, 1);
968
969 param = 0x06;
970 rm68200_dcs_write(dev, MCS_GAMMA_VN24, ¶m, 1);
971
972 param = 0x12;
973 rm68200_dcs_write(dev, MCS_GAMMA_VN52, ¶m, 1);
974
975 param = 0x0E;
976 rm68200_dcs_write(dev, MCS_GAMMA_VN80, ¶m, 1);
977
978 param = 0x0B;
979 rm68200_dcs_write(dev, MCS_GAMMA_VN108, ¶m, 1);
980
981 param = 0x15;
982 rm68200_dcs_write(dev, MCS_GAMMA_VN147, ¶m, 1);
983
984 param = 0x0B;
985 rm68200_dcs_write(dev, MCS_GAMMA_VN175, ¶m, 1);
986
987 param = 0x10;
988 rm68200_dcs_write(dev, MCS_GAMMA_VN203, ¶m, 1);
989
990 param = 0x07;
991 rm68200_dcs_write(dev, MCS_GAMMA_VN231, ¶m, 1);
992
993 param = 0x0F;
994 rm68200_dcs_write(dev, MCS_GAMMA_VN239, ¶m, 1);
995
996 param = 0x12;
997 rm68200_dcs_write(dev, MCS_GAMMA_VN247, ¶m, 1);
998
999 param = 0x0C;
1000 rm68200_dcs_write(dev, MCS_GAMMA_VN251, ¶m, 1);
1001
1002 param = 0x00;
1003 rm68200_dcs_write(dev, MCS_GAMMA_VN255, ¶m, 1);
1004
1005 /* Page 0 */
1006 param = DCS_CMD_PAGE_UCS;
1007 rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1);
1008
1009 rm68200_dcs_write(dev, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
1010
1011 k_sleep(K_MSEC(200));
1012
1013 rm68200_dcs_write(dev, MIPI_DCS_SET_DISPLAY_ON, NULL, 0);
1014
1015 k_sleep(K_MSEC(100));
1016
1017 rm68200_dcs_write(dev, MIPI_DCS_WRITE_MEMORY_START, NULL, 0);
1018
1019 param = 0x00;
1020 rm68200_dcs_write(dev, MIPI_DCS_SET_TEAR_ON, ¶m, 1);
1021
1022 k_sleep(K_MSEC(200));
1023
1024 if (config->bl_gpio.port != NULL) {
1025 ret = gpio_pin_configure_dt(&config->bl_gpio, GPIO_OUTPUT_ACTIVE);
1026 if (ret < 0) {
1027 LOG_ERR("Could not configure bl GPIO (%d)", ret);
1028 return ret;
1029 }
1030 }
1031
1032 return 0;
1033 }
1034
1035 #define RM68200_PANEL(id) \
1036 static const struct rm68200_config rm68200_config_##id = { \
1037 .mipi_dsi = DEVICE_DT_GET(DT_INST_BUS(id)), \
1038 .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(id, reset_gpios, {0}), \
1039 .bl_gpio = GPIO_DT_SPEC_INST_GET_OR(id, bl_gpios, {0}), \
1040 .num_of_lanes = DT_INST_PROP_BY_IDX(id, data_lanes, 0), \
1041 .pixel_format = DT_INST_PROP(id, pixel_format), \
1042 .panel_width = DT_INST_PROP(id, width), \
1043 .panel_height = DT_INST_PROP(id, height), \
1044 .channel = DT_INST_REG_ADDR(id), \
1045 }; \
1046 DEVICE_DT_INST_DEFINE(id, \
1047 &rm68200_init, \
1048 NULL, \
1049 NULL, \
1050 &rm68200_config_##id, \
1051 POST_KERNEL, \
1052 CONFIG_APPLICATION_INIT_PRIORITY, \
1053 &rm68200_api);
1054
1055 DT_INST_FOREACH_STATUS_OKAY(RM68200_PANEL)
1056