blob: a06d9d353bec8024763cf2bce4a888aec3409b01 [file] [log] [blame]
Thierry Reding280921d2013-08-30 15:10:14 +02001/*
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>
Alexandre Courbotcfdf0542014-03-01 14:00:58 +090025#include <linux/gpio/consumer.h>
Thierry Reding280921d2013-08-30 15:10:14 +020026#include <linux/module.h>
Thierry Reding280921d2013-08-30 15:10:14 +020027#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>
Thierry Reding210fcd92013-11-22 19:27:11 +010033#include <drm/drm_mipi_dsi.h>
Thierry Reding280921d2013-08-30 15:10:14 +020034#include <drm/drm_panel.h>
35
Philipp Zabela5d3e622014-12-11 18:32:45 +010036#include <video/display_timing.h>
37#include <video/videomode.h>
38
Thierry Reding280921d2013-08-30 15:10:14 +020039struct panel_desc {
40 const struct drm_display_mode *modes;
41 unsigned int num_modes;
Philipp Zabela5d3e622014-12-11 18:32:45 +010042 const struct display_timing *timings;
43 unsigned int num_timings;
Thierry Reding280921d2013-08-30 15:10:14 +020044
Stéphane Marchesin0208d512014-06-19 18:18:28 -070045 unsigned int bpc;
46
Thierry Reding280921d2013-08-30 15:10:14 +020047 struct {
48 unsigned int width;
49 unsigned int height;
50 } size;
Ajay Kumarf673c372014-07-31 23:12:11 +053051
52 /**
53 * @prepare: the time (in milliseconds) that it takes for the panel to
54 * become ready and start receiving video data
55 * @enable: the time (in milliseconds) that it takes for the panel to
56 * display the first valid frame after starting to receive
57 * video data
58 * @disable: the time (in milliseconds) that it takes for the panel to
59 * turn the display off (no content is visible)
60 * @unprepare: the time (in milliseconds) that it takes for the panel
61 * to power itself down completely
62 */
63 struct {
64 unsigned int prepare;
65 unsigned int enable;
66 unsigned int disable;
67 unsigned int unprepare;
68 } delay;
Boris Brezillon795f7ab2014-07-22 13:33:59 +020069
70 u32 bus_format;
Thierry Reding280921d2013-08-30 15:10:14 +020071};
72
Thierry Reding280921d2013-08-30 15:10:14 +020073struct panel_simple {
74 struct drm_panel base;
Ajay Kumar613a6332014-07-31 23:12:10 +053075 bool prepared;
Thierry Reding280921d2013-08-30 15:10:14 +020076 bool enabled;
77
78 const struct panel_desc *desc;
79
80 struct backlight_device *backlight;
81 struct regulator *supply;
82 struct i2c_adapter *ddc;
83
Alexandre Courbotcfdf0542014-03-01 14:00:58 +090084 struct gpio_desc *enable_gpio;
Thierry Reding280921d2013-08-30 15:10:14 +020085};
86
87static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
88{
89 return container_of(panel, struct panel_simple, base);
90}
91
92static int panel_simple_get_fixed_modes(struct panel_simple *panel)
93{
94 struct drm_connector *connector = panel->base.connector;
95 struct drm_device *drm = panel->base.drm;
96 struct drm_display_mode *mode;
97 unsigned int i, num = 0;
98
99 if (!panel->desc)
100 return 0;
101
Philipp Zabela5d3e622014-12-11 18:32:45 +0100102 for (i = 0; i < panel->desc->num_timings; i++) {
103 const struct display_timing *dt = &panel->desc->timings[i];
104 struct videomode vm;
105
106 videomode_from_timing(dt, &vm);
107 mode = drm_mode_create(drm);
108 if (!mode) {
109 dev_err(drm->dev, "failed to add mode %ux%u\n",
110 dt->hactive.typ, dt->vactive.typ);
111 continue;
112 }
113
114 drm_display_mode_from_videomode(&vm, mode);
115 drm_mode_set_name(mode);
116
117 drm_mode_probed_add(connector, mode);
118 num++;
119 }
120
Thierry Reding280921d2013-08-30 15:10:14 +0200121 for (i = 0; i < panel->desc->num_modes; i++) {
122 const struct drm_display_mode *m = &panel->desc->modes[i];
123
124 mode = drm_mode_duplicate(drm, m);
125 if (!mode) {
126 dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
127 m->hdisplay, m->vdisplay, m->vrefresh);
128 continue;
129 }
130
131 drm_mode_set_name(mode);
132
133 drm_mode_probed_add(connector, mode);
134 num++;
135 }
136
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700137 connector->display_info.bpc = panel->desc->bpc;
Thierry Reding280921d2013-08-30 15:10:14 +0200138 connector->display_info.width_mm = panel->desc->size.width;
139 connector->display_info.height_mm = panel->desc->size.height;
Boris Brezillon795f7ab2014-07-22 13:33:59 +0200140 if (panel->desc->bus_format)
141 drm_display_info_set_bus_formats(&connector->display_info,
142 &panel->desc->bus_format, 1);
Thierry Reding280921d2013-08-30 15:10:14 +0200143
144 return num;
145}
146
147static int panel_simple_disable(struct drm_panel *panel)
148{
149 struct panel_simple *p = to_panel_simple(panel);
150
151 if (!p->enabled)
152 return 0;
153
154 if (p->backlight) {
155 p->backlight->props.power = FB_BLANK_POWERDOWN;
156 backlight_update_status(p->backlight);
157 }
158
Ajay Kumarf673c372014-07-31 23:12:11 +0530159 if (p->desc->delay.disable)
160 msleep(p->desc->delay.disable);
161
Thierry Reding280921d2013-08-30 15:10:14 +0200162 p->enabled = false;
163
164 return 0;
165}
166
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530167static int panel_simple_unprepare(struct drm_panel *panel)
168{
Ajay Kumar613a6332014-07-31 23:12:10 +0530169 struct panel_simple *p = to_panel_simple(panel);
170
171 if (!p->prepared)
172 return 0;
173
174 if (p->enable_gpio)
175 gpiod_set_value_cansleep(p->enable_gpio, 0);
176
177 regulator_disable(p->supply);
178
Ajay Kumarf673c372014-07-31 23:12:11 +0530179 if (p->desc->delay.unprepare)
180 msleep(p->desc->delay.unprepare);
181
Ajay Kumar613a6332014-07-31 23:12:10 +0530182 p->prepared = false;
183
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530184 return 0;
185}
186
187static int panel_simple_prepare(struct drm_panel *panel)
188{
Thierry Reding280921d2013-08-30 15:10:14 +0200189 struct panel_simple *p = to_panel_simple(panel);
190 int err;
191
Ajay Kumar613a6332014-07-31 23:12:10 +0530192 if (p->prepared)
Thierry Reding280921d2013-08-30 15:10:14 +0200193 return 0;
194
195 err = regulator_enable(p->supply);
196 if (err < 0) {
197 dev_err(panel->dev, "failed to enable supply: %d\n", err);
198 return err;
199 }
200
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900201 if (p->enable_gpio)
Thierry Reding15c1a912014-03-14 12:03:47 +0100202 gpiod_set_value_cansleep(p->enable_gpio, 1);
Thierry Reding280921d2013-08-30 15:10:14 +0200203
Ajay Kumarf673c372014-07-31 23:12:11 +0530204 if (p->desc->delay.prepare)
205 msleep(p->desc->delay.prepare);
206
Ajay Kumar613a6332014-07-31 23:12:10 +0530207 p->prepared = true;
208
209 return 0;
210}
211
212static int panel_simple_enable(struct drm_panel *panel)
213{
214 struct panel_simple *p = to_panel_simple(panel);
215
216 if (p->enabled)
217 return 0;
218
Ajay Kumarf673c372014-07-31 23:12:11 +0530219 if (p->desc->delay.enable)
220 msleep(p->desc->delay.enable);
221
Thierry Reding280921d2013-08-30 15:10:14 +0200222 if (p->backlight) {
223 p->backlight->props.power = FB_BLANK_UNBLANK;
224 backlight_update_status(p->backlight);
225 }
226
227 p->enabled = true;
228
229 return 0;
230}
231
232static int panel_simple_get_modes(struct drm_panel *panel)
233{
234 struct panel_simple *p = to_panel_simple(panel);
235 int num = 0;
236
237 /* probe EDID if a DDC bus is available */
238 if (p->ddc) {
239 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
Stephen Warren70bf6872014-01-09 11:37:34 -0700240 drm_mode_connector_update_edid_property(panel->connector, edid);
Thierry Reding280921d2013-08-30 15:10:14 +0200241 if (edid) {
242 num += drm_add_edid_modes(panel->connector, edid);
243 kfree(edid);
244 }
245 }
246
247 /* add hard-coded panel modes */
248 num += panel_simple_get_fixed_modes(p);
249
250 return num;
251}
252
Philipp Zabela5d3e622014-12-11 18:32:45 +0100253static int panel_simple_get_timings(struct drm_panel *panel,
254 unsigned int num_timings,
255 struct display_timing *timings)
256{
257 struct panel_simple *p = to_panel_simple(panel);
258 unsigned int i;
259
260 if (p->desc->num_timings < num_timings)
261 num_timings = p->desc->num_timings;
262
263 if (timings)
264 for (i = 0; i < num_timings; i++)
265 timings[i] = p->desc->timings[i];
266
267 return p->desc->num_timings;
268}
269
Thierry Reding280921d2013-08-30 15:10:14 +0200270static const struct drm_panel_funcs panel_simple_funcs = {
271 .disable = panel_simple_disable,
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530272 .unprepare = panel_simple_unprepare,
273 .prepare = panel_simple_prepare,
Thierry Reding280921d2013-08-30 15:10:14 +0200274 .enable = panel_simple_enable,
275 .get_modes = panel_simple_get_modes,
Philipp Zabela5d3e622014-12-11 18:32:45 +0100276 .get_timings = panel_simple_get_timings,
Thierry Reding280921d2013-08-30 15:10:14 +0200277};
278
279static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
280{
281 struct device_node *backlight, *ddc;
282 struct panel_simple *panel;
Thierry Reding280921d2013-08-30 15:10:14 +0200283 int err;
284
285 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
286 if (!panel)
287 return -ENOMEM;
288
289 panel->enabled = false;
Ajay Kumar613a6332014-07-31 23:12:10 +0530290 panel->prepared = false;
Thierry Reding280921d2013-08-30 15:10:14 +0200291 panel->desc = desc;
292
293 panel->supply = devm_regulator_get(dev, "power");
294 if (IS_ERR(panel->supply))
295 return PTR_ERR(panel->supply);
296
Alexandre Courbota61400d2014-10-23 17:16:58 +0900297 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
298 GPIOD_OUT_LOW);
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900299 if (IS_ERR(panel->enable_gpio)) {
300 err = PTR_ERR(panel->enable_gpio);
Alexandre Courbot9746c612014-07-25 23:47:25 +0900301 dev_err(dev, "failed to request GPIO: %d\n", err);
302 return err;
303 }
Thierry Reding280921d2013-08-30 15:10:14 +0200304
Thierry Reding280921d2013-08-30 15:10:14 +0200305 backlight = of_parse_phandle(dev->of_node, "backlight", 0);
306 if (backlight) {
307 panel->backlight = of_find_backlight_by_node(backlight);
308 of_node_put(backlight);
309
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900310 if (!panel->backlight)
311 return -EPROBE_DEFER;
Thierry Reding280921d2013-08-30 15:10:14 +0200312 }
313
314 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
315 if (ddc) {
316 panel->ddc = of_find_i2c_adapter_by_node(ddc);
317 of_node_put(ddc);
318
319 if (!panel->ddc) {
320 err = -EPROBE_DEFER;
321 goto free_backlight;
322 }
323 }
324
325 drm_panel_init(&panel->base);
326 panel->base.dev = dev;
327 panel->base.funcs = &panel_simple_funcs;
328
329 err = drm_panel_add(&panel->base);
330 if (err < 0)
331 goto free_ddc;
332
333 dev_set_drvdata(dev, panel);
334
335 return 0;
336
337free_ddc:
338 if (panel->ddc)
339 put_device(&panel->ddc->dev);
340free_backlight:
341 if (panel->backlight)
342 put_device(&panel->backlight->dev);
Thierry Reding280921d2013-08-30 15:10:14 +0200343
344 return err;
345}
346
347static int panel_simple_remove(struct device *dev)
348{
349 struct panel_simple *panel = dev_get_drvdata(dev);
350
351 drm_panel_detach(&panel->base);
352 drm_panel_remove(&panel->base);
353
354 panel_simple_disable(&panel->base);
355
356 if (panel->ddc)
357 put_device(&panel->ddc->dev);
358
359 if (panel->backlight)
360 put_device(&panel->backlight->dev);
361
Thierry Reding280921d2013-08-30 15:10:14 +0200362 return 0;
363}
364
Thierry Redingd02fd932014-04-29 17:21:21 +0200365static void panel_simple_shutdown(struct device *dev)
366{
367 struct panel_simple *panel = dev_get_drvdata(dev);
368
369 panel_simple_disable(&panel->base);
370}
371
Philipp Zabel1c550fa12015-02-11 18:50:09 +0100372static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
373 .clock = 33333,
374 .hdisplay = 800,
375 .hsync_start = 800 + 0,
376 .hsync_end = 800 + 0 + 255,
377 .htotal = 800 + 0 + 255 + 0,
378 .vdisplay = 480,
379 .vsync_start = 480 + 2,
380 .vsync_end = 480 + 2 + 45,
381 .vtotal = 480 + 2 + 45 + 0,
382 .vrefresh = 60,
383 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
384};
385
386static const struct panel_desc ampire_am800480r3tmqwa1h = {
387 .modes = &ampire_am800480r3tmqwa1h_mode,
388 .num_modes = 1,
389 .bpc = 6,
390 .size = {
391 .width = 152,
392 .height = 91,
393 },
394 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
395};
396
Thierry Reding280921d2013-08-30 15:10:14 +0200397static const struct drm_display_mode auo_b101aw03_mode = {
398 .clock = 51450,
399 .hdisplay = 1024,
400 .hsync_start = 1024 + 156,
401 .hsync_end = 1024 + 156 + 8,
402 .htotal = 1024 + 156 + 8 + 156,
403 .vdisplay = 600,
404 .vsync_start = 600 + 16,
405 .vsync_end = 600 + 16 + 6,
406 .vtotal = 600 + 16 + 6 + 16,
407 .vrefresh = 60,
408};
409
410static const struct panel_desc auo_b101aw03 = {
411 .modes = &auo_b101aw03_mode,
412 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700413 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200414 .size = {
415 .width = 223,
416 .height = 125,
417 },
418};
419
Huang Lina531bc32015-02-28 10:18:58 +0800420static const struct drm_display_mode auo_b101ean01_mode = {
421 .clock = 72500,
422 .hdisplay = 1280,
423 .hsync_start = 1280 + 119,
424 .hsync_end = 1280 + 119 + 32,
425 .htotal = 1280 + 119 + 32 + 21,
426 .vdisplay = 800,
427 .vsync_start = 800 + 4,
428 .vsync_end = 800 + 4 + 20,
429 .vtotal = 800 + 4 + 20 + 8,
430 .vrefresh = 60,
431};
432
433static const struct panel_desc auo_b101ean01 = {
434 .modes = &auo_b101ean01_mode,
435 .num_modes = 1,
436 .bpc = 6,
437 .size = {
438 .width = 217,
439 .height = 136,
440 },
441};
442
Rob Clarkdac746e2014-08-01 17:01:06 -0400443static const struct drm_display_mode auo_b101xtn01_mode = {
444 .clock = 72000,
445 .hdisplay = 1366,
446 .hsync_start = 1366 + 20,
447 .hsync_end = 1366 + 20 + 70,
448 .htotal = 1366 + 20 + 70,
449 .vdisplay = 768,
450 .vsync_start = 768 + 14,
451 .vsync_end = 768 + 14 + 42,
452 .vtotal = 768 + 14 + 42,
453 .vrefresh = 60,
454 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
455};
456
457static const struct panel_desc auo_b101xtn01 = {
458 .modes = &auo_b101xtn01_mode,
459 .num_modes = 1,
460 .bpc = 6,
461 .size = {
462 .width = 223,
463 .height = 125,
464 },
465};
466
Ajay Kumare35e3052014-09-01 15:40:02 +0530467static const struct drm_display_mode auo_b116xw03_mode = {
468 .clock = 70589,
469 .hdisplay = 1366,
470 .hsync_start = 1366 + 40,
471 .hsync_end = 1366 + 40 + 40,
472 .htotal = 1366 + 40 + 40 + 32,
473 .vdisplay = 768,
474 .vsync_start = 768 + 10,
475 .vsync_end = 768 + 10 + 12,
476 .vtotal = 768 + 10 + 12 + 6,
477 .vrefresh = 60,
478};
479
480static const struct panel_desc auo_b116xw03 = {
481 .modes = &auo_b116xw03_mode,
482 .num_modes = 1,
483 .bpc = 6,
484 .size = {
485 .width = 256,
486 .height = 144,
487 },
488};
489
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700490static const struct drm_display_mode auo_b133xtn01_mode = {
491 .clock = 69500,
492 .hdisplay = 1366,
493 .hsync_start = 1366 + 48,
494 .hsync_end = 1366 + 48 + 32,
495 .htotal = 1366 + 48 + 32 + 20,
496 .vdisplay = 768,
497 .vsync_start = 768 + 3,
498 .vsync_end = 768 + 3 + 6,
499 .vtotal = 768 + 3 + 6 + 13,
500 .vrefresh = 60,
501};
502
503static const struct panel_desc auo_b133xtn01 = {
504 .modes = &auo_b133xtn01_mode,
505 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700506 .bpc = 6,
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700507 .size = {
508 .width = 293,
509 .height = 165,
510 },
511};
512
Ajay Kumar3e51d602014-07-31 23:12:12 +0530513static const struct drm_display_mode auo_b133htn01_mode = {
514 .clock = 150660,
515 .hdisplay = 1920,
516 .hsync_start = 1920 + 172,
517 .hsync_end = 1920 + 172 + 80,
518 .htotal = 1920 + 172 + 80 + 60,
519 .vdisplay = 1080,
520 .vsync_start = 1080 + 25,
521 .vsync_end = 1080 + 25 + 10,
522 .vtotal = 1080 + 25 + 10 + 10,
523 .vrefresh = 60,
524};
525
526static const struct panel_desc auo_b133htn01 = {
527 .modes = &auo_b133htn01_mode,
528 .num_modes = 1,
Thierry Redingd7a839c2014-11-06 10:11:01 +0100529 .bpc = 6,
Ajay Kumar3e51d602014-07-31 23:12:12 +0530530 .size = {
531 .width = 293,
532 .height = 165,
533 },
534 .delay = {
535 .prepare = 105,
536 .enable = 20,
537 .unprepare = 50,
538 },
539};
540
Philipp Zabeld47df632014-12-18 16:43:43 +0100541static const struct drm_display_mode avic_tm070ddh03_mode = {
542 .clock = 51200,
543 .hdisplay = 1024,
544 .hsync_start = 1024 + 160,
545 .hsync_end = 1024 + 160 + 4,
546 .htotal = 1024 + 160 + 4 + 156,
547 .vdisplay = 600,
548 .vsync_start = 600 + 17,
549 .vsync_end = 600 + 17 + 1,
550 .vtotal = 600 + 17 + 1 + 17,
551 .vrefresh = 60,
552};
553
554static const struct panel_desc avic_tm070ddh03 = {
555 .modes = &avic_tm070ddh03_mode,
556 .num_modes = 1,
557 .bpc = 8,
558 .size = {
559 .width = 154,
560 .height = 90,
561 },
562 .delay = {
563 .prepare = 20,
564 .enable = 200,
565 .disable = 200,
566 },
567};
568
Stephen Warren4c930752014-01-07 16:46:26 -0700569static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
570 .clock = 72070,
571 .hdisplay = 1366,
572 .hsync_start = 1366 + 58,
573 .hsync_end = 1366 + 58 + 58,
574 .htotal = 1366 + 58 + 58 + 58,
575 .vdisplay = 768,
576 .vsync_start = 768 + 4,
577 .vsync_end = 768 + 4 + 4,
578 .vtotal = 768 + 4 + 4 + 4,
579 .vrefresh = 60,
580};
581
582static const struct panel_desc chunghwa_claa101wa01a = {
583 .modes = &chunghwa_claa101wa01a_mode,
584 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700585 .bpc = 6,
Stephen Warren4c930752014-01-07 16:46:26 -0700586 .size = {
587 .width = 220,
588 .height = 120,
589 },
590};
591
Thierry Reding280921d2013-08-30 15:10:14 +0200592static const struct drm_display_mode chunghwa_claa101wb01_mode = {
593 .clock = 69300,
594 .hdisplay = 1366,
595 .hsync_start = 1366 + 48,
596 .hsync_end = 1366 + 48 + 32,
597 .htotal = 1366 + 48 + 32 + 20,
598 .vdisplay = 768,
599 .vsync_start = 768 + 16,
600 .vsync_end = 768 + 16 + 8,
601 .vtotal = 768 + 16 + 8 + 16,
602 .vrefresh = 60,
603};
604
605static const struct panel_desc chunghwa_claa101wb01 = {
606 .modes = &chunghwa_claa101wb01_mode,
607 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700608 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200609 .size = {
610 .width = 223,
611 .height = 125,
612 },
613};
614
Stefan Agner26ab0062014-05-15 11:38:45 +0200615static const struct drm_display_mode edt_et057090dhu_mode = {
616 .clock = 25175,
617 .hdisplay = 640,
618 .hsync_start = 640 + 16,
619 .hsync_end = 640 + 16 + 30,
620 .htotal = 640 + 16 + 30 + 114,
621 .vdisplay = 480,
622 .vsync_start = 480 + 10,
623 .vsync_end = 480 + 10 + 3,
624 .vtotal = 480 + 10 + 3 + 32,
625 .vrefresh = 60,
626 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
627};
628
629static const struct panel_desc edt_et057090dhu = {
630 .modes = &edt_et057090dhu_mode,
631 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700632 .bpc = 6,
Stefan Agner26ab0062014-05-15 11:38:45 +0200633 .size = {
634 .width = 115,
635 .height = 86,
636 },
637};
638
Philipp Zabelfff5de42014-05-15 12:25:47 +0200639static const struct drm_display_mode edt_etm0700g0dh6_mode = {
640 .clock = 33260,
641 .hdisplay = 800,
642 .hsync_start = 800 + 40,
643 .hsync_end = 800 + 40 + 128,
644 .htotal = 800 + 40 + 128 + 88,
645 .vdisplay = 480,
646 .vsync_start = 480 + 10,
647 .vsync_end = 480 + 10 + 2,
648 .vtotal = 480 + 10 + 2 + 33,
649 .vrefresh = 60,
650 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
651};
652
653static const struct panel_desc edt_etm0700g0dh6 = {
654 .modes = &edt_etm0700g0dh6_mode,
655 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700656 .bpc = 6,
Philipp Zabelfff5de42014-05-15 12:25:47 +0200657 .size = {
658 .width = 152,
659 .height = 91,
660 },
661};
662
Boris BREZILLON102932b2014-06-05 15:53:32 +0200663static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
664 .clock = 32260,
665 .hdisplay = 800,
666 .hsync_start = 800 + 168,
667 .hsync_end = 800 + 168 + 64,
668 .htotal = 800 + 168 + 64 + 88,
669 .vdisplay = 480,
670 .vsync_start = 480 + 37,
671 .vsync_end = 480 + 37 + 2,
672 .vtotal = 480 + 37 + 2 + 8,
673 .vrefresh = 60,
674};
675
676static const struct panel_desc foxlink_fl500wvr00_a0t = {
677 .modes = &foxlink_fl500wvr00_a0t_mode,
678 .num_modes = 1,
Thierry Redingd7a839c2014-11-06 10:11:01 +0100679 .bpc = 8,
Boris BREZILLON102932b2014-06-05 15:53:32 +0200680 .size = {
681 .width = 108,
682 .height = 65,
683 },
Boris Brezillonbb276cb2014-07-22 13:35:47 +0200684 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
Boris BREZILLON102932b2014-06-05 15:53:32 +0200685};
686
Philipp Zabeld435a2a2014-11-19 10:29:55 +0100687static const struct drm_display_mode giantplus_gpg482739qs5_mode = {
688 .clock = 9000,
689 .hdisplay = 480,
690 .hsync_start = 480 + 5,
691 .hsync_end = 480 + 5 + 1,
692 .htotal = 480 + 5 + 1 + 40,
693 .vdisplay = 272,
694 .vsync_start = 272 + 8,
695 .vsync_end = 272 + 8 + 1,
696 .vtotal = 272 + 8 + 1 + 8,
697 .vrefresh = 60,
698};
699
700static const struct panel_desc giantplus_gpg482739qs5 = {
701 .modes = &giantplus_gpg482739qs5_mode,
702 .num_modes = 1,
703 .bpc = 8,
704 .size = {
705 .width = 95,
706 .height = 54,
707 },
Philipp Zabel33536a02015-02-11 18:50:07 +0100708 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
Philipp Zabeld435a2a2014-11-19 10:29:55 +0100709};
710
Philipp Zabelab077252014-12-11 18:32:46 +0100711static const struct display_timing hannstar_hsd070pww1_timing = {
712 .pixelclock = { 64300000, 71100000, 82000000 },
713 .hactive = { 1280, 1280, 1280 },
714 .hfront_porch = { 1, 1, 10 },
715 .hback_porch = { 1, 1, 10 },
716 .hsync_len = { 52, 158, 661 },
717 .vactive = { 800, 800, 800 },
718 .vfront_porch = { 1, 1, 10 },
719 .vback_porch = { 1, 1, 10 },
720 .vsync_len = { 1, 21, 203 },
721 .flags = DISPLAY_FLAGS_DE_HIGH,
Philipp Zabela8532052014-10-23 16:31:06 +0200722};
723
724static const struct panel_desc hannstar_hsd070pww1 = {
Philipp Zabelab077252014-12-11 18:32:46 +0100725 .timings = &hannstar_hsd070pww1_timing,
726 .num_timings = 1,
Philipp Zabela8532052014-10-23 16:31:06 +0200727 .bpc = 6,
728 .size = {
729 .width = 151,
730 .height = 94,
731 },
732};
733
Lucas Stach61ac0bf2014-11-06 17:44:35 +0100734static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = {
735 .clock = 33333,
736 .hdisplay = 800,
737 .hsync_start = 800 + 85,
738 .hsync_end = 800 + 85 + 86,
739 .htotal = 800 + 85 + 86 + 85,
740 .vdisplay = 480,
741 .vsync_start = 480 + 16,
742 .vsync_end = 480 + 16 + 13,
743 .vtotal = 480 + 16 + 13 + 16,
744 .vrefresh = 60,
745};
746
747static const struct panel_desc hitachi_tx23d38vm0caa = {
748 .modes = &hitachi_tx23d38vm0caa_mode,
749 .num_modes = 1,
750 .bpc = 6,
751 .size = {
752 .width = 195,
753 .height = 117,
754 },
755};
756
Nicolas Ferre41bcceb2015-03-19 14:43:01 +0100757static const struct drm_display_mode innolux_at043tn24_mode = {
758 .clock = 9000,
759 .hdisplay = 480,
760 .hsync_start = 480 + 2,
761 .hsync_end = 480 + 2 + 41,
762 .htotal = 480 + 2 + 41 + 2,
763 .vdisplay = 272,
764 .vsync_start = 272 + 2,
765 .vsync_end = 272 + 2 + 11,
766 .vtotal = 272 + 2 + 11 + 2,
767 .vrefresh = 60,
768 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
769};
770
771static const struct panel_desc innolux_at043tn24 = {
772 .modes = &innolux_at043tn24_mode,
773 .num_modes = 1,
774 .bpc = 8,
775 .size = {
776 .width = 95,
777 .height = 54,
778 },
779 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
780};
781
Lucas Stachd731f662014-11-06 17:44:33 +0100782static const struct drm_display_mode innolux_g121i1_l01_mode = {
Thierry Reding0a2288c2014-07-03 14:02:59 +0200783 .clock = 71000,
Lucas Stachd731f662014-11-06 17:44:33 +0100784 .hdisplay = 1280,
785 .hsync_start = 1280 + 64,
786 .hsync_end = 1280 + 64 + 32,
787 .htotal = 1280 + 64 + 32 + 64,
788 .vdisplay = 800,
789 .vsync_start = 800 + 9,
790 .vsync_end = 800 + 9 + 6,
791 .vtotal = 800 + 9 + 6 + 9,
792 .vrefresh = 60,
793};
794
795static const struct panel_desc innolux_g121i1_l01 = {
796 .modes = &innolux_g121i1_l01_mode,
797 .num_modes = 1,
798 .bpc = 6,
799 .size = {
800 .width = 261,
801 .height = 163,
802 },
803};
804
Thierry Reding0a2288c2014-07-03 14:02:59 +0200805static const struct drm_display_mode innolux_n116bge_mode = {
Daniel Kurtz7fe8c772014-09-02 10:56:46 +0800806 .clock = 76420,
Thierry Reding0a2288c2014-07-03 14:02:59 +0200807 .hdisplay = 1366,
Daniel Kurtz7fe8c772014-09-02 10:56:46 +0800808 .hsync_start = 1366 + 136,
809 .hsync_end = 1366 + 136 + 30,
810 .htotal = 1366 + 136 + 30 + 60,
Thierry Reding0a2288c2014-07-03 14:02:59 +0200811 .vdisplay = 768,
812 .vsync_start = 768 + 8,
Daniel Kurtz7fe8c772014-09-02 10:56:46 +0800813 .vsync_end = 768 + 8 + 12,
814 .vtotal = 768 + 8 + 12 + 12,
Thierry Reding0a2288c2014-07-03 14:02:59 +0200815 .vrefresh = 60,
816 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
817};
818
819static const struct panel_desc innolux_n116bge = {
820 .modes = &innolux_n116bge_mode,
821 .num_modes = 1,
822 .bpc = 6,
823 .size = {
824 .width = 256,
825 .height = 144,
826 },
827};
828
Alban Bedelea447392014-07-22 08:38:55 +0200829static const struct drm_display_mode innolux_n156bge_l21_mode = {
830 .clock = 69300,
831 .hdisplay = 1366,
832 .hsync_start = 1366 + 16,
833 .hsync_end = 1366 + 16 + 34,
834 .htotal = 1366 + 16 + 34 + 50,
835 .vdisplay = 768,
836 .vsync_start = 768 + 2,
837 .vsync_end = 768 + 2 + 6,
838 .vtotal = 768 + 2 + 6 + 12,
839 .vrefresh = 60,
840};
841
842static const struct panel_desc innolux_n156bge_l21 = {
843 .modes = &innolux_n156bge_l21_mode,
844 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700845 .bpc = 6,
Alban Bedelea447392014-07-22 08:38:55 +0200846 .size = {
847 .width = 344,
848 .height = 193,
849 },
850};
851
Michael Grzeschikbccac3f2015-03-19 12:22:44 +0100852static const struct drm_display_mode innolux_zj070na_01p_mode = {
853 .clock = 51501,
854 .hdisplay = 1024,
855 .hsync_start = 1024 + 128,
856 .hsync_end = 1024 + 128 + 64,
857 .htotal = 1024 + 128 + 64 + 128,
858 .vdisplay = 600,
859 .vsync_start = 600 + 16,
860 .vsync_end = 600 + 16 + 4,
861 .vtotal = 600 + 16 + 4 + 16,
862 .vrefresh = 60,
863};
864
865static const struct panel_desc innolux_zj070na_01p = {
866 .modes = &innolux_zj070na_01p_mode,
867 .num_modes = 1,
868 .bpc = 6,
869 .size = {
870 .width = 1024,
871 .height = 600,
872 },
873};
874
Heiko Schocherdd015002015-05-22 10:25:57 +0200875static const struct drm_display_mode lg_lb070wv8_mode = {
876 .clock = 33246,
877 .hdisplay = 800,
878 .hsync_start = 800 + 88,
879 .hsync_end = 800 + 88 + 80,
880 .htotal = 800 + 88 + 80 + 88,
881 .vdisplay = 480,
882 .vsync_start = 480 + 10,
883 .vsync_end = 480 + 10 + 25,
884 .vtotal = 480 + 10 + 25 + 10,
885 .vrefresh = 60,
886};
887
888static const struct panel_desc lg_lb070wv8 = {
889 .modes = &lg_lb070wv8_mode,
890 .num_modes = 1,
891 .bpc = 16,
892 .size = {
893 .width = 151,
894 .height = 91,
895 },
896 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
897};
898
Thierry Redingec7c5652013-11-15 15:59:32 +0100899static const struct drm_display_mode lg_lp129qe_mode = {
900 .clock = 285250,
901 .hdisplay = 2560,
902 .hsync_start = 2560 + 48,
903 .hsync_end = 2560 + 48 + 32,
904 .htotal = 2560 + 48 + 32 + 80,
905 .vdisplay = 1700,
906 .vsync_start = 1700 + 3,
907 .vsync_end = 1700 + 3 + 10,
908 .vtotal = 1700 + 3 + 10 + 36,
909 .vrefresh = 60,
910};
911
912static const struct panel_desc lg_lp129qe = {
913 .modes = &lg_lp129qe_mode,
914 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700915 .bpc = 8,
Thierry Redingec7c5652013-11-15 15:59:32 +0100916 .size = {
917 .width = 272,
918 .height = 181,
919 },
920};
921
Philipp Zabel725c9d42015-02-11 18:50:11 +0100922static const struct drm_display_mode ortustech_com43h4m85ulc_mode = {
923 .clock = 25000,
924 .hdisplay = 480,
925 .hsync_start = 480 + 10,
926 .hsync_end = 480 + 10 + 10,
927 .htotal = 480 + 10 + 10 + 15,
928 .vdisplay = 800,
929 .vsync_start = 800 + 3,
930 .vsync_end = 800 + 3 + 3,
931 .vtotal = 800 + 3 + 3 + 3,
932 .vrefresh = 60,
933};
934
935static const struct panel_desc ortustech_com43h4m85ulc = {
936 .modes = &ortustech_com43h4m85ulc_mode,
937 .num_modes = 1,
938 .bpc = 8,
939 .size = {
940 .width = 56,
941 .height = 93,
942 },
943 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
944};
945
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100946static const struct drm_display_mode samsung_ltn101nt05_mode = {
947 .clock = 54030,
948 .hdisplay = 1024,
949 .hsync_start = 1024 + 24,
950 .hsync_end = 1024 + 24 + 136,
951 .htotal = 1024 + 24 + 136 + 160,
952 .vdisplay = 600,
953 .vsync_start = 600 + 3,
954 .vsync_end = 600 + 3 + 6,
955 .vtotal = 600 + 3 + 6 + 61,
956 .vrefresh = 60,
957};
958
959static const struct panel_desc samsung_ltn101nt05 = {
960 .modes = &samsung_ltn101nt05_mode,
961 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700962 .bpc = 6,
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100963 .size = {
964 .width = 1024,
965 .height = 600,
966 },
967};
968
Stéphane Marchesin0c934302015-03-18 10:52:18 +0100969static const struct drm_display_mode samsung_ltn140at29_301_mode = {
970 .clock = 76300,
971 .hdisplay = 1366,
972 .hsync_start = 1366 + 64,
973 .hsync_end = 1366 + 64 + 48,
974 .htotal = 1366 + 64 + 48 + 128,
975 .vdisplay = 768,
976 .vsync_start = 768 + 2,
977 .vsync_end = 768 + 2 + 5,
978 .vtotal = 768 + 2 + 5 + 17,
979 .vrefresh = 60,
980};
981
982static const struct panel_desc samsung_ltn140at29_301 = {
983 .modes = &samsung_ltn140at29_301_mode,
984 .num_modes = 1,
985 .bpc = 6,
986 .size = {
987 .width = 320,
988 .height = 187,
989 },
990};
991
Boris BREZILLON9c6615b2015-03-19 14:43:00 +0100992static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode = {
993 .clock = 33300,
994 .hdisplay = 800,
995 .hsync_start = 800 + 1,
996 .hsync_end = 800 + 1 + 64,
997 .htotal = 800 + 1 + 64 + 64,
998 .vdisplay = 480,
999 .vsync_start = 480 + 1,
1000 .vsync_end = 480 + 1 + 23,
1001 .vtotal = 480 + 1 + 23 + 22,
1002 .vrefresh = 60,
1003};
1004
1005static const struct panel_desc shelly_sca07010_bfn_lnn = {
1006 .modes = &shelly_sca07010_bfn_lnn_mode,
1007 .num_modes = 1,
1008 .size = {
1009 .width = 152,
1010 .height = 91,
1011 },
1012 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1013};
1014
Thierry Reding280921d2013-08-30 15:10:14 +02001015static const struct of_device_id platform_of_match[] = {
1016 {
Philipp Zabel1c550fa12015-02-11 18:50:09 +01001017 .compatible = "ampire,am800480r3tmqwa1h",
1018 .data = &ampire_am800480r3tmqwa1h,
1019 }, {
Thierry Reding280921d2013-08-30 15:10:14 +02001020 .compatible = "auo,b101aw03",
1021 .data = &auo_b101aw03,
1022 }, {
Huang Lina531bc32015-02-28 10:18:58 +08001023 .compatible = "auo,b101ean01",
1024 .data = &auo_b101ean01,
1025 }, {
Rob Clarkdac746e2014-08-01 17:01:06 -04001026 .compatible = "auo,b101xtn01",
1027 .data = &auo_b101xtn01,
1028 }, {
Ajay Kumare35e3052014-09-01 15:40:02 +05301029 .compatible = "auo,b116xw03",
1030 .data = &auo_b116xw03,
1031 }, {
Ajay Kumar3e51d602014-07-31 23:12:12 +05301032 .compatible = "auo,b133htn01",
1033 .data = &auo_b133htn01,
1034 }, {
Stéphane Marchesina333f7a2014-05-23 19:27:59 -07001035 .compatible = "auo,b133xtn01",
1036 .data = &auo_b133xtn01,
1037 }, {
Philipp Zabeld47df632014-12-18 16:43:43 +01001038 .compatible = "avic,tm070ddh03",
1039 .data = &avic_tm070ddh03,
1040 }, {
Stephen Warren4c930752014-01-07 16:46:26 -07001041 .compatible = "chunghwa,claa101wa01a",
1042 .data = &chunghwa_claa101wa01a
1043 }, {
Thierry Reding280921d2013-08-30 15:10:14 +02001044 .compatible = "chunghwa,claa101wb01",
1045 .data = &chunghwa_claa101wb01
1046 }, {
Stefan Agner26ab0062014-05-15 11:38:45 +02001047 .compatible = "edt,et057090dhu",
1048 .data = &edt_et057090dhu,
1049 }, {
Philipp Zabelfff5de42014-05-15 12:25:47 +02001050 .compatible = "edt,et070080dh6",
1051 .data = &edt_etm0700g0dh6,
1052 }, {
1053 .compatible = "edt,etm0700g0dh6",
1054 .data = &edt_etm0700g0dh6,
1055 }, {
Boris BREZILLON102932b2014-06-05 15:53:32 +02001056 .compatible = "foxlink,fl500wvr00-a0t",
1057 .data = &foxlink_fl500wvr00_a0t,
1058 }, {
Philipp Zabeld435a2a2014-11-19 10:29:55 +01001059 .compatible = "giantplus,gpg482739qs5",
1060 .data = &giantplus_gpg482739qs5
1061 }, {
Philipp Zabela8532052014-10-23 16:31:06 +02001062 .compatible = "hannstar,hsd070pww1",
1063 .data = &hannstar_hsd070pww1,
1064 }, {
Lucas Stach61ac0bf2014-11-06 17:44:35 +01001065 .compatible = "hit,tx23d38vm0caa",
1066 .data = &hitachi_tx23d38vm0caa
1067 }, {
Nicolas Ferre41bcceb2015-03-19 14:43:01 +01001068 .compatible = "innolux,at043tn24",
1069 .data = &innolux_at043tn24,
1070 }, {
Lucas Stachd731f662014-11-06 17:44:33 +01001071 .compatible ="innolux,g121i1-l01",
1072 .data = &innolux_g121i1_l01
1073 }, {
Thierry Reding0a2288c2014-07-03 14:02:59 +02001074 .compatible = "innolux,n116bge",
1075 .data = &innolux_n116bge,
1076 }, {
Alban Bedelea447392014-07-22 08:38:55 +02001077 .compatible = "innolux,n156bge-l21",
1078 .data = &innolux_n156bge_l21,
1079 }, {
Michael Grzeschikbccac3f2015-03-19 12:22:44 +01001080 .compatible = "innolux,zj070na-01p",
1081 .data = &innolux_zj070na_01p,
1082 }, {
Heiko Schocherdd015002015-05-22 10:25:57 +02001083 .compatible = "lg,lb070wv8",
1084 .data = &lg_lb070wv8,
1085 }, {
Thierry Redingec7c5652013-11-15 15:59:32 +01001086 .compatible = "lg,lp129qe",
1087 .data = &lg_lp129qe,
1088 }, {
Philipp Zabel725c9d42015-02-11 18:50:11 +01001089 .compatible = "ortustech,com43h4m85ulc",
1090 .data = &ortustech_com43h4m85ulc,
1091 }, {
Marc Dietrich6d54e3d2013-12-21 21:38:12 +01001092 .compatible = "samsung,ltn101nt05",
1093 .data = &samsung_ltn101nt05,
1094 }, {
Stéphane Marchesin0c934302015-03-18 10:52:18 +01001095 .compatible = "samsung,ltn140at29-301",
1096 .data = &samsung_ltn140at29_301,
1097 }, {
Boris BREZILLON9c6615b2015-03-19 14:43:00 +01001098 .compatible = "shelly,sca07010-bfn-lnn",
1099 .data = &shelly_sca07010_bfn_lnn,
1100 }, {
Thierry Reding280921d2013-08-30 15:10:14 +02001101 /* sentinel */
1102 }
1103};
1104MODULE_DEVICE_TABLE(of, platform_of_match);
1105
1106static int panel_simple_platform_probe(struct platform_device *pdev)
1107{
1108 const struct of_device_id *id;
1109
1110 id = of_match_node(platform_of_match, pdev->dev.of_node);
1111 if (!id)
1112 return -ENODEV;
1113
1114 return panel_simple_probe(&pdev->dev, id->data);
1115}
1116
1117static int panel_simple_platform_remove(struct platform_device *pdev)
1118{
1119 return panel_simple_remove(&pdev->dev);
1120}
1121
Thierry Redingd02fd932014-04-29 17:21:21 +02001122static void panel_simple_platform_shutdown(struct platform_device *pdev)
1123{
1124 panel_simple_shutdown(&pdev->dev);
1125}
1126
Thierry Reding280921d2013-08-30 15:10:14 +02001127static struct platform_driver panel_simple_platform_driver = {
1128 .driver = {
1129 .name = "panel-simple",
Thierry Reding280921d2013-08-30 15:10:14 +02001130 .of_match_table = platform_of_match,
1131 },
1132 .probe = panel_simple_platform_probe,
1133 .remove = panel_simple_platform_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +02001134 .shutdown = panel_simple_platform_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +02001135};
1136
Thierry Reding210fcd92013-11-22 19:27:11 +01001137struct panel_desc_dsi {
1138 struct panel_desc desc;
1139
Thierry Reding462658b2014-03-14 11:24:57 +01001140 unsigned long flags;
Thierry Reding210fcd92013-11-22 19:27:11 +01001141 enum mipi_dsi_pixel_format format;
1142 unsigned int lanes;
1143};
1144
Alexandre Courbot712ac1b2014-01-21 18:57:10 +09001145static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
1146 .clock = 71000,
1147 .hdisplay = 800,
1148 .hsync_start = 800 + 32,
1149 .hsync_end = 800 + 32 + 1,
1150 .htotal = 800 + 32 + 1 + 57,
1151 .vdisplay = 1280,
1152 .vsync_start = 1280 + 28,
1153 .vsync_end = 1280 + 28 + 1,
1154 .vtotal = 1280 + 28 + 1 + 14,
1155 .vrefresh = 60,
1156};
1157
1158static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
1159 .desc = {
1160 .modes = &lg_ld070wx3_sl01_mode,
1161 .num_modes = 1,
Thierry Redingd7a839c2014-11-06 10:11:01 +01001162 .bpc = 8,
Alexandre Courbot712ac1b2014-01-21 18:57:10 +09001163 .size = {
1164 .width = 94,
1165 .height = 151,
1166 },
1167 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +09001168 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
Alexandre Courbot712ac1b2014-01-21 18:57:10 +09001169 .format = MIPI_DSI_FMT_RGB888,
1170 .lanes = 4,
1171};
1172
Alexandre Courbot499ce852014-01-21 18:57:09 +09001173static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
1174 .clock = 67000,
1175 .hdisplay = 720,
1176 .hsync_start = 720 + 12,
1177 .hsync_end = 720 + 12 + 4,
1178 .htotal = 720 + 12 + 4 + 112,
1179 .vdisplay = 1280,
1180 .vsync_start = 1280 + 8,
1181 .vsync_end = 1280 + 8 + 4,
1182 .vtotal = 1280 + 8 + 4 + 12,
1183 .vrefresh = 60,
1184};
1185
1186static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
1187 .desc = {
1188 .modes = &lg_lh500wx1_sd03_mode,
1189 .num_modes = 1,
Thierry Redingd7a839c2014-11-06 10:11:01 +01001190 .bpc = 8,
Alexandre Courbot499ce852014-01-21 18:57:09 +09001191 .size = {
1192 .width = 62,
1193 .height = 110,
1194 },
1195 },
1196 .flags = MIPI_DSI_MODE_VIDEO,
1197 .format = MIPI_DSI_FMT_RGB888,
1198 .lanes = 4,
1199};
1200
Thierry Reding280921d2013-08-30 15:10:14 +02001201static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
1202 .clock = 157200,
1203 .hdisplay = 1920,
1204 .hsync_start = 1920 + 154,
1205 .hsync_end = 1920 + 154 + 16,
1206 .htotal = 1920 + 154 + 16 + 32,
1207 .vdisplay = 1200,
1208 .vsync_start = 1200 + 17,
1209 .vsync_end = 1200 + 17 + 2,
1210 .vtotal = 1200 + 17 + 2 + 16,
1211 .vrefresh = 60,
1212};
1213
Thierry Reding210fcd92013-11-22 19:27:11 +01001214static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
1215 .desc = {
1216 .modes = &panasonic_vvx10f004b00_mode,
1217 .num_modes = 1,
Thierry Redingd7a839c2014-11-06 10:11:01 +01001218 .bpc = 8,
Thierry Reding210fcd92013-11-22 19:27:11 +01001219 .size = {
1220 .width = 217,
1221 .height = 136,
1222 },
Thierry Reding280921d2013-08-30 15:10:14 +02001223 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +09001224 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1225 MIPI_DSI_CLOCK_NON_CONTINUOUS,
Thierry Reding210fcd92013-11-22 19:27:11 +01001226 .format = MIPI_DSI_FMT_RGB888,
1227 .lanes = 4,
1228};
1229
1230static const struct of_device_id dsi_of_match[] = {
1231 {
Alexandre Courbot712ac1b2014-01-21 18:57:10 +09001232 .compatible = "lg,ld070wx3-sl01",
1233 .data = &lg_ld070wx3_sl01
1234 }, {
Alexandre Courbot499ce852014-01-21 18:57:09 +09001235 .compatible = "lg,lh500wx1-sd03",
1236 .data = &lg_lh500wx1_sd03
1237 }, {
Thierry Reding210fcd92013-11-22 19:27:11 +01001238 .compatible = "panasonic,vvx10f004b00",
1239 .data = &panasonic_vvx10f004b00
1240 }, {
1241 /* sentinel */
1242 }
1243};
1244MODULE_DEVICE_TABLE(of, dsi_of_match);
1245
1246static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
1247{
1248 const struct panel_desc_dsi *desc;
1249 const struct of_device_id *id;
1250 int err;
1251
1252 id = of_match_node(dsi_of_match, dsi->dev.of_node);
1253 if (!id)
1254 return -ENODEV;
1255
1256 desc = id->data;
1257
1258 err = panel_simple_probe(&dsi->dev, &desc->desc);
1259 if (err < 0)
1260 return err;
1261
Thierry Reding462658b2014-03-14 11:24:57 +01001262 dsi->mode_flags = desc->flags;
Thierry Reding210fcd92013-11-22 19:27:11 +01001263 dsi->format = desc->format;
1264 dsi->lanes = desc->lanes;
1265
1266 return mipi_dsi_attach(dsi);
1267}
1268
1269static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
1270{
1271 int err;
1272
1273 err = mipi_dsi_detach(dsi);
1274 if (err < 0)
1275 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
1276
1277 return panel_simple_remove(&dsi->dev);
1278}
1279
Thierry Redingd02fd932014-04-29 17:21:21 +02001280static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
1281{
1282 panel_simple_shutdown(&dsi->dev);
1283}
1284
Thierry Reding210fcd92013-11-22 19:27:11 +01001285static struct mipi_dsi_driver panel_simple_dsi_driver = {
1286 .driver = {
1287 .name = "panel-simple-dsi",
Thierry Reding210fcd92013-11-22 19:27:11 +01001288 .of_match_table = dsi_of_match,
1289 },
1290 .probe = panel_simple_dsi_probe,
1291 .remove = panel_simple_dsi_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +02001292 .shutdown = panel_simple_dsi_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +02001293};
1294
1295static int __init panel_simple_init(void)
1296{
Thierry Reding210fcd92013-11-22 19:27:11 +01001297 int err;
1298
1299 err = platform_driver_register(&panel_simple_platform_driver);
1300 if (err < 0)
1301 return err;
1302
1303 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
1304 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
1305 if (err < 0)
1306 return err;
1307 }
1308
1309 return 0;
Thierry Reding280921d2013-08-30 15:10:14 +02001310}
1311module_init(panel_simple_init);
1312
1313static void __exit panel_simple_exit(void)
1314{
Thierry Reding210fcd92013-11-22 19:27:11 +01001315 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
1316 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
1317
Thierry Reding280921d2013-08-30 15:10:14 +02001318 platform_driver_unregister(&panel_simple_platform_driver);
1319}
1320module_exit(panel_simple_exit);
1321
1322MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
1323MODULE_DESCRIPTION("DRM Driver for Simple Panels");
1324MODULE_LICENSE("GPL and additional rights");