]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/panel/panel-simple.c
drm/panel: simple: add support for EDT ET1010G0DSA/ETML1010G0DKA 10.1" WXGA LVDS...
[karo-tx-linux.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/videomode.h>
38
39 struct panel_desc {
40         const struct drm_display_mode *modes;
41         unsigned int num_modes;
42         const struct display_timing *timings;
43         unsigned int num_timings;
44
45         unsigned int bpc;
46
47         /**
48          * @width: width (in millimeters) of the panel's active display area
49          * @height: height (in millimeters) of the panel's active display area
50          */
51         struct {
52                 unsigned int width;
53                 unsigned int height;
54         } size;
55
56         /**
57          * @prepare: the time (in milliseconds) that it takes for the panel to
58          *           become ready and start receiving video data
59          * @enable: the time (in milliseconds) that it takes for the panel to
60          *          display the first valid frame after starting to receive
61          *          video data
62          * @disable: the time (in milliseconds) that it takes for the panel to
63          *           turn the display off (no content is visible)
64          * @unprepare: the time (in milliseconds) that it takes for the panel
65          *             to power itself down completely
66          */
67         struct {
68                 unsigned int prepare;
69                 unsigned int enable;
70                 unsigned int disable;
71                 unsigned int unprepare;
72         } delay;
73
74         u32 bus_format;
75         u32 bus_flags;
76 };
77
78 struct panel_simple {
79         struct drm_panel base;
80         bool prepared;
81         bool enabled;
82
83         const struct panel_desc *desc;
84
85         struct backlight_device *backlight;
86         struct regulator *supply;
87         struct i2c_adapter *ddc;
88
89         struct gpio_desc *enable_gpio;
90
91         u32 bus_fmt_override;
92         u32 quirks;
93 };
94
95 enum {
96         PANEL_QUIRK_PIXDATA_NEGEDGE = BIT(0),
97         PANEL_QUIRK_PIXDATA_POSEDGE = BIT(1),
98 };
99
100 #define SP_DISPLAY_MODE(freq, ha, hfp, hs, hbp, va, vfp, vs, vbp, vr, flgs) { \
101         .clock = freq,                                                  \
102         .hdisplay = ha,                                                 \
103         .hsync_start = (ha) + (hfp),                                    \
104         .hsync_end = (ha) + (hfp) + (hs),                               \
105         .htotal = (ha) + (hfp) + (hs) + (hbp),                          \
106         .vdisplay = (va),                                               \
107         .vsync_start = (va) + (vfp),                                    \
108         .vsync_end = (va) + (vfp) + (vs),                               \
109         .vtotal = (va) + (vfp) + (vs) + (vbp),                          \
110         .vrefresh = vr,                                                 \
111         .flags = flgs,                                                  \
112 }
113
114 static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
115 {
116         return container_of(panel, struct panel_simple, base);
117 }
118
119 static inline void panel_simple_apply_quirks(struct panel_simple *panel,
120                                              struct drm_display_info *info)
121 {
122         if (panel->quirks & PANEL_QUIRK_PIXDATA_NEGEDGE)
123                 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
124         if (panel->quirks & PANEL_QUIRK_PIXDATA_POSEDGE)
125                 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
126 }
127
128 static int panel_simple_get_fixed_modes(struct panel_simple *panel)
129 {
130         struct drm_connector *connector = panel->base.connector;
131         struct drm_device *drm = panel->base.drm;
132         struct drm_display_mode *mode;
133         unsigned int i, num = 0;
134
135         if (!panel->desc)
136                 return 0;
137
138         for (i = 0; i < panel->desc->num_timings; i++) {
139                 const struct display_timing *dt = &panel->desc->timings[i];
140                 struct videomode vm;
141
142                 videomode_from_timing(dt, &vm);
143                 mode = drm_mode_create(drm);
144                 if (!mode) {
145                         dev_err(drm->dev, "failed to add mode %ux%u\n",
146                                 dt->hactive.typ, dt->vactive.typ);
147                         continue;
148                 }
149
150                 drm_display_mode_from_videomode(&vm, mode);
151
152                 mode->type |= DRM_MODE_TYPE_DRIVER;
153
154                 if (panel->desc->num_timings == 1)
155                         mode->type |= DRM_MODE_TYPE_PREFERRED;
156
157                 drm_mode_probed_add(connector, mode);
158                 num++;
159         }
160
161         for (i = 0; i < panel->desc->num_modes; i++) {
162                 const struct drm_display_mode *m = &panel->desc->modes[i];
163
164                 mode = drm_mode_duplicate(drm, m);
165                 if (!mode) {
166                         dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
167                                 m->hdisplay, m->vdisplay, m->vrefresh);
168                         continue;
169                 }
170
171                 mode->type |= DRM_MODE_TYPE_DRIVER;
172
173                 if (panel->desc->num_modes == 1)
174                         mode->type |= DRM_MODE_TYPE_PREFERRED;
175
176                 drm_mode_set_name(mode);
177
178                 drm_mode_probed_add(connector, mode);
179                 num++;
180         }
181
182         connector->display_info.bpc = panel->desc->bpc;
183         connector->display_info.width_mm = panel->desc->size.width;
184         connector->display_info.height_mm = panel->desc->size.height;
185
186         if (panel->bus_fmt_override)
187                 drm_display_info_set_bus_formats(&connector->display_info,
188                                                  &panel->bus_fmt_override, 1);
189         else if (panel->desc->bus_format)
190                 drm_display_info_set_bus_formats(&connector->display_info,
191                                                  &panel->desc->bus_format, 1);
192         connector->display_info.bus_flags = panel->desc->bus_flags;
193         if (panel->quirks)
194                 panel_simple_apply_quirks(panel, &connector->display_info);
195
196         return num;
197 }
198
199 static int panel_simple_disable(struct drm_panel *panel)
200 {
201         struct panel_simple *p = to_panel_simple(panel);
202
203         if (!p->enabled)
204                 return 0;
205
206         if (p->backlight) {
207                 p->backlight->props.power = FB_BLANK_POWERDOWN;
208                 p->backlight->props.state |= BL_CORE_FBBLANK;
209                 backlight_update_status(p->backlight);
210         }
211
212         if (p->desc->delay.disable)
213                 msleep(p->desc->delay.disable);
214
215         p->enabled = false;
216
217         return 0;
218 }
219
220 static int panel_simple_unprepare(struct drm_panel *panel)
221 {
222         struct panel_simple *p = to_panel_simple(panel);
223
224         if (!p->prepared)
225                 return 0;
226
227         if (p->enable_gpio)
228                 gpiod_set_value_cansleep(p->enable_gpio, 0);
229
230         regulator_disable(p->supply);
231
232         if (p->desc->delay.unprepare)
233                 msleep(p->desc->delay.unprepare);
234
235         p->prepared = false;
236
237         return 0;
238 }
239
240 static int panel_simple_prepare(struct drm_panel *panel)
241 {
242         struct panel_simple *p = to_panel_simple(panel);
243         int err;
244
245         if (p->prepared)
246                 return 0;
247
248         err = regulator_enable(p->supply);
249         if (err < 0) {
250                 dev_err(panel->dev, "failed to enable supply: %d\n", err);
251                 return err;
252         }
253
254         if (p->enable_gpio)
255                 gpiod_set_value_cansleep(p->enable_gpio, 1);
256
257         if (p->desc->delay.prepare)
258                 msleep(p->desc->delay.prepare);
259
260         p->prepared = true;
261
262         return 0;
263 }
264
265 static int panel_simple_enable(struct drm_panel *panel)
266 {
267         struct panel_simple *p = to_panel_simple(panel);
268
269         if (p->enabled)
270                 return 0;
271
272         if (p->desc->delay.enable)
273                 msleep(p->desc->delay.enable);
274
275         if (p->backlight) {
276                 p->backlight->props.state &= ~BL_CORE_FBBLANK;
277                 p->backlight->props.power = FB_BLANK_UNBLANK;
278                 backlight_update_status(p->backlight);
279         }
280
281         p->enabled = true;
282
283         return 0;
284 }
285
286 static int panel_simple_get_modes(struct drm_panel *panel)
287 {
288         struct panel_simple *p = to_panel_simple(panel);
289         int num = 0;
290
291         /* probe EDID if a DDC bus is available */
292         if (p->ddc) {
293                 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
294                 drm_mode_connector_update_edid_property(panel->connector, edid);
295                 if (edid) {
296                         num += drm_add_edid_modes(panel->connector, edid);
297                         kfree(edid);
298                 }
299         }
300
301         /* add hard-coded panel modes */
302         num += panel_simple_get_fixed_modes(p);
303
304         return num;
305 }
306
307 static int panel_simple_get_timings(struct drm_panel *panel,
308                                     unsigned int num_timings,
309                                     struct display_timing *timings)
310 {
311         struct panel_simple *p = to_panel_simple(panel);
312         unsigned int i;
313
314         if (p->desc->num_timings < num_timings)
315                 num_timings = p->desc->num_timings;
316
317         if (timings)
318                 for (i = 0; i < num_timings; i++)
319                         timings[i] = p->desc->timings[i];
320
321         return p->desc->num_timings;
322 }
323
324 static inline int panel_simple_check_quirks(struct device *dev,
325                                             struct panel_simple *p)
326 {
327         const char *bus_fmt;
328         u32 clkpol;
329
330         if (of_property_read_string(dev->of_node, "bus-format-override",
331                                     &bus_fmt) == 0) {
332                 if (strcmp(bus_fmt, "rgb24") == 0)
333                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB888_1X24;
334                 else if (strcmp(bus_fmt, "rgb666") == 0)
335                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB666_1X18;
336                 else if (strcmp(bus_fmt, "rgb565") == 0)
337                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB565_1X16;
338                 else if (strcmp(bus_fmt, "spwg-18") == 0)
339                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
340                 else if (strcmp(bus_fmt, "spwg-24") == 0)
341                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
342                 else if (strcmp(bus_fmt, "jeida-24") == 0)
343                         p->bus_fmt_override = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
344                 else
345                         dev_err(dev,
346                                 "Unsupported bus-format-override value: '%s'\n",
347                                 bus_fmt);
348                 return p->bus_fmt_override ? 0 : -EINVAL;
349         }
350
351         if (of_property_read_u32(dev->of_node, "pixelclk-active",
352                                  &clkpol) == 0) {
353                 if (clkpol & ~1) {
354                         dev_err(dev,
355                                 "Invalid value for pixelclk-active: '%u' (should be <0> or <1>)\n",
356                                 clkpol);
357                         return -EINVAL;
358                 }
359                 p->quirks |= clkpol ? PANEL_QUIRK_PIXDATA_POSEDGE :
360                         PANEL_QUIRK_PIXDATA_NEGEDGE;
361         }
362         return 0;
363 }
364
365 static const struct drm_panel_funcs panel_simple_funcs = {
366         .disable = panel_simple_disable,
367         .unprepare = panel_simple_unprepare,
368         .prepare = panel_simple_prepare,
369         .enable = panel_simple_enable,
370         .get_modes = panel_simple_get_modes,
371         .get_timings = panel_simple_get_timings,
372 };
373
374 static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
375 {
376         struct device_node *backlight, *ddc;
377         struct panel_simple *panel;
378         int err;
379
380         panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
381         if (!panel)
382                 return -ENOMEM;
383
384         panel->enabled = false;
385         panel->prepared = false;
386         panel->desc = desc;
387
388         panel->supply = devm_regulator_get(dev, "power");
389         if (IS_ERR(panel->supply))
390                 return PTR_ERR(panel->supply);
391
392         panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
393                                                      GPIOD_OUT_LOW);
394         if (IS_ERR(panel->enable_gpio)) {
395                 err = PTR_ERR(panel->enable_gpio);
396                 dev_err(dev, "failed to request GPIO: %d\n", err);
397                 return err;
398         }
399
400         backlight = of_parse_phandle(dev->of_node, "backlight", 0);
401         if (backlight) {
402                 panel->backlight = of_find_backlight_by_node(backlight);
403                 of_node_put(backlight);
404
405                 if (!panel->backlight)
406                         return -EPROBE_DEFER;
407         }
408
409         ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
410         if (ddc) {
411                 panel->ddc = of_find_i2c_adapter_by_node(ddc);
412                 of_node_put(ddc);
413
414                 if (!panel->ddc) {
415                         err = -EPROBE_DEFER;
416                         goto free_backlight;
417                 }
418         }
419
420         err = panel_simple_check_quirks(dev, panel);
421         if (err)
422                 goto free_ddc;
423
424         drm_panel_init(&panel->base);
425         panel->base.dev = dev;
426         panel->base.funcs = &panel_simple_funcs;
427
428         err = drm_panel_add(&panel->base);
429         if (err < 0)
430                 goto free_ddc;
431
432         dev_set_drvdata(dev, panel);
433
434         return 0;
435
436 free_ddc:
437         if (panel->ddc)
438                 put_device(&panel->ddc->dev);
439 free_backlight:
440         if (panel->backlight)
441                 put_device(&panel->backlight->dev);
442
443         return err;
444 }
445
446 static int panel_simple_remove(struct device *dev)
447 {
448         struct panel_simple *panel = dev_get_drvdata(dev);
449
450         drm_panel_detach(&panel->base);
451         drm_panel_remove(&panel->base);
452
453         panel_simple_disable(&panel->base);
454
455         if (panel->ddc)
456                 put_device(&panel->ddc->dev);
457
458         if (panel->backlight)
459                 put_device(&panel->backlight->dev);
460
461         return 0;
462 }
463
464 static void panel_simple_shutdown(struct device *dev)
465 {
466         struct panel_simple *panel = dev_get_drvdata(dev);
467
468         panel_simple_disable(&panel->base);
469 }
470
471 static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode =
472         SP_DISPLAY_MODE(9000, 480, 2, 41, 2, 272, 2, 10, 2, 60,
473                         DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
474
475 static const struct panel_desc ampire_am_480272h3tmqw_t01h = {
476         .modes = &ampire_am_480272h3tmqw_t01h_mode,
477         .num_modes = 1,
478         .bpc = 8,
479         .size = {
480                 .width = 105,
481                 .height = 67,
482         },
483         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
484 };
485
486 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode =
487         SP_DISPLAY_MODE(33333, 800, 0, 255, 0, 480, 2, 45, 0, 60,
488                         DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
489
490 static const struct panel_desc ampire_am800480r3tmqwa1h = {
491         .modes = &ampire_am800480r3tmqwa1h_mode,
492         .num_modes = 1,
493         .bpc = 6,
494         .size = {
495                 .width = 152,
496                 .height = 91,
497         },
498         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
499 };
500
501 static const struct drm_display_mode auo_b101aw03_mode =
502         SP_DISPLAY_MODE(51450, 1024, 156, 8, 156, 600, 16, 6, 16, 60, 0);
503
504 static const struct panel_desc auo_b101aw03 = {
505         .modes = &auo_b101aw03_mode,
506         .num_modes = 1,
507         .bpc = 6,
508         .size = {
509                 .width = 223,
510                 .height = 125,
511         },
512 };
513
514 static const struct drm_display_mode auo_b101ean01_mode =
515         SP_DISPLAY_MODE(72500, 1280, 119, 32, 21, 800, 4, 20, 8, 60, 0);
516
517 static const struct panel_desc auo_b101ean01 = {
518         .modes = &auo_b101ean01_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         SP_DISPLAY_MODE(72000, 1366, 20, 70, 0, 768, 14, 42, 0, 60,
529                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
530
531 static const struct panel_desc auo_b101xtn01 = {
532         .modes = &auo_b101xtn01_mode,
533         .num_modes = 1,
534         .bpc = 6,
535         .size = {
536                 .width = 223,
537                 .height = 125,
538         },
539 };
540
541 static const struct drm_display_mode auo_b116xw03_mode =
542         SP_DISPLAY_MODE(70589, 1366, 40, 40, 32, 768, 10, 12, 6, 60, 0);
543
544 static const struct panel_desc auo_b116xw03 = {
545         .modes = &auo_b116xw03_mode,
546         .num_modes = 1,
547         .bpc = 6,
548         .size = {
549                 .width = 256,
550                 .height = 144,
551         },
552 };
553
554 static const struct drm_display_mode auo_b133xtn01_mode =
555         SP_DISPLAY_MODE(69500, 1366, 48, 32, 20, 768, 3, 6, 13, 60, 0);
556
557 static const struct panel_desc auo_b133xtn01 = {
558         .modes = &auo_b133xtn01_mode,
559         .num_modes = 1,
560         .bpc = 6,
561         .size = {
562                 .width = 293,
563                 .height = 165,
564         },
565 };
566
567 static const struct drm_display_mode auo_b133htn01_mode =
568         SP_DISPLAY_MODE(150660, 1920, 172, 80, 60, 1080, 25, 10, 10, 60, 0);
569
570 static const struct panel_desc auo_b133htn01 = {
571         .modes = &auo_b133htn01_mode,
572         .num_modes = 1,
573         .bpc = 6,
574         .size = {
575                 .width = 293,
576                 .height = 165,
577         },
578         .delay = {
579                 .prepare = 105,
580                 .enable = 20,
581                 .unprepare = 50,
582         },
583 };
584
585 static const struct display_timing auo_g133han01_timings = {
586         .pixelclock = { 134000000, 141200000, 149000000 },
587         .hactive = { 1920, 1920, 1920 },
588         .hfront_porch = { 39, 58, 77 },
589         .hback_porch = { 59, 88, 117 },
590         .hsync_len = { 28, 42, 56 },
591         .vactive = { 1080, 1080, 1080 },
592         .vfront_porch = { 3, 8, 11 },
593         .vback_porch = { 5, 14, 19 },
594         .vsync_len = { 4, 14, 19 },
595 };
596
597 static const struct panel_desc auo_g133han01 = {
598         .timings = &auo_g133han01_timings,
599         .num_timings = 1,
600         .bpc = 8,
601         .size = {
602                 .width = 293,
603                 .height = 165,
604         },
605         .delay = {
606                 .prepare = 200,
607                 .enable = 50,
608                 .disable = 50,
609                 .unprepare = 1000,
610         },
611         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
612 };
613
614 static const struct display_timing auo_g185han01_timings = {
615         .pixelclock = { 120000000, 144000000, 175000000 },
616         .hactive = { 1920, 1920, 1920 },
617         .hfront_porch = { 18, 60, 74 },
618         .hback_porch = { 12, 44, 54 },
619         .hsync_len = { 10, 24, 32 },
620         .vactive = { 1080, 1080, 1080 },
621         .vfront_porch = { 6, 10, 40 },
622         .vback_porch = { 2, 5, 20 },
623         .vsync_len = { 2, 5, 20 },
624 };
625
626 static const struct panel_desc auo_g185han01 = {
627         .timings = &auo_g185han01_timings,
628         .num_timings = 1,
629         .bpc = 8,
630         .size = {
631                 .width = 409,
632                 .height = 230,
633         },
634         .delay = {
635                 .prepare = 50,
636                 .enable = 200,
637                 .disable = 110,
638                 .unprepare = 1000,
639         },
640         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
641 };
642
643 static const struct display_timing auo_p320hvn03_timings = {
644         .pixelclock = { 106000000, 148500000, 164000000 },
645         .hactive = { 1920, 1920, 1920 },
646         .hfront_porch = { 25, 50, 130 },
647         .hback_porch = { 25, 50, 130 },
648         .hsync_len = { 20, 40, 105 },
649         .vactive = { 1080, 1080, 1080 },
650         .vfront_porch = { 8, 17, 150 },
651         .vback_porch = { 8, 17, 150 },
652         .vsync_len = { 4, 11, 100 },
653 };
654
655 static const struct panel_desc auo_p320hvn03 = {
656         .timings = &auo_p320hvn03_timings,
657         .num_timings = 1,
658         .bpc = 8,
659         .size = {
660                 .width = 698,
661                 .height = 393,
662         },
663         .delay = {
664                 .prepare = 1,
665                 .enable = 450,
666                 .unprepare = 500,
667         },
668         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
669 };
670
671 static const struct drm_display_mode auo_t215hvn01_mode =
672         SP_DISPLAY_MODE(148800, 1920, 88, 44, 148, 1080, 4, 5, 36, 60, 0);
673
674 static const struct panel_desc auo_t215hvn01 = {
675         .modes = &auo_t215hvn01_mode,
676         .num_modes = 1,
677         .bpc = 8,
678         .size = {
679                 .width = 430,
680                 .height = 270,
681         },
682         .delay = {
683                 .disable = 5,
684                 .unprepare = 1000,
685         }
686 };
687
688 static const struct drm_display_mode avic_tm070ddh03_mode =
689         SP_DISPLAY_MODE(51200, 1024, 160, 4, 156, 600, 17, 1, 17, 60, 0);
690
691 static const struct panel_desc avic_tm070ddh03 = {
692         .modes = &avic_tm070ddh03_mode,
693         .num_modes = 1,
694         .bpc = 8,
695         .size = {
696                 .width = 154,
697                 .height = 90,
698         },
699         .delay = {
700                 .prepare = 20,
701                 .enable = 200,
702                 .disable = 200,
703         },
704 };
705
706 static const struct drm_display_mode boe_nv101wxmn51_modes[] = {
707         SP_DISPLAY_MODE(71900, 1280, 48, 32, 80, 800, 3, 5, 24, 60, 0),
708         SP_DISPLAY_MODE(57500, 1280, 48, 32, 80, 800, 3, 5, 24, 48, 0),
709 };
710
711 static const struct panel_desc boe_nv101wxmn51 = {
712         .modes = boe_nv101wxmn51_modes,
713         .num_modes = ARRAY_SIZE(boe_nv101wxmn51_modes),
714         .bpc = 8,
715         .size = {
716                 .width = 217,
717                 .height = 136,
718         },
719         .delay = {
720                 .prepare = 210,
721                 .enable = 50,
722                 .unprepare = 160,
723         },
724 };
725
726 static const struct drm_display_mode chunghwa_claa070wp03xg_mode =
727         SP_DISPLAY_MODE(66770, 800, 49, 33, 17, 1280, 1, 7, 15, 60,
728                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
729
730 static const struct panel_desc chunghwa_claa070wp03xg = {
731         .modes = &chunghwa_claa070wp03xg_mode,
732         .num_modes = 1,
733         .bpc = 6,
734         .size = {
735                 .width = 94,
736                 .height = 150,
737         },
738 };
739
740 static const struct drm_display_mode chunghwa_claa101wa01a_mode =
741         SP_DISPLAY_MODE(72070, 1366, 58, 58, 58, 768, 4, 4, 4, 60, 0);
742
743 static const struct panel_desc chunghwa_claa101wa01a = {
744         .modes = &chunghwa_claa101wa01a_mode,
745         .num_modes = 1,
746         .bpc = 6,
747         .size = {
748                 .width = 220,
749                 .height = 120,
750         },
751 };
752
753 static const struct drm_display_mode chunghwa_claa101wb01_mode =
754         SP_DISPLAY_MODE(69300, 1366, 48, 32, 20, 768, 16, 8, 16, 60, 0);
755
756 static const struct panel_desc chunghwa_claa101wb01 = {
757         .modes = &chunghwa_claa101wb01_mode,
758         .num_modes = 1,
759         .bpc = 6,
760         .size = {
761                 .width = 223,
762                 .height = 125,
763         },
764 };
765
766 static const struct drm_display_mode edt_et0350g0dh6_mode =
767         SP_DISPLAY_MODE(6500, 320, 20, 0, 68, 240, 4, 0, 18, 60,
768                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
769
770 static const struct panel_desc edt_et0350g0dh6 = {
771         .modes = &edt_et0350g0dh6_mode,
772         .num_modes = 1,
773         .bpc = 6,
774         .size = {
775                 .width = 70,
776                 .height = 53,
777         },
778         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
779         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_NEGEDGE,
780 };
781
782 static const struct drm_display_mode edt_et0430g0dh6_mode =
783         SP_DISPLAY_MODE(9000, 480, 2, 41, 2, 272, 2, 10, 2, 60,
784                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
785
786 static const struct panel_desc edt_et0430g0dh6 = {
787         .modes = &edt_et0430g0dh6_mode,
788         .num_modes = 1,
789         .bpc = 6,
790         .size = {
791                 .width = 95,
792                 .height = 54,
793         },
794         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
795         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_POSEDGE,
796 };
797
798 static const struct drm_display_mode edt_et057090dhu_mode =
799         SP_DISPLAY_MODE(25175, 640, 16, 30, 114, 480, 10, 3, 32, 60,
800                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
801
802 static const struct panel_desc edt_et057090dhu = {
803         .modes = &edt_et057090dhu_mode,
804         .num_modes = 1,
805         .bpc = 6,
806         .size = {
807                 .width = 115,
808                 .height = 86,
809         },
810         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
811         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_NEGEDGE,
812 };
813
814 static const struct drm_display_mode edt_etm0700g0dh6_mode =
815         SP_DISPLAY_MODE(33260, 800, 40, 128, 88, 480, 10, 2, 33, 60,
816                         DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
817
818 static const struct panel_desc edt_etm0700g0dh6 = {
819         .modes = &edt_etm0700g0dh6_mode,
820         .num_modes = 1,
821         .bpc = 6,
822         .size = {
823                 .width = 152,
824                 .height = 91,
825         },
826         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
827         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_NEGEDGE,
828 };
829
830 static const struct panel_desc edt_etm0700g0edh6 = {
831         .modes = &edt_etm0700g0dh6_mode,
832         .num_modes = 1,
833         .bpc = 6,
834         .size = {
835                 .width = 152,
836                 .height = 91,
837         },
838         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
839         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_POSEDGE,
840 };
841
842 static const struct drm_display_mode edt_et1010g0dsa_mode =
843         SP_DISPLAY_MODE(71100, 1280, 25, 80, 55, 800, 5, 2, 16, 60,
844                         DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
845
846 static const struct panel_desc edt_et1010g0dsa = {
847         .modes = &edt_et1010g0dsa_mode,
848         .num_modes = 1,
849         .bpc = 8,
850         .size = {
851                 .width = 217,
852                 .height = 136,
853         },
854         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
855         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_NEGEDGE,
856 };
857
858 static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode =
859         SP_DISPLAY_MODE(32260, 800, 168, 64, 88, 480, 37, 2, 8, 60, 0);
860
861 static const struct panel_desc foxlink_fl500wvr00_a0t = {
862         .modes = &foxlink_fl500wvr00_a0t_mode,
863         .num_modes = 1,
864         .bpc = 8,
865         .size = {
866                 .width = 108,
867                 .height = 65,
868         },
869         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
870 };
871
872 static const struct drm_display_mode giantplus_gpg482739qs5_mode =
873         SP_DISPLAY_MODE(9000, 480, 5, 1, 40, 272, 8, 1, 8, 60, 0);
874
875 static const struct panel_desc giantplus_gpg482739qs5 = {
876         .modes = &giantplus_gpg482739qs5_mode,
877         .num_modes = 1,
878         .bpc = 8,
879         .size = {
880                 .width = 95,
881                 .height = 54,
882         },
883         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
884 };
885
886 static const struct display_timing hannstar_hsd070pww1_timing = {
887         .pixelclock = { 64300000, 71100000, 82000000 },
888         .hactive = { 1280, 1280, 1280 },
889         .hfront_porch = { 1, 1, 10 },
890         .hback_porch = { 1, 1, 10 },
891         /*
892          * According to the data sheet, the minimum horizontal blanking interval
893          * is 54 clocks (1 + 52 + 1), but tests with a Nitrogen6X have shown the
894          * minimum working horizontal blanking interval to be 60 clocks.
895          */
896         .hsync_len = { 58, 158, 661 },
897         .vactive = { 800, 800, 800 },
898         .vfront_porch = { 1, 1, 10 },
899         .vback_porch = { 1, 1, 10 },
900         .vsync_len = { 1, 21, 203 },
901         .flags = DISPLAY_FLAGS_DE_HIGH,
902 };
903
904 static const struct panel_desc hannstar_hsd070pww1 = {
905         .timings = &hannstar_hsd070pww1_timing,
906         .num_timings = 1,
907         .bpc = 6,
908         .size = {
909                 .width = 151,
910                 .height = 94,
911         },
912         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
913 };
914
915 static const struct display_timing hannstar_hsd100pxn1_timing = {
916         .pixelclock = { 55000000, 65000000, 75000000 },
917         .hactive = { 1024, 1024, 1024 },
918         .hfront_porch = { 40, 40, 40 },
919         .hback_porch = { 220, 220, 220 },
920         .hsync_len = { 20, 60, 100 },
921         .vactive = { 768, 768, 768 },
922         .vfront_porch = { 7, 7, 7 },
923         .vback_porch = { 21, 21, 21 },
924         .vsync_len = { 10, 10, 10 },
925         .flags = DISPLAY_FLAGS_DE_HIGH,
926 };
927
928 static const struct panel_desc hannstar_hsd100pxn1 = {
929         .timings = &hannstar_hsd100pxn1_timing,
930         .num_timings = 1,
931         .bpc = 6,
932         .size = {
933                 .width = 203,
934                 .height = 152,
935         },
936         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
937 };
938
939 static const struct drm_display_mode hitachi_tx23d38vm0caa_mode =
940         SP_DISPLAY_MODE(33333, 800, 85, 86, 85, 480, 16, 13, 16, 60, 0);
941
942 static const struct panel_desc hitachi_tx23d38vm0caa = {
943         .modes = &hitachi_tx23d38vm0caa_mode,
944         .num_modes = 1,
945         .bpc = 6,
946         .size = {
947                 .width = 195,
948                 .height = 117,
949         },
950 };
951
952 static const struct drm_display_mode innolux_at043tn24_mode =
953         SP_DISPLAY_MODE(9000, 480, 2, 41, 2, 272, 2, 11, 2, 60,
954                         DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
955
956 static const struct panel_desc innolux_at043tn24 = {
957         .modes = &innolux_at043tn24_mode,
958         .num_modes = 1,
959         .bpc = 8,
960         .size = {
961                 .width = 95,
962                 .height = 54,
963         },
964         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
965 };
966
967 static const struct drm_display_mode innolux_at070tn92_mode =
968         SP_DISPLAY_MODE(33333, 800, 210, 20, 46, 480, 22, 10, 23, 60, 0);
969
970 static const struct panel_desc innolux_at070tn92 = {
971         .modes = &innolux_at070tn92_mode,
972         .num_modes = 1,
973         .size = {
974                 .width = 154,
975                 .height = 86,
976         },
977         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
978 };
979
980 static const struct display_timing innolux_g101ice_l01_timing = {
981         .pixelclock = { 60400000, 71100000, 74700000 },
982         .hactive = { 1280, 1280, 1280 },
983         .hfront_porch = { 41, 80, 100 },
984         .hback_porch = { 40, 79, 99 },
985         .hsync_len = { 1, 1, 1 },
986         .vactive = { 800, 800, 800 },
987         .vfront_porch = { 5, 11, 14 },
988         .vback_porch = { 4, 11, 14 },
989         .vsync_len = { 1, 1, 1 },
990         .flags = DISPLAY_FLAGS_DE_HIGH,
991 };
992
993 static const struct panel_desc innolux_g101ice_l01 = {
994         .timings = &innolux_g101ice_l01_timing,
995         .num_timings = 1,
996         .bpc = 8,
997         .size = {
998                 .width = 217,
999                 .height = 135,
1000         },
1001         .delay = {
1002                 .enable = 200,
1003                 .disable = 200,
1004         },
1005         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1006 };
1007
1008 static const struct display_timing innolux_g121i1_l01_timing = {
1009         .pixelclock = { 67450000, 71000000, 74550000 },
1010         .hactive = { 1280, 1280, 1280 },
1011         .hfront_porch = { 40, 80, 160 },
1012         .hback_porch = { 39, 79, 159 },
1013         .hsync_len = { 1, 1, 1 },
1014         .vactive = { 800, 800, 800 },
1015         .vfront_porch = { 5, 11, 100 },
1016         .vback_porch = { 4, 11, 99 },
1017         .vsync_len = { 1, 1, 1 },
1018 };
1019
1020 static const struct panel_desc innolux_g121i1_l01 = {
1021         .timings = &innolux_g121i1_l01_timing,
1022         .num_timings = 1,
1023         .bpc = 6,
1024         .size = {
1025                 .width = 261,
1026                 .height = 163,
1027         },
1028         .delay = {
1029                 .enable = 200,
1030                 .disable = 20,
1031         },
1032         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1033 };
1034
1035 static const struct drm_display_mode innolux_g121x1_l03_mode =
1036         SP_DISPLAY_MODE(65000, 1024, 0, 1, 320, 768, 38, 1, 0, 60,
1037                         DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
1038
1039 static const struct panel_desc innolux_g121x1_l03 = {
1040         .modes = &innolux_g121x1_l03_mode,
1041         .num_modes = 1,
1042         .bpc = 6,
1043         .size = {
1044                 .width = 246,
1045                 .height = 185,
1046         },
1047         .delay = {
1048                 .enable = 200,
1049                 .unprepare = 200,
1050                 .disable = 400,
1051         },
1052 };
1053
1054 static const struct drm_display_mode innolux_n116bge_mode =
1055         SP_DISPLAY_MODE(76420, 1366, 136, 30, 60, 768, 8, 12, 12, 60,
1056                         DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
1057
1058 static const struct panel_desc innolux_n116bge = {
1059         .modes = &innolux_n116bge_mode,
1060         .num_modes = 1,
1061         .bpc = 6,
1062         .size = {
1063                 .width = 256,
1064                 .height = 144,
1065         },
1066 };
1067
1068 static const struct drm_display_mode innolux_n156bge_l21_mode =
1069         SP_DISPLAY_MODE(69300, 1366, 16, 34, 50, 768, 2, 6, 12, 60, 0);
1070
1071 static const struct panel_desc innolux_n156bge_l21 = {
1072         .modes = &innolux_n156bge_l21_mode,
1073         .num_modes = 1,
1074         .bpc = 6,
1075         .size = {
1076                 .width = 344,
1077                 .height = 193,
1078         },
1079 };
1080
1081 static const struct drm_display_mode innolux_zj070na_01p_mode =
1082         SP_DISPLAY_MODE(51501, 1024, 128, 64, 128, 600, 16, 4, 16, 60, 0);
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 = 154,
1090                 .height = 90,
1091         },
1092 };
1093
1094 static const struct display_timing kyo_tcg121xglp_timing = {
1095         .pixelclock = { 52000000, 65000000, 71000000 },
1096         .hactive = { 1024, 1024, 1024 },
1097         .hfront_porch = { 2, 2, 2 },
1098         .hback_porch = { 2, 2, 2 },
1099         .hsync_len = { 86, 124, 244 },
1100         .vactive = { 768, 768, 768 },
1101         .vfront_porch = { 2, 2, 2 },
1102         .vback_porch = { 2, 2, 2 },
1103         .vsync_len = { 6, 34, 73 },
1104         .flags = DISPLAY_FLAGS_DE_HIGH,
1105 };
1106
1107 static const struct panel_desc kyo_tcg121xglp = {
1108         .timings = &kyo_tcg121xglp_timing,
1109         .num_timings = 1,
1110         .bpc = 8,
1111         .size = {
1112                 .width = 246,
1113                 .height = 184,
1114         },
1115         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1116 };
1117
1118 static const struct drm_display_mode lg_lb070wv8_mode =
1119         SP_DISPLAY_MODE(33246, 800, 88, 80, 88, 480, 10, 25, 10, 60, 0);
1120
1121 static const struct panel_desc lg_lb070wv8 = {
1122         .modes = &lg_lb070wv8_mode,
1123         .num_modes = 1,
1124         .bpc = 16,
1125         .size = {
1126                 .width = 151,
1127                 .height = 91,
1128         },
1129         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1130 };
1131
1132 static const struct drm_display_mode lg_lp079qx1_sp0v_mode =
1133         SP_DISPLAY_MODE(200000, 1536, 12, 16, 48, 2048, 8, 4, 8, 60,
1134                          DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1135
1136 static const struct panel_desc lg_lp079qx1_sp0v = {
1137         .modes = &lg_lp079qx1_sp0v_mode,
1138         .num_modes = 1,
1139         .size = {
1140                 .width = 129,
1141                 .height = 171,
1142         },
1143 };
1144
1145 static const struct drm_display_mode lg_lp097qx1_spa1_mode =
1146         SP_DISPLAY_MODE(205210, 2048, 150, 5, 5, 1536, 3, 1, 9, 60, 0);
1147
1148 static const struct panel_desc lg_lp097qx1_spa1 = {
1149         .modes = &lg_lp097qx1_spa1_mode,
1150         .num_modes = 1,
1151         .size = {
1152                 .width = 208,
1153                 .height = 147,
1154         },
1155 };
1156
1157 static const struct drm_display_mode lg_lp120up1_mode =
1158         SP_DISPLAY_MODE(162300, 1920, 40, 40, 80, 1280, 4, 4, 12, 60, 0);
1159
1160 static const struct panel_desc lg_lp120up1 = {
1161         .modes = &lg_lp120up1_mode,
1162         .num_modes = 1,
1163         .bpc = 8,
1164         .size = {
1165                 .width = 267,
1166                 .height = 183,
1167         },
1168 };
1169
1170 static const struct drm_display_mode lg_lp129qe_mode =
1171         SP_DISPLAY_MODE(285250, 2560, 48, 32, 80, 1700, 3, 10, 36, 60, 0);
1172
1173 static const struct panel_desc lg_lp129qe = {
1174         .modes = &lg_lp129qe_mode,
1175         .num_modes = 1,
1176         .bpc = 8,
1177         .size = {
1178                 .width = 272,
1179                 .height = 181,
1180         },
1181 };
1182
1183 static const struct display_timing nec_nl12880bc20_05_timing = {
1184         .pixelclock = { 67000000, 71000000, 75000000 },
1185         .hactive = { 1280, 1280, 1280 },
1186         .hfront_porch = { 2, 30, 30 },
1187         .hback_porch = { 6, 100, 100 },
1188         .hsync_len = { 2, 30, 30 },
1189         .vactive = { 800, 800, 800 },
1190         .vfront_porch = { 5, 5, 5 },
1191         .vback_porch = { 11, 11, 11 },
1192         .vsync_len = { 7, 7, 7 },
1193 };
1194
1195 static const struct panel_desc nec_nl12880bc20_05 = {
1196         .timings = &nec_nl12880bc20_05_timing,
1197         .num_timings = 1,
1198         .bpc = 8,
1199         .size = {
1200                 .width = 261,
1201                 .height = 163,
1202         },
1203         .delay = {
1204                 .enable = 50,
1205                 .disable = 50,
1206         },
1207         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1208 };
1209
1210 static const struct drm_display_mode nec_nl4827hc19_05b_mode =
1211         SP_DISPLAY_MODE(10870, 480, 2, 41, 2, 272, 2, 4, 2, 74,
1212                          DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1213
1214 static const struct panel_desc nec_nl4827hc19_05b = {
1215         .modes = &nec_nl4827hc19_05b_mode,
1216         .num_modes = 1,
1217         .bpc = 8,
1218         .size = {
1219                 .width = 95,
1220                 .height = 54,
1221         },
1222         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1223         .bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE,
1224 };
1225
1226 static const struct drm_display_mode netron_dy_e231732_mode =
1227         SP_DISPLAY_MODE(66000, 1024, 160, 70, 90, 600, 127, 20, 3, 60, 0);
1228
1229 static const struct panel_desc netron_dy_e231732 = {
1230         .modes = &netron_dy_e231732_mode,
1231         .num_modes = 1,
1232         .size = {
1233                 .width = 154,
1234                 .height = 87,
1235         },
1236         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1237 };
1238
1239 static const struct display_timing nlt_nl192108ac18_02d_timing = {
1240         .pixelclock = { 130000000, 148350000, 163000000 },
1241         .hactive = { 1920, 1920, 1920 },
1242         .hfront_porch = { 80, 100, 100 },
1243         .hback_porch = { 100, 120, 120 },
1244         .hsync_len = { 50, 60, 60 },
1245         .vactive = { 1080, 1080, 1080 },
1246         .vfront_porch = { 12, 30, 30 },
1247         .vback_porch = { 4, 10, 10 },
1248         .vsync_len = { 4, 5, 5 },
1249 };
1250
1251 static const struct panel_desc nlt_nl192108ac18_02d = {
1252         .timings = &nlt_nl192108ac18_02d_timing,
1253         .num_timings = 1,
1254         .bpc = 8,
1255         .size = {
1256                 .width = 344,
1257                 .height = 194,
1258         },
1259         .delay = {
1260                 .unprepare = 500,
1261         },
1262         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1263 };
1264
1265 static const struct drm_display_mode nlt_nl12880bc20_mode =
1266         SP_DISPLAY_MODE(71000, 1280, 50, 60, 50, 800, 5, 13, 5, 0, 0);
1267
1268 static const struct panel_desc nlt_nl12880bc20_jeida = {
1269         .modes = &nlt_nl12880bc20_mode,
1270         .num_modes = 1,
1271         .bpc = 8,
1272         .size = {
1273                 .width = 261,
1274                 .height = 163,
1275         },
1276         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
1277 };
1278
1279 static const struct panel_desc nlt_nl12880bc20_spwg_18 = {
1280         .modes = &nlt_nl12880bc20_mode,
1281         .num_modes = 1,
1282         .bpc = 6,
1283         .size = {
1284                 .width = 261,
1285                 .height = 163,
1286         },
1287         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
1288 };
1289
1290 static const struct panel_desc nlt_nl12880bc20_spwg_24 = {
1291         .modes = &nlt_nl12880bc20_mode,
1292         .num_modes = 1,
1293         .bpc = 8,
1294         .size = {
1295                 .width = 261,
1296                 .height = 163,
1297         },
1298         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1299 };
1300
1301 static const struct drm_display_mode nvd_9128_mode =
1302         SP_DISPLAY_MODE(29500, 800, 130, 98, 0, 480, 10, 50, 0, 0, 0);
1303
1304 static const struct panel_desc nvd_9128 = {
1305         .modes = &nvd_9128_mode,
1306         .num_modes = 1,
1307         .bpc = 8,
1308         .size = {
1309                 .width = 156,
1310                 .height = 88,
1311         },
1312         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1313 };
1314
1315 static const struct display_timing okaya_rs800480t_7x0gp_timing = {
1316         .pixelclock = { 30000000, 30000000, 40000000 },
1317         .hactive = { 800, 800, 800 },
1318         .hfront_porch = { 40, 40, 40 },
1319         .hback_porch = { 40, 40, 40 },
1320         .hsync_len = { 1, 48, 48 },
1321         .vactive = { 480, 480, 480 },
1322         .vfront_porch = { 13, 13, 13 },
1323         .vback_porch = { 29, 29, 29 },
1324         .vsync_len = { 3, 3, 3 },
1325         .flags = DISPLAY_FLAGS_DE_HIGH,
1326 };
1327
1328 static const struct panel_desc okaya_rs800480t_7x0gp = {
1329         .timings = &okaya_rs800480t_7x0gp_timing,
1330         .num_timings = 1,
1331         .bpc = 6,
1332         .size = {
1333                 .width = 154,
1334                 .height = 87,
1335         },
1336         .delay = {
1337                 .prepare = 41,
1338                 .enable = 50,
1339                 .unprepare = 41,
1340                 .disable = 50,
1341         },
1342         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1343 };
1344
1345 static const struct drm_display_mode olimex_lcd_olinuxino_43ts_mode =
1346         SP_DISPLAY_MODE(9000, 480, 5, 30, 10, 272, 8, 5, 3, 60, 0);
1347
1348 static const struct panel_desc olimex_lcd_olinuxino_43ts = {
1349         .modes = &olimex_lcd_olinuxino_43ts_mode,
1350         .num_modes = 1,
1351         .size = {
1352                 .width = 105,
1353                 .height = 67,
1354         },
1355         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1356 };
1357
1358 /*
1359  * 800x480 CVT. The panel appears to be quite accepting, at least as far as
1360  * pixel clocks, but this is the timing that was being used in the Adafruit
1361  * installation instructions.
1362  */
1363 static const struct drm_display_mode ontat_yx700wv03_mode =
1364         SP_DISPLAY_MODE(29500, 800, 24, 72, 96, 480, 3, 10, 7, 60,
1365                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1366
1367 /*
1368  * Specification at:
1369  * https://www.adafruit.com/images/product-files/2406/c3163.pdf
1370  */
1371 static const struct panel_desc ontat_yx700wv03 = {
1372         .modes = &ontat_yx700wv03_mode,
1373         .num_modes = 1,
1374         .bpc = 8,
1375         .size = {
1376                 .width = 154,
1377                 .height = 83,
1378         },
1379         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1380 };
1381
1382 static const struct drm_display_mode ortustech_com43h4m85ulc_mode  =
1383         SP_DISPLAY_MODE(25000, 480, 10, 10, 15, 800, 3, 3, 3, 60, 0);
1384
1385 static const struct panel_desc ortustech_com43h4m85ulc = {
1386         .modes = &ortustech_com43h4m85ulc_mode,
1387         .num_modes = 1,
1388         .bpc = 8,
1389         .size = {
1390                 .width = 56,
1391                 .height = 93,
1392         },
1393         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1394         .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_POSEDGE,
1395 };
1396
1397 static const struct drm_display_mode qd43003c0_40_mode =
1398         SP_DISPLAY_MODE(9000, 480, 8, 4, 39, 272, 4, 10, 2, 60, 0);
1399
1400 static const struct panel_desc qd43003c0_40 = {
1401         .modes = &qd43003c0_40_mode,
1402         .num_modes = 1,
1403         .bpc = 8,
1404         .size = {
1405                 .width = 95,
1406                 .height = 53,
1407         },
1408         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1409 };
1410
1411 static const struct drm_display_mode samsung_lsn122dl01_c01_mode =
1412         SP_DISPLAY_MODE(271560, 2560, 48, 32, 80, 1600, 2, 5, 57, 60, 0);
1413
1414 static const struct panel_desc samsung_lsn122dl01_c01 = {
1415         .modes = &samsung_lsn122dl01_c01_mode,
1416         .num_modes = 1,
1417         .size = {
1418                 .width = 263,
1419                 .height = 164,
1420         },
1421 };
1422
1423 static const struct drm_display_mode samsung_ltn101nt05_mode =
1424         SP_DISPLAY_MODE(54030, 1024, 24, 136, 160, 600, 3, 6, 61, 60, 0);
1425
1426 static const struct panel_desc samsung_ltn101nt05 = {
1427         .modes = &samsung_ltn101nt05_mode,
1428         .num_modes = 1,
1429         .bpc = 6,
1430         .size = {
1431                 .width = 223,
1432                 .height = 125,
1433         },
1434 };
1435
1436 static const struct drm_display_mode samsung_ltn140at29_301_mode =
1437         SP_DISPLAY_MODE(76300, 1366, 64, 48, 128, 768, 2, 5, 17, 60, 0);
1438
1439 static const struct panel_desc samsung_ltn140at29_301 = {
1440         .modes = &samsung_ltn140at29_301_mode,
1441         .num_modes = 1,
1442         .bpc = 6,
1443         .size = {
1444                 .width = 320,
1445                 .height = 187,
1446         },
1447 };
1448
1449 static const struct display_timing sharp_lq101k1ly04_timing = {
1450         .pixelclock = { 60000000, 65000000, 80000000 },
1451         .hactive = { 1280, 1280, 1280 },
1452         .hfront_porch = { 20, 20, 20 },
1453         .hback_porch = { 20, 20, 20 },
1454         .hsync_len = { 10, 10, 10 },
1455         .vactive = { 800, 800, 800 },
1456         .vfront_porch = { 4, 4, 4 },
1457         .vback_porch = { 4, 4, 4 },
1458         .vsync_len = { 4, 4, 4 },
1459         .flags = DISPLAY_FLAGS_PIXDATA_POSEDGE,
1460 };
1461
1462 static const struct panel_desc sharp_lq101k1ly04 = {
1463         .timings = &sharp_lq101k1ly04_timing,
1464         .num_timings = 1,
1465         .bpc = 8,
1466         .size = {
1467                 .width = 217,
1468                 .height = 136,
1469         },
1470         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
1471 };
1472
1473 static const struct drm_display_mode sharp_lq123p1jx31_mode =
1474         SP_DISPLAY_MODE(252750, 2400, 48, 32, 80, 1600, 3, 10, 33, 60,
1475                          DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1476
1477 static const struct panel_desc sharp_lq123p1jx31 = {
1478         .modes = &sharp_lq123p1jx31_mode,
1479         .num_modes = 1,
1480         .bpc = 8,
1481         .size = {
1482                 .width = 259,
1483                 .height = 173,
1484         },
1485         .delay = {
1486                 .prepare = 110,
1487                 .enable = 50,
1488                 .unprepare = 550,
1489         },
1490 };
1491
1492 static const struct drm_display_mode sharp_lq150x1lg11_mode =
1493         SP_DISPLAY_MODE(71100, 1024, 168, 64, 88, 768, 37, 2, 8, 60, 0);
1494
1495 static const struct panel_desc sharp_lq150x1lg11 = {
1496         .modes = &sharp_lq150x1lg11_mode,
1497         .num_modes = 1,
1498         .bpc = 6,
1499         .size = {
1500                 .width = 304,
1501                 .height = 228,
1502         },
1503         .bus_format = MEDIA_BUS_FMT_RGB565_1X16,
1504 };
1505
1506 static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode =
1507         SP_DISPLAY_MODE(33300, 800, 1, 64, 64, 480, 1, 23, 22, 60, 0);
1508
1509 static const struct panel_desc shelly_sca07010_bfn_lnn = {
1510         .modes = &shelly_sca07010_bfn_lnn_mode,
1511         .num_modes = 1,
1512         .size = {
1513                 .width = 152,
1514                 .height = 91,
1515         },
1516         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1517 };
1518
1519 static const struct drm_display_mode starry_kr122ea0sra_mode =
1520         SP_DISPLAY_MODE(147000, 1920, 16, 16, 32, 1200, 15, 2, 18, 60,
1521                          DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1522
1523 static const struct panel_desc starry_kr122ea0sra = {
1524         .modes = &starry_kr122ea0sra_mode,
1525         .num_modes = 1,
1526         .size = {
1527                 .width = 263,
1528                 .height = 164,
1529         },
1530         .delay = {
1531                 .prepare = 10 + 200,
1532                 .enable = 50,
1533                 .unprepare = 10 + 500,
1534         },
1535 };
1536
1537 static const struct display_timing tianma_tm070jdhg30_timing = {
1538         .pixelclock = { 62600000, 68200000, 78100000 },
1539         .hactive = { 1280, 1280, 1280 },
1540         .hfront_porch = { 15, 64, 159 },
1541         .hback_porch = { 5, 5, 5 },
1542         .hsync_len = { 1, 1, 256 },
1543         .vactive = { 800, 800, 800 },
1544         .vfront_porch = { 3, 40, 99 },
1545         .vback_porch = { 2, 2, 2 },
1546         .vsync_len = { 1, 1, 128 },
1547         .flags = DISPLAY_FLAGS_DE_HIGH,
1548 };
1549
1550 static const struct panel_desc tianma_tm070jdhg30 = {
1551         .timings = &tianma_tm070jdhg30_timing,
1552         .num_timings = 1,
1553         .bpc = 8,
1554         .size = {
1555                 .width = 151,
1556                 .height = 95,
1557         },
1558         .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1559 };
1560
1561 static const struct drm_display_mode tpk_f07a_0102_mode =
1562         SP_DISPLAY_MODE(33260, 800, 40, 128, 88, 480, 10, 2, 33, 60, 0);
1563
1564 static const struct panel_desc tpk_f07a_0102 = {
1565         .modes = &tpk_f07a_0102_mode,
1566         .num_modes = 1,
1567         .size = {
1568                 .width = 152,
1569                 .height = 91,
1570         },
1571         .bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE,
1572 };
1573
1574 static const struct drm_display_mode tpk_f10a_0102_mode =
1575         SP_DISPLAY_MODE(45000, 1024, 176, 5, 88, 600, 20, 5, 25, 60, 0);
1576
1577 static const struct panel_desc tpk_f10a_0102 = {
1578         .modes = &tpk_f10a_0102_mode,
1579         .num_modes = 1,
1580         .size = {
1581                 .width = 223,
1582                 .height = 125,
1583         },
1584 };
1585
1586 static const struct display_timing urt_umsh_8596md_timing = {
1587         .pixelclock = { 33260000, 33260000, 33260000 },
1588         .hactive = { 800, 800, 800 },
1589         .hfront_porch = { 41, 41, 41 },
1590         .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
1591         .hsync_len = { 71, 128, 128 },
1592         .vactive = { 480, 480, 480 },
1593         .vfront_porch = { 10, 10, 10 },
1594         .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
1595         .vsync_len = { 2, 2, 2 },
1596         .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
1597                 DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
1598 };
1599
1600 static const struct panel_desc urt_umsh_8596md_lvds = {
1601         .timings = &urt_umsh_8596md_timing,
1602         .num_timings = 1,
1603         .bpc = 6,
1604         .size = {
1605                 .width = 152,
1606                 .height = 91,
1607         },
1608         .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
1609 };
1610
1611 static const struct panel_desc urt_umsh_8596md_parallel = {
1612         .timings = &urt_umsh_8596md_timing,
1613         .num_timings = 1,
1614         .bpc = 6,
1615         .size = {
1616                 .width = 152,
1617                 .height = 91,
1618         },
1619         .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1620 };
1621
1622 static const struct drm_display_mode winstar_wf35ltiacd_mode =
1623         SP_DISPLAY_MODE(6410, 320, 20, 30, 38, 240, 4, 3, 15, 60,
1624                         DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1625
1626 static const struct panel_desc winstar_wf35ltiacd = {
1627         .modes = &winstar_wf35ltiacd_mode,
1628         .num_modes = 1,
1629         .bpc = 8,
1630         .size = {
1631                 .width = 70,
1632                 .height = 53,
1633         },
1634         .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1635 };
1636
1637 static const struct of_device_id platform_of_match[] = {
1638         {
1639                 .compatible = "ampire,am-480272h3tmqw-t01h",
1640                 .data = &ampire_am_480272h3tmqw_t01h,
1641         }, {
1642                 .compatible = "ampire,am800480r3tmqwa1h",
1643                 .data = &ampire_am800480r3tmqwa1h,
1644         }, {
1645                 .compatible = "auo,b101aw03",
1646                 .data = &auo_b101aw03,
1647         }, {
1648                 .compatible = "auo,b101ean01",
1649                 .data = &auo_b101ean01,
1650         }, {
1651                 .compatible = "auo,b101xtn01",
1652                 .data = &auo_b101xtn01,
1653         }, {
1654                 .compatible = "auo,b116xw03",
1655                 .data = &auo_b116xw03,
1656         }, {
1657                 .compatible = "auo,b133htn01",
1658                 .data = &auo_b133htn01,
1659         }, {
1660                 .compatible = "auo,b133xtn01",
1661                 .data = &auo_b133xtn01,
1662         }, {
1663                 .compatible = "auo,g133han01",
1664                 .data = &auo_g133han01,
1665         }, {
1666                 .compatible = "auo,g185han01",
1667                 .data = &auo_g185han01,
1668         }, {
1669                 .compatible = "auo,p320hvn03",
1670                 .data = &auo_p320hvn03,
1671         }, {
1672                 .compatible = "auo,t215hvn01",
1673                 .data = &auo_t215hvn01,
1674         }, {
1675                 .compatible = "avic,tm070ddh03",
1676                 .data = &avic_tm070ddh03,
1677         }, {
1678                 .compatible = "boe,nv101wxmn51",
1679                 .data = &boe_nv101wxmn51,
1680         }, {
1681                 .compatible = "chunghwa,claa070wp03xg",
1682                 .data = &chunghwa_claa070wp03xg,
1683         }, {
1684                 .compatible = "chunghwa,claa101wa01a",
1685                 .data = &chunghwa_claa101wa01a
1686         }, {
1687                 .compatible = "chunghwa,claa101wb01",
1688                 .data = &chunghwa_claa101wb01
1689         }, {
1690                 .compatible = "edt,et0350g0dh6",
1691                 .data = &edt_et0350g0dh6,
1692         }, {
1693                 .compatible = "edt,et0430g0dh6",
1694                 .data = &edt_et0430g0dh6,
1695         }, {
1696                 .compatible = "edt,et057090dhu",
1697                 .data = &edt_et057090dhu,
1698         }, {
1699                 .compatible = "edt,et070080dh6",
1700                 .data = &edt_etm0700g0dh6,
1701         }, {
1702                 .compatible = "edt,et1010g0dsa",
1703                 .data = &edt_et1010g0dsa,
1704         }, {
1705                 .compatible = "edt,etml1010g0dka",
1706                 .data = &edt_et1010g0dsa,
1707         }, {
1708                 .compatible = "edt,etm0700g0dh6",
1709                 .data = &edt_etm0700g0dh6,
1710         }, {
1711                 .compatible = "edt,etm0700g0edh6",
1712                 .data = &edt_etm0700g0edh6,
1713         }, {
1714                 .compatible = "foxlink,fl500wvr00-a0t",
1715                 .data = &foxlink_fl500wvr00_a0t,
1716         }, {
1717                 .compatible = "giantplus,gpg482739qs5",
1718                 .data = &giantplus_gpg482739qs5
1719         }, {
1720                 .compatible = "hannstar,hsd070pww1",
1721                 .data = &hannstar_hsd070pww1,
1722         }, {
1723                 .compatible = "hannstar,hsd100pxn1",
1724                 .data = &hannstar_hsd100pxn1,
1725         }, {
1726                 .compatible = "hit,tx23d38vm0caa",
1727                 .data = &hitachi_tx23d38vm0caa
1728         }, {
1729                 .compatible = "innolux,at043tn24",
1730                 .data = &innolux_at043tn24,
1731         }, {
1732                 .compatible = "innolux,at070tn92",
1733                 .data = &innolux_at070tn92,
1734         }, {
1735                 .compatible ="innolux,g101ice-l01",
1736                 .data = &innolux_g101ice_l01
1737         }, {
1738                 .compatible ="innolux,g121i1-l01",
1739                 .data = &innolux_g121i1_l01
1740         }, {
1741                 .compatible = "innolux,g121x1-l03",
1742                 .data = &innolux_g121x1_l03,
1743         }, {
1744                 .compatible = "innolux,n116bge",
1745                 .data = &innolux_n116bge,
1746         }, {
1747                 .compatible = "innolux,n156bge-l21",
1748                 .data = &innolux_n156bge_l21,
1749         }, {
1750                 .compatible = "innolux,zj070na-01p",
1751                 .data = &innolux_zj070na_01p,
1752         }, {
1753                 .compatible = "kyo,tcg121xglp",
1754                 .data = &kyo_tcg121xglp,
1755         }, {
1756                 .compatible = "lg,lb070wv8",
1757                 .data = &lg_lb070wv8,
1758         }, {
1759                 .compatible = "lg,lp079qx1-sp0v",
1760                 .data = &lg_lp079qx1_sp0v,
1761         }, {
1762                 .compatible = "lg,lp097qx1-spa1",
1763                 .data = &lg_lp097qx1_spa1,
1764         }, {
1765                 .compatible = "lg,lp120up1",
1766                 .data = &lg_lp120up1,
1767         }, {
1768                 .compatible = "lg,lp129qe",
1769                 .data = &lg_lp129qe,
1770         }, {
1771                 .compatible = "nec,nl12880bc20-05",
1772                 .data = &nec_nl12880bc20_05,
1773         }, {
1774                 .compatible = "nec,nl4827hc19-05b",
1775                 .data = &nec_nl4827hc19_05b,
1776         }, {
1777                 .compatible = "netron-dy,e231732",
1778                 .data = &netron_dy_e231732,
1779         }, {
1780                 .compatible = "nlt,nl192108ac18-02d",
1781                 .data = &nlt_nl192108ac18_02d,
1782         }, {
1783                 .compatible = "nlt,nl12880bc20-jeida",
1784                 .data = &nlt_nl12880bc20_jeida,
1785         }, {
1786                 .compatible = "nlt,nl12880bc20-spwg-18",
1787                 .data = &nlt_nl12880bc20_spwg_18,
1788         }, {
1789                 .compatible = "nlt,nl12880bc20-spwg-24",
1790                 .data = &nlt_nl12880bc20_spwg_24,
1791         }, {
1792                 .compatible = "nvd,9128",
1793                 .data = &nvd_9128,
1794         }, {
1795                 .compatible = "okaya,rs800480t-7x0gp",
1796                 .data = &okaya_rs800480t_7x0gp,
1797         }, {
1798                 .compatible = "olimex,lcd-olinuxino-43-ts",
1799                 .data = &olimex_lcd_olinuxino_43ts,
1800         }, {
1801                 .compatible = "ontat,yx700wv03",
1802                 .data = &ontat_yx700wv03,
1803         }, {
1804                 .compatible = "ortustech,com43h4m85ulc",
1805                 .data = &ortustech_com43h4m85ulc,
1806         }, {
1807                 .compatible = "qiaodian,qd43003c0-40",
1808                 .data = &qd43003c0_40,
1809         }, {
1810                 .compatible = "samsung,lsn122dl01-c01",
1811                 .data = &samsung_lsn122dl01_c01,
1812         }, {
1813                 .compatible = "samsung,ltn101nt05",
1814                 .data = &samsung_ltn101nt05,
1815         }, {
1816                 .compatible = "samsung,ltn140at29-301",
1817                 .data = &samsung_ltn140at29_301,
1818         }, {
1819                 .compatible = "sharp,lq101k1ly04",
1820                 .data = &sharp_lq101k1ly04,
1821         }, {
1822                 .compatible = "sharp,lq123p1jx31",
1823                 .data = &sharp_lq123p1jx31,
1824         }, {
1825                 .compatible = "sharp,lq150x1lg11",
1826                 .data = &sharp_lq150x1lg11,
1827         }, {
1828                 .compatible = "shelly,sca07010-bfn-lnn",
1829                 .data = &shelly_sca07010_bfn_lnn,
1830         }, {
1831                 .compatible = "starry,kr122ea0sra",
1832                 .data = &starry_kr122ea0sra,
1833         }, {
1834                 .compatible = "tianma,tm070jdhg30",
1835                 .data = &tianma_tm070jdhg30,
1836         }, {
1837                 .compatible = "tpk,f07a-0102",
1838                 .data = &tpk_f07a_0102,
1839         }, {
1840                 .compatible = "tpk,f10a-0102",
1841                 .data = &tpk_f10a_0102,
1842         }, {
1843                 .compatible = "urt,umsh-8596md-t",
1844                 .data = &urt_umsh_8596md_parallel,
1845         }, {
1846                 .compatible = "urt,umsh-8596md-1t",
1847                 .data = &urt_umsh_8596md_parallel,
1848         }, {
1849                 .compatible = "urt,umsh-8596md-7t",
1850                 .data = &urt_umsh_8596md_parallel,
1851         }, {
1852                 .compatible = "urt,umsh-8596md-11t",
1853                 .data = &urt_umsh_8596md_lvds,
1854         }, {
1855                 .compatible = "urt,umsh-8596md-19t",
1856                 .data = &urt_umsh_8596md_lvds,
1857         }, {
1858                 .compatible = "urt,umsh-8596md-20t",
1859                 .data = &urt_umsh_8596md_parallel,
1860         }, {
1861                 .compatible = "winstar,wf35ltiacd",
1862                 .data = &winstar_wf35ltiacd,
1863         }, {
1864                 /* sentinel */
1865         }
1866 };
1867 MODULE_DEVICE_TABLE(of, platform_of_match);
1868
1869 static int panel_simple_platform_probe(struct platform_device *pdev)
1870 {
1871         const struct of_device_id *id;
1872
1873         id = of_match_node(platform_of_match, pdev->dev.of_node);
1874         if (!id)
1875                 return -ENODEV;
1876
1877         return panel_simple_probe(&pdev->dev, id->data);
1878 }
1879
1880 static int panel_simple_platform_remove(struct platform_device *pdev)
1881 {
1882         return panel_simple_remove(&pdev->dev);
1883 }
1884
1885 static void panel_simple_platform_shutdown(struct platform_device *pdev)
1886 {
1887         panel_simple_shutdown(&pdev->dev);
1888 }
1889
1890 static struct platform_driver panel_simple_platform_driver = {
1891         .driver = {
1892                 .name = "panel-simple",
1893                 .of_match_table = platform_of_match,
1894         },
1895         .probe = panel_simple_platform_probe,
1896         .remove = panel_simple_platform_remove,
1897         .shutdown = panel_simple_platform_shutdown,
1898 };
1899
1900 struct panel_desc_dsi {
1901         struct panel_desc desc;
1902
1903         unsigned long flags;
1904         enum mipi_dsi_pixel_format format;
1905         unsigned int lanes;
1906 };
1907
1908 static const struct drm_display_mode auo_b080uan01_mode =
1909         SP_DISPLAY_MODE(154500, 1200, 62, 4, 62, 1920, 9, 2, 8, 60, 0);
1910
1911 static const struct panel_desc_dsi auo_b080uan01 = {
1912         .desc = {
1913                 .modes = &auo_b080uan01_mode,
1914                 .num_modes = 1,
1915                 .bpc = 8,
1916                 .size = {
1917                         .width = 108,
1918                         .height = 272,
1919                 },
1920         },
1921         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1922         .format = MIPI_DSI_FMT_RGB888,
1923         .lanes = 4,
1924 };
1925
1926 static const struct drm_display_mode boe_tv080wum_nl0_mode =
1927         SP_DISPLAY_MODE(160000, 1200, 120, 20, 21, 1920, 21, 3, 18, 60,
1928                          DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC);
1929
1930 static const struct panel_desc_dsi boe_tv080wum_nl0 = {
1931         .desc = {
1932                 .modes = &boe_tv080wum_nl0_mode,
1933                 .num_modes = 1,
1934                 .size = {
1935                         .width = 107,
1936                         .height = 172,
1937                 },
1938         },
1939         .flags = MIPI_DSI_MODE_VIDEO |
1940                  MIPI_DSI_MODE_VIDEO_BURST |
1941                  MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1942         .format = MIPI_DSI_FMT_RGB888,
1943         .lanes = 4,
1944 };
1945
1946 static const struct drm_display_mode lg_ld070wx3_sl01_mode =
1947         SP_DISPLAY_MODE(71000, 800, 32, 1, 57, 1280, 28, 1, 14, 60, 0);
1948
1949 static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
1950         .desc = {
1951                 .modes = &lg_ld070wx3_sl01_mode,
1952                 .num_modes = 1,
1953                 .bpc = 8,
1954                 .size = {
1955                         .width = 94,
1956                         .height = 151,
1957                 },
1958         },
1959         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1960         .format = MIPI_DSI_FMT_RGB888,
1961         .lanes = 4,
1962 };
1963
1964 static const struct drm_display_mode lg_lh500wx1_sd03_mode =
1965         SP_DISPLAY_MODE(67000, 720, 12, 4, 112, 1280, 8, 4, 12, 60, 0);
1966
1967 static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
1968         .desc = {
1969                 .modes = &lg_lh500wx1_sd03_mode,
1970                 .num_modes = 1,
1971                 .bpc = 8,
1972                 .size = {
1973                         .width = 62,
1974                         .height = 110,
1975                 },
1976         },
1977         .flags = MIPI_DSI_MODE_VIDEO,
1978         .format = MIPI_DSI_FMT_RGB888,
1979         .lanes = 4,
1980 };
1981
1982 static const struct drm_display_mode panasonic_vvx10f004b00_mode =
1983         SP_DISPLAY_MODE(157200, 1920, 154, 16, 32, 1200, 17, 2, 16, 60, 0);
1984
1985 static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
1986         .desc = {
1987                 .modes = &panasonic_vvx10f004b00_mode,
1988                 .num_modes = 1,
1989                 .bpc = 8,
1990                 .size = {
1991                         .width = 217,
1992                         .height = 136,
1993                 },
1994         },
1995         .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1996                  MIPI_DSI_CLOCK_NON_CONTINUOUS,
1997         .format = MIPI_DSI_FMT_RGB888,
1998         .lanes = 4,
1999 };
2000
2001 static const struct of_device_id dsi_of_match[] = {
2002         {
2003                 .compatible = "auo,b080uan01",
2004                 .data = &auo_b080uan01
2005         }, {
2006                 .compatible = "boe,tv080wum-nl0",
2007                 .data = &boe_tv080wum_nl0
2008         }, {
2009                 .compatible = "lg,ld070wx3-sl01",
2010                 .data = &lg_ld070wx3_sl01
2011         }, {
2012                 .compatible = "lg,lh500wx1-sd03",
2013                 .data = &lg_lh500wx1_sd03
2014         }, {
2015                 .compatible = "panasonic,vvx10f004b00",
2016                 .data = &panasonic_vvx10f004b00
2017         }, {
2018                 /* sentinel */
2019         }
2020 };
2021 MODULE_DEVICE_TABLE(of, dsi_of_match);
2022
2023 static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
2024 {
2025         const struct panel_desc_dsi *desc;
2026         const struct of_device_id *id;
2027         int err;
2028
2029         id = of_match_node(dsi_of_match, dsi->dev.of_node);
2030         if (!id)
2031                 return -ENODEV;
2032
2033         desc = id->data;
2034
2035         err = panel_simple_probe(&dsi->dev, &desc->desc);
2036         if (err < 0)
2037                 return err;
2038
2039         dsi->mode_flags = desc->flags;
2040         dsi->format = desc->format;
2041         dsi->lanes = desc->lanes;
2042
2043         return mipi_dsi_attach(dsi);
2044 }
2045
2046 static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
2047 {
2048         int err;
2049
2050         err = mipi_dsi_detach(dsi);
2051         if (err < 0)
2052                 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
2053
2054         return panel_simple_remove(&dsi->dev);
2055 }
2056
2057 static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
2058 {
2059         panel_simple_shutdown(&dsi->dev);
2060 }
2061
2062 static struct mipi_dsi_driver panel_simple_dsi_driver = {
2063         .driver = {
2064                 .name = "panel-simple-dsi",
2065                 .of_match_table = dsi_of_match,
2066         },
2067         .probe = panel_simple_dsi_probe,
2068         .remove = panel_simple_dsi_remove,
2069         .shutdown = panel_simple_dsi_shutdown,
2070 };
2071
2072 static int __init panel_simple_init(void)
2073 {
2074         int err;
2075
2076         err = platform_driver_register(&panel_simple_platform_driver);
2077         if (err < 0)
2078                 return err;
2079
2080         if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
2081                 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
2082                 if (err < 0)
2083                         return err;
2084         }
2085
2086         return 0;
2087 }
2088 module_init(panel_simple_init);
2089
2090 static void __exit panel_simple_exit(void)
2091 {
2092         if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
2093                 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
2094
2095         platform_driver_unregister(&panel_simple_platform_driver);
2096 }
2097 module_exit(panel_simple_exit);
2098
2099 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
2100 MODULE_DESCRIPTION("DRM Driver for Simple Panels");
2101 MODULE_LICENSE("GPL and additional rights");