drm/panel: simple: Add support for INNOLUX N125HCE-GPA 1920x1080 panel
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / panel / panel-simple.c
1 /*
2  * Copyright (C) 2013, NVIDIA Corporation.  All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sub license,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the
12  * next paragraph) shall be included in all copies or substantial portions
13  * of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23
24 #include <linux/backlight.h>
25 #include <linux/gpio/consumer.h>
26 #include <linux/module.h>
27 #include <linux/of_platform.h>
28 #include <linux/platform_device.h>
29 #include <linux/regulator/consumer.h>
30
31 #include <drm/drmP.h>
32 #include <drm/drm_crtc.h>
33 #include <drm/drm_mipi_dsi.h>
34 #include <drm/drm_panel.h>
35
36 #include <video/display_timing.h>
37 #include <video/of_display_timing.h>
38 #include <video/videomode.h>
39
40 struct panel_desc {
41         const struct drm_display_mode *modes;
42         unsigned int num_modes;
43         const struct display_timing *timings;
44         unsigned int num_timings;
45
46         unsigned int bpc;
47
48         struct {
49                 unsigned int width;
50                 unsigned int height;
51         } size;
52
53         /**
54          * @prepare: the time (in milliseconds) that it takes for the panel to
55          *           become ready and start receiving video data
56          * @enable: the time (in milliseconds) that it takes for the panel to
57          *          display the first valid frame after starting to receive
58          *          video data
59          * @disable: the time (in milliseconds) that it takes for the panel to
60          *           turn the display off (no content is visible)
61          * @unprepare: the time (in milliseconds) that it takes for the panel
62          *             to power itself down completely
63          */
64         struct {
65                 unsigned int prepare;
66                 unsigned int enable;
67                 unsigned int disable;
68                 unsigned int unprepare;
69         } delay;
70
71         u32 bus_format;
72 };
73
74 struct panel_simple {
75         struct drm_panel base;
76         bool prepared;
77         bool enabled;
78
79         struct device *dev;
80         const struct panel_desc *desc;
81
82         struct backlight_device *backlight;
83         struct regulator *supply;
84         struct i2c_adapter *ddc;
85
86         struct gpio_desc *enable_gpio;
87 };
88
89 static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
90 {
91         return container_of(panel, struct panel_simple, base);
92 }
93
94 static int panel_simple_get_fixed_modes(struct panel_simple *panel)
95 {
96         struct drm_connector *connector = panel->base.connector;
97         struct drm_device *drm = panel->base.drm;
98         struct drm_display_mode *mode;
99         unsigned int i, num = 0;
100
101         if (!panel->desc)
102                 return 0;
103
104         for (i = 0; i < panel->desc->num_timings; i++) {
105                 const struct display_timing *dt = &panel->desc->timings[i];
106                 struct videomode vm;
107
108                 videomode_from_timing(dt, &vm);
109                 mode = drm_mode_create(drm);
110                 if (!mode) {
111                         dev_err(drm->dev, "failed to add mode %ux%u\n",
112                                 dt->hactive.typ, dt->vactive.typ);
113                         continue;
114                 }
115
116                 drm_display_mode_from_videomode(&vm, mode);
117                 drm_mode_set_name(mode);
118
119                 drm_mode_probed_add(connector, mode);
120                 num++;
121         }
122
123         for (i = 0; i < panel->desc->num_modes; i++) {
124                 const struct drm_display_mode *m = &panel->desc->modes[i];
125
126                 mode = drm_mode_duplicate(drm, m);
127                 if (!mode) {
128                         dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
129                                 m->hdisplay, m->vdisplay, m->vrefresh);
130                         continue;
131                 }
132
133                 drm_mode_set_name(mode);
134
135                 drm_mode_probed_add(connector, mode);
136                 num++;
137         }
138
139         connector->display_info.bpc = panel->desc->bpc;
140         connector->display_info.width_mm = panel->desc->size.width;
141         connector->display_info.height_mm = panel->desc->size.height;
142         if (panel->desc->bus_format)
143                 drm_display_info_set_bus_formats(&connector->display_info,
144                                                  &panel->desc->bus_format, 1);
145
146         return num;
147 }
148
149 static int panel_simple_of_get_native_mode(struct panel_simple *panel)
150 {
151         struct drm_connector *connector = panel->base.connector;
152         struct drm_device *drm = panel->base.drm;
153         struct drm_display_mode *mode;
154         struct device_node *timings_np;
155         int ret;
156
157         timings_np = of_get_child_by_name(panel->dev->of_node,
158                                           "display-timings");
159         if (!timings_np) {
160                 dev_dbg(panel->dev, "failed to find display-timings node\n");
161                 return 0;
162         }
163
164         of_node_put(timings_np);
165         mode = drm_mode_create(drm);
166         if (!mode)
167                 return 0;
168
169         ret = of_get_drm_display_mode(panel->dev->of_node, mode,
170                                       OF_USE_NATIVE_MODE);
171         if (ret) {
172                 dev_dbg(panel->dev, "failed to find dts display timings\n");
173                 drm_mode_destroy(drm, mode);
174                 return 0;
175         }
176
177         drm_mode_set_name(mode);
178         mode->type |= DRM_MODE_TYPE_PREFERRED;
179         drm_mode_probed_add(connector, mode);
180
181         return 1;
182 }
183
184 static int panel_simple_disable(struct drm_panel *panel)
185 {
186         struct panel_simple *p = to_panel_simple(panel);
187
188         if (!p->enabled)
189                 return 0;
190
191         if (p->backlight) {
192                 p->backlight->props.power = FB_BLANK_POWERDOWN;
193                 backlight_update_status(p->backlight);
194         }
195
196         if (p->desc && p->desc->delay.disable)
197                 msleep(p->desc->delay.disable);
198
199         p->enabled = false;
200
201         return 0;
202 }
203
204 static int panel_simple_unprepare(struct drm_panel *panel)
205 {
206         struct panel_simple *p = to_panel_simple(panel);
207
208         if (!p->prepared)
209                 return 0;
210
211         if (p->enable_gpio)
212                 gpiod_direction_output(p->enable_gpio, 0);
213
214         regulator_disable(p->supply);
215
216         if (p->desc && p->desc->delay.unprepare)
217                 msleep(p->desc->delay.unprepare);
218
219         p->prepared = false;
220
221         return 0;
222 }
223
224 static int panel_simple_prepare(struct drm_panel *panel)
225 {
226         struct panel_simple *p = to_panel_simple(panel);
227         int err;
228
229         if (p->prepared)
230                 return 0;
231
232         err = regulator_enable(p->supply);
233         if (err < 0) {
234                 dev_err(panel->dev, "failed to enable supply: %d\n", err);
235                 return err;
236         }
237
238         if (p->enable_gpio)
239                 gpiod_direction_output(p->enable_gpio, 1);
240
241         if (p->desc && p->desc->delay.prepare)
242                 msleep(p->desc->delay.prepare);
243
244         p->prepared = true;
245
246         return 0;
247 }
248
249 static int panel_simple_enable(struct drm_panel *panel)
250 {
251         struct panel_simple *p = to_panel_simple(panel);
252
253         if (p->enabled)
254                 return 0;
255
256         if (p->desc && p->desc->delay.enable)
257                 msleep(p->desc->delay.enable);
258
259         if (p->backlight) {
260                 p->backlight->props.power = FB_BLANK_UNBLANK;
261                 backlight_update_status(p->backlight);
262         }
263
264         p->enabled = true;
265
266         return 0;
267 }
268
269 static int panel_simple_get_modes(struct drm_panel *panel)
270 {
271         struct panel_simple *p = to_panel_simple(panel);
272         int num = 0;
273
274         /* probe EDID if a DDC bus is available */
275         if (p->ddc) {
276                 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
277                 drm_mode_connector_update_edid_property(panel->connector, edid);
278                 if (edid) {
279                         num += drm_add_edid_modes(panel->connector, edid);
280                         kfree(edid);
281                 }
282         }
283
284         /* add hard-coded panel modes */
285         num += panel_simple_get_fixed_modes(p);
286
287         /* add device node plane modes */
288         num += panel_simple_of_get_native_mode(p);
289
290         return num;
291 }
292
293 static int panel_simple_get_timings(struct drm_panel *panel,
294                                     unsigned int num_timings,
295                                     struct display_timing *timings)
296 {
297         struct panel_simple *p = to_panel_simple(panel);
298         unsigned int i;
299
300         if (!p->desc)
301                 return 0;
302
303         if (p->desc->num_timings < num_timings)
304                 num_timings = p->desc->num_timings;
305
306         if (timings)
307                 for (i = 0; i < num_timings; i++)
308                         timings[i] = p->desc->timings[i];
309
310         return p->desc->num_timings;
311 }
312
313 static const struct drm_panel_funcs panel_simple_funcs = {
314         .disable = panel_simple_disable,
315         .unprepare = panel_simple_unprepare,
316         .prepare = panel_simple_prepare,
317         .enable = panel_simple_enable,
318         .get_modes = panel_simple_get_modes,
319         .get_timings = panel_simple_get_timings,
320 };
321
322 static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
323 {
324         struct device_node *backlight, *ddc;
325         struct panel_simple *panel;
326         int err;
327
328         panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
329         if (!panel)
330                 return -ENOMEM;
331
332         panel->enabled = false;
333         panel->prepared = false;
334         panel->desc = desc;
335         panel->dev = dev;
336
337         panel->supply = devm_regulator_get(dev, "power");
338         if (IS_ERR(panel->supply))
339                 return PTR_ERR(panel->supply);
340
341         panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", 0);
342         if (IS_ERR(panel->enable_gpio)) {
343                 err = PTR_ERR(panel->enable_gpio);
344                 dev_err(dev, "failed to request GPIO: %d\n", err);
345                 return err;
346         }
347
348         backlight = of_parse_phandle(dev->of_node, "backlight", 0);
349         if (backlight) {
350                 panel->backlight = of_find_backlight_by_node(backlight);
351                 of_node_put(backlight);
352
353                 if (!panel->backlight)
354                         return -EPROBE_DEFER;
355         }
356
357         ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
358         if (ddc) {
359                 panel->ddc = of_find_i2c_adapter_by_node(ddc);
360                 of_node_put(ddc);
361
362                 if (!panel->ddc) {
363                         err = -EPROBE_DEFER;
364                         goto free_backlight;
365                 }
366         }
367
368         drm_panel_init(&panel->base);
369         panel->base.dev = dev;
370         panel->base.funcs = &panel_simple_funcs;
371
372         err = drm_panel_add(&panel->base);
373         if (err < 0)
374                 goto free_ddc;
375
376         dev_set_drvdata(dev, panel);
377
378         return 0;
379
380 free_ddc:
381         if (panel->ddc)
382                 put_device(&panel->ddc->dev);
383 free_backlight:
384         if (panel->backlight)
385                 put_device(&panel->backlight->dev);
386
387         return err;
388 }
389
390 static int panel_simple_remove(struct device *dev)
391 {
392         struct panel_simple *panel = dev_get_drvdata(dev);
393
394         drm_panel_detach(&panel->base);
395         drm_panel_remove(&panel->base);
396
397         panel_simple_disable(&panel->base);
398
399         if (panel->ddc)
400                 put_device(&panel->ddc->dev);
401
402         if (panel->backlight)
403                 put_device(&panel->backlight->dev);
404
405         return 0;
406 }
407
408 static void panel_simple_shutdown(struct device *dev)
409 {
410         struct panel_simple *panel = dev_get_drvdata(dev);
411
412         panel_simple_disable(&panel->base);
413 }
414
415 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
416         .clock = 33333,
417         .hdisplay = 800,
418         .hsync_start = 800 + 0,
419         .hsync_end = 800 + 0 + 255,
420         .htotal = 800 + 0 + 255 + 0,
421         .vdisplay = 480,
422         .vsync_start = 480 + 2,
423         .vsync_end = 480 + 2 + 45,
424         .vtotal = 480 + 2 + 45 + 0,
425         .vrefresh = 60,
426         .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
427 };
428
429 static const struct panel_desc ampire_am800480r3tmqwa1h = {
430         .modes = &ampire_am800480r3tmqwa1h_mode,
431         .num_modes = 1,
432         .bpc = 6,
433         .size = {
434                 .width = 152,
435                 .height = 91,
436         },
437         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
438 };
439
440 static const struct drm_display_mode auo_b101aw03_mode = {
441         .clock = 51450,
442         .hdisplay = 1024,
443         .hsync_start = 1024 + 156,
444         .hsync_end = 1024 + 156 + 8,
445         .htotal = 1024 + 156 + 8 + 156,
446         .vdisplay = 600,
447         .vsync_start = 600 + 16,
448         .vsync_end = 600 + 16 + 6,
449         .vtotal = 600 + 16 + 6 + 16,
450         .vrefresh = 60,
451 };
452
453 static const struct panel_desc auo_b101aw03 = {
454         .modes = &auo_b101aw03_mode,
455         .num_modes = 1,
456         .bpc = 6,
457         .size = {
458                 .width = 223,
459                 .height = 125,
460         },
461 };
462
463 static const struct drm_display_mode auo_b101ean01_mode = {
464         .clock = 72500,
465         .hdisplay = 1280,
466         .hsync_start = 1280 + 119,
467         .hsync_end = 1280 + 119 + 32,
468         .htotal = 1280 + 119 + 32 + 21,
469         .vdisplay = 800,
470         .vsync_start = 800 + 4,
471         .vsync_end = 800 + 4 + 20,
472         .vtotal = 800 + 4 + 20 + 8,
473         .vrefresh = 60,
474 };
475
476 static const struct panel_desc auo_b101ean01 = {
477         .modes = &auo_b101ean01_mode,
478         .num_modes = 1,
479         .bpc = 6,
480         .size = {
481                 .width = 217,
482                 .height = 136,
483         },
484 };
485
486 static const struct drm_display_mode auo_b101ew05_mode = {
487         .clock = 71000,
488         .hdisplay = 1280,
489         .hsync_start = 1280 + 18,
490         .hsync_end = 1280 + 18 + 10,
491         .htotal = 1280 + 18 + 10 + 100,
492         .vdisplay = 800,
493         .vsync_start = 800 + 6,
494         .vsync_end = 800 + 6 + 2,
495         .vtotal = 800 + 6 + 2 + 8,
496         .vrefresh = 60,
497 };
498
499 static const struct panel_desc auo_b101ew05 = {
500         .modes = &auo_b101ew05_mode,
501         .num_modes = 1,
502         .bpc = 6,
503         .size = {
504                 .width = 217,
505                 .height = 136,
506         },
507 };
508
509 static const struct drm_display_mode auo_b101xtn01_mode = {
510         .clock = 72000,
511         .hdisplay = 1366,
512         .hsync_start = 1366 + 20,
513         .hsync_end = 1366 + 20 + 70,
514         .htotal = 1366 + 20 + 70,
515         .vdisplay = 768,
516         .vsync_start = 768 + 14,
517         .vsync_end = 768 + 14 + 42,
518         .vtotal = 768 + 14 + 42,
519         .vrefresh = 60,
520         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
521 };
522
523 static const struct panel_desc auo_b101xtn01 = {
524         .modes = &auo_b101xtn01_mode,
525         .num_modes = 1,
526         .bpc = 6,
527         .size = {
528                 .width = 223,
529                 .height = 125,
530         },
531 };
532
533 static const struct drm_display_mode auo_b116xw03_mode = {
534         .clock = 70589,
535         .hdisplay = 1366,
536         .hsync_start = 1366 + 40,
537         .hsync_end = 1366 + 40 + 40,
538         .htotal = 1366 + 40 + 40 + 32,
539         .vdisplay = 768,
540         .vsync_start = 768 + 10,
541         .vsync_end = 768 + 10 + 12,
542         .vtotal = 768 + 10 + 12 + 6,
543         .vrefresh = 60,
544 };
545
546 static const struct panel_desc auo_b116xw03 = {
547         .modes = &auo_b116xw03_mode,
548         .num_modes = 1,
549         .bpc = 6,
550         .size = {
551                 .width = 256,
552                 .height = 144,
553         },
554 };
555
556 static const struct drm_display_mode auo_b125han03_mode = {
557         .clock = 141000,
558         .hdisplay = 1920,
559         .hsync_start = 1920 + 88,
560         .hsync_end = 1920 + 88 + 60,
561         .htotal = 1920 + 88 + 60 + 36,
562         .vdisplay = 1080,
563         .vsync_start = 1080 + 12,
564         .vsync_end = 1080 + 12 + 4,
565         .vtotal = 1080 + 12 + 4 + 20,
566         .vrefresh = 60,
567         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
568 };
569
570 static const struct panel_desc auo_b125han03 = {
571         .modes = &auo_b125han03_mode,
572         .num_modes = 1,
573         .bpc = 6,
574         .size = {
575                 .width = 276,
576                 .height = 156,
577         },
578         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
579 };
580
581 static const struct drm_display_mode auo_b133xtn01_mode = {
582         .clock = 69500,
583         .hdisplay = 1366,
584         .hsync_start = 1366 + 48,
585         .hsync_end = 1366 + 48 + 32,
586         .htotal = 1366 + 48 + 32 + 20,
587         .vdisplay = 768,
588         .vsync_start = 768 + 3,
589         .vsync_end = 768 + 3 + 6,
590         .vtotal = 768 + 3 + 6 + 13,
591         .vrefresh = 60,
592 };
593
594 static const struct panel_desc auo_b133xtn01 = {
595         .modes = &auo_b133xtn01_mode,
596         .num_modes = 1,
597         .bpc = 6,
598         .size = {
599                 .width = 293,
600                 .height = 165,
601         },
602 };
603
604 static const struct drm_display_mode auo_b133htn01_mode = {
605         .clock = 150660,
606         .hdisplay = 1920,
607         .hsync_start = 1920 + 172,
608         .hsync_end = 1920 + 172 + 80,
609         .htotal = 1920 + 172 + 80 + 60,
610         .vdisplay = 1080,
611         .vsync_start = 1080 + 25,
612         .vsync_end = 1080 + 25 + 10,
613         .vtotal = 1080 + 25 + 10 + 10,
614         .vrefresh = 60,
615 };
616
617 static const struct panel_desc auo_b133htn01 = {
618         .modes = &auo_b133htn01_mode,
619         .num_modes = 1,
620         .bpc = 6,
621         .size = {
622                 .width = 293,
623                 .height = 165,
624         },
625         .delay = {
626                 .prepare = 105,
627                 .enable = 20,
628                 .unprepare = 50,
629         },
630 };
631
632 static const struct drm_display_mode avic_tm070ddh03_mode = {
633         .clock = 51200,
634         .hdisplay = 1024,
635         .hsync_start = 1024 + 160,
636         .hsync_end = 1024 + 160 + 4,
637         .htotal = 1024 + 160 + 4 + 156,
638         .vdisplay = 600,
639         .vsync_start = 600 + 17,
640         .vsync_end = 600 + 17 + 1,
641         .vtotal = 600 + 17 + 1 + 17,
642         .vrefresh = 60,
643 };
644
645 static const struct panel_desc avic_tm070ddh03 = {
646         .modes = &avic_tm070ddh03_mode,
647         .num_modes = 1,
648         .bpc = 8,
649         .size = {
650                 .width = 154,
651                 .height = 90,
652         },
653         .delay = {
654                 .prepare = 20,
655                 .enable = 200,
656                 .disable = 200,
657         },
658 };
659
660 static const struct drm_display_mode boe_nv125fhm_n73_mode = {
661         .clock = 72300,
662         .hdisplay = 1366,
663         .hsync_start = 1366 + 80,
664         .hsync_end = 1366 + 80 + 20,
665         .htotal = 1366 + 80 + 20 + 60,
666         .vdisplay = 768,
667         .vsync_start = 768 + 12,
668         .vsync_end = 768 + 12 + 2,
669         .vtotal = 768 + 12 + 2 + 8,
670         .vrefresh = 60,
671         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
672 };
673
674 static const struct panel_desc boe_nv125fhm_n73 = {
675         .modes = &boe_nv125fhm_n73_mode,
676         .num_modes = 1,
677         .bpc = 6,
678         .size = {
679                 .width = 276,
680                 .height = 156,
681         },
682         .delay = {
683                 .unprepare = 160,
684         },
685         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
686 };
687
688 static const struct drm_display_mode chunghwa_claa070wp03xg_mode = {
689         .clock = 67000,
690         .hdisplay = 800,
691         .hsync_start = 800 + 24,
692         .hsync_end = 800 + 24 + 16,
693         .htotal = 800 + 24 + 16 + 24,
694         .vdisplay = 1280,
695         .vsync_start = 1280 + 2,
696         .vsync_end = 1280 + 2 + 2,
697         .vtotal = 1280 + 2 + 2 + 4,
698         .vrefresh = 60,
699 };
700
701 static const struct panel_desc chunghwa_claa070wp03xg = {
702         .modes = &chunghwa_claa070wp03xg_mode,
703         .num_modes = 1,
704         .bpc = 6,
705         .size = {
706                 .width = 94,
707                 .height = 151,
708         },
709 };
710
711 static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
712         .clock = 72070,
713         .hdisplay = 1366,
714         .hsync_start = 1366 + 58,
715         .hsync_end = 1366 + 58 + 58,
716         .htotal = 1366 + 58 + 58 + 58,
717         .vdisplay = 768,
718         .vsync_start = 768 + 4,
719         .vsync_end = 768 + 4 + 4,
720         .vtotal = 768 + 4 + 4 + 4,
721         .vrefresh = 60,
722 };
723
724 static const struct panel_desc chunghwa_claa101wa01a = {
725         .modes = &chunghwa_claa101wa01a_mode,
726         .num_modes = 1,
727         .bpc = 6,
728         .size = {
729                 .width = 220,
730                 .height = 120,
731         },
732 };
733
734 static const struct drm_display_mode chunghwa_claa101wb01_mode = {
735         .clock = 69300,
736         .hdisplay = 1366,
737         .hsync_start = 1366 + 48,
738         .hsync_end = 1366 + 48 + 32,
739         .htotal = 1366 + 48 + 32 + 20,
740         .vdisplay = 768,
741         .vsync_start = 768 + 16,
742         .vsync_end = 768 + 16 + 8,
743         .vtotal = 768 + 16 + 8 + 16,
744         .vrefresh = 60,
745 };
746
747 static const struct panel_desc chunghwa_claa101wb01 = {
748         .modes = &chunghwa_claa101wb01_mode,
749         .num_modes = 1,
750         .bpc = 6,
751         .size = {
752                 .width = 223,
753                 .height = 125,
754         },
755 };
756
757 static const struct drm_display_mode edt_et057090dhu_mode = {
758         .clock = 25175,
759         .hdisplay = 640,
760         .hsync_start = 640 + 16,
761         .hsync_end = 640 + 16 + 30,
762         .htotal = 640 + 16 + 30 + 114,
763         .vdisplay = 480,
764         .vsync_start = 480 + 10,
765         .vsync_end = 480 + 10 + 3,
766         .vtotal = 480 + 10 + 3 + 32,
767         .vrefresh = 60,
768         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
769 };
770
771 static const struct panel_desc edt_et057090dhu = {
772         .modes = &edt_et057090dhu_mode,
773         .num_modes = 1,
774         .bpc = 6,
775         .size = {
776                 .width = 115,
777                 .height = 86,
778         },
779 };
780
781 static const struct drm_display_mode edt_etm0700g0dh6_mode = {
782         .clock = 33260,
783         .hdisplay = 800,
784         .hsync_start = 800 + 40,
785         .hsync_end = 800 + 40 + 128,
786         .htotal = 800 + 40 + 128 + 88,
787         .vdisplay = 480,
788         .vsync_start = 480 + 10,
789         .vsync_end = 480 + 10 + 2,
790         .vtotal = 480 + 10 + 2 + 33,
791         .vrefresh = 60,
792         .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
793 };
794
795 static const struct panel_desc edt_etm0700g0dh6 = {
796         .modes = &edt_etm0700g0dh6_mode,
797         .num_modes = 1,
798         .bpc = 6,
799         .size = {
800                 .width = 152,
801                 .height = 91,
802         },
803 };
804
805 static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
806         .clock = 32260,
807         .hdisplay = 800,
808         .hsync_start = 800 + 168,
809         .hsync_end = 800 + 168 + 64,
810         .htotal = 800 + 168 + 64 + 88,
811         .vdisplay = 480,
812         .vsync_start = 480 + 37,
813         .vsync_end = 480 + 37 + 2,
814         .vtotal = 480 + 37 + 2 + 8,
815         .vrefresh = 60,
816 };
817
818 static const struct panel_desc foxlink_fl500wvr00_a0t = {
819         .modes = &foxlink_fl500wvr00_a0t_mode,
820         .num_modes = 1,
821         .bpc = 8,
822         .size = {
823                 .width = 108,
824                 .height = 65,
825         },
826         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
827 };
828
829 static const struct drm_display_mode giantplus_gpg482739qs5_mode = {
830         .clock = 9000,
831         .hdisplay = 480,
832         .hsync_start = 480 + 5,
833         .hsync_end = 480 + 5 + 1,
834         .htotal = 480 + 5 + 1 + 40,
835         .vdisplay = 272,
836         .vsync_start = 272 + 8,
837         .vsync_end = 272 + 8 + 1,
838         .vtotal = 272 + 8 + 1 + 8,
839         .vrefresh = 60,
840 };
841
842 static const struct panel_desc giantplus_gpg482739qs5 = {
843         .modes = &giantplus_gpg482739qs5_mode,
844         .num_modes = 1,
845         .bpc = 8,
846         .size = {
847                 .width = 95,
848                 .height = 54,
849         },
850         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
851 };
852
853 static const struct display_timing hannstar_hsd070pww1_timing = {
854         .pixelclock = { 64300000, 71100000, 82000000 },
855         .hactive = { 1280, 1280, 1280 },
856         .hfront_porch = { 1, 1, 10 },
857         .hback_porch = { 1, 1, 10 },
858         /*
859          * According to the data sheet, the minimum horizontal blanking interval
860          * is 54 clocks (1 + 52 + 1), but tests with a Nitrogen6X have shown the
861          * minimum working horizontal blanking interval to be 60 clocks.
862          */
863         .hsync_len = { 58, 158, 661 },
864         .vactive = { 800, 800, 800 },
865         .vfront_porch = { 1, 1, 10 },
866         .vback_porch = { 1, 1, 10 },
867         .vsync_len = { 1, 21, 203 },
868         .flags = DISPLAY_FLAGS_DE_HIGH,
869 };
870
871 static const struct panel_desc hannstar_hsd070pww1 = {
872         .timings = &hannstar_hsd070pww1_timing,
873         .num_timings = 1,
874         .bpc = 6,
875         .size = {
876                 .width = 151,
877                 .height = 94,
878         },
879         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
880 };
881
882 static const struct display_timing hannstar_hsd100pxn1_timing = {
883         .pixelclock = { 55000000, 65000000, 75000000 },
884         .hactive = { 1024, 1024, 1024 },
885         .hfront_porch = { 40, 40, 40 },
886         .hback_porch = { 220, 220, 220 },
887         .hsync_len = { 20, 60, 100 },
888         .vactive = { 768, 768, 768 },
889         .vfront_porch = { 7, 7, 7 },
890         .vback_porch = { 21, 21, 21 },
891         .vsync_len = { 10, 10, 10 },
892         .flags = DISPLAY_FLAGS_DE_HIGH,
893 };
894
895 static const struct panel_desc hannstar_hsd100pxn1 = {
896         .timings = &hannstar_hsd100pxn1_timing,
897         .num_timings = 1,
898         .bpc = 6,
899         .size = {
900                 .width = 203,
901                 .height = 152,
902         },
903         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
904 };
905
906 static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = {
907         .clock = 33333,
908         .hdisplay = 800,
909         .hsync_start = 800 + 85,
910         .hsync_end = 800 + 85 + 86,
911         .htotal = 800 + 85 + 86 + 85,
912         .vdisplay = 480,
913         .vsync_start = 480 + 16,
914         .vsync_end = 480 + 16 + 13,
915         .vtotal = 480 + 16 + 13 + 16,
916         .vrefresh = 60,
917 };
918
919 static const struct panel_desc hitachi_tx23d38vm0caa = {
920         .modes = &hitachi_tx23d38vm0caa_mode,
921         .num_modes = 1,
922         .bpc = 6,
923         .size = {
924                 .width = 195,
925                 .height = 117,
926         },
927 };
928
929 static const struct drm_display_mode innolux_at043tn24_mode = {
930         .clock = 9000,
931         .hdisplay = 480,
932         .hsync_start = 480 + 2,
933         .hsync_end = 480 + 2 + 41,
934         .htotal = 480 + 2 + 41 + 2,
935         .vdisplay = 272,
936         .vsync_start = 272 + 2,
937         .vsync_end = 272 + 2 + 11,
938         .vtotal = 272 + 2 + 11 + 2,
939         .vrefresh = 60,
940         .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
941 };
942
943 static const struct panel_desc innolux_at043tn24 = {
944         .modes = &innolux_at043tn24_mode,
945         .num_modes = 1,
946         .bpc = 8,
947         .size = {
948                 .width = 95,
949                 .height = 54,
950         },
951         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
952 };
953
954 static const struct drm_display_mode innolux_g121i1_l01_mode = {
955         .clock = 71000,
956         .hdisplay = 1280,
957         .hsync_start = 1280 + 64,
958         .hsync_end = 1280 + 64 + 32,
959         .htotal = 1280 + 64 + 32 + 64,
960         .vdisplay = 800,
961         .vsync_start = 800 + 9,
962         .vsync_end = 800 + 9 + 6,
963         .vtotal = 800 + 9 + 6 + 9,
964         .vrefresh = 60,
965 };
966
967 static const struct panel_desc innolux_g121i1_l01 = {
968         .modes = &innolux_g121i1_l01_mode,
969         .num_modes = 1,
970         .bpc = 6,
971         .size = {
972                 .width = 261,
973                 .height = 163,
974         },
975 };
976
977 static const struct drm_display_mode innolux_n116bge_mode = {
978         .clock = 76420,
979         .hdisplay = 1366,
980         .hsync_start = 1366 + 136,
981         .hsync_end = 1366 + 136 + 30,
982         .htotal = 1366 + 136 + 30 + 60,
983         .vdisplay = 768,
984         .vsync_start = 768 + 8,
985         .vsync_end = 768 + 8 + 12,
986         .vtotal = 768 + 8 + 12 + 12,
987         .vrefresh = 60,
988         .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
989 };
990
991 static const struct panel_desc innolux_n116bge = {
992         .modes = &innolux_n116bge_mode,
993         .num_modes = 1,
994         .bpc = 6,
995         .size = {
996                 .width = 256,
997                 .height = 144,
998         },
999 };
1000
1001 static const struct drm_display_mode innolux_n125hce_mode = {
1002         .clock = 138780,
1003         .hdisplay = 1920,
1004         .hsync_start = 1920 + 80,
1005         .hsync_end = 1920 + 80 + 30,
1006         .htotal = 1920 + 80 + 30 + 50,
1007         .vdisplay = 1080,
1008         .vsync_start = 1080 + 12,
1009         .vsync_end = 1080 + 12 + 4,
1010         .vtotal = 1080 + 12 + 4 + 16,
1011         .vrefresh = 60,
1012         .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
1013 };
1014
1015 static const struct panel_desc innolux_n125hce = {
1016         .modes = &innolux_n125hce_mode,
1017         .num_modes = 1,
1018         .bpc = 6,
1019         .size = {
1020                 .width = 283,
1021                 .height = 168,
1022         },
1023         .delay = {
1024                 .unprepare = 600,
1025                 .enable = 100,
1026         },
1027         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1028 };
1029
1030 static const struct drm_display_mode innolux_n156bge_l21_mode = {
1031         .clock = 69300,
1032         .hdisplay = 1366,
1033         .hsync_start = 1366 + 16,
1034         .hsync_end = 1366 + 16 + 34,
1035         .htotal = 1366 + 16 + 34 + 50,
1036         .vdisplay = 768,
1037         .vsync_start = 768 + 2,
1038         .vsync_end = 768 + 2 + 6,
1039         .vtotal = 768 + 2 + 6 + 12,
1040         .vrefresh = 60,
1041 };
1042
1043 static const struct panel_desc innolux_n156bge_l21 = {
1044         .modes = &innolux_n156bge_l21_mode,
1045         .num_modes = 1,
1046         .bpc = 6,
1047         .size = {
1048                 .width = 344,
1049                 .height = 193,
1050         },
1051 };
1052
1053 static const struct drm_display_mode innolux_zj070na_01p_mode = {
1054         .clock = 51501,
1055         .hdisplay = 1024,
1056         .hsync_start = 1024 + 128,
1057         .hsync_end = 1024 + 128 + 64,
1058         .htotal = 1024 + 128 + 64 + 128,
1059         .vdisplay = 600,
1060         .vsync_start = 600 + 16,
1061         .vsync_end = 600 + 16 + 4,
1062         .vtotal = 600 + 16 + 4 + 16,
1063         .vrefresh = 60,
1064 };
1065
1066 static const struct panel_desc innolux_zj070na_01p = {
1067         .modes = &innolux_zj070na_01p_mode,
1068         .num_modes = 1,
1069         .bpc = 6,
1070         .size = {
1071                 .width = 1024,
1072                 .height = 600,
1073         },
1074 };
1075
1076 static const struct drm_display_mode lg_lb070wv8_mode = {
1077         .clock = 33246,
1078         .hdisplay = 800,
1079         .hsync_start = 800 + 88,
1080         .hsync_end = 800 + 88 + 80,
1081         .htotal = 800 + 88 + 80 + 88,
1082         .vdisplay = 480,
1083         .vsync_start = 480 + 10,
1084         .vsync_end = 480 + 10 + 25,
1085         .vtotal = 480 + 10 + 25 + 10,
1086         .vrefresh = 60,
1087 };
1088
1089 static const struct panel_desc lg_lb070wv8 = {
1090         .modes = &lg_lb070wv8_mode,
1091         .num_modes = 1,
1092         .bpc = 16,
1093         .size = {
1094                 .width = 151,
1095                 .height = 91,
1096         },
1097         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1098 };
1099
1100 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1101         .clock = 200000,
1102         .hdisplay = 1536,
1103         .hsync_start = 1536 + 12,
1104         .hsync_end = 1536 + 12 + 16,
1105         .htotal = 1536 + 12 + 16 + 48,
1106         .vdisplay = 2048,
1107         .vsync_start = 2048 + 8,
1108         .vsync_end = 2048 + 8 + 4,
1109         .vtotal = 2048 + 8 + 4 + 8,
1110         .vrefresh = 60,
1111         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1112 };
1113
1114 static const struct panel_desc lg_lp079qx1_sp0v = {
1115         .modes = &lg_lp079qx1_sp0v_mode,
1116         .num_modes = 1,
1117         .size = {
1118                 .width = 129,
1119                 .height = 171,
1120         },
1121         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1122 };
1123
1124 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1125         .clock = 205210,
1126         .hdisplay = 2048,
1127         .hsync_start = 2048 + 150,
1128         .hsync_end = 2048 + 150 + 5,
1129         .htotal = 2048 + 150 + 5 + 5,
1130         .vdisplay = 1536,
1131         .vsync_start = 1536 + 3,
1132         .vsync_end = 1536 + 3 + 1,
1133         .vtotal = 1536 + 3 + 1 + 9,
1134         .vrefresh = 60,
1135 };
1136
1137 static const struct panel_desc lg_lp097qx1_spa1 = {
1138         .modes = &lg_lp097qx1_spa1_mode,
1139         .num_modes = 1,
1140         .size = {
1141                 .width = 320,
1142                 .height = 187,
1143         },
1144 };
1145
1146 static const struct drm_display_mode lg_lp129qe_mode = {
1147         .clock = 285250,
1148         .hdisplay = 2560,
1149         .hsync_start = 2560 + 48,
1150         .hsync_end = 2560 + 48 + 32,
1151         .htotal = 2560 + 48 + 32 + 80,
1152         .vdisplay = 1700,
1153         .vsync_start = 1700 + 3,
1154         .vsync_end = 1700 + 3 + 10,
1155         .vtotal = 1700 + 3 + 10 + 36,
1156         .vrefresh = 60,
1157 };
1158
1159 static const struct panel_desc lg_lp129qe = {
1160         .modes = &lg_lp129qe_mode,
1161         .num_modes = 1,
1162         .bpc = 8,
1163         .size = {
1164                 .width = 272,
1165                 .height = 181,
1166         },
1167 };
1168
1169 static const struct drm_display_mode nec_nl4827hc19_05b_mode = {
1170         .clock = 10870,
1171         .hdisplay = 480,
1172         .hsync_start = 480 + 2,
1173         .hsync_end = 480 + 2 + 41,
1174         .htotal = 480 + 2 + 41 + 2,
1175         .vdisplay = 272,
1176         .vsync_start = 272 + 2,
1177         .vsync_end = 272 + 2 + 4,
1178         .vtotal = 272 + 2 + 4 + 2,
1179         .vrefresh = 74,
1180 };
1181
1182 static const struct panel_desc nec_nl4827hc19_05b = {
1183         .modes = &nec_nl4827hc19_05b_mode,
1184         .num_modes = 1,
1185         .bpc = 8,
1186         .size = {
1187                 .width = 95,
1188                 .height = 54,
1189         },
1190         .bus_format = MEDIA_BUS_FMT_RGB888_1X24
1191 };
1192
1193 static const struct display_timing okaya_rs800480t_7x0gp_timing = {
1194         .pixelclock = { 30000000, 30000000, 40000000 },
1195         .hactive = { 800, 800, 800 },
1196         .hfront_porch = { 40, 40, 40 },
1197         .hback_porch = { 40, 40, 40 },
1198         .hsync_len = { 1, 48, 48 },
1199         .vactive = { 480, 480, 480 },
1200         .vfront_porch = { 13, 13, 13 },
1201         .vback_porch = { 29, 29, 29 },
1202         .vsync_len = { 3, 3, 3 },
1203         .flags = DISPLAY_FLAGS_DE_HIGH,
1204 };
1205
1206 static const struct panel_desc okaya_rs800480t_7x0gp = {
1207         .timings = &okaya_rs800480t_7x0gp_timing,
1208         .num_timings = 1,
1209         .bpc = 6,
1210         .size = {
1211                 .width = 154,
1212                 .height = 87,
1213         },
1214         .delay = {
1215                 .prepare = 41,
1216                 .enable = 50,
1217                 .unprepare = 41,
1218                 .disable = 50,
1219         },
1220         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1221 };
1222
1223 static const struct drm_display_mode ortustech_com43h4m85ulc_mode  = {
1224         .clock = 25000,
1225         .hdisplay = 480,
1226         .hsync_start = 480 + 10,
1227         .hsync_end = 480 + 10 + 10,
1228         .htotal = 480 + 10 + 10 + 15,
1229         .vdisplay = 800,
1230         .vsync_start = 800 + 3,
1231         .vsync_end = 800 + 3 + 3,
1232         .vtotal = 800 + 3 + 3 + 3,
1233         .vrefresh = 60,
1234 };
1235
1236 static const struct panel_desc ortustech_com43h4m85ulc = {
1237         .modes = &ortustech_com43h4m85ulc_mode,
1238         .num_modes = 1,
1239         .bpc = 8,
1240         .size = {
1241                 .width = 56,
1242                 .height = 93,
1243         },
1244         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1245 };
1246
1247 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1248         .clock = 271560,
1249         .hdisplay = 2560,
1250         .hsync_start = 2560 + 48,
1251         .hsync_end = 2560 + 48 + 32,
1252         .htotal = 2560 + 48 + 32 + 80,
1253         .vdisplay = 1600,
1254         .vsync_start = 1600 + 2,
1255         .vsync_end = 1600 + 2 + 5,
1256         .vtotal = 1600 + 2 + 5 + 57,
1257         .vrefresh = 60,
1258 };
1259
1260 static const struct panel_desc samsung_lsn122dl01_c01 = {
1261         .modes = &samsung_lsn122dl01_c01_mode,
1262         .num_modes = 1,
1263         .size = {
1264                 .width = 2560,
1265                 .height = 1600,
1266         },
1267 };
1268
1269 static const struct drm_display_mode samsung_ltn101nt05_mode = {
1270         .clock = 54030,
1271         .hdisplay = 1024,
1272         .hsync_start = 1024 + 24,
1273         .hsync_end = 1024 + 24 + 136,
1274         .htotal = 1024 + 24 + 136 + 160,
1275         .vdisplay = 600,
1276         .vsync_start = 600 + 3,
1277         .vsync_end = 600 + 3 + 6,
1278         .vtotal = 600 + 3 + 6 + 61,
1279         .vrefresh = 60,
1280 };
1281
1282 static const struct panel_desc samsung_ltn101nt05 = {
1283         .modes = &samsung_ltn101nt05_mode,
1284         .num_modes = 1,
1285         .bpc = 6,
1286         .size = {
1287                 .width = 1024,
1288                 .height = 600,
1289         },
1290 };
1291
1292 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1293         .clock = 76300,
1294         .hdisplay = 1366,
1295         .hsync_start = 1366 + 64,
1296         .hsync_end = 1366 + 64 + 48,
1297         .htotal = 1366 + 64 + 48 + 128,
1298         .vdisplay = 768,
1299         .vsync_start = 768 + 2,
1300         .vsync_end = 768 + 2 + 5,
1301         .vtotal = 768 + 2 + 5 + 17,
1302         .vrefresh = 60,
1303 };
1304
1305 static const struct panel_desc samsung_ltn140at29_301 = {
1306         .modes = &samsung_ltn140at29_301_mode,
1307         .num_modes = 1,
1308         .bpc = 6,
1309         .size = {
1310                 .width = 320,
1311                 .height = 187,
1312         },
1313 };
1314
1315 static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode = {
1316         .clock = 33300,
1317         .hdisplay = 800,
1318         .hsync_start = 800 + 1,
1319         .hsync_end = 800 + 1 + 64,
1320         .htotal = 800 + 1 + 64 + 64,
1321         .vdisplay = 480,
1322         .vsync_start = 480 + 1,
1323         .vsync_end = 480 + 1 + 23,
1324         .vtotal = 480 + 1 + 23 + 22,
1325         .vrefresh = 60,
1326 };
1327
1328 static const struct panel_desc shelly_sca07010_bfn_lnn = {
1329         .modes = &shelly_sca07010_bfn_lnn_mode,
1330         .num_modes = 1,
1331         .size = {
1332                 .width = 152,
1333                 .height = 91,
1334         },
1335         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1336 };
1337
1338 static const struct of_device_id platform_of_match[] = {
1339         {
1340                 .compatible = "simple-panel",
1341                 .data = NULL,
1342         }, {
1343                 .compatible = "ampire,am800480r3tmqwa1h",
1344                 .data = &ampire_am800480r3tmqwa1h,
1345         }, {
1346                 .compatible = "auo,b101aw03",
1347                 .data = &auo_b101aw03,
1348         }, {
1349                 .compatible = "auo,b101ean01",
1350                 .data = &auo_b101ean01,
1351         }, {
1352                 .compatible = "auo,b101ew05",
1353                 .data = &auo_b101ew05,
1354         }, {
1355                 .compatible = "auo,b101xtn01",
1356                 .data = &auo_b101xtn01,
1357         }, {
1358                 .compatible = "auo,b116xw03",
1359                 .data = &auo_b116xw03,
1360         }, {
1361                 .compatible = "auo,b125han03",
1362                 .data = &auo_b125han03,
1363         }, {
1364                 .compatible = "auo,b133htn01",
1365                 .data = &auo_b133htn01,
1366         }, {
1367                 .compatible = "auo,b133xtn01",
1368                 .data = &auo_b133xtn01,
1369         }, {
1370                 .compatible = "avic,tm070ddh03",
1371                 .data = &avic_tm070ddh03,
1372         }, {
1373                 .compatible = "boe,nv125fhm-n73",
1374                 .data = &boe_nv125fhm_n73,
1375         }, {
1376                 .compatible = "chunghwa,claa070wp03xg",
1377                 .data = &chunghwa_claa070wp03xg,
1378         }, {
1379                 .compatible = "chunghwa,claa101wa01a",
1380                 .data = &chunghwa_claa101wa01a
1381         }, {
1382                 .compatible = "chunghwa,claa101wb01",
1383                 .data = &chunghwa_claa101wb01
1384         }, {
1385                 .compatible = "edt,et057090dhu",
1386                 .data = &edt_et057090dhu,
1387         }, {
1388                 .compatible = "edt,et070080dh6",
1389                 .data = &edt_etm0700g0dh6,
1390         }, {
1391                 .compatible = "edt,etm0700g0dh6",
1392                 .data = &edt_etm0700g0dh6,
1393         }, {
1394                 .compatible = "foxlink,fl500wvr00-a0t",
1395                 .data = &foxlink_fl500wvr00_a0t,
1396         }, {
1397                 .compatible = "giantplus,gpg482739qs5",
1398                 .data = &giantplus_gpg482739qs5
1399         }, {
1400                 .compatible = "hannstar,hsd070pww1",
1401                 .data = &hannstar_hsd070pww1,
1402         }, {
1403                 .compatible = "hannstar,hsd100pxn1",
1404                 .data = &hannstar_hsd100pxn1,
1405         }, {
1406                 .compatible = "hit,tx23d38vm0caa",
1407                 .data = &hitachi_tx23d38vm0caa
1408         }, {
1409                 .compatible = "innolux,at043tn24",
1410                 .data = &innolux_at043tn24,
1411         }, {
1412                 .compatible ="innolux,g121i1-l01",
1413                 .data = &innolux_g121i1_l01
1414         }, {
1415                 .compatible = "innolux,n116bge",
1416                 .data = &innolux_n116bge,
1417         }, {
1418                 .compatible = "innolux,n125hce",
1419                 .data = &innolux_n125hce,
1420         }, {
1421                 .compatible = "innolux,n156bge-l21",
1422                 .data = &innolux_n156bge_l21,
1423         }, {
1424                 .compatible = "innolux,zj070na-01p",
1425                 .data = &innolux_zj070na_01p,
1426         }, {
1427                 .compatible = "lg,lb070wv8",
1428                 .data = &lg_lb070wv8,
1429         }, {
1430                 .compatible = "lg,lp079qx1-sp0v",
1431                 .data = &lg_lp079qx1_sp0v,
1432         }, {
1433                 .compatible = "lg,lp097qx1-spa1",
1434                 .data = &lg_lp097qx1_spa1,
1435         }, {
1436                 .compatible = "lg,lp129qe",
1437                 .data = &lg_lp129qe,
1438         }, {
1439                 .compatible = "nec,nl4827hc19-05b",
1440                 .data = &nec_nl4827hc19_05b,
1441         }, {
1442                 .compatible = "okaya,rs800480t-7x0gp",
1443                 .data = &okaya_rs800480t_7x0gp,
1444         }, {
1445                 .compatible = "ortustech,com43h4m85ulc",
1446                 .data = &ortustech_com43h4m85ulc,
1447         }, {
1448                 .compatible = "samsung,lsn122dl01-c01",
1449                 .data = &samsung_lsn122dl01_c01,
1450         }, {
1451                 .compatible = "samsung,ltn101nt05",
1452                 .data = &samsung_ltn101nt05,
1453         }, {
1454                 .compatible = "samsung,ltn140at29-301",
1455                 .data = &samsung_ltn140at29_301,
1456         }, {
1457                 .compatible = "shelly,sca07010-bfn-lnn",
1458                 .data = &shelly_sca07010_bfn_lnn,
1459         }, {
1460                 /* sentinel */
1461         }
1462 };
1463 MODULE_DEVICE_TABLE(of, platform_of_match);
1464
1465 static int panel_simple_platform_probe(struct platform_device *pdev)
1466 {
1467         const struct of_device_id *id;
1468
1469         id = of_match_node(platform_of_match, pdev->dev.of_node);
1470         if (!id)
1471                 return -ENODEV;
1472
1473         return panel_simple_probe(&pdev->dev, id->data);
1474 }
1475
1476 static int panel_simple_platform_remove(struct platform_device *pdev)
1477 {
1478         return panel_simple_remove(&pdev->dev);
1479 }
1480
1481 static void panel_simple_platform_shutdown(struct platform_device *pdev)
1482 {
1483         panel_simple_shutdown(&pdev->dev);
1484 }
1485
1486 static struct platform_driver panel_simple_platform_driver = {
1487         .driver = {
1488                 .name = "panel-simple",
1489                 .of_match_table = platform_of_match,
1490         },
1491         .probe = panel_simple_platform_probe,
1492         .remove = panel_simple_platform_remove,
1493         .shutdown = panel_simple_platform_shutdown,
1494 };
1495
1496 struct panel_desc_dsi {
1497         struct panel_desc desc;
1498
1499         unsigned long flags;
1500         enum mipi_dsi_pixel_format format;
1501         unsigned int lanes;
1502 };
1503
1504 static const struct drm_display_mode auo_b080uan01_mode = {
1505         .clock = 154500,
1506         .hdisplay = 1200,
1507         .hsync_start = 1200 + 62,
1508         .hsync_end = 1200 + 62 + 4,
1509         .htotal = 1200 + 62 + 4 + 62,
1510         .vdisplay = 1920,
1511         .vsync_start = 1920 + 9,
1512         .vsync_end = 1920 + 9 + 2,
1513         .vtotal = 1920 + 9 + 2 + 8,
1514         .vrefresh = 60,
1515 };
1516
1517 static const struct panel_desc_dsi auo_b080uan01 = {
1518         .desc = {
1519                 .modes = &auo_b080uan01_mode,
1520                 .num_modes = 1,
1521                 .bpc = 8,
1522                 .size = {
1523                         .width = 108,
1524                         .height = 272,
1525                 },
1526         },
1527         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1528         .format = MIPI_DSI_FMT_RGB888,
1529         .lanes = 4,
1530 };
1531
1532 static const struct drm_display_mode boe_tv080wum_nl0_mode = {
1533         .clock = 160000,
1534         .hdisplay = 1200,
1535         .hsync_start = 1200 + 120,
1536         .hsync_end = 1200 + 120 + 20,
1537         .htotal = 1200 + 120 + 20 + 21,
1538         .vdisplay = 1920,
1539         .vsync_start = 1920 + 21,
1540         .vsync_end = 1920 + 21 + 3,
1541         .vtotal = 1920 + 21 + 3 + 18,
1542         .vrefresh = 60,
1543         .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1544 };
1545
1546 static const struct panel_desc_dsi boe_tv080wum_nl0 = {
1547         .desc = {
1548                 .modes = &boe_tv080wum_nl0_mode,
1549                 .num_modes = 1,
1550                 .size = {
1551                         .width = 107,
1552                         .height = 172,
1553                 },
1554         },
1555         .flags = MIPI_DSI_MODE_VIDEO |
1556                  MIPI_DSI_MODE_VIDEO_BURST |
1557                  MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1558         .format = MIPI_DSI_FMT_RGB888,
1559         .lanes = 4,
1560 };
1561
1562 static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
1563         .clock = 71000,
1564         .hdisplay = 800,
1565         .hsync_start = 800 + 32,
1566         .hsync_end = 800 + 32 + 1,
1567         .htotal = 800 + 32 + 1 + 57,
1568         .vdisplay = 1280,
1569         .vsync_start = 1280 + 28,
1570         .vsync_end = 1280 + 28 + 1,
1571         .vtotal = 1280 + 28 + 1 + 14,
1572         .vrefresh = 60,
1573 };
1574
1575 static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
1576         .desc = {
1577                 .modes = &lg_ld070wx3_sl01_mode,
1578                 .num_modes = 1,
1579                 .bpc = 8,
1580                 .size = {
1581                         .width = 94,
1582                         .height = 151,
1583                 },
1584         },
1585         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1586         .format = MIPI_DSI_FMT_RGB888,
1587         .lanes = 4,
1588 };
1589
1590 static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
1591         .clock = 67000,
1592         .hdisplay = 720,
1593         .hsync_start = 720 + 12,
1594         .hsync_end = 720 + 12 + 4,
1595         .htotal = 720 + 12 + 4 + 112,
1596         .vdisplay = 1280,
1597         .vsync_start = 1280 + 8,
1598         .vsync_end = 1280 + 8 + 4,
1599         .vtotal = 1280 + 8 + 4 + 12,
1600         .vrefresh = 60,
1601 };
1602
1603 static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
1604         .desc = {
1605                 .modes = &lg_lh500wx1_sd03_mode,
1606                 .num_modes = 1,
1607                 .bpc = 8,
1608                 .size = {
1609                         .width = 62,
1610                         .height = 110,
1611                 },
1612         },
1613         .flags = MIPI_DSI_MODE_VIDEO,
1614         .format = MIPI_DSI_FMT_RGB888,
1615         .lanes = 4,
1616 };
1617
1618 static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
1619         .clock = 157200,
1620         .hdisplay = 1920,
1621         .hsync_start = 1920 + 154,
1622         .hsync_end = 1920 + 154 + 16,
1623         .htotal = 1920 + 154 + 16 + 32,
1624         .vdisplay = 1200,
1625         .vsync_start = 1200 + 17,
1626         .vsync_end = 1200 + 17 + 2,
1627         .vtotal = 1200 + 17 + 2 + 16,
1628         .vrefresh = 60,
1629 };
1630
1631 static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
1632         .desc = {
1633                 .modes = &panasonic_vvx10f004b00_mode,
1634                 .num_modes = 1,
1635                 .bpc = 8,
1636                 .size = {
1637                         .width = 217,
1638                         .height = 136,
1639                 },
1640         },
1641         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1642                  MIPI_DSI_CLOCK_NON_CONTINUOUS,
1643         .format = MIPI_DSI_FMT_RGB888,
1644         .lanes = 4,
1645 };
1646
1647
1648 static const struct of_device_id dsi_of_match[] = {
1649         {
1650                 .compatible = "simple-panel-dsi",
1651                 .data = NULL
1652         }, {
1653                 .compatible = "auo,b080uan01",
1654                 .data = &auo_b080uan01
1655         }, {
1656                 .compatible = "boe,tv080wum-nl0",
1657                 .data = &boe_tv080wum_nl0
1658         }, {
1659                 .compatible = "lg,ld070wx3-sl01",
1660                 .data = &lg_ld070wx3_sl01
1661         }, {
1662                 .compatible = "lg,lh500wx1-sd03",
1663                 .data = &lg_lh500wx1_sd03
1664         }, {
1665                 .compatible = "panasonic,vvx10f004b00",
1666                 .data = &panasonic_vvx10f004b00
1667         }, {
1668                 /* sentinel */
1669         }
1670 };
1671 MODULE_DEVICE_TABLE(of, dsi_of_match);
1672
1673 static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
1674 {
1675         const struct panel_desc_dsi *desc;
1676         const struct of_device_id *id;
1677         const struct panel_desc *pdesc;
1678         u32 val;
1679         int err;
1680
1681         id = of_match_node(dsi_of_match, dsi->dev.of_node);
1682         if (!id)
1683                 return -ENODEV;
1684
1685         desc = id->data;
1686
1687         if (desc) {
1688                 dsi->mode_flags = desc->flags;
1689                 dsi->format = desc->format;
1690                 dsi->lanes = desc->lanes;
1691                 pdesc = &desc->desc;
1692         } else {
1693                 pdesc = NULL;
1694         }
1695
1696         err = panel_simple_probe(&dsi->dev, pdesc);
1697         if (err < 0)
1698                 return err;
1699
1700         if (!of_property_read_u32(dsi->dev.of_node, "dsi,flags", &val))
1701                 dsi->mode_flags = val;
1702
1703         if (!of_property_read_u32(dsi->dev.of_node, "dsi,format", &val))
1704                 dsi->format = val;
1705
1706         if (!of_property_read_u32(dsi->dev.of_node, "dsi,lanes", &val))
1707                 dsi->lanes = val;
1708
1709         return mipi_dsi_attach(dsi);
1710 }
1711
1712 static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
1713 {
1714         int err;
1715
1716         err = mipi_dsi_detach(dsi);
1717         if (err < 0)
1718                 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
1719
1720         return panel_simple_remove(&dsi->dev);
1721 }
1722
1723 static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
1724 {
1725         panel_simple_shutdown(&dsi->dev);
1726 }
1727
1728 static struct mipi_dsi_driver panel_simple_dsi_driver = {
1729         .driver = {
1730                 .name = "panel-simple-dsi",
1731                 .of_match_table = dsi_of_match,
1732         },
1733         .probe = panel_simple_dsi_probe,
1734         .remove = panel_simple_dsi_remove,
1735         .shutdown = panel_simple_dsi_shutdown,
1736 };
1737
1738 static int __init panel_simple_init(void)
1739 {
1740         int err;
1741
1742         err = platform_driver_register(&panel_simple_platform_driver);
1743         if (err < 0)
1744                 return err;
1745
1746         if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
1747                 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
1748                 if (err < 0)
1749                         return err;
1750         }
1751
1752         return 0;
1753 }
1754 module_init(panel_simple_init);
1755
1756 static void __exit panel_simple_exit(void)
1757 {
1758         if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
1759                 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
1760
1761         platform_driver_unregister(&panel_simple_platform_driver);
1762 }
1763 module_exit(panel_simple_exit);
1764
1765 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
1766 MODULE_DESCRIPTION("DRM Driver for Simple Panels");
1767 MODULE_LICENSE("GPL and additional rights");