blob: 4ce1db0a68ff5754c37cb1eace4edccc6d6f03db [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
36struct panel_desc {
37 const struct drm_display_mode *modes;
38 unsigned int num_modes;
39
Stéphane Marchesin0208d512014-06-19 18:18:28 -070040 unsigned int bpc;
41
Thierry Reding280921d2013-08-30 15:10:14 +020042 struct {
43 unsigned int width;
44 unsigned int height;
45 } size;
Ajay Kumarf673c372014-07-31 23:12:11 +053046
47 /**
48 * @prepare: the time (in milliseconds) that it takes for the panel to
49 * become ready and start receiving video data
50 * @enable: the time (in milliseconds) that it takes for the panel to
51 * display the first valid frame after starting to receive
52 * video data
53 * @disable: the time (in milliseconds) that it takes for the panel to
54 * turn the display off (no content is visible)
55 * @unprepare: the time (in milliseconds) that it takes for the panel
56 * to power itself down completely
57 */
58 struct {
59 unsigned int prepare;
60 unsigned int enable;
61 unsigned int disable;
62 unsigned int unprepare;
63 } delay;
Thierry Reding280921d2013-08-30 15:10:14 +020064};
65
Thierry Reding280921d2013-08-30 15:10:14 +020066struct panel_simple {
67 struct drm_panel base;
Ajay Kumar613a6332014-07-31 23:12:10 +053068 bool prepared;
Thierry Reding280921d2013-08-30 15:10:14 +020069 bool enabled;
70
71 const struct panel_desc *desc;
72
73 struct backlight_device *backlight;
74 struct regulator *supply;
75 struct i2c_adapter *ddc;
76
Alexandre Courbotcfdf0542014-03-01 14:00:58 +090077 struct gpio_desc *enable_gpio;
Thierry Reding280921d2013-08-30 15:10:14 +020078};
79
80static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
81{
82 return container_of(panel, struct panel_simple, base);
83}
84
85static int panel_simple_get_fixed_modes(struct panel_simple *panel)
86{
87 struct drm_connector *connector = panel->base.connector;
88 struct drm_device *drm = panel->base.drm;
89 struct drm_display_mode *mode;
90 unsigned int i, num = 0;
91
92 if (!panel->desc)
93 return 0;
94
95 for (i = 0; i < panel->desc->num_modes; i++) {
96 const struct drm_display_mode *m = &panel->desc->modes[i];
97
98 mode = drm_mode_duplicate(drm, m);
99 if (!mode) {
100 dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
101 m->hdisplay, m->vdisplay, m->vrefresh);
102 continue;
103 }
104
105 drm_mode_set_name(mode);
106
107 drm_mode_probed_add(connector, mode);
108 num++;
109 }
110
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700111 connector->display_info.bpc = panel->desc->bpc;
Thierry Reding280921d2013-08-30 15:10:14 +0200112 connector->display_info.width_mm = panel->desc->size.width;
113 connector->display_info.height_mm = panel->desc->size.height;
114
115 return num;
116}
117
118static int panel_simple_disable(struct drm_panel *panel)
119{
120 struct panel_simple *p = to_panel_simple(panel);
121
122 if (!p->enabled)
123 return 0;
124
125 if (p->backlight) {
126 p->backlight->props.power = FB_BLANK_POWERDOWN;
127 backlight_update_status(p->backlight);
128 }
129
Ajay Kumarf673c372014-07-31 23:12:11 +0530130 if (p->desc->delay.disable)
131 msleep(p->desc->delay.disable);
132
Thierry Reding280921d2013-08-30 15:10:14 +0200133 p->enabled = false;
134
135 return 0;
136}
137
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530138static int panel_simple_unprepare(struct drm_panel *panel)
139{
Ajay Kumar613a6332014-07-31 23:12:10 +0530140 struct panel_simple *p = to_panel_simple(panel);
141
142 if (!p->prepared)
143 return 0;
144
145 if (p->enable_gpio)
146 gpiod_set_value_cansleep(p->enable_gpio, 0);
147
148 regulator_disable(p->supply);
149
Ajay Kumarf673c372014-07-31 23:12:11 +0530150 if (p->desc->delay.unprepare)
151 msleep(p->desc->delay.unprepare);
152
Ajay Kumar613a6332014-07-31 23:12:10 +0530153 p->prepared = false;
154
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530155 return 0;
156}
157
158static int panel_simple_prepare(struct drm_panel *panel)
159{
Thierry Reding280921d2013-08-30 15:10:14 +0200160 struct panel_simple *p = to_panel_simple(panel);
161 int err;
162
Ajay Kumar613a6332014-07-31 23:12:10 +0530163 if (p->prepared)
Thierry Reding280921d2013-08-30 15:10:14 +0200164 return 0;
165
166 err = regulator_enable(p->supply);
167 if (err < 0) {
168 dev_err(panel->dev, "failed to enable supply: %d\n", err);
169 return err;
170 }
171
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900172 if (p->enable_gpio)
Thierry Reding15c1a912014-03-14 12:03:47 +0100173 gpiod_set_value_cansleep(p->enable_gpio, 1);
Thierry Reding280921d2013-08-30 15:10:14 +0200174
Ajay Kumarf673c372014-07-31 23:12:11 +0530175 if (p->desc->delay.prepare)
176 msleep(p->desc->delay.prepare);
177
Ajay Kumar613a6332014-07-31 23:12:10 +0530178 p->prepared = true;
179
180 return 0;
181}
182
183static int panel_simple_enable(struct drm_panel *panel)
184{
185 struct panel_simple *p = to_panel_simple(panel);
186
187 if (p->enabled)
188 return 0;
189
Ajay Kumarf673c372014-07-31 23:12:11 +0530190 if (p->desc->delay.enable)
191 msleep(p->desc->delay.enable);
192
Thierry Reding280921d2013-08-30 15:10:14 +0200193 if (p->backlight) {
194 p->backlight->props.power = FB_BLANK_UNBLANK;
195 backlight_update_status(p->backlight);
196 }
197
198 p->enabled = true;
199
200 return 0;
201}
202
203static int panel_simple_get_modes(struct drm_panel *panel)
204{
205 struct panel_simple *p = to_panel_simple(panel);
206 int num = 0;
207
208 /* probe EDID if a DDC bus is available */
209 if (p->ddc) {
210 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
Stephen Warren70bf6872014-01-09 11:37:34 -0700211 drm_mode_connector_update_edid_property(panel->connector, edid);
Thierry Reding280921d2013-08-30 15:10:14 +0200212 if (edid) {
213 num += drm_add_edid_modes(panel->connector, edid);
214 kfree(edid);
215 }
216 }
217
218 /* add hard-coded panel modes */
219 num += panel_simple_get_fixed_modes(p);
220
221 return num;
222}
223
224static const struct drm_panel_funcs panel_simple_funcs = {
225 .disable = panel_simple_disable,
Ajay Kumarc0e1d172014-07-31 23:12:04 +0530226 .unprepare = panel_simple_unprepare,
227 .prepare = panel_simple_prepare,
Thierry Reding280921d2013-08-30 15:10:14 +0200228 .enable = panel_simple_enable,
229 .get_modes = panel_simple_get_modes,
230};
231
232static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
233{
234 struct device_node *backlight, *ddc;
235 struct panel_simple *panel;
Thierry Reding280921d2013-08-30 15:10:14 +0200236 int err;
237
238 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
239 if (!panel)
240 return -ENOMEM;
241
242 panel->enabled = false;
Ajay Kumar613a6332014-07-31 23:12:10 +0530243 panel->prepared = false;
Thierry Reding280921d2013-08-30 15:10:14 +0200244 panel->desc = desc;
245
246 panel->supply = devm_regulator_get(dev, "power");
247 if (IS_ERR(panel->supply))
248 return PTR_ERR(panel->supply);
249
Alexandre Courbot9746c612014-07-25 23:47:25 +0900250 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable");
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900251 if (IS_ERR(panel->enable_gpio)) {
252 err = PTR_ERR(panel->enable_gpio);
Alexandre Courbot9746c612014-07-25 23:47:25 +0900253 dev_err(dev, "failed to request GPIO: %d\n", err);
254 return err;
255 }
Thierry Reding280921d2013-08-30 15:10:14 +0200256
Alexandre Courbot9746c612014-07-25 23:47:25 +0900257 if (panel->enable_gpio) {
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900258 err = gpiod_direction_output(panel->enable_gpio, 0);
Thierry Reding280921d2013-08-30 15:10:14 +0200259 if (err < 0) {
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900260 dev_err(dev, "failed to setup GPIO: %d\n", err);
261 return err;
Thierry Reding280921d2013-08-30 15:10:14 +0200262 }
263 }
264
265 backlight = of_parse_phandle(dev->of_node, "backlight", 0);
266 if (backlight) {
267 panel->backlight = of_find_backlight_by_node(backlight);
268 of_node_put(backlight);
269
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900270 if (!panel->backlight)
271 return -EPROBE_DEFER;
Thierry Reding280921d2013-08-30 15:10:14 +0200272 }
273
274 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
275 if (ddc) {
276 panel->ddc = of_find_i2c_adapter_by_node(ddc);
277 of_node_put(ddc);
278
279 if (!panel->ddc) {
280 err = -EPROBE_DEFER;
281 goto free_backlight;
282 }
283 }
284
285 drm_panel_init(&panel->base);
286 panel->base.dev = dev;
287 panel->base.funcs = &panel_simple_funcs;
288
289 err = drm_panel_add(&panel->base);
290 if (err < 0)
291 goto free_ddc;
292
293 dev_set_drvdata(dev, panel);
294
295 return 0;
296
297free_ddc:
298 if (panel->ddc)
299 put_device(&panel->ddc->dev);
300free_backlight:
301 if (panel->backlight)
302 put_device(&panel->backlight->dev);
Thierry Reding280921d2013-08-30 15:10:14 +0200303
304 return err;
305}
306
307static int panel_simple_remove(struct device *dev)
308{
309 struct panel_simple *panel = dev_get_drvdata(dev);
310
311 drm_panel_detach(&panel->base);
312 drm_panel_remove(&panel->base);
313
314 panel_simple_disable(&panel->base);
315
316 if (panel->ddc)
317 put_device(&panel->ddc->dev);
318
319 if (panel->backlight)
320 put_device(&panel->backlight->dev);
321
Thierry Reding280921d2013-08-30 15:10:14 +0200322 return 0;
323}
324
Thierry Redingd02fd932014-04-29 17:21:21 +0200325static void panel_simple_shutdown(struct device *dev)
326{
327 struct panel_simple *panel = dev_get_drvdata(dev);
328
329 panel_simple_disable(&panel->base);
330}
331
Thierry Reding280921d2013-08-30 15:10:14 +0200332static const struct drm_display_mode auo_b101aw03_mode = {
333 .clock = 51450,
334 .hdisplay = 1024,
335 .hsync_start = 1024 + 156,
336 .hsync_end = 1024 + 156 + 8,
337 .htotal = 1024 + 156 + 8 + 156,
338 .vdisplay = 600,
339 .vsync_start = 600 + 16,
340 .vsync_end = 600 + 16 + 6,
341 .vtotal = 600 + 16 + 6 + 16,
342 .vrefresh = 60,
343};
344
345static const struct panel_desc auo_b101aw03 = {
346 .modes = &auo_b101aw03_mode,
347 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700348 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200349 .size = {
350 .width = 223,
351 .height = 125,
352 },
353};
354
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700355static const struct drm_display_mode auo_b133xtn01_mode = {
356 .clock = 69500,
357 .hdisplay = 1366,
358 .hsync_start = 1366 + 48,
359 .hsync_end = 1366 + 48 + 32,
360 .htotal = 1366 + 48 + 32 + 20,
361 .vdisplay = 768,
362 .vsync_start = 768 + 3,
363 .vsync_end = 768 + 3 + 6,
364 .vtotal = 768 + 3 + 6 + 13,
365 .vrefresh = 60,
366};
367
368static const struct panel_desc auo_b133xtn01 = {
369 .modes = &auo_b133xtn01_mode,
370 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700371 .bpc = 6,
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700372 .size = {
373 .width = 293,
374 .height = 165,
375 },
376};
377
Ajay Kumar3e51d602014-07-31 23:12:12 +0530378static const struct drm_display_mode auo_b133htn01_mode = {
379 .clock = 150660,
380 .hdisplay = 1920,
381 .hsync_start = 1920 + 172,
382 .hsync_end = 1920 + 172 + 80,
383 .htotal = 1920 + 172 + 80 + 60,
384 .vdisplay = 1080,
385 .vsync_start = 1080 + 25,
386 .vsync_end = 1080 + 25 + 10,
387 .vtotal = 1080 + 25 + 10 + 10,
388 .vrefresh = 60,
389};
390
391static const struct panel_desc auo_b133htn01 = {
392 .modes = &auo_b133htn01_mode,
393 .num_modes = 1,
394 .size = {
395 .width = 293,
396 .height = 165,
397 },
398 .delay = {
399 .prepare = 105,
400 .enable = 20,
401 .unprepare = 50,
402 },
403};
404
Stephen Warren4c930752014-01-07 16:46:26 -0700405static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
406 .clock = 72070,
407 .hdisplay = 1366,
408 .hsync_start = 1366 + 58,
409 .hsync_end = 1366 + 58 + 58,
410 .htotal = 1366 + 58 + 58 + 58,
411 .vdisplay = 768,
412 .vsync_start = 768 + 4,
413 .vsync_end = 768 + 4 + 4,
414 .vtotal = 768 + 4 + 4 + 4,
415 .vrefresh = 60,
416};
417
418static const struct panel_desc chunghwa_claa101wa01a = {
419 .modes = &chunghwa_claa101wa01a_mode,
420 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700421 .bpc = 6,
Stephen Warren4c930752014-01-07 16:46:26 -0700422 .size = {
423 .width = 220,
424 .height = 120,
425 },
426};
427
Thierry Reding280921d2013-08-30 15:10:14 +0200428static const struct drm_display_mode chunghwa_claa101wb01_mode = {
429 .clock = 69300,
430 .hdisplay = 1366,
431 .hsync_start = 1366 + 48,
432 .hsync_end = 1366 + 48 + 32,
433 .htotal = 1366 + 48 + 32 + 20,
434 .vdisplay = 768,
435 .vsync_start = 768 + 16,
436 .vsync_end = 768 + 16 + 8,
437 .vtotal = 768 + 16 + 8 + 16,
438 .vrefresh = 60,
439};
440
441static const struct panel_desc chunghwa_claa101wb01 = {
442 .modes = &chunghwa_claa101wb01_mode,
443 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700444 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200445 .size = {
446 .width = 223,
447 .height = 125,
448 },
449};
450
Stefan Agner26ab0062014-05-15 11:38:45 +0200451static const struct drm_display_mode edt_et057090dhu_mode = {
452 .clock = 25175,
453 .hdisplay = 640,
454 .hsync_start = 640 + 16,
455 .hsync_end = 640 + 16 + 30,
456 .htotal = 640 + 16 + 30 + 114,
457 .vdisplay = 480,
458 .vsync_start = 480 + 10,
459 .vsync_end = 480 + 10 + 3,
460 .vtotal = 480 + 10 + 3 + 32,
461 .vrefresh = 60,
462 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
463};
464
465static const struct panel_desc edt_et057090dhu = {
466 .modes = &edt_et057090dhu_mode,
467 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700468 .bpc = 6,
Stefan Agner26ab0062014-05-15 11:38:45 +0200469 .size = {
470 .width = 115,
471 .height = 86,
472 },
473};
474
Philipp Zabelfff5de42014-05-15 12:25:47 +0200475static const struct drm_display_mode edt_etm0700g0dh6_mode = {
476 .clock = 33260,
477 .hdisplay = 800,
478 .hsync_start = 800 + 40,
479 .hsync_end = 800 + 40 + 128,
480 .htotal = 800 + 40 + 128 + 88,
481 .vdisplay = 480,
482 .vsync_start = 480 + 10,
483 .vsync_end = 480 + 10 + 2,
484 .vtotal = 480 + 10 + 2 + 33,
485 .vrefresh = 60,
486 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
487};
488
489static const struct panel_desc edt_etm0700g0dh6 = {
490 .modes = &edt_etm0700g0dh6_mode,
491 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700492 .bpc = 6,
Philipp Zabelfff5de42014-05-15 12:25:47 +0200493 .size = {
494 .width = 152,
495 .height = 91,
496 },
497};
498
Boris BREZILLON102932b2014-06-05 15:53:32 +0200499static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
500 .clock = 32260,
501 .hdisplay = 800,
502 .hsync_start = 800 + 168,
503 .hsync_end = 800 + 168 + 64,
504 .htotal = 800 + 168 + 64 + 88,
505 .vdisplay = 480,
506 .vsync_start = 480 + 37,
507 .vsync_end = 480 + 37 + 2,
508 .vtotal = 480 + 37 + 2 + 8,
509 .vrefresh = 60,
510};
511
512static const struct panel_desc foxlink_fl500wvr00_a0t = {
513 .modes = &foxlink_fl500wvr00_a0t_mode,
514 .num_modes = 1,
515 .size = {
516 .width = 108,
517 .height = 65,
518 },
519};
520
Thierry Reding0a2288c2014-07-03 14:02:59 +0200521static const struct drm_display_mode innolux_n116bge_mode = {
522 .clock = 71000,
523 .hdisplay = 1366,
524 .hsync_start = 1366 + 64,
525 .hsync_end = 1366 + 64 + 6,
526 .htotal = 1366 + 64 + 6 + 64,
527 .vdisplay = 768,
528 .vsync_start = 768 + 8,
529 .vsync_end = 768 + 8 + 4,
530 .vtotal = 768 + 8 + 4 + 8,
531 .vrefresh = 60,
532 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
533};
534
535static const struct panel_desc innolux_n116bge = {
536 .modes = &innolux_n116bge_mode,
537 .num_modes = 1,
538 .bpc = 6,
539 .size = {
540 .width = 256,
541 .height = 144,
542 },
543};
544
Alban Bedelea447392014-07-22 08:38:55 +0200545static const struct drm_display_mode innolux_n156bge_l21_mode = {
546 .clock = 69300,
547 .hdisplay = 1366,
548 .hsync_start = 1366 + 16,
549 .hsync_end = 1366 + 16 + 34,
550 .htotal = 1366 + 16 + 34 + 50,
551 .vdisplay = 768,
552 .vsync_start = 768 + 2,
553 .vsync_end = 768 + 2 + 6,
554 .vtotal = 768 + 2 + 6 + 12,
555 .vrefresh = 60,
556};
557
558static const struct panel_desc innolux_n156bge_l21 = {
559 .modes = &innolux_n156bge_l21_mode,
560 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700561 .bpc = 6,
Alban Bedelea447392014-07-22 08:38:55 +0200562 .size = {
563 .width = 344,
564 .height = 193,
565 },
566};
567
Thierry Redingec7c5652013-11-15 15:59:32 +0100568static const struct drm_display_mode lg_lp129qe_mode = {
569 .clock = 285250,
570 .hdisplay = 2560,
571 .hsync_start = 2560 + 48,
572 .hsync_end = 2560 + 48 + 32,
573 .htotal = 2560 + 48 + 32 + 80,
574 .vdisplay = 1700,
575 .vsync_start = 1700 + 3,
576 .vsync_end = 1700 + 3 + 10,
577 .vtotal = 1700 + 3 + 10 + 36,
578 .vrefresh = 60,
579};
580
581static const struct panel_desc lg_lp129qe = {
582 .modes = &lg_lp129qe_mode,
583 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700584 .bpc = 8,
Thierry Redingec7c5652013-11-15 15:59:32 +0100585 .size = {
586 .width = 272,
587 .height = 181,
588 },
589};
590
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100591static const struct drm_display_mode samsung_ltn101nt05_mode = {
592 .clock = 54030,
593 .hdisplay = 1024,
594 .hsync_start = 1024 + 24,
595 .hsync_end = 1024 + 24 + 136,
596 .htotal = 1024 + 24 + 136 + 160,
597 .vdisplay = 600,
598 .vsync_start = 600 + 3,
599 .vsync_end = 600 + 3 + 6,
600 .vtotal = 600 + 3 + 6 + 61,
601 .vrefresh = 60,
602};
603
604static const struct panel_desc samsung_ltn101nt05 = {
605 .modes = &samsung_ltn101nt05_mode,
606 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700607 .bpc = 6,
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100608 .size = {
609 .width = 1024,
610 .height = 600,
611 },
612};
613
Thierry Reding280921d2013-08-30 15:10:14 +0200614static const struct of_device_id platform_of_match[] = {
615 {
616 .compatible = "auo,b101aw03",
617 .data = &auo_b101aw03,
618 }, {
Ajay Kumar3e51d602014-07-31 23:12:12 +0530619 .compatible = "auo,b133htn01",
620 .data = &auo_b133htn01,
621 }, {
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700622 .compatible = "auo,b133xtn01",
623 .data = &auo_b133xtn01,
624 }, {
Stephen Warren4c930752014-01-07 16:46:26 -0700625 .compatible = "chunghwa,claa101wa01a",
626 .data = &chunghwa_claa101wa01a
627 }, {
Thierry Reding280921d2013-08-30 15:10:14 +0200628 .compatible = "chunghwa,claa101wb01",
629 .data = &chunghwa_claa101wb01
630 }, {
Stefan Agner26ab0062014-05-15 11:38:45 +0200631 .compatible = "edt,et057090dhu",
632 .data = &edt_et057090dhu,
633 }, {
Philipp Zabelfff5de42014-05-15 12:25:47 +0200634 .compatible = "edt,et070080dh6",
635 .data = &edt_etm0700g0dh6,
636 }, {
637 .compatible = "edt,etm0700g0dh6",
638 .data = &edt_etm0700g0dh6,
639 }, {
Boris BREZILLON102932b2014-06-05 15:53:32 +0200640 .compatible = "foxlink,fl500wvr00-a0t",
641 .data = &foxlink_fl500wvr00_a0t,
642 }, {
Thierry Reding0a2288c2014-07-03 14:02:59 +0200643 .compatible = "innolux,n116bge",
644 .data = &innolux_n116bge,
645 }, {
Alban Bedelea447392014-07-22 08:38:55 +0200646 .compatible = "innolux,n156bge-l21",
647 .data = &innolux_n156bge_l21,
648 }, {
Thierry Redingec7c5652013-11-15 15:59:32 +0100649 .compatible = "lg,lp129qe",
650 .data = &lg_lp129qe,
651 }, {
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100652 .compatible = "samsung,ltn101nt05",
653 .data = &samsung_ltn101nt05,
654 }, {
Thierry Reding280921d2013-08-30 15:10:14 +0200655 /* sentinel */
656 }
657};
658MODULE_DEVICE_TABLE(of, platform_of_match);
659
660static int panel_simple_platform_probe(struct platform_device *pdev)
661{
662 const struct of_device_id *id;
663
664 id = of_match_node(platform_of_match, pdev->dev.of_node);
665 if (!id)
666 return -ENODEV;
667
668 return panel_simple_probe(&pdev->dev, id->data);
669}
670
671static int panel_simple_platform_remove(struct platform_device *pdev)
672{
673 return panel_simple_remove(&pdev->dev);
674}
675
Thierry Redingd02fd932014-04-29 17:21:21 +0200676static void panel_simple_platform_shutdown(struct platform_device *pdev)
677{
678 panel_simple_shutdown(&pdev->dev);
679}
680
Thierry Reding280921d2013-08-30 15:10:14 +0200681static struct platform_driver panel_simple_platform_driver = {
682 .driver = {
683 .name = "panel-simple",
684 .owner = THIS_MODULE,
685 .of_match_table = platform_of_match,
686 },
687 .probe = panel_simple_platform_probe,
688 .remove = panel_simple_platform_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +0200689 .shutdown = panel_simple_platform_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +0200690};
691
Thierry Reding210fcd92013-11-22 19:27:11 +0100692struct panel_desc_dsi {
693 struct panel_desc desc;
694
Thierry Reding462658b2014-03-14 11:24:57 +0100695 unsigned long flags;
Thierry Reding210fcd92013-11-22 19:27:11 +0100696 enum mipi_dsi_pixel_format format;
697 unsigned int lanes;
698};
699
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900700static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
701 .clock = 71000,
702 .hdisplay = 800,
703 .hsync_start = 800 + 32,
704 .hsync_end = 800 + 32 + 1,
705 .htotal = 800 + 32 + 1 + 57,
706 .vdisplay = 1280,
707 .vsync_start = 1280 + 28,
708 .vsync_end = 1280 + 28 + 1,
709 .vtotal = 1280 + 28 + 1 + 14,
710 .vrefresh = 60,
711};
712
713static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
714 .desc = {
715 .modes = &lg_ld070wx3_sl01_mode,
716 .num_modes = 1,
717 .size = {
718 .width = 94,
719 .height = 151,
720 },
721 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +0900722 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900723 .format = MIPI_DSI_FMT_RGB888,
724 .lanes = 4,
725};
726
Alexandre Courbot499ce852014-01-21 18:57:09 +0900727static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
728 .clock = 67000,
729 .hdisplay = 720,
730 .hsync_start = 720 + 12,
731 .hsync_end = 720 + 12 + 4,
732 .htotal = 720 + 12 + 4 + 112,
733 .vdisplay = 1280,
734 .vsync_start = 1280 + 8,
735 .vsync_end = 1280 + 8 + 4,
736 .vtotal = 1280 + 8 + 4 + 12,
737 .vrefresh = 60,
738};
739
740static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
741 .desc = {
742 .modes = &lg_lh500wx1_sd03_mode,
743 .num_modes = 1,
744 .size = {
745 .width = 62,
746 .height = 110,
747 },
748 },
749 .flags = MIPI_DSI_MODE_VIDEO,
750 .format = MIPI_DSI_FMT_RGB888,
751 .lanes = 4,
752};
753
Thierry Reding280921d2013-08-30 15:10:14 +0200754static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
755 .clock = 157200,
756 .hdisplay = 1920,
757 .hsync_start = 1920 + 154,
758 .hsync_end = 1920 + 154 + 16,
759 .htotal = 1920 + 154 + 16 + 32,
760 .vdisplay = 1200,
761 .vsync_start = 1200 + 17,
762 .vsync_end = 1200 + 17 + 2,
763 .vtotal = 1200 + 17 + 2 + 16,
764 .vrefresh = 60,
765};
766
Thierry Reding210fcd92013-11-22 19:27:11 +0100767static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
768 .desc = {
769 .modes = &panasonic_vvx10f004b00_mode,
770 .num_modes = 1,
771 .size = {
772 .width = 217,
773 .height = 136,
774 },
Thierry Reding280921d2013-08-30 15:10:14 +0200775 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +0900776 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
777 MIPI_DSI_CLOCK_NON_CONTINUOUS,
Thierry Reding210fcd92013-11-22 19:27:11 +0100778 .format = MIPI_DSI_FMT_RGB888,
779 .lanes = 4,
780};
781
782static const struct of_device_id dsi_of_match[] = {
783 {
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900784 .compatible = "lg,ld070wx3-sl01",
785 .data = &lg_ld070wx3_sl01
786 }, {
Alexandre Courbot499ce852014-01-21 18:57:09 +0900787 .compatible = "lg,lh500wx1-sd03",
788 .data = &lg_lh500wx1_sd03
789 }, {
Thierry Reding210fcd92013-11-22 19:27:11 +0100790 .compatible = "panasonic,vvx10f004b00",
791 .data = &panasonic_vvx10f004b00
792 }, {
793 /* sentinel */
794 }
795};
796MODULE_DEVICE_TABLE(of, dsi_of_match);
797
798static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
799{
800 const struct panel_desc_dsi *desc;
801 const struct of_device_id *id;
802 int err;
803
804 id = of_match_node(dsi_of_match, dsi->dev.of_node);
805 if (!id)
806 return -ENODEV;
807
808 desc = id->data;
809
810 err = panel_simple_probe(&dsi->dev, &desc->desc);
811 if (err < 0)
812 return err;
813
Thierry Reding462658b2014-03-14 11:24:57 +0100814 dsi->mode_flags = desc->flags;
Thierry Reding210fcd92013-11-22 19:27:11 +0100815 dsi->format = desc->format;
816 dsi->lanes = desc->lanes;
817
818 return mipi_dsi_attach(dsi);
819}
820
821static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
822{
823 int err;
824
825 err = mipi_dsi_detach(dsi);
826 if (err < 0)
827 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
828
829 return panel_simple_remove(&dsi->dev);
830}
831
Thierry Redingd02fd932014-04-29 17:21:21 +0200832static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
833{
834 panel_simple_shutdown(&dsi->dev);
835}
836
Thierry Reding210fcd92013-11-22 19:27:11 +0100837static struct mipi_dsi_driver panel_simple_dsi_driver = {
838 .driver = {
839 .name = "panel-simple-dsi",
840 .owner = THIS_MODULE,
841 .of_match_table = dsi_of_match,
842 },
843 .probe = panel_simple_dsi_probe,
844 .remove = panel_simple_dsi_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +0200845 .shutdown = panel_simple_dsi_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +0200846};
847
848static int __init panel_simple_init(void)
849{
Thierry Reding210fcd92013-11-22 19:27:11 +0100850 int err;
851
852 err = platform_driver_register(&panel_simple_platform_driver);
853 if (err < 0)
854 return err;
855
856 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
857 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
858 if (err < 0)
859 return err;
860 }
861
862 return 0;
Thierry Reding280921d2013-08-30 15:10:14 +0200863}
864module_init(panel_simple_init);
865
866static void __exit panel_simple_exit(void)
867{
Thierry Reding210fcd92013-11-22 19:27:11 +0100868 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
869 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
870
Thierry Reding280921d2013-08-30 15:10:14 +0200871 platform_driver_unregister(&panel_simple_platform_driver);
872}
873module_exit(panel_simple_exit);
874
875MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
876MODULE_DESCRIPTION("DRM Driver for Simple Panels");
877MODULE_LICENSE("GPL and additional rights");