panel-simple.c revision 3e51d609321601627fb571bdc403c330f416d1af
1/* 2 * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sub license, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the 12 * next paragraph) shall be included in all copies or substantial portions 13 * of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24#include <linux/backlight.h> 25#include <linux/gpio/consumer.h> 26#include <linux/module.h> 27#include <linux/of_platform.h> 28#include <linux/platform_device.h> 29#include <linux/regulator/consumer.h> 30 31#include <drm/drmP.h> 32#include <drm/drm_crtc.h> 33#include <drm/drm_mipi_dsi.h> 34#include <drm/drm_panel.h> 35 36struct panel_desc { 37 const struct drm_display_mode *modes; 38 unsigned int num_modes; 39 40 unsigned int bpc; 41 42 struct { 43 unsigned int width; 44 unsigned int height; 45 } size; 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; 64}; 65 66struct panel_simple { 67 struct drm_panel base; 68 bool prepared; 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 77 struct gpio_desc *enable_gpio; 78}; 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 111 connector->display_info.bpc = panel->desc->bpc; 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 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 130 if (p->desc->delay.disable) 131 msleep(p->desc->delay.disable); 132 133 p->enabled = false; 134 135 return 0; 136} 137 138static int panel_simple_unprepare(struct drm_panel *panel) 139{ 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 150 if (p->desc->delay.unprepare) 151 msleep(p->desc->delay.unprepare); 152 153 p->prepared = false; 154 155 return 0; 156} 157 158static int panel_simple_prepare(struct drm_panel *panel) 159{ 160 struct panel_simple *p = to_panel_simple(panel); 161 int err; 162 163 if (p->prepared) 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 172 if (p->enable_gpio) 173 gpiod_set_value_cansleep(p->enable_gpio, 1); 174 175 if (p->desc->delay.prepare) 176 msleep(p->desc->delay.prepare); 177 178 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 190 if (p->desc->delay.enable) 191 msleep(p->desc->delay.enable); 192 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 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); 211 drm_mode_connector_update_edid_property(panel->connector, edid); 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 224static const struct drm_panel_funcs panel_simple_funcs = { 225 .disable = panel_simple_disable, 226 .unprepare = panel_simple_unprepare, 227 .prepare = panel_simple_prepare, 228 .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; 236 int err; 237 238 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); 239 if (!panel) 240 return -ENOMEM; 241 242 panel->enabled = false; 243 panel->prepared = false; 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 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); 255 return err; 256 } 257 258 panel->enable_gpio = NULL; 259 } else { 260 err = gpiod_direction_output(panel->enable_gpio, 0); 261 if (err < 0) { 262 dev_err(dev, "failed to setup GPIO: %d\n", err); 263 return err; 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 272 if (!panel->backlight) 273 return -EPROBE_DEFER; 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 299free_ddc: 300 if (panel->ddc) 301 put_device(&panel->ddc->dev); 302free_backlight: 303 if (panel->backlight) 304 put_device(&panel->backlight->dev); 305 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 324 return 0; 325} 326 327static 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 334static 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, 350 .bpc = 6, 351 .size = { 352 .width = 223, 353 .height = 125, 354 }, 355}; 356 357static 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, 373 .bpc = 6, 374 .size = { 375 .width = 293, 376 .height = 165, 377 }, 378}; 379 380static 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 407static 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, 423 .bpc = 6, 424 .size = { 425 .width = 220, 426 .height = 120, 427 }, 428}; 429 430static 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, 446 .bpc = 6, 447 .size = { 448 .width = 223, 449 .height = 125, 450 }, 451}; 452 453static 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, 470 .bpc = 6, 471 .size = { 472 .width = 115, 473 .height = 86, 474 }, 475}; 476 477static 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, 494 .bpc = 6, 495 .size = { 496 .width = 152, 497 .height = 91, 498 }, 499}; 500 501static 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 523static 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 547static 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, 563 .bpc = 6, 564 .size = { 565 .width = 344, 566 .height = 193, 567 }, 568}; 569 570static 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, 586 .bpc = 8, 587 .size = { 588 .width = 272, 589 .height = 181, 590 }, 591}; 592 593static 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, 609 .bpc = 6, 610 .size = { 611 .width = 1024, 612 .height = 600, 613 }, 614}; 615 616static const struct of_device_id platform_of_match[] = { 617 { 618 .compatible = "auo,b101aw03", 619 .data = &auo_b101aw03, 620 }, { 621 .compatible = "auo,b133htn01", 622 .data = &auo_b133htn01, 623 }, { 624 .compatible = "auo,b133xtn01", 625 .data = &auo_b133xtn01, 626 }, { 627 .compatible = "chunghwa,claa101wa01a", 628 .data = &chunghwa_claa101wa01a 629 }, { 630 .compatible = "chunghwa,claa101wb01", 631 .data = &chunghwa_claa101wb01 632 }, { 633 .compatible = "edt,et057090dhu", 634 .data = &edt_et057090dhu, 635 }, { 636 .compatible = "edt,et070080dh6", 637 .data = &edt_etm0700g0dh6, 638 }, { 639 .compatible = "edt,etm0700g0dh6", 640 .data = &edt_etm0700g0dh6, 641 }, { 642 .compatible = "foxlink,fl500wvr00-a0t", 643 .data = &foxlink_fl500wvr00_a0t, 644 }, { 645 .compatible = "innolux,n116bge", 646 .data = &innolux_n116bge, 647 }, { 648 .compatible = "innolux,n156bge-l21", 649 .data = &innolux_n156bge_l21, 650 }, { 651 .compatible = "lg,lp129qe", 652 .data = &lg_lp129qe, 653 }, { 654 .compatible = "samsung,ltn101nt05", 655 .data = &samsung_ltn101nt05, 656 }, { 657 /* 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 678static void panel_simple_platform_shutdown(struct platform_device *pdev) 679{ 680 panel_simple_shutdown(&pdev->dev); 681} 682 683static 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, 691 .shutdown = panel_simple_platform_shutdown, 692}; 693 694struct panel_desc_dsi { 695 struct panel_desc desc; 696 697 unsigned long flags; 698 enum mipi_dsi_pixel_format format; 699 unsigned int lanes; 700}; 701 702static 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 }, 724 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS, 725 .format = MIPI_DSI_FMT_RGB888, 726 .lanes = 4, 727}; 728 729static 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 756static 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 769static 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 }, 777 }, 778 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | 779 MIPI_DSI_CLOCK_NON_CONTINUOUS, 780 .format = MIPI_DSI_FMT_RGB888, 781 .lanes = 4, 782}; 783 784static const struct of_device_id dsi_of_match[] = { 785 { 786 .compatible = "lg,ld070wx3-sl01", 787 .data = &lg_ld070wx3_sl01 788 }, { 789 .compatible = "lg,lh500wx1-sd03", 790 .data = &lg_lh500wx1_sd03 791 }, { 792 .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 816 dsi->mode_flags = desc->flags; 817 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 834static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi) 835{ 836 panel_simple_shutdown(&dsi->dev); 837} 838 839static 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, 847 .shutdown = panel_simple_dsi_shutdown, 848}; 849 850static int __init panel_simple_init(void) 851{ 852 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; 865} 866module_init(panel_simple_init); 867 868static void __exit panel_simple_exit(void) 869{ 870 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) 871 mipi_dsi_driver_unregister(&panel_simple_dsi_driver); 872 873 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"); 880