Commit | Line | Data |
---|---|---|
280921de TR |
1 | /* |
2 | * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | * copy of this software and associated documentation files (the "Software"), | |
6 | * to deal in the Software without restriction, including without limitation | |
7 | * the rights to use, copy, modify, merge, publish, distribute, sub license, | |
8 | * and/or sell copies of the Software, and to permit persons to whom the | |
9 | * Software is furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice (including the | |
12 | * next paragraph) shall be included in all copies or substantial portions | |
13 | * of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
21 | * DEALINGS IN THE SOFTWARE. | |
22 | */ | |
23 | ||
24 | #include <linux/backlight.h> | |
cfdf0549 | 25 | #include <linux/gpio/consumer.h> |
280921de | 26 | #include <linux/module.h> |
280921de TR |
27 | #include <linux/of_platform.h> |
28 | #include <linux/platform_device.h> | |
29 | #include <linux/regulator/consumer.h> | |
30 | ||
31 | #include <drm/drmP.h> | |
32 | #include <drm/drm_crtc.h> | |
210fcd9d | 33 | #include <drm/drm_mipi_dsi.h> |
280921de TR |
34 | #include <drm/drm_panel.h> |
35 | ||
36 | struct panel_desc { | |
37 | const struct drm_display_mode *modes; | |
38 | unsigned int num_modes; | |
39 | ||
0208d511 SM |
40 | unsigned int bpc; |
41 | ||
280921de TR |
42 | struct { |
43 | unsigned int width; | |
44 | unsigned int height; | |
45 | } size; | |
f673c37e AK |
46 | |
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; | |
280921de TR |
64 | }; |
65 | ||
280921de TR |
66 | struct panel_simple { |
67 | struct drm_panel base; | |
613a633e | 68 | bool prepared; |
280921de TR |
69 | 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 | ||
cfdf0549 | 77 | struct gpio_desc *enable_gpio; |
280921de TR |
78 | }; |
79 | ||
80 | static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) | |
81 | { | |
82 | return container_of(panel, struct panel_simple, base); | |
83 | } | |
84 | ||
85 | static 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 | ||
0208d511 | 111 | connector->display_info.bpc = panel->desc->bpc; |
280921de TR |
112 | 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 | ||
118 | static 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 | ||
f673c37e AK |
130 | if (p->desc->delay.disable) |
131 | msleep(p->desc->delay.disable); | |
132 | ||
280921de TR |
133 | p->enabled = false; |
134 | ||
135 | return 0; | |
136 | } | |
137 | ||
c0e1d170 AK |
138 | static int panel_simple_unprepare(struct drm_panel *panel) |
139 | { | |
613a633e AK |
140 | 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 | ||
f673c37e AK |
150 | if (p->desc->delay.unprepare) |
151 | msleep(p->desc->delay.unprepare); | |
152 | ||
613a633e | 153 | p->prepared = false; |
c0e1d170 | 154 | |
c0e1d170 AK |
155 | return 0; |
156 | } | |
157 | ||
613a633e | 158 | static int panel_simple_prepare(struct drm_panel *panel) |
280921de TR |
159 | { |
160 | struct panel_simple *p = to_panel_simple(panel); | |
161 | int err; | |
162 | ||
613a633e | 163 | if (p->prepared) |
280921de TR |
164 | 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 | ||
cfdf0549 | 172 | if (p->enable_gpio) |
15c1a919 | 173 | gpiod_set_value_cansleep(p->enable_gpio, 1); |
280921de | 174 | |
f673c37e AK |
175 | if (p->desc->delay.prepare) |
176 | msleep(p->desc->delay.prepare); | |
177 | ||
613a633e AK |
178 | p->prepared = true; |
179 | ||
180 | return 0; | |
181 | } | |
182 | ||
183 | static 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 | ||
f673c37e AK |
190 | if (p->desc->delay.enable) |
191 | msleep(p->desc->delay.enable); | |
192 | ||
280921de TR |
193 | 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 | ||
203 | static 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); | |
70bf6878 | 211 | drm_mode_connector_update_edid_property(panel->connector, edid); |
280921de TR |
212 | 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 | ||
224 | static const struct drm_panel_funcs panel_simple_funcs = { | |
225 | .disable = panel_simple_disable, | |
c0e1d170 AK |
226 | .unprepare = panel_simple_unprepare, |
227 | .prepare = panel_simple_prepare, | |
280921de TR |
228 | .enable = panel_simple_enable, |
229 | .get_modes = panel_simple_get_modes, | |
230 | }; | |
231 | ||
232 | static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) | |
233 | { | |
234 | struct device_node *backlight, *ddc; | |
235 | struct panel_simple *panel; | |
280921de TR |
236 | int err; |
237 | ||
238 | panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); | |
239 | if (!panel) | |
240 | return -ENOMEM; | |
241 | ||
242 | panel->enabled = false; | |
613a633e | 243 | panel->prepared = false; |
280921de TR |
244 | 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 | ||
cfdf0549 AC |
250 | 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); | |
280921de TR |
255 | return err; |
256 | } | |
257 | ||
cfdf0549 AC |
258 | panel->enable_gpio = NULL; |
259 | } else { | |
260 | err = gpiod_direction_output(panel->enable_gpio, 0); | |
280921de | 261 | if (err < 0) { |
cfdf0549 AC |
262 | dev_err(dev, "failed to setup GPIO: %d\n", err); |
263 | return err; | |
280921de TR |
264 | } |
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 | ||
cfdf0549 AC |
272 | if (!panel->backlight) |
273 | return -EPROBE_DEFER; | |
280921de TR |
274 | } |
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 | ||
299 | free_ddc: | |
300 | if (panel->ddc) | |
301 | put_device(&panel->ddc->dev); | |
302 | free_backlight: | |
303 | if (panel->backlight) | |
304 | put_device(&panel->backlight->dev); | |
280921de TR |
305 | |
306 | return err; | |
307 | } | |
308 | ||
309 | static 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 | ||
280921de TR |
324 | return 0; |
325 | } | |
326 | ||
d02fd93e TR |
327 | static 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 | ||
280921de TR |
334 | static 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 | ||
347 | static const struct panel_desc auo_b101aw03 = { | |
348 | .modes = &auo_b101aw03_mode, | |
349 | .num_modes = 1, | |
0208d511 | 350 | .bpc = 6, |
280921de TR |
351 | .size = { |
352 | .width = 223, | |
353 | .height = 125, | |
354 | }, | |
355 | }; | |
356 | ||
a333f7ad SM |
357 | static 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 | ||
370 | static const struct panel_desc auo_b133xtn01 = { | |
371 | .modes = &auo_b133xtn01_mode, | |
372 | .num_modes = 1, | |
0208d511 | 373 | .bpc = 6, |
a333f7ad SM |
374 | .size = { |
375 | .width = 293, | |
376 | .height = 165, | |
377 | }, | |
378 | }; | |
379 | ||
4c930757 SW |
380 | static const struct drm_display_mode chunghwa_claa101wa01a_mode = { |
381 | .clock = 72070, | |
382 | .hdisplay = 1366, | |
383 | .hsync_start = 1366 + 58, | |
384 | .hsync_end = 1366 + 58 + 58, | |
385 | .htotal = 1366 + 58 + 58 + 58, | |
386 | .vdisplay = 768, | |
387 | .vsync_start = 768 + 4, | |
388 | .vsync_end = 768 + 4 + 4, | |
389 | .vtotal = 768 + 4 + 4 + 4, | |
390 | .vrefresh = 60, | |
391 | }; | |
392 | ||
393 | static const struct panel_desc chunghwa_claa101wa01a = { | |
394 | .modes = &chunghwa_claa101wa01a_mode, | |
395 | .num_modes = 1, | |
0208d511 | 396 | .bpc = 6, |
4c930757 SW |
397 | .size = { |
398 | .width = 220, | |
399 | .height = 120, | |
400 | }, | |
401 | }; | |
402 | ||
280921de TR |
403 | static const struct drm_display_mode chunghwa_claa101wb01_mode = { |
404 | .clock = 69300, | |
405 | .hdisplay = 1366, | |
406 | .hsync_start = 1366 + 48, | |
407 | .hsync_end = 1366 + 48 + 32, | |
408 | .htotal = 1366 + 48 + 32 + 20, | |
409 | .vdisplay = 768, | |
410 | .vsync_start = 768 + 16, | |
411 | .vsync_end = 768 + 16 + 8, | |
412 | .vtotal = 768 + 16 + 8 + 16, | |
413 | .vrefresh = 60, | |
414 | }; | |
415 | ||
416 | static const struct panel_desc chunghwa_claa101wb01 = { | |
417 | .modes = &chunghwa_claa101wb01_mode, | |
418 | .num_modes = 1, | |
0208d511 | 419 | .bpc = 6, |
280921de TR |
420 | .size = { |
421 | .width = 223, | |
422 | .height = 125, | |
423 | }, | |
424 | }; | |
425 | ||
26ab0065 SA |
426 | static const struct drm_display_mode edt_et057090dhu_mode = { |
427 | .clock = 25175, | |
428 | .hdisplay = 640, | |
429 | .hsync_start = 640 + 16, | |
430 | .hsync_end = 640 + 16 + 30, | |
431 | .htotal = 640 + 16 + 30 + 114, | |
432 | .vdisplay = 480, | |
433 | .vsync_start = 480 + 10, | |
434 | .vsync_end = 480 + 10 + 3, | |
435 | .vtotal = 480 + 10 + 3 + 32, | |
436 | .vrefresh = 60, | |
437 | .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, | |
438 | }; | |
439 | ||
440 | static const struct panel_desc edt_et057090dhu = { | |
441 | .modes = &edt_et057090dhu_mode, | |
442 | .num_modes = 1, | |
0208d511 | 443 | .bpc = 6, |
26ab0065 SA |
444 | .size = { |
445 | .width = 115, | |
446 | .height = 86, | |
447 | }, | |
448 | }; | |
449 | ||
fff5de45 PZ |
450 | static const struct drm_display_mode edt_etm0700g0dh6_mode = { |
451 | .clock = 33260, | |
452 | .hdisplay = 800, | |
453 | .hsync_start = 800 + 40, | |
454 | .hsync_end = 800 + 40 + 128, | |
455 | .htotal = 800 + 40 + 128 + 88, | |
456 | .vdisplay = 480, | |
457 | .vsync_start = 480 + 10, | |
458 | .vsync_end = 480 + 10 + 2, | |
459 | .vtotal = 480 + 10 + 2 + 33, | |
460 | .vrefresh = 60, | |
461 | .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, | |
462 | }; | |
463 | ||
464 | static const struct panel_desc edt_etm0700g0dh6 = { | |
465 | .modes = &edt_etm0700g0dh6_mode, | |
466 | .num_modes = 1, | |
0208d511 | 467 | .bpc = 6, |
fff5de45 PZ |
468 | .size = { |
469 | .width = 152, | |
470 | .height = 91, | |
471 | }, | |
472 | }; | |
473 | ||
102932b0 BB |
474 | static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = { |
475 | .clock = 32260, | |
476 | .hdisplay = 800, | |
477 | .hsync_start = 800 + 168, | |
478 | .hsync_end = 800 + 168 + 64, | |
479 | .htotal = 800 + 168 + 64 + 88, | |
480 | .vdisplay = 480, | |
481 | .vsync_start = 480 + 37, | |
482 | .vsync_end = 480 + 37 + 2, | |
483 | .vtotal = 480 + 37 + 2 + 8, | |
484 | .vrefresh = 60, | |
485 | }; | |
486 | ||
487 | static const struct panel_desc foxlink_fl500wvr00_a0t = { | |
488 | .modes = &foxlink_fl500wvr00_a0t_mode, | |
489 | .num_modes = 1, | |
490 | .size = { | |
491 | .width = 108, | |
492 | .height = 65, | |
493 | }, | |
494 | }; | |
495 | ||
0a2288c0 TR |
496 | static const struct drm_display_mode innolux_n116bge_mode = { |
497 | .clock = 71000, | |
498 | .hdisplay = 1366, | |
499 | .hsync_start = 1366 + 64, | |
500 | .hsync_end = 1366 + 64 + 6, | |
501 | .htotal = 1366 + 64 + 6 + 64, | |
502 | .vdisplay = 768, | |
503 | .vsync_start = 768 + 8, | |
504 | .vsync_end = 768 + 8 + 4, | |
505 | .vtotal = 768 + 8 + 4 + 8, | |
506 | .vrefresh = 60, | |
507 | .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, | |
508 | }; | |
509 | ||
510 | static const struct panel_desc innolux_n116bge = { | |
511 | .modes = &innolux_n116bge_mode, | |
512 | .num_modes = 1, | |
513 | .bpc = 6, | |
514 | .size = { | |
515 | .width = 256, | |
516 | .height = 144, | |
517 | }, | |
518 | }; | |
519 | ||
ea44739d AB |
520 | static const struct drm_display_mode innolux_n156bge_l21_mode = { |
521 | .clock = 69300, | |
522 | .hdisplay = 1366, | |
523 | .hsync_start = 1366 + 16, | |
524 | .hsync_end = 1366 + 16 + 34, | |
525 | .htotal = 1366 + 16 + 34 + 50, | |
526 | .vdisplay = 768, | |
527 | .vsync_start = 768 + 2, | |
528 | .vsync_end = 768 + 2 + 6, | |
529 | .vtotal = 768 + 2 + 6 + 12, | |
530 | .vrefresh = 60, | |
531 | }; | |
532 | ||
533 | static const struct panel_desc innolux_n156bge_l21 = { | |
534 | .modes = &innolux_n156bge_l21_mode, | |
535 | .num_modes = 1, | |
0208d511 | 536 | .bpc = 6, |
ea44739d AB |
537 | .size = { |
538 | .width = 344, | |
539 | .height = 193, | |
540 | }, | |
541 | }; | |
542 | ||
ec7c5653 TR |
543 | static const struct drm_display_mode lg_lp129qe_mode = { |
544 | .clock = 285250, | |
545 | .hdisplay = 2560, | |
546 | .hsync_start = 2560 + 48, | |
547 | .hsync_end = 2560 + 48 + 32, | |
548 | .htotal = 2560 + 48 + 32 + 80, | |
549 | .vdisplay = 1700, | |
550 | .vsync_start = 1700 + 3, | |
551 | .vsync_end = 1700 + 3 + 10, | |
552 | .vtotal = 1700 + 3 + 10 + 36, | |
553 | .vrefresh = 60, | |
554 | }; | |
555 | ||
556 | static const struct panel_desc lg_lp129qe = { | |
557 | .modes = &lg_lp129qe_mode, | |
558 | .num_modes = 1, | |
0208d511 | 559 | .bpc = 8, |
ec7c5653 TR |
560 | .size = { |
561 | .width = 272, | |
562 | .height = 181, | |
563 | }, | |
564 | }; | |
565 | ||
6d54e3d2 MD |
566 | static const struct drm_display_mode samsung_ltn101nt05_mode = { |
567 | .clock = 54030, | |
568 | .hdisplay = 1024, | |
569 | .hsync_start = 1024 + 24, | |
570 | .hsync_end = 1024 + 24 + 136, | |
571 | .htotal = 1024 + 24 + 136 + 160, | |
572 | .vdisplay = 600, | |
573 | .vsync_start = 600 + 3, | |
574 | .vsync_end = 600 + 3 + 6, | |
575 | .vtotal = 600 + 3 + 6 + 61, | |
576 | .vrefresh = 60, | |
577 | }; | |
578 | ||
579 | static const struct panel_desc samsung_ltn101nt05 = { | |
580 | .modes = &samsung_ltn101nt05_mode, | |
581 | .num_modes = 1, | |
0208d511 | 582 | .bpc = 6, |
6d54e3d2 MD |
583 | .size = { |
584 | .width = 1024, | |
585 | .height = 600, | |
586 | }, | |
587 | }; | |
588 | ||
280921de TR |
589 | static const struct of_device_id platform_of_match[] = { |
590 | { | |
591 | .compatible = "auo,b101aw03", | |
592 | .data = &auo_b101aw03, | |
a333f7ad SM |
593 | }, { |
594 | .compatible = "auo,b133xtn01", | |
595 | .data = &auo_b133xtn01, | |
4c930757 SW |
596 | }, { |
597 | .compatible = "chunghwa,claa101wa01a", | |
598 | .data = &chunghwa_claa101wa01a | |
280921de TR |
599 | }, { |
600 | .compatible = "chunghwa,claa101wb01", | |
601 | .data = &chunghwa_claa101wb01 | |
26ab0065 SA |
602 | }, { |
603 | .compatible = "edt,et057090dhu", | |
604 | .data = &edt_et057090dhu, | |
fff5de45 PZ |
605 | }, { |
606 | .compatible = "edt,et070080dh6", | |
607 | .data = &edt_etm0700g0dh6, | |
608 | }, { | |
609 | .compatible = "edt,etm0700g0dh6", | |
610 | .data = &edt_etm0700g0dh6, | |
102932b0 BB |
611 | }, { |
612 | .compatible = "foxlink,fl500wvr00-a0t", | |
613 | .data = &foxlink_fl500wvr00_a0t, | |
0a2288c0 TR |
614 | }, { |
615 | .compatible = "innolux,n116bge", | |
616 | .data = &innolux_n116bge, | |
ea44739d AB |
617 | }, { |
618 | .compatible = "innolux,n156bge-l21", | |
619 | .data = &innolux_n156bge_l21, | |
ec7c5653 TR |
620 | }, { |
621 | .compatible = "lg,lp129qe", | |
622 | .data = &lg_lp129qe, | |
6d54e3d2 MD |
623 | }, { |
624 | .compatible = "samsung,ltn101nt05", | |
625 | .data = &samsung_ltn101nt05, | |
280921de TR |
626 | }, { |
627 | /* sentinel */ | |
628 | } | |
629 | }; | |
630 | MODULE_DEVICE_TABLE(of, platform_of_match); | |
631 | ||
632 | static int panel_simple_platform_probe(struct platform_device *pdev) | |
633 | { | |
634 | const struct of_device_id *id; | |
635 | ||
636 | id = of_match_node(platform_of_match, pdev->dev.of_node); | |
637 | if (!id) | |
638 | return -ENODEV; | |
639 | ||
640 | return panel_simple_probe(&pdev->dev, id->data); | |
641 | } | |
642 | ||
643 | static int panel_simple_platform_remove(struct platform_device *pdev) | |
644 | { | |
645 | return panel_simple_remove(&pdev->dev); | |
646 | } | |
647 | ||
d02fd93e TR |
648 | static void panel_simple_platform_shutdown(struct platform_device *pdev) |
649 | { | |
650 | panel_simple_shutdown(&pdev->dev); | |
651 | } | |
652 | ||
280921de TR |
653 | static struct platform_driver panel_simple_platform_driver = { |
654 | .driver = { | |
655 | .name = "panel-simple", | |
656 | .owner = THIS_MODULE, | |
657 | .of_match_table = platform_of_match, | |
658 | }, | |
659 | .probe = panel_simple_platform_probe, | |
660 | .remove = panel_simple_platform_remove, | |
d02fd93e | 661 | .shutdown = panel_simple_platform_shutdown, |
280921de TR |
662 | }; |
663 | ||
210fcd9d TR |
664 | struct panel_desc_dsi { |
665 | struct panel_desc desc; | |
666 | ||
462658b8 | 667 | unsigned long flags; |
210fcd9d TR |
668 | enum mipi_dsi_pixel_format format; |
669 | unsigned int lanes; | |
670 | }; | |
671 | ||
712ac1ba AC |
672 | static const struct drm_display_mode lg_ld070wx3_sl01_mode = { |
673 | .clock = 71000, | |
674 | .hdisplay = 800, | |
675 | .hsync_start = 800 + 32, | |
676 | .hsync_end = 800 + 32 + 1, | |
677 | .htotal = 800 + 32 + 1 + 57, | |
678 | .vdisplay = 1280, | |
679 | .vsync_start = 1280 + 28, | |
680 | .vsync_end = 1280 + 28 + 1, | |
681 | .vtotal = 1280 + 28 + 1 + 14, | |
682 | .vrefresh = 60, | |
683 | }; | |
684 | ||
685 | static const struct panel_desc_dsi lg_ld070wx3_sl01 = { | |
686 | .desc = { | |
687 | .modes = &lg_ld070wx3_sl01_mode, | |
688 | .num_modes = 1, | |
689 | .size = { | |
690 | .width = 94, | |
691 | .height = 151, | |
692 | }, | |
693 | }, | |
5e4cc278 | 694 | .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS, |
712ac1ba AC |
695 | .format = MIPI_DSI_FMT_RGB888, |
696 | .lanes = 4, | |
697 | }; | |
698 | ||
499ce85a AC |
699 | static const struct drm_display_mode lg_lh500wx1_sd03_mode = { |
700 | .clock = 67000, | |
701 | .hdisplay = 720, | |
702 | .hsync_start = 720 + 12, | |
703 | .hsync_end = 720 + 12 + 4, | |
704 | .htotal = 720 + 12 + 4 + 112, | |
705 | .vdisplay = 1280, | |
706 | .vsync_start = 1280 + 8, | |
707 | .vsync_end = 1280 + 8 + 4, | |
708 | .vtotal = 1280 + 8 + 4 + 12, | |
709 | .vrefresh = 60, | |
710 | }; | |
711 | ||
712 | static const struct panel_desc_dsi lg_lh500wx1_sd03 = { | |
713 | .desc = { | |
714 | .modes = &lg_lh500wx1_sd03_mode, | |
715 | .num_modes = 1, | |
716 | .size = { | |
717 | .width = 62, | |
718 | .height = 110, | |
719 | }, | |
720 | }, | |
721 | .flags = MIPI_DSI_MODE_VIDEO, | |
722 | .format = MIPI_DSI_FMT_RGB888, | |
723 | .lanes = 4, | |
724 | }; | |
725 | ||
280921de TR |
726 | static const struct drm_display_mode panasonic_vvx10f004b00_mode = { |
727 | .clock = 157200, | |
728 | .hdisplay = 1920, | |
729 | .hsync_start = 1920 + 154, | |
730 | .hsync_end = 1920 + 154 + 16, | |
731 | .htotal = 1920 + 154 + 16 + 32, | |
732 | .vdisplay = 1200, | |
733 | .vsync_start = 1200 + 17, | |
734 | .vsync_end = 1200 + 17 + 2, | |
735 | .vtotal = 1200 + 17 + 2 + 16, | |
736 | .vrefresh = 60, | |
737 | }; | |
738 | ||
210fcd9d TR |
739 | static const struct panel_desc_dsi panasonic_vvx10f004b00 = { |
740 | .desc = { | |
741 | .modes = &panasonic_vvx10f004b00_mode, | |
742 | .num_modes = 1, | |
743 | .size = { | |
744 | .width = 217, | |
745 | .height = 136, | |
746 | }, | |
280921de | 747 | }, |
5e4cc278 AC |
748 | .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | |
749 | MIPI_DSI_CLOCK_NON_CONTINUOUS, | |
210fcd9d TR |
750 | .format = MIPI_DSI_FMT_RGB888, |
751 | .lanes = 4, | |
752 | }; | |
753 | ||
754 | static const struct of_device_id dsi_of_match[] = { | |
755 | { | |
712ac1ba AC |
756 | .compatible = "lg,ld070wx3-sl01", |
757 | .data = &lg_ld070wx3_sl01 | |
758 | }, { | |
499ce85a AC |
759 | .compatible = "lg,lh500wx1-sd03", |
760 | .data = &lg_lh500wx1_sd03 | |
761 | }, { | |
210fcd9d TR |
762 | .compatible = "panasonic,vvx10f004b00", |
763 | .data = &panasonic_vvx10f004b00 | |
764 | }, { | |
765 | /* sentinel */ | |
766 | } | |
767 | }; | |
768 | MODULE_DEVICE_TABLE(of, dsi_of_match); | |
769 | ||
770 | static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi) | |
771 | { | |
772 | const struct panel_desc_dsi *desc; | |
773 | const struct of_device_id *id; | |
774 | int err; | |
775 | ||
776 | id = of_match_node(dsi_of_match, dsi->dev.of_node); | |
777 | if (!id) | |
778 | return -ENODEV; | |
779 | ||
780 | desc = id->data; | |
781 | ||
782 | err = panel_simple_probe(&dsi->dev, &desc->desc); | |
783 | if (err < 0) | |
784 | return err; | |
785 | ||
462658b8 | 786 | dsi->mode_flags = desc->flags; |
210fcd9d TR |
787 | dsi->format = desc->format; |
788 | dsi->lanes = desc->lanes; | |
789 | ||
790 | return mipi_dsi_attach(dsi); | |
791 | } | |
792 | ||
793 | static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi) | |
794 | { | |
795 | int err; | |
796 | ||
797 | err = mipi_dsi_detach(dsi); | |
798 | if (err < 0) | |
799 | dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err); | |
800 | ||
801 | return panel_simple_remove(&dsi->dev); | |
802 | } | |
803 | ||
d02fd93e TR |
804 | static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi) |
805 | { | |
806 | panel_simple_shutdown(&dsi->dev); | |
807 | } | |
808 | ||
210fcd9d TR |
809 | static struct mipi_dsi_driver panel_simple_dsi_driver = { |
810 | .driver = { | |
811 | .name = "panel-simple-dsi", | |
812 | .owner = THIS_MODULE, | |
813 | .of_match_table = dsi_of_match, | |
814 | }, | |
815 | .probe = panel_simple_dsi_probe, | |
816 | .remove = panel_simple_dsi_remove, | |
d02fd93e | 817 | .shutdown = panel_simple_dsi_shutdown, |
280921de TR |
818 | }; |
819 | ||
820 | static int __init panel_simple_init(void) | |
821 | { | |
210fcd9d TR |
822 | int err; |
823 | ||
824 | err = platform_driver_register(&panel_simple_platform_driver); | |
825 | if (err < 0) | |
826 | return err; | |
827 | ||
828 | if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) { | |
829 | err = mipi_dsi_driver_register(&panel_simple_dsi_driver); | |
830 | if (err < 0) | |
831 | return err; | |
832 | } | |
833 | ||
834 | return 0; | |
280921de TR |
835 | } |
836 | module_init(panel_simple_init); | |
837 | ||
838 | static void __exit panel_simple_exit(void) | |
839 | { | |
210fcd9d TR |
840 | if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) |
841 | mipi_dsi_driver_unregister(&panel_simple_dsi_driver); | |
842 | ||
280921de TR |
843 | platform_driver_unregister(&panel_simple_platform_driver); |
844 | } | |
845 | module_exit(panel_simple_exit); | |
846 | ||
847 | MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>"); | |
848 | MODULE_DESCRIPTION("DRM Driver for Simple Panels"); | |
849 | MODULE_LICENSE("GPL and additional rights"); |