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