blob: 6ae1aada63733ab17ff2eb99029ca4baed3dcb35 [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 Courbotcfdf0542014-03-01 14:00:58 +0900250 panel->enable_gpio = devm_gpiod_get(dev, "enable");
251 if (IS_ERR(panel->enable_gpio)) {
252 err = PTR_ERR(panel->enable_gpio);
253 if (err != -ENOENT) {
254 dev_err(dev, "failed to request GPIO: %d\n", err);
Thierry Reding280921d2013-08-30 15:10:14 +0200255 return err;
256 }
257
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900258 panel->enable_gpio = NULL;
259 } else {
260 err = gpiod_direction_output(panel->enable_gpio, 0);
Thierry Reding280921d2013-08-30 15:10:14 +0200261 if (err < 0) {
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900262 dev_err(dev, "failed to setup GPIO: %d\n", err);
263 return err;
Thierry Reding280921d2013-08-30 15:10:14 +0200264 }
265 }
266
267 backlight = of_parse_phandle(dev->of_node, "backlight", 0);
268 if (backlight) {
269 panel->backlight = of_find_backlight_by_node(backlight);
270 of_node_put(backlight);
271
Alexandre Courbotcfdf0542014-03-01 14:00:58 +0900272 if (!panel->backlight)
273 return -EPROBE_DEFER;
Thierry Reding280921d2013-08-30 15:10:14 +0200274 }
275
276 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
277 if (ddc) {
278 panel->ddc = of_find_i2c_adapter_by_node(ddc);
279 of_node_put(ddc);
280
281 if (!panel->ddc) {
282 err = -EPROBE_DEFER;
283 goto free_backlight;
284 }
285 }
286
287 drm_panel_init(&panel->base);
288 panel->base.dev = dev;
289 panel->base.funcs = &panel_simple_funcs;
290
291 err = drm_panel_add(&panel->base);
292 if (err < 0)
293 goto free_ddc;
294
295 dev_set_drvdata(dev, panel);
296
297 return 0;
298
299free_ddc:
300 if (panel->ddc)
301 put_device(&panel->ddc->dev);
302free_backlight:
303 if (panel->backlight)
304 put_device(&panel->backlight->dev);
Thierry Reding280921d2013-08-30 15:10:14 +0200305
306 return err;
307}
308
309static int panel_simple_remove(struct device *dev)
310{
311 struct panel_simple *panel = dev_get_drvdata(dev);
312
313 drm_panel_detach(&panel->base);
314 drm_panel_remove(&panel->base);
315
316 panel_simple_disable(&panel->base);
317
318 if (panel->ddc)
319 put_device(&panel->ddc->dev);
320
321 if (panel->backlight)
322 put_device(&panel->backlight->dev);
323
Thierry Reding280921d2013-08-30 15:10:14 +0200324 return 0;
325}
326
Thierry Redingd02fd932014-04-29 17:21:21 +0200327static void panel_simple_shutdown(struct device *dev)
328{
329 struct panel_simple *panel = dev_get_drvdata(dev);
330
331 panel_simple_disable(&panel->base);
332}
333
Thierry Reding280921d2013-08-30 15:10:14 +0200334static const struct drm_display_mode auo_b101aw03_mode = {
335 .clock = 51450,
336 .hdisplay = 1024,
337 .hsync_start = 1024 + 156,
338 .hsync_end = 1024 + 156 + 8,
339 .htotal = 1024 + 156 + 8 + 156,
340 .vdisplay = 600,
341 .vsync_start = 600 + 16,
342 .vsync_end = 600 + 16 + 6,
343 .vtotal = 600 + 16 + 6 + 16,
344 .vrefresh = 60,
345};
346
347static const struct panel_desc auo_b101aw03 = {
348 .modes = &auo_b101aw03_mode,
349 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700350 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200351 .size = {
352 .width = 223,
353 .height = 125,
354 },
355};
356
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700357static const struct drm_display_mode auo_b133xtn01_mode = {
358 .clock = 69500,
359 .hdisplay = 1366,
360 .hsync_start = 1366 + 48,
361 .hsync_end = 1366 + 48 + 32,
362 .htotal = 1366 + 48 + 32 + 20,
363 .vdisplay = 768,
364 .vsync_start = 768 + 3,
365 .vsync_end = 768 + 3 + 6,
366 .vtotal = 768 + 3 + 6 + 13,
367 .vrefresh = 60,
368};
369
370static const struct panel_desc auo_b133xtn01 = {
371 .modes = &auo_b133xtn01_mode,
372 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700373 .bpc = 6,
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700374 .size = {
375 .width = 293,
376 .height = 165,
377 },
378};
379
Ajay Kumar3e51d602014-07-31 23:12:12 +0530380static const struct drm_display_mode auo_b133htn01_mode = {
381 .clock = 150660,
382 .hdisplay = 1920,
383 .hsync_start = 1920 + 172,
384 .hsync_end = 1920 + 172 + 80,
385 .htotal = 1920 + 172 + 80 + 60,
386 .vdisplay = 1080,
387 .vsync_start = 1080 + 25,
388 .vsync_end = 1080 + 25 + 10,
389 .vtotal = 1080 + 25 + 10 + 10,
390 .vrefresh = 60,
391};
392
393static const struct panel_desc auo_b133htn01 = {
394 .modes = &auo_b133htn01_mode,
395 .num_modes = 1,
396 .size = {
397 .width = 293,
398 .height = 165,
399 },
400 .delay = {
401 .prepare = 105,
402 .enable = 20,
403 .unprepare = 50,
404 },
405};
406
Stephen Warren4c930752014-01-07 16:46:26 -0700407static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
408 .clock = 72070,
409 .hdisplay = 1366,
410 .hsync_start = 1366 + 58,
411 .hsync_end = 1366 + 58 + 58,
412 .htotal = 1366 + 58 + 58 + 58,
413 .vdisplay = 768,
414 .vsync_start = 768 + 4,
415 .vsync_end = 768 + 4 + 4,
416 .vtotal = 768 + 4 + 4 + 4,
417 .vrefresh = 60,
418};
419
420static const struct panel_desc chunghwa_claa101wa01a = {
421 .modes = &chunghwa_claa101wa01a_mode,
422 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700423 .bpc = 6,
Stephen Warren4c930752014-01-07 16:46:26 -0700424 .size = {
425 .width = 220,
426 .height = 120,
427 },
428};
429
Thierry Reding280921d2013-08-30 15:10:14 +0200430static const struct drm_display_mode chunghwa_claa101wb01_mode = {
431 .clock = 69300,
432 .hdisplay = 1366,
433 .hsync_start = 1366 + 48,
434 .hsync_end = 1366 + 48 + 32,
435 .htotal = 1366 + 48 + 32 + 20,
436 .vdisplay = 768,
437 .vsync_start = 768 + 16,
438 .vsync_end = 768 + 16 + 8,
439 .vtotal = 768 + 16 + 8 + 16,
440 .vrefresh = 60,
441};
442
443static const struct panel_desc chunghwa_claa101wb01 = {
444 .modes = &chunghwa_claa101wb01_mode,
445 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700446 .bpc = 6,
Thierry Reding280921d2013-08-30 15:10:14 +0200447 .size = {
448 .width = 223,
449 .height = 125,
450 },
451};
452
Stefan Agner26ab0062014-05-15 11:38:45 +0200453static const struct drm_display_mode edt_et057090dhu_mode = {
454 .clock = 25175,
455 .hdisplay = 640,
456 .hsync_start = 640 + 16,
457 .hsync_end = 640 + 16 + 30,
458 .htotal = 640 + 16 + 30 + 114,
459 .vdisplay = 480,
460 .vsync_start = 480 + 10,
461 .vsync_end = 480 + 10 + 3,
462 .vtotal = 480 + 10 + 3 + 32,
463 .vrefresh = 60,
464 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
465};
466
467static const struct panel_desc edt_et057090dhu = {
468 .modes = &edt_et057090dhu_mode,
469 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700470 .bpc = 6,
Stefan Agner26ab0062014-05-15 11:38:45 +0200471 .size = {
472 .width = 115,
473 .height = 86,
474 },
475};
476
Philipp Zabelfff5de42014-05-15 12:25:47 +0200477static const struct drm_display_mode edt_etm0700g0dh6_mode = {
478 .clock = 33260,
479 .hdisplay = 800,
480 .hsync_start = 800 + 40,
481 .hsync_end = 800 + 40 + 128,
482 .htotal = 800 + 40 + 128 + 88,
483 .vdisplay = 480,
484 .vsync_start = 480 + 10,
485 .vsync_end = 480 + 10 + 2,
486 .vtotal = 480 + 10 + 2 + 33,
487 .vrefresh = 60,
488 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
489};
490
491static const struct panel_desc edt_etm0700g0dh6 = {
492 .modes = &edt_etm0700g0dh6_mode,
493 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700494 .bpc = 6,
Philipp Zabelfff5de42014-05-15 12:25:47 +0200495 .size = {
496 .width = 152,
497 .height = 91,
498 },
499};
500
Boris BREZILLON102932b2014-06-05 15:53:32 +0200501static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
502 .clock = 32260,
503 .hdisplay = 800,
504 .hsync_start = 800 + 168,
505 .hsync_end = 800 + 168 + 64,
506 .htotal = 800 + 168 + 64 + 88,
507 .vdisplay = 480,
508 .vsync_start = 480 + 37,
509 .vsync_end = 480 + 37 + 2,
510 .vtotal = 480 + 37 + 2 + 8,
511 .vrefresh = 60,
512};
513
514static const struct panel_desc foxlink_fl500wvr00_a0t = {
515 .modes = &foxlink_fl500wvr00_a0t_mode,
516 .num_modes = 1,
517 .size = {
518 .width = 108,
519 .height = 65,
520 },
521};
522
Thierry Reding0a2288c2014-07-03 14:02:59 +0200523static const struct drm_display_mode innolux_n116bge_mode = {
524 .clock = 71000,
525 .hdisplay = 1366,
526 .hsync_start = 1366 + 64,
527 .hsync_end = 1366 + 64 + 6,
528 .htotal = 1366 + 64 + 6 + 64,
529 .vdisplay = 768,
530 .vsync_start = 768 + 8,
531 .vsync_end = 768 + 8 + 4,
532 .vtotal = 768 + 8 + 4 + 8,
533 .vrefresh = 60,
534 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
535};
536
537static const struct panel_desc innolux_n116bge = {
538 .modes = &innolux_n116bge_mode,
539 .num_modes = 1,
540 .bpc = 6,
541 .size = {
542 .width = 256,
543 .height = 144,
544 },
545};
546
Alban Bedelea447392014-07-22 08:38:55 +0200547static const struct drm_display_mode innolux_n156bge_l21_mode = {
548 .clock = 69300,
549 .hdisplay = 1366,
550 .hsync_start = 1366 + 16,
551 .hsync_end = 1366 + 16 + 34,
552 .htotal = 1366 + 16 + 34 + 50,
553 .vdisplay = 768,
554 .vsync_start = 768 + 2,
555 .vsync_end = 768 + 2 + 6,
556 .vtotal = 768 + 2 + 6 + 12,
557 .vrefresh = 60,
558};
559
560static const struct panel_desc innolux_n156bge_l21 = {
561 .modes = &innolux_n156bge_l21_mode,
562 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700563 .bpc = 6,
Alban Bedelea447392014-07-22 08:38:55 +0200564 .size = {
565 .width = 344,
566 .height = 193,
567 },
568};
569
Thierry Redingec7c5652013-11-15 15:59:32 +0100570static const struct drm_display_mode lg_lp129qe_mode = {
571 .clock = 285250,
572 .hdisplay = 2560,
573 .hsync_start = 2560 + 48,
574 .hsync_end = 2560 + 48 + 32,
575 .htotal = 2560 + 48 + 32 + 80,
576 .vdisplay = 1700,
577 .vsync_start = 1700 + 3,
578 .vsync_end = 1700 + 3 + 10,
579 .vtotal = 1700 + 3 + 10 + 36,
580 .vrefresh = 60,
581};
582
583static const struct panel_desc lg_lp129qe = {
584 .modes = &lg_lp129qe_mode,
585 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700586 .bpc = 8,
Thierry Redingec7c5652013-11-15 15:59:32 +0100587 .size = {
588 .width = 272,
589 .height = 181,
590 },
591};
592
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100593static const struct drm_display_mode samsung_ltn101nt05_mode = {
594 .clock = 54030,
595 .hdisplay = 1024,
596 .hsync_start = 1024 + 24,
597 .hsync_end = 1024 + 24 + 136,
598 .htotal = 1024 + 24 + 136 + 160,
599 .vdisplay = 600,
600 .vsync_start = 600 + 3,
601 .vsync_end = 600 + 3 + 6,
602 .vtotal = 600 + 3 + 6 + 61,
603 .vrefresh = 60,
604};
605
606static const struct panel_desc samsung_ltn101nt05 = {
607 .modes = &samsung_ltn101nt05_mode,
608 .num_modes = 1,
Stéphane Marchesin0208d512014-06-19 18:18:28 -0700609 .bpc = 6,
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100610 .size = {
611 .width = 1024,
612 .height = 600,
613 },
614};
615
Thierry Reding280921d2013-08-30 15:10:14 +0200616static const struct of_device_id platform_of_match[] = {
617 {
618 .compatible = "auo,b101aw03",
619 .data = &auo_b101aw03,
620 }, {
Ajay Kumar3e51d602014-07-31 23:12:12 +0530621 .compatible = "auo,b133htn01",
622 .data = &auo_b133htn01,
623 }, {
Stéphane Marchesina333f7a2014-05-23 19:27:59 -0700624 .compatible = "auo,b133xtn01",
625 .data = &auo_b133xtn01,
626 }, {
Stephen Warren4c930752014-01-07 16:46:26 -0700627 .compatible = "chunghwa,claa101wa01a",
628 .data = &chunghwa_claa101wa01a
629 }, {
Thierry Reding280921d2013-08-30 15:10:14 +0200630 .compatible = "chunghwa,claa101wb01",
631 .data = &chunghwa_claa101wb01
632 }, {
Stefan Agner26ab0062014-05-15 11:38:45 +0200633 .compatible = "edt,et057090dhu",
634 .data = &edt_et057090dhu,
635 }, {
Philipp Zabelfff5de42014-05-15 12:25:47 +0200636 .compatible = "edt,et070080dh6",
637 .data = &edt_etm0700g0dh6,
638 }, {
639 .compatible = "edt,etm0700g0dh6",
640 .data = &edt_etm0700g0dh6,
641 }, {
Boris BREZILLON102932b2014-06-05 15:53:32 +0200642 .compatible = "foxlink,fl500wvr00-a0t",
643 .data = &foxlink_fl500wvr00_a0t,
644 }, {
Thierry Reding0a2288c2014-07-03 14:02:59 +0200645 .compatible = "innolux,n116bge",
646 .data = &innolux_n116bge,
647 }, {
Alban Bedelea447392014-07-22 08:38:55 +0200648 .compatible = "innolux,n156bge-l21",
649 .data = &innolux_n156bge_l21,
650 }, {
Thierry Redingec7c5652013-11-15 15:59:32 +0100651 .compatible = "lg,lp129qe",
652 .data = &lg_lp129qe,
653 }, {
Marc Dietrich6d54e3d2013-12-21 21:38:12 +0100654 .compatible = "samsung,ltn101nt05",
655 .data = &samsung_ltn101nt05,
656 }, {
Thierry Reding280921d2013-08-30 15:10:14 +0200657 /* sentinel */
658 }
659};
660MODULE_DEVICE_TABLE(of, platform_of_match);
661
662static int panel_simple_platform_probe(struct platform_device *pdev)
663{
664 const struct of_device_id *id;
665
666 id = of_match_node(platform_of_match, pdev->dev.of_node);
667 if (!id)
668 return -ENODEV;
669
670 return panel_simple_probe(&pdev->dev, id->data);
671}
672
673static int panel_simple_platform_remove(struct platform_device *pdev)
674{
675 return panel_simple_remove(&pdev->dev);
676}
677
Thierry Redingd02fd932014-04-29 17:21:21 +0200678static void panel_simple_platform_shutdown(struct platform_device *pdev)
679{
680 panel_simple_shutdown(&pdev->dev);
681}
682
Thierry Reding280921d2013-08-30 15:10:14 +0200683static struct platform_driver panel_simple_platform_driver = {
684 .driver = {
685 .name = "panel-simple",
686 .owner = THIS_MODULE,
687 .of_match_table = platform_of_match,
688 },
689 .probe = panel_simple_platform_probe,
690 .remove = panel_simple_platform_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +0200691 .shutdown = panel_simple_platform_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +0200692};
693
Thierry Reding210fcd92013-11-22 19:27:11 +0100694struct panel_desc_dsi {
695 struct panel_desc desc;
696
Thierry Reding462658b2014-03-14 11:24:57 +0100697 unsigned long flags;
Thierry Reding210fcd92013-11-22 19:27:11 +0100698 enum mipi_dsi_pixel_format format;
699 unsigned int lanes;
700};
701
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900702static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
703 .clock = 71000,
704 .hdisplay = 800,
705 .hsync_start = 800 + 32,
706 .hsync_end = 800 + 32 + 1,
707 .htotal = 800 + 32 + 1 + 57,
708 .vdisplay = 1280,
709 .vsync_start = 1280 + 28,
710 .vsync_end = 1280 + 28 + 1,
711 .vtotal = 1280 + 28 + 1 + 14,
712 .vrefresh = 60,
713};
714
715static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
716 .desc = {
717 .modes = &lg_ld070wx3_sl01_mode,
718 .num_modes = 1,
719 .size = {
720 .width = 94,
721 .height = 151,
722 },
723 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +0900724 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900725 .format = MIPI_DSI_FMT_RGB888,
726 .lanes = 4,
727};
728
Alexandre Courbot499ce852014-01-21 18:57:09 +0900729static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
730 .clock = 67000,
731 .hdisplay = 720,
732 .hsync_start = 720 + 12,
733 .hsync_end = 720 + 12 + 4,
734 .htotal = 720 + 12 + 4 + 112,
735 .vdisplay = 1280,
736 .vsync_start = 1280 + 8,
737 .vsync_end = 1280 + 8 + 4,
738 .vtotal = 1280 + 8 + 4 + 12,
739 .vrefresh = 60,
740};
741
742static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
743 .desc = {
744 .modes = &lg_lh500wx1_sd03_mode,
745 .num_modes = 1,
746 .size = {
747 .width = 62,
748 .height = 110,
749 },
750 },
751 .flags = MIPI_DSI_MODE_VIDEO,
752 .format = MIPI_DSI_FMT_RGB888,
753 .lanes = 4,
754};
755
Thierry Reding280921d2013-08-30 15:10:14 +0200756static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
757 .clock = 157200,
758 .hdisplay = 1920,
759 .hsync_start = 1920 + 154,
760 .hsync_end = 1920 + 154 + 16,
761 .htotal = 1920 + 154 + 16 + 32,
762 .vdisplay = 1200,
763 .vsync_start = 1200 + 17,
764 .vsync_end = 1200 + 17 + 2,
765 .vtotal = 1200 + 17 + 2 + 16,
766 .vrefresh = 60,
767};
768
Thierry Reding210fcd92013-11-22 19:27:11 +0100769static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
770 .desc = {
771 .modes = &panasonic_vvx10f004b00_mode,
772 .num_modes = 1,
773 .size = {
774 .width = 217,
775 .height = 136,
776 },
Thierry Reding280921d2013-08-30 15:10:14 +0200777 },
Alexandre Courbot5e4cc272014-07-08 21:32:12 +0900778 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
779 MIPI_DSI_CLOCK_NON_CONTINUOUS,
Thierry Reding210fcd92013-11-22 19:27:11 +0100780 .format = MIPI_DSI_FMT_RGB888,
781 .lanes = 4,
782};
783
784static const struct of_device_id dsi_of_match[] = {
785 {
Alexandre Courbot712ac1b2014-01-21 18:57:10 +0900786 .compatible = "lg,ld070wx3-sl01",
787 .data = &lg_ld070wx3_sl01
788 }, {
Alexandre Courbot499ce852014-01-21 18:57:09 +0900789 .compatible = "lg,lh500wx1-sd03",
790 .data = &lg_lh500wx1_sd03
791 }, {
Thierry Reding210fcd92013-11-22 19:27:11 +0100792 .compatible = "panasonic,vvx10f004b00",
793 .data = &panasonic_vvx10f004b00
794 }, {
795 /* sentinel */
796 }
797};
798MODULE_DEVICE_TABLE(of, dsi_of_match);
799
800static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
801{
802 const struct panel_desc_dsi *desc;
803 const struct of_device_id *id;
804 int err;
805
806 id = of_match_node(dsi_of_match, dsi->dev.of_node);
807 if (!id)
808 return -ENODEV;
809
810 desc = id->data;
811
812 err = panel_simple_probe(&dsi->dev, &desc->desc);
813 if (err < 0)
814 return err;
815
Thierry Reding462658b2014-03-14 11:24:57 +0100816 dsi->mode_flags = desc->flags;
Thierry Reding210fcd92013-11-22 19:27:11 +0100817 dsi->format = desc->format;
818 dsi->lanes = desc->lanes;
819
820 return mipi_dsi_attach(dsi);
821}
822
823static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
824{
825 int err;
826
827 err = mipi_dsi_detach(dsi);
828 if (err < 0)
829 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
830
831 return panel_simple_remove(&dsi->dev);
832}
833
Thierry Redingd02fd932014-04-29 17:21:21 +0200834static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
835{
836 panel_simple_shutdown(&dsi->dev);
837}
838
Thierry Reding210fcd92013-11-22 19:27:11 +0100839static struct mipi_dsi_driver panel_simple_dsi_driver = {
840 .driver = {
841 .name = "panel-simple-dsi",
842 .owner = THIS_MODULE,
843 .of_match_table = dsi_of_match,
844 },
845 .probe = panel_simple_dsi_probe,
846 .remove = panel_simple_dsi_remove,
Thierry Redingd02fd932014-04-29 17:21:21 +0200847 .shutdown = panel_simple_dsi_shutdown,
Thierry Reding280921d2013-08-30 15:10:14 +0200848};
849
850static int __init panel_simple_init(void)
851{
Thierry Reding210fcd92013-11-22 19:27:11 +0100852 int err;
853
854 err = platform_driver_register(&panel_simple_platform_driver);
855 if (err < 0)
856 return err;
857
858 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
859 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
860 if (err < 0)
861 return err;
862 }
863
864 return 0;
Thierry Reding280921d2013-08-30 15:10:14 +0200865}
866module_init(panel_simple_init);
867
868static void __exit panel_simple_exit(void)
869{
Thierry Reding210fcd92013-11-22 19:27:11 +0100870 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
871 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
872
Thierry Reding280921d2013-08-30 15:10:14 +0200873 platform_driver_unregister(&panel_simple_platform_driver);
874}
875module_exit(panel_simple_exit);
876
877MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
878MODULE_DESCRIPTION("DRM Driver for Simple Panels");
879MODULE_LICENSE("GPL and additional rights");