| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Generic DSI Command Mode panel driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ |
|---|
| 5 | 6 | * Author: Tomi Valkeinen <tomi.valkeinen@ti.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 8 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 9 | | - * the Free Software Foundation. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | /* #define DEBUG */ |
|---|
| .. | .. |
|---|
| 23 | 20 | #include <linux/workqueue.h> |
|---|
| 24 | 21 | #include <linux/of_device.h> |
|---|
| 25 | 22 | #include <linux/regulator/consumer.h> |
|---|
| 23 | + |
|---|
| 24 | +#include <drm/drm_connector.h> |
|---|
| 26 | 25 | |
|---|
| 27 | 26 | #include <video/mipi_display.h> |
|---|
| 28 | 27 | #include <video/of_display_timing.h> |
|---|
| .. | .. |
|---|
| 41 | 40 | |
|---|
| 42 | 41 | struct panel_drv_data { |
|---|
| 43 | 42 | struct omap_dss_device dssdev; |
|---|
| 44 | | - struct omap_dss_device *in; |
|---|
| 43 | + struct omap_dss_device *src; |
|---|
| 45 | 44 | |
|---|
| 46 | 45 | struct videomode vm; |
|---|
| 47 | 46 | |
|---|
| .. | .. |
|---|
| 142 | 141 | |
|---|
| 143 | 142 | static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) |
|---|
| 144 | 143 | { |
|---|
| 145 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 144 | + struct omap_dss_device *src = ddata->src; |
|---|
| 146 | 145 | int r; |
|---|
| 147 | 146 | u8 buf[1]; |
|---|
| 148 | 147 | |
|---|
| 149 | | - r = in->ops.dsi->dcs_read(in, ddata->channel, dcs_cmd, buf, 1); |
|---|
| 148 | + r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1); |
|---|
| 150 | 149 | |
|---|
| 151 | 150 | if (r < 0) |
|---|
| 152 | 151 | return r; |
|---|
| .. | .. |
|---|
| 158 | 157 | |
|---|
| 159 | 158 | static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) |
|---|
| 160 | 159 | { |
|---|
| 161 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 162 | | - return in->ops.dsi->dcs_write(in, ddata->channel, &dcs_cmd, 1); |
|---|
| 160 | + struct omap_dss_device *src = ddata->src; |
|---|
| 161 | + |
|---|
| 162 | + return src->ops->dsi.dcs_write(src, ddata->channel, &dcs_cmd, 1); |
|---|
| 163 | 163 | } |
|---|
| 164 | 164 | |
|---|
| 165 | 165 | static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) |
|---|
| 166 | 166 | { |
|---|
| 167 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 167 | + struct omap_dss_device *src = ddata->src; |
|---|
| 168 | 168 | u8 buf[2] = { dcs_cmd, param }; |
|---|
| 169 | 169 | |
|---|
| 170 | | - return in->ops.dsi->dcs_write(in, ddata->channel, buf, 2); |
|---|
| 170 | + return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2); |
|---|
| 171 | 171 | } |
|---|
| 172 | 172 | |
|---|
| 173 | 173 | static int dsicm_sleep_in(struct panel_drv_data *ddata) |
|---|
| 174 | 174 | |
|---|
| 175 | 175 | { |
|---|
| 176 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 176 | + struct omap_dss_device *src = ddata->src; |
|---|
| 177 | 177 | u8 cmd; |
|---|
| 178 | 178 | int r; |
|---|
| 179 | 179 | |
|---|
| 180 | 180 | hw_guard_wait(ddata); |
|---|
| 181 | 181 | |
|---|
| 182 | 182 | cmd = MIPI_DCS_ENTER_SLEEP_MODE; |
|---|
| 183 | | - r = in->ops.dsi->dcs_write_nosync(in, ddata->channel, &cmd, 1); |
|---|
| 183 | + r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, &cmd, 1); |
|---|
| 184 | 184 | if (r) |
|---|
| 185 | 185 | return r; |
|---|
| 186 | 186 | |
|---|
| .. | .. |
|---|
| 228 | 228 | static int dsicm_set_update_window(struct panel_drv_data *ddata, |
|---|
| 229 | 229 | u16 x, u16 y, u16 w, u16 h) |
|---|
| 230 | 230 | { |
|---|
| 231 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 231 | + struct omap_dss_device *src = ddata->src; |
|---|
| 232 | 232 | int r; |
|---|
| 233 | 233 | u16 x1 = x; |
|---|
| 234 | 234 | u16 x2 = x + w - 1; |
|---|
| .. | .. |
|---|
| 242 | 242 | buf[3] = (x2 >> 8) & 0xff; |
|---|
| 243 | 243 | buf[4] = (x2 >> 0) & 0xff; |
|---|
| 244 | 244 | |
|---|
| 245 | | - r = in->ops.dsi->dcs_write_nosync(in, ddata->channel, buf, sizeof(buf)); |
|---|
| 245 | + r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); |
|---|
| 246 | 246 | if (r) |
|---|
| 247 | 247 | return r; |
|---|
| 248 | 248 | |
|---|
| .. | .. |
|---|
| 252 | 252 | buf[3] = (y2 >> 8) & 0xff; |
|---|
| 253 | 253 | buf[4] = (y2 >> 0) & 0xff; |
|---|
| 254 | 254 | |
|---|
| 255 | | - r = in->ops.dsi->dcs_write_nosync(in, ddata->channel, buf, sizeof(buf)); |
|---|
| 255 | + r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); |
|---|
| 256 | 256 | if (r) |
|---|
| 257 | 257 | return r; |
|---|
| 258 | 258 | |
|---|
| 259 | | - in->ops.dsi->bta_sync(in, ddata->channel); |
|---|
| 259 | + src->ops->dsi.bta_sync(src, ddata->channel); |
|---|
| 260 | 260 | |
|---|
| 261 | 261 | return r; |
|---|
| 262 | 262 | } |
|---|
| .. | .. |
|---|
| 275 | 275 | |
|---|
| 276 | 276 | static int dsicm_enter_ulps(struct panel_drv_data *ddata) |
|---|
| 277 | 277 | { |
|---|
| 278 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 278 | + struct omap_dss_device *src = ddata->src; |
|---|
| 279 | 279 | int r; |
|---|
| 280 | 280 | |
|---|
| 281 | 281 | if (ddata->ulps_enabled) |
|---|
| .. | .. |
|---|
| 290 | 290 | if (ddata->ext_te_gpio) |
|---|
| 291 | 291 | disable_irq(gpiod_to_irq(ddata->ext_te_gpio)); |
|---|
| 292 | 292 | |
|---|
| 293 | | - in->ops.dsi->disable(in, false, true); |
|---|
| 293 | + src->ops->dsi.disable(src, false, true); |
|---|
| 294 | 294 | |
|---|
| 295 | 295 | ddata->ulps_enabled = true; |
|---|
| 296 | 296 | |
|---|
| .. | .. |
|---|
| 309 | 309 | |
|---|
| 310 | 310 | static int dsicm_exit_ulps(struct panel_drv_data *ddata) |
|---|
| 311 | 311 | { |
|---|
| 312 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 312 | + struct omap_dss_device *src = ddata->src; |
|---|
| 313 | 313 | int r; |
|---|
| 314 | 314 | |
|---|
| 315 | 315 | if (!ddata->ulps_enabled) |
|---|
| 316 | 316 | return 0; |
|---|
| 317 | 317 | |
|---|
| 318 | | - r = in->ops.dsi->enable(in); |
|---|
| 319 | | - if (r) { |
|---|
| 320 | | - dev_err(&ddata->pdev->dev, "failed to enable DSI\n"); |
|---|
| 321 | | - goto err1; |
|---|
| 322 | | - } |
|---|
| 323 | | - |
|---|
| 324 | | - in->ops.dsi->enable_hs(in, ddata->channel, true); |
|---|
| 318 | + src->ops->enable(src); |
|---|
| 319 | + src->ops->dsi.enable_hs(src, ddata->channel, true); |
|---|
| 325 | 320 | |
|---|
| 326 | 321 | r = _dsicm_enable_te(ddata, true); |
|---|
| 327 | 322 | if (r) { |
|---|
| .. | .. |
|---|
| 347 | 342 | enable_irq(gpiod_to_irq(ddata->ext_te_gpio)); |
|---|
| 348 | 343 | ddata->ulps_enabled = false; |
|---|
| 349 | 344 | } |
|---|
| 350 | | -err1: |
|---|
| 345 | + |
|---|
| 351 | 346 | dsicm_queue_ulps_work(ddata); |
|---|
| 352 | 347 | |
|---|
| 353 | 348 | return r; |
|---|
| .. | .. |
|---|
| 366 | 361 | static int dsicm_bl_update_status(struct backlight_device *dev) |
|---|
| 367 | 362 | { |
|---|
| 368 | 363 | struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); |
|---|
| 369 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 364 | + struct omap_dss_device *src = ddata->src; |
|---|
| 370 | 365 | int r = 0; |
|---|
| 371 | 366 | int level; |
|---|
| 372 | 367 | |
|---|
| .. | .. |
|---|
| 381 | 376 | mutex_lock(&ddata->lock); |
|---|
| 382 | 377 | |
|---|
| 383 | 378 | if (ddata->enabled) { |
|---|
| 384 | | - in->ops.dsi->bus_lock(in); |
|---|
| 379 | + src->ops->dsi.bus_lock(src); |
|---|
| 385 | 380 | |
|---|
| 386 | 381 | r = dsicm_wake_up(ddata); |
|---|
| 387 | 382 | if (!r) |
|---|
| 388 | 383 | r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level); |
|---|
| 389 | 384 | |
|---|
| 390 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 385 | + src->ops->dsi.bus_unlock(src); |
|---|
| 391 | 386 | } |
|---|
| 392 | 387 | |
|---|
| 393 | 388 | mutex_unlock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 412 | 407 | static ssize_t dsicm_num_errors_show(struct device *dev, |
|---|
| 413 | 408 | struct device_attribute *attr, char *buf) |
|---|
| 414 | 409 | { |
|---|
| 415 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 416 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 417 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 410 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 411 | + struct omap_dss_device *src = ddata->src; |
|---|
| 418 | 412 | u8 errors = 0; |
|---|
| 419 | 413 | int r; |
|---|
| 420 | 414 | |
|---|
| 421 | 415 | mutex_lock(&ddata->lock); |
|---|
| 422 | 416 | |
|---|
| 423 | 417 | if (ddata->enabled) { |
|---|
| 424 | | - in->ops.dsi->bus_lock(in); |
|---|
| 418 | + src->ops->dsi.bus_lock(src); |
|---|
| 425 | 419 | |
|---|
| 426 | 420 | r = dsicm_wake_up(ddata); |
|---|
| 427 | 421 | if (!r) |
|---|
| 428 | 422 | r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, |
|---|
| 429 | 423 | &errors); |
|---|
| 430 | 424 | |
|---|
| 431 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 425 | + src->ops->dsi.bus_unlock(src); |
|---|
| 432 | 426 | } else { |
|---|
| 433 | 427 | r = -ENODEV; |
|---|
| 434 | 428 | } |
|---|
| .. | .. |
|---|
| 444 | 438 | static ssize_t dsicm_hw_revision_show(struct device *dev, |
|---|
| 445 | 439 | struct device_attribute *attr, char *buf) |
|---|
| 446 | 440 | { |
|---|
| 447 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 448 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 449 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 441 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 442 | + struct omap_dss_device *src = ddata->src; |
|---|
| 450 | 443 | u8 id1, id2, id3; |
|---|
| 451 | 444 | int r; |
|---|
| 452 | 445 | |
|---|
| 453 | 446 | mutex_lock(&ddata->lock); |
|---|
| 454 | 447 | |
|---|
| 455 | 448 | if (ddata->enabled) { |
|---|
| 456 | | - in->ops.dsi->bus_lock(in); |
|---|
| 449 | + src->ops->dsi.bus_lock(src); |
|---|
| 457 | 450 | |
|---|
| 458 | 451 | r = dsicm_wake_up(ddata); |
|---|
| 459 | 452 | if (!r) |
|---|
| 460 | 453 | r = dsicm_get_id(ddata, &id1, &id2, &id3); |
|---|
| 461 | 454 | |
|---|
| 462 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 455 | + src->ops->dsi.bus_unlock(src); |
|---|
| 463 | 456 | } else { |
|---|
| 464 | 457 | r = -ENODEV; |
|---|
| 465 | 458 | } |
|---|
| .. | .. |
|---|
| 476 | 469 | struct device_attribute *attr, |
|---|
| 477 | 470 | const char *buf, size_t count) |
|---|
| 478 | 471 | { |
|---|
| 479 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 480 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 481 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 472 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 473 | + struct omap_dss_device *src = ddata->src; |
|---|
| 482 | 474 | unsigned long t; |
|---|
| 483 | 475 | int r; |
|---|
| 484 | 476 | |
|---|
| .. | .. |
|---|
| 489 | 481 | mutex_lock(&ddata->lock); |
|---|
| 490 | 482 | |
|---|
| 491 | 483 | if (ddata->enabled) { |
|---|
| 492 | | - in->ops.dsi->bus_lock(in); |
|---|
| 484 | + src->ops->dsi.bus_lock(src); |
|---|
| 493 | 485 | |
|---|
| 494 | 486 | if (t) |
|---|
| 495 | 487 | r = dsicm_enter_ulps(ddata); |
|---|
| 496 | 488 | else |
|---|
| 497 | 489 | r = dsicm_wake_up(ddata); |
|---|
| 498 | 490 | |
|---|
| 499 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 491 | + src->ops->dsi.bus_unlock(src); |
|---|
| 500 | 492 | } |
|---|
| 501 | 493 | |
|---|
| 502 | 494 | mutex_unlock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 511 | 503 | struct device_attribute *attr, |
|---|
| 512 | 504 | char *buf) |
|---|
| 513 | 505 | { |
|---|
| 514 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 515 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 506 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 516 | 507 | unsigned int t; |
|---|
| 517 | 508 | |
|---|
| 518 | 509 | mutex_lock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 526 | 517 | struct device_attribute *attr, |
|---|
| 527 | 518 | const char *buf, size_t count) |
|---|
| 528 | 519 | { |
|---|
| 529 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 530 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 531 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 520 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 521 | + struct omap_dss_device *src = ddata->src; |
|---|
| 532 | 522 | unsigned long t; |
|---|
| 533 | 523 | int r; |
|---|
| 534 | 524 | |
|---|
| .. | .. |
|---|
| 541 | 531 | |
|---|
| 542 | 532 | if (ddata->enabled) { |
|---|
| 543 | 533 | /* dsicm_wake_up will restart the timer */ |
|---|
| 544 | | - in->ops.dsi->bus_lock(in); |
|---|
| 534 | + src->ops->dsi.bus_lock(src); |
|---|
| 545 | 535 | r = dsicm_wake_up(ddata); |
|---|
| 546 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 536 | + src->ops->dsi.bus_unlock(src); |
|---|
| 547 | 537 | } |
|---|
| 548 | 538 | |
|---|
| 549 | 539 | mutex_unlock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 558 | 548 | struct device_attribute *attr, |
|---|
| 559 | 549 | char *buf) |
|---|
| 560 | 550 | { |
|---|
| 561 | | - struct platform_device *pdev = to_platform_device(dev); |
|---|
| 562 | | - struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 551 | + struct panel_drv_data *ddata = dev_get_drvdata(dev); |
|---|
| 563 | 552 | unsigned int t; |
|---|
| 564 | 553 | |
|---|
| 565 | 554 | mutex_lock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 603 | 592 | |
|---|
| 604 | 593 | static int dsicm_power_on(struct panel_drv_data *ddata) |
|---|
| 605 | 594 | { |
|---|
| 606 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 595 | + struct omap_dss_device *src = ddata->src; |
|---|
| 607 | 596 | u8 id1, id2, id3; |
|---|
| 608 | 597 | int r; |
|---|
| 609 | 598 | struct omap_dss_dsi_config dsi_config = { |
|---|
| .. | .. |
|---|
| 635 | 624 | } |
|---|
| 636 | 625 | |
|---|
| 637 | 626 | if (ddata->pin_config.num_pins > 0) { |
|---|
| 638 | | - r = in->ops.dsi->configure_pins(in, &ddata->pin_config); |
|---|
| 627 | + r = src->ops->dsi.configure_pins(src, &ddata->pin_config); |
|---|
| 639 | 628 | if (r) { |
|---|
| 640 | 629 | dev_err(&ddata->pdev->dev, |
|---|
| 641 | 630 | "failed to configure DSI pins\n"); |
|---|
| .. | .. |
|---|
| 643 | 632 | } |
|---|
| 644 | 633 | } |
|---|
| 645 | 634 | |
|---|
| 646 | | - r = in->ops.dsi->set_config(in, &dsi_config); |
|---|
| 635 | + r = src->ops->dsi.set_config(src, &dsi_config); |
|---|
| 647 | 636 | if (r) { |
|---|
| 648 | 637 | dev_err(&ddata->pdev->dev, "failed to configure DSI\n"); |
|---|
| 649 | 638 | goto err_vddi; |
|---|
| 650 | 639 | } |
|---|
| 651 | 640 | |
|---|
| 652 | | - r = in->ops.dsi->enable(in); |
|---|
| 653 | | - if (r) { |
|---|
| 654 | | - dev_err(&ddata->pdev->dev, "failed to enable DSI\n"); |
|---|
| 655 | | - goto err_vddi; |
|---|
| 656 | | - } |
|---|
| 641 | + src->ops->enable(src); |
|---|
| 657 | 642 | |
|---|
| 658 | 643 | dsicm_hw_reset(ddata); |
|---|
| 659 | 644 | |
|---|
| 660 | | - in->ops.dsi->enable_hs(in, ddata->channel, false); |
|---|
| 645 | + src->ops->dsi.enable_hs(src, ddata->channel, false); |
|---|
| 661 | 646 | |
|---|
| 662 | 647 | r = dsicm_sleep_out(ddata); |
|---|
| 663 | 648 | if (r) |
|---|
| .. | .. |
|---|
| 689 | 674 | if (r) |
|---|
| 690 | 675 | goto err; |
|---|
| 691 | 676 | |
|---|
| 692 | | - r = in->ops.dsi->enable_video_output(in, ddata->channel); |
|---|
| 677 | + r = src->ops->dsi.enable_video_output(src, ddata->channel); |
|---|
| 693 | 678 | if (r) |
|---|
| 694 | 679 | goto err; |
|---|
| 695 | 680 | |
|---|
| 696 | | - ddata->enabled = 1; |
|---|
| 681 | + ddata->enabled = true; |
|---|
| 697 | 682 | |
|---|
| 698 | 683 | if (!ddata->intro_printed) { |
|---|
| 699 | 684 | dev_info(&ddata->pdev->dev, "panel revision %02x.%02x.%02x\n", |
|---|
| .. | .. |
|---|
| 701 | 686 | ddata->intro_printed = true; |
|---|
| 702 | 687 | } |
|---|
| 703 | 688 | |
|---|
| 704 | | - in->ops.dsi->enable_hs(in, ddata->channel, true); |
|---|
| 689 | + src->ops->dsi.enable_hs(src, ddata->channel, true); |
|---|
| 705 | 690 | |
|---|
| 706 | 691 | return 0; |
|---|
| 707 | 692 | err: |
|---|
| .. | .. |
|---|
| 709 | 694 | |
|---|
| 710 | 695 | dsicm_hw_reset(ddata); |
|---|
| 711 | 696 | |
|---|
| 712 | | - in->ops.dsi->disable(in, true, false); |
|---|
| 697 | + src->ops->dsi.disable(src, true, false); |
|---|
| 713 | 698 | err_vddi: |
|---|
| 714 | 699 | if (ddata->vddi) |
|---|
| 715 | 700 | regulator_disable(ddata->vddi); |
|---|
| .. | .. |
|---|
| 722 | 707 | |
|---|
| 723 | 708 | static void dsicm_power_off(struct panel_drv_data *ddata) |
|---|
| 724 | 709 | { |
|---|
| 725 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 710 | + struct omap_dss_device *src = ddata->src; |
|---|
| 726 | 711 | int r; |
|---|
| 727 | 712 | |
|---|
| 728 | | - in->ops.dsi->disable_video_output(in, ddata->channel); |
|---|
| 713 | + src->ops->dsi.disable_video_output(src, ddata->channel); |
|---|
| 729 | 714 | |
|---|
| 730 | 715 | r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_OFF); |
|---|
| 731 | 716 | if (!r) |
|---|
| .. | .. |
|---|
| 737 | 722 | dsicm_hw_reset(ddata); |
|---|
| 738 | 723 | } |
|---|
| 739 | 724 | |
|---|
| 740 | | - in->ops.dsi->disable(in, true, false); |
|---|
| 725 | + src->ops->dsi.disable(src, true, false); |
|---|
| 741 | 726 | |
|---|
| 742 | 727 | if (ddata->vddi) |
|---|
| 743 | 728 | regulator_disable(ddata->vddi); |
|---|
| 744 | 729 | if (ddata->vpnl) |
|---|
| 745 | 730 | regulator_disable(ddata->vpnl); |
|---|
| 746 | 731 | |
|---|
| 747 | | - ddata->enabled = 0; |
|---|
| 732 | + ddata->enabled = false; |
|---|
| 748 | 733 | } |
|---|
| 749 | 734 | |
|---|
| 750 | 735 | static int dsicm_panel_reset(struct panel_drv_data *ddata) |
|---|
| .. | .. |
|---|
| 756 | 741 | return dsicm_power_on(ddata); |
|---|
| 757 | 742 | } |
|---|
| 758 | 743 | |
|---|
| 759 | | -static int dsicm_connect(struct omap_dss_device *dssdev) |
|---|
| 744 | +static int dsicm_connect(struct omap_dss_device *src, |
|---|
| 745 | + struct omap_dss_device *dst) |
|---|
| 760 | 746 | { |
|---|
| 761 | | - struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 747 | + struct panel_drv_data *ddata = to_panel_data(dst); |
|---|
| 762 | 748 | struct device *dev = &ddata->pdev->dev; |
|---|
| 763 | | - struct omap_dss_device *in; |
|---|
| 764 | 749 | int r; |
|---|
| 765 | 750 | |
|---|
| 766 | | - if (omapdss_device_is_connected(dssdev)) |
|---|
| 767 | | - return 0; |
|---|
| 768 | | - |
|---|
| 769 | | - in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node); |
|---|
| 770 | | - if (IS_ERR(in)) { |
|---|
| 771 | | - dev_err(dssdev->dev, "failed to find video source\n"); |
|---|
| 772 | | - return PTR_ERR(in); |
|---|
| 773 | | - } |
|---|
| 774 | | - |
|---|
| 775 | | - r = in->ops.dsi->connect(in, dssdev); |
|---|
| 776 | | - if (r) { |
|---|
| 777 | | - dev_err(dev, "Failed to connect to video source\n"); |
|---|
| 778 | | - goto err_connect; |
|---|
| 779 | | - } |
|---|
| 780 | | - |
|---|
| 781 | | - r = in->ops.dsi->request_vc(in, &ddata->channel); |
|---|
| 751 | + r = src->ops->dsi.request_vc(src, &ddata->channel); |
|---|
| 782 | 752 | if (r) { |
|---|
| 783 | 753 | dev_err(dev, "failed to get virtual channel\n"); |
|---|
| 784 | | - goto err_req_vc; |
|---|
| 754 | + return r; |
|---|
| 785 | 755 | } |
|---|
| 786 | 756 | |
|---|
| 787 | | - r = in->ops.dsi->set_vc_id(in, ddata->channel, TCH); |
|---|
| 757 | + r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH); |
|---|
| 788 | 758 | if (r) { |
|---|
| 789 | 759 | dev_err(dev, "failed to set VC_ID\n"); |
|---|
| 790 | | - goto err_vc_id; |
|---|
| 760 | + src->ops->dsi.release_vc(src, ddata->channel); |
|---|
| 761 | + return r; |
|---|
| 791 | 762 | } |
|---|
| 792 | 763 | |
|---|
| 793 | | - ddata->in = in; |
|---|
| 764 | + ddata->src = src; |
|---|
| 794 | 765 | return 0; |
|---|
| 795 | | - |
|---|
| 796 | | -err_vc_id: |
|---|
| 797 | | - in->ops.dsi->release_vc(in, ddata->channel); |
|---|
| 798 | | -err_req_vc: |
|---|
| 799 | | - in->ops.dsi->disconnect(in, dssdev); |
|---|
| 800 | | -err_connect: |
|---|
| 801 | | - omap_dss_put_device(in); |
|---|
| 802 | | - return r; |
|---|
| 803 | 766 | } |
|---|
| 804 | 767 | |
|---|
| 805 | | -static void dsicm_disconnect(struct omap_dss_device *dssdev) |
|---|
| 768 | +static void dsicm_disconnect(struct omap_dss_device *src, |
|---|
| 769 | + struct omap_dss_device *dst) |
|---|
| 806 | 770 | { |
|---|
| 807 | | - struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 808 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 771 | + struct panel_drv_data *ddata = to_panel_data(dst); |
|---|
| 809 | 772 | |
|---|
| 810 | | - if (!omapdss_device_is_connected(dssdev)) |
|---|
| 811 | | - return; |
|---|
| 812 | | - |
|---|
| 813 | | - in->ops.dsi->release_vc(in, ddata->channel); |
|---|
| 814 | | - in->ops.dsi->disconnect(in, dssdev); |
|---|
| 815 | | - |
|---|
| 816 | | - omap_dss_put_device(in); |
|---|
| 817 | | - ddata->in = NULL; |
|---|
| 773 | + src->ops->dsi.release_vc(src, ddata->channel); |
|---|
| 774 | + ddata->src = NULL; |
|---|
| 818 | 775 | } |
|---|
| 819 | 776 | |
|---|
| 820 | | -static int dsicm_enable(struct omap_dss_device *dssdev) |
|---|
| 777 | +static void dsicm_enable(struct omap_dss_device *dssdev) |
|---|
| 821 | 778 | { |
|---|
| 822 | 779 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 823 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 780 | + struct omap_dss_device *src = ddata->src; |
|---|
| 824 | 781 | int r; |
|---|
| 825 | | - |
|---|
| 826 | | - dev_dbg(&ddata->pdev->dev, "enable\n"); |
|---|
| 827 | 782 | |
|---|
| 828 | 783 | mutex_lock(&ddata->lock); |
|---|
| 829 | 784 | |
|---|
| 830 | | - if (!omapdss_device_is_connected(dssdev)) { |
|---|
| 831 | | - r = -ENODEV; |
|---|
| 832 | | - goto err; |
|---|
| 833 | | - } |
|---|
| 834 | | - |
|---|
| 835 | | - if (omapdss_device_is_enabled(dssdev)) { |
|---|
| 836 | | - r = 0; |
|---|
| 837 | | - goto err; |
|---|
| 838 | | - } |
|---|
| 839 | | - |
|---|
| 840 | | - in->ops.dsi->bus_lock(in); |
|---|
| 785 | + src->ops->dsi.bus_lock(src); |
|---|
| 841 | 786 | |
|---|
| 842 | 787 | r = dsicm_power_on(ddata); |
|---|
| 843 | 788 | |
|---|
| 844 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 789 | + src->ops->dsi.bus_unlock(src); |
|---|
| 845 | 790 | |
|---|
| 846 | 791 | if (r) |
|---|
| 847 | 792 | goto err; |
|---|
| 848 | | - |
|---|
| 849 | | - dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; |
|---|
| 850 | 793 | |
|---|
| 851 | 794 | mutex_unlock(&ddata->lock); |
|---|
| 852 | 795 | |
|---|
| 853 | 796 | dsicm_bl_power(ddata, true); |
|---|
| 854 | 797 | |
|---|
| 855 | | - return 0; |
|---|
| 798 | + return; |
|---|
| 856 | 799 | err: |
|---|
| 857 | | - dev_dbg(&ddata->pdev->dev, "enable failed\n"); |
|---|
| 800 | + dev_dbg(&ddata->pdev->dev, "enable failed (%d)\n", r); |
|---|
| 858 | 801 | mutex_unlock(&ddata->lock); |
|---|
| 859 | | - return r; |
|---|
| 860 | 802 | } |
|---|
| 861 | 803 | |
|---|
| 862 | 804 | static void dsicm_disable(struct omap_dss_device *dssdev) |
|---|
| 863 | 805 | { |
|---|
| 864 | 806 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 865 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 807 | + struct omap_dss_device *src = ddata->src; |
|---|
| 866 | 808 | int r; |
|---|
| 867 | | - |
|---|
| 868 | | - dev_dbg(&ddata->pdev->dev, "disable\n"); |
|---|
| 869 | 809 | |
|---|
| 870 | 810 | dsicm_bl_power(ddata, false); |
|---|
| 871 | 811 | |
|---|
| .. | .. |
|---|
| 873 | 813 | |
|---|
| 874 | 814 | dsicm_cancel_ulps_work(ddata); |
|---|
| 875 | 815 | |
|---|
| 876 | | - in->ops.dsi->bus_lock(in); |
|---|
| 816 | + src->ops->dsi.bus_lock(src); |
|---|
| 877 | 817 | |
|---|
| 878 | | - if (omapdss_device_is_enabled(dssdev)) { |
|---|
| 879 | | - r = dsicm_wake_up(ddata); |
|---|
| 880 | | - if (!r) |
|---|
| 881 | | - dsicm_power_off(ddata); |
|---|
| 882 | | - } |
|---|
| 818 | + r = dsicm_wake_up(ddata); |
|---|
| 819 | + if (!r) |
|---|
| 820 | + dsicm_power_off(ddata); |
|---|
| 883 | 821 | |
|---|
| 884 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 885 | | - |
|---|
| 886 | | - dssdev->state = OMAP_DSS_DISPLAY_DISABLED; |
|---|
| 822 | + src->ops->dsi.bus_unlock(src); |
|---|
| 887 | 823 | |
|---|
| 888 | 824 | mutex_unlock(&ddata->lock); |
|---|
| 889 | 825 | } |
|---|
| .. | .. |
|---|
| 891 | 827 | static void dsicm_framedone_cb(int err, void *data) |
|---|
| 892 | 828 | { |
|---|
| 893 | 829 | struct panel_drv_data *ddata = data; |
|---|
| 894 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 830 | + struct omap_dss_device *src = ddata->src; |
|---|
| 895 | 831 | |
|---|
| 896 | 832 | dev_dbg(&ddata->pdev->dev, "framedone, err %d\n", err); |
|---|
| 897 | | - in->ops.dsi->bus_unlock(ddata->in); |
|---|
| 833 | + src->ops->dsi.bus_unlock(src); |
|---|
| 898 | 834 | } |
|---|
| 899 | 835 | |
|---|
| 900 | 836 | static irqreturn_t dsicm_te_isr(int irq, void *data) |
|---|
| 901 | 837 | { |
|---|
| 902 | 838 | struct panel_drv_data *ddata = data; |
|---|
| 903 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 839 | + struct omap_dss_device *src = ddata->src; |
|---|
| 904 | 840 | int old; |
|---|
| 905 | 841 | int r; |
|---|
| 906 | 842 | |
|---|
| .. | .. |
|---|
| 909 | 845 | if (old) { |
|---|
| 910 | 846 | cancel_delayed_work(&ddata->te_timeout_work); |
|---|
| 911 | 847 | |
|---|
| 912 | | - r = in->ops.dsi->update(in, ddata->channel, dsicm_framedone_cb, |
|---|
| 848 | + r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb, |
|---|
| 913 | 849 | ddata); |
|---|
| 914 | 850 | if (r) |
|---|
| 915 | 851 | goto err; |
|---|
| .. | .. |
|---|
| 918 | 854 | return IRQ_HANDLED; |
|---|
| 919 | 855 | err: |
|---|
| 920 | 856 | dev_err(&ddata->pdev->dev, "start update failed\n"); |
|---|
| 921 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 857 | + src->ops->dsi.bus_unlock(src); |
|---|
| 922 | 858 | return IRQ_HANDLED; |
|---|
| 923 | 859 | } |
|---|
| 924 | 860 | |
|---|
| .. | .. |
|---|
| 926 | 862 | { |
|---|
| 927 | 863 | struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, |
|---|
| 928 | 864 | te_timeout_work.work); |
|---|
| 929 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 865 | + struct omap_dss_device *src = ddata->src; |
|---|
| 930 | 866 | |
|---|
| 931 | 867 | dev_err(&ddata->pdev->dev, "TE not received for 250ms!\n"); |
|---|
| 932 | 868 | |
|---|
| 933 | 869 | atomic_set(&ddata->do_update, 0); |
|---|
| 934 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 870 | + src->ops->dsi.bus_unlock(src); |
|---|
| 935 | 871 | } |
|---|
| 936 | 872 | |
|---|
| 937 | 873 | static int dsicm_update(struct omap_dss_device *dssdev, |
|---|
| 938 | 874 | u16 x, u16 y, u16 w, u16 h) |
|---|
| 939 | 875 | { |
|---|
| 940 | 876 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 941 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 877 | + struct omap_dss_device *src = ddata->src; |
|---|
| 942 | 878 | int r; |
|---|
| 943 | 879 | |
|---|
| 944 | 880 | dev_dbg(&ddata->pdev->dev, "update %d, %d, %d x %d\n", x, y, w, h); |
|---|
| 945 | 881 | |
|---|
| 946 | 882 | mutex_lock(&ddata->lock); |
|---|
| 947 | | - in->ops.dsi->bus_lock(in); |
|---|
| 883 | + src->ops->dsi.bus_lock(src); |
|---|
| 948 | 884 | |
|---|
| 949 | 885 | r = dsicm_wake_up(ddata); |
|---|
| 950 | 886 | if (r) |
|---|
| .. | .. |
|---|
| 956 | 892 | } |
|---|
| 957 | 893 | |
|---|
| 958 | 894 | /* XXX no need to send this every frame, but dsi break if not done */ |
|---|
| 959 | | - r = dsicm_set_update_window(ddata, 0, 0, |
|---|
| 960 | | - dssdev->panel.vm.hactive, |
|---|
| 961 | | - dssdev->panel.vm.vactive); |
|---|
| 895 | + r = dsicm_set_update_window(ddata, 0, 0, ddata->vm.hactive, |
|---|
| 896 | + ddata->vm.vactive); |
|---|
| 962 | 897 | if (r) |
|---|
| 963 | 898 | goto err; |
|---|
| 964 | 899 | |
|---|
| .. | .. |
|---|
| 967 | 902 | msecs_to_jiffies(250)); |
|---|
| 968 | 903 | atomic_set(&ddata->do_update, 1); |
|---|
| 969 | 904 | } else { |
|---|
| 970 | | - r = in->ops.dsi->update(in, ddata->channel, dsicm_framedone_cb, |
|---|
| 905 | + r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb, |
|---|
| 971 | 906 | ddata); |
|---|
| 972 | 907 | if (r) |
|---|
| 973 | 908 | goto err; |
|---|
| 974 | 909 | } |
|---|
| 975 | 910 | |
|---|
| 976 | | - /* note: no bus_unlock here. unlock is in framedone_cb */ |
|---|
| 911 | + /* note: no bus_unlock here. unlock is src framedone_cb */ |
|---|
| 977 | 912 | mutex_unlock(&ddata->lock); |
|---|
| 978 | 913 | return 0; |
|---|
| 979 | 914 | err: |
|---|
| 980 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 915 | + src->ops->dsi.bus_unlock(src); |
|---|
| 981 | 916 | mutex_unlock(&ddata->lock); |
|---|
| 982 | 917 | return r; |
|---|
| 983 | 918 | } |
|---|
| .. | .. |
|---|
| 985 | 920 | static int dsicm_sync(struct omap_dss_device *dssdev) |
|---|
| 986 | 921 | { |
|---|
| 987 | 922 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 988 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 923 | + struct omap_dss_device *src = ddata->src; |
|---|
| 989 | 924 | |
|---|
| 990 | 925 | dev_dbg(&ddata->pdev->dev, "sync\n"); |
|---|
| 991 | 926 | |
|---|
| 992 | 927 | mutex_lock(&ddata->lock); |
|---|
| 993 | | - in->ops.dsi->bus_lock(in); |
|---|
| 994 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 928 | + src->ops->dsi.bus_lock(src); |
|---|
| 929 | + src->ops->dsi.bus_unlock(src); |
|---|
| 995 | 930 | mutex_unlock(&ddata->lock); |
|---|
| 996 | 931 | |
|---|
| 997 | 932 | dev_dbg(&ddata->pdev->dev, "sync done\n"); |
|---|
| .. | .. |
|---|
| 1001 | 936 | |
|---|
| 1002 | 937 | static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) |
|---|
| 1003 | 938 | { |
|---|
| 1004 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 939 | + struct omap_dss_device *src = ddata->src; |
|---|
| 1005 | 940 | int r; |
|---|
| 1006 | 941 | |
|---|
| 1007 | 942 | if (enable) |
|---|
| .. | .. |
|---|
| 1010 | 945 | r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF); |
|---|
| 1011 | 946 | |
|---|
| 1012 | 947 | if (!ddata->ext_te_gpio) |
|---|
| 1013 | | - in->ops.dsi->enable_te(in, enable); |
|---|
| 948 | + src->ops->dsi.enable_te(src, enable); |
|---|
| 1014 | 949 | |
|---|
| 1015 | 950 | /* possible panel bug */ |
|---|
| 1016 | 951 | msleep(100); |
|---|
| .. | .. |
|---|
| 1021 | 956 | static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable) |
|---|
| 1022 | 957 | { |
|---|
| 1023 | 958 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 1024 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 959 | + struct omap_dss_device *src = ddata->src; |
|---|
| 1025 | 960 | int r; |
|---|
| 1026 | 961 | |
|---|
| 1027 | 962 | mutex_lock(&ddata->lock); |
|---|
| .. | .. |
|---|
| 1029 | 964 | if (ddata->te_enabled == enable) |
|---|
| 1030 | 965 | goto end; |
|---|
| 1031 | 966 | |
|---|
| 1032 | | - in->ops.dsi->bus_lock(in); |
|---|
| 967 | + src->ops->dsi.bus_lock(src); |
|---|
| 1033 | 968 | |
|---|
| 1034 | 969 | if (ddata->enabled) { |
|---|
| 1035 | 970 | r = dsicm_wake_up(ddata); |
|---|
| .. | .. |
|---|
| 1043 | 978 | |
|---|
| 1044 | 979 | ddata->te_enabled = enable; |
|---|
| 1045 | 980 | |
|---|
| 1046 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 981 | + src->ops->dsi.bus_unlock(src); |
|---|
| 1047 | 982 | end: |
|---|
| 1048 | 983 | mutex_unlock(&ddata->lock); |
|---|
| 1049 | 984 | |
|---|
| 1050 | 985 | return 0; |
|---|
| 1051 | 986 | err: |
|---|
| 1052 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 987 | + src->ops->dsi.bus_unlock(src); |
|---|
| 1053 | 988 | mutex_unlock(&ddata->lock); |
|---|
| 1054 | 989 | |
|---|
| 1055 | 990 | return r; |
|---|
| .. | .. |
|---|
| 1072 | 1007 | u16 x, u16 y, u16 w, u16 h) |
|---|
| 1073 | 1008 | { |
|---|
| 1074 | 1009 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 1075 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 1010 | + struct omap_dss_device *src = ddata->src; |
|---|
| 1076 | 1011 | int r; |
|---|
| 1077 | 1012 | int first = 1; |
|---|
| 1078 | 1013 | int plen; |
|---|
| .. | .. |
|---|
| 1089 | 1024 | } |
|---|
| 1090 | 1025 | |
|---|
| 1091 | 1026 | size = min((u32)w * h * 3, |
|---|
| 1092 | | - dssdev->panel.vm.hactive * dssdev->panel.vm.vactive * 3); |
|---|
| 1027 | + ddata->vm.hactive * ddata->vm.vactive * 3); |
|---|
| 1093 | 1028 | |
|---|
| 1094 | | - in->ops.dsi->bus_lock(in); |
|---|
| 1029 | + src->ops->dsi.bus_lock(src); |
|---|
| 1095 | 1030 | |
|---|
| 1096 | 1031 | r = dsicm_wake_up(ddata); |
|---|
| 1097 | 1032 | if (r) |
|---|
| .. | .. |
|---|
| 1107 | 1042 | |
|---|
| 1108 | 1043 | dsicm_set_update_window(ddata, x, y, w, h); |
|---|
| 1109 | 1044 | |
|---|
| 1110 | | - r = in->ops.dsi->set_max_rx_packet_size(in, ddata->channel, plen); |
|---|
| 1045 | + r = src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, plen); |
|---|
| 1111 | 1046 | if (r) |
|---|
| 1112 | 1047 | goto err2; |
|---|
| 1113 | 1048 | |
|---|
| .. | .. |
|---|
| 1115 | 1050 | u8 dcs_cmd = first ? 0x2e : 0x3e; |
|---|
| 1116 | 1051 | first = 0; |
|---|
| 1117 | 1052 | |
|---|
| 1118 | | - r = in->ops.dsi->dcs_read(in, ddata->channel, dcs_cmd, |
|---|
| 1053 | + r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, |
|---|
| 1119 | 1054 | buf + buf_used, size - buf_used); |
|---|
| 1120 | 1055 | |
|---|
| 1121 | 1056 | if (r < 0) { |
|---|
| .. | .. |
|---|
| 1141 | 1076 | r = buf_used; |
|---|
| 1142 | 1077 | |
|---|
| 1143 | 1078 | err3: |
|---|
| 1144 | | - in->ops.dsi->set_max_rx_packet_size(in, ddata->channel, 1); |
|---|
| 1079 | + src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, 1); |
|---|
| 1145 | 1080 | err2: |
|---|
| 1146 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 1081 | + src->ops->dsi.bus_unlock(src); |
|---|
| 1147 | 1082 | err1: |
|---|
| 1148 | 1083 | mutex_unlock(&ddata->lock); |
|---|
| 1149 | 1084 | return r; |
|---|
| .. | .. |
|---|
| 1154 | 1089 | struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, |
|---|
| 1155 | 1090 | ulps_work.work); |
|---|
| 1156 | 1091 | struct omap_dss_device *dssdev = &ddata->dssdev; |
|---|
| 1157 | | - struct omap_dss_device *in = ddata->in; |
|---|
| 1092 | + struct omap_dss_device *src = ddata->src; |
|---|
| 1158 | 1093 | |
|---|
| 1159 | 1094 | mutex_lock(&ddata->lock); |
|---|
| 1160 | 1095 | |
|---|
| .. | .. |
|---|
| 1163 | 1098 | return; |
|---|
| 1164 | 1099 | } |
|---|
| 1165 | 1100 | |
|---|
| 1166 | | - in->ops.dsi->bus_lock(in); |
|---|
| 1101 | + src->ops->dsi.bus_lock(src); |
|---|
| 1167 | 1102 | |
|---|
| 1168 | 1103 | dsicm_enter_ulps(ddata); |
|---|
| 1169 | 1104 | |
|---|
| 1170 | | - in->ops.dsi->bus_unlock(in); |
|---|
| 1105 | + src->ops->dsi.bus_unlock(src); |
|---|
| 1171 | 1106 | mutex_unlock(&ddata->lock); |
|---|
| 1172 | 1107 | } |
|---|
| 1173 | 1108 | |
|---|
| 1174 | | -static void dsicm_get_timings(struct omap_dss_device *dssdev, |
|---|
| 1175 | | - struct videomode *vm) |
|---|
| 1109 | +static int dsicm_get_modes(struct omap_dss_device *dssdev, |
|---|
| 1110 | + struct drm_connector *connector) |
|---|
| 1176 | 1111 | { |
|---|
| 1177 | 1112 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 1178 | 1113 | |
|---|
| 1179 | | - *vm = ddata->vm; |
|---|
| 1114 | + connector->display_info.width_mm = ddata->width_mm; |
|---|
| 1115 | + connector->display_info.height_mm = ddata->height_mm; |
|---|
| 1116 | + |
|---|
| 1117 | + return omapdss_display_get_modes(connector, &ddata->vm); |
|---|
| 1180 | 1118 | } |
|---|
| 1181 | 1119 | |
|---|
| 1182 | 1120 | static int dsicm_check_timings(struct omap_dss_device *dssdev, |
|---|
| 1183 | | - struct videomode *vm) |
|---|
| 1121 | + struct drm_display_mode *mode) |
|---|
| 1184 | 1122 | { |
|---|
| 1185 | 1123 | struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 1186 | 1124 | int ret = 0; |
|---|
| 1187 | 1125 | |
|---|
| 1188 | | - if (vm->hactive != ddata->vm.hactive) |
|---|
| 1126 | + if (mode->hdisplay != ddata->vm.hactive) |
|---|
| 1189 | 1127 | ret = -EINVAL; |
|---|
| 1190 | 1128 | |
|---|
| 1191 | | - if (vm->vactive != ddata->vm.vactive) |
|---|
| 1129 | + if (mode->vdisplay != ddata->vm.vactive) |
|---|
| 1192 | 1130 | ret = -EINVAL; |
|---|
| 1193 | 1131 | |
|---|
| 1194 | 1132 | if (ret) { |
|---|
| 1195 | 1133 | dev_warn(dssdev->dev, "wrong resolution: %d x %d", |
|---|
| 1196 | | - vm->hactive, vm->vactive); |
|---|
| 1134 | + mode->hdisplay, mode->vdisplay); |
|---|
| 1197 | 1135 | dev_warn(dssdev->dev, "panel resolution: %d x %d", |
|---|
| 1198 | 1136 | ddata->vm.hactive, ddata->vm.vactive); |
|---|
| 1199 | 1137 | } |
|---|
| .. | .. |
|---|
| 1201 | 1139 | return ret; |
|---|
| 1202 | 1140 | } |
|---|
| 1203 | 1141 | |
|---|
| 1204 | | -static void dsicm_get_size(struct omap_dss_device *dssdev, |
|---|
| 1205 | | - unsigned int *width, unsigned int *height) |
|---|
| 1206 | | -{ |
|---|
| 1207 | | - struct panel_drv_data *ddata = to_panel_data(dssdev); |
|---|
| 1208 | | - |
|---|
| 1209 | | - *width = ddata->width_mm; |
|---|
| 1210 | | - *height = ddata->height_mm; |
|---|
| 1211 | | -} |
|---|
| 1212 | | - |
|---|
| 1213 | | -static struct omap_dss_driver dsicm_ops = { |
|---|
| 1142 | +static const struct omap_dss_device_ops dsicm_ops = { |
|---|
| 1214 | 1143 | .connect = dsicm_connect, |
|---|
| 1215 | 1144 | .disconnect = dsicm_disconnect, |
|---|
| 1216 | 1145 | |
|---|
| 1217 | 1146 | .enable = dsicm_enable, |
|---|
| 1218 | 1147 | .disable = dsicm_disable, |
|---|
| 1219 | 1148 | |
|---|
| 1149 | + .get_modes = dsicm_get_modes, |
|---|
| 1150 | + .check_timings = dsicm_check_timings, |
|---|
| 1151 | +}; |
|---|
| 1152 | + |
|---|
| 1153 | +static const struct omap_dss_driver dsicm_dss_driver = { |
|---|
| 1220 | 1154 | .update = dsicm_update, |
|---|
| 1221 | 1155 | .sync = dsicm_sync, |
|---|
| 1222 | | - |
|---|
| 1223 | | - .get_timings = dsicm_get_timings, |
|---|
| 1224 | | - .check_timings = dsicm_check_timings, |
|---|
| 1225 | | - .get_size = dsicm_get_size, |
|---|
| 1226 | 1156 | |
|---|
| 1227 | 1157 | .enable_te = dsicm_enable_te, |
|---|
| 1228 | 1158 | .get_te = dsicm_get_te, |
|---|
| .. | .. |
|---|
| 1233 | 1163 | static int dsicm_probe_of(struct platform_device *pdev) |
|---|
| 1234 | 1164 | { |
|---|
| 1235 | 1165 | struct device_node *node = pdev->dev.of_node; |
|---|
| 1236 | | - struct device_node *backlight; |
|---|
| 1166 | + struct backlight_device *backlight; |
|---|
| 1237 | 1167 | struct panel_drv_data *ddata = platform_get_drvdata(pdev); |
|---|
| 1238 | 1168 | struct display_timing timing; |
|---|
| 1239 | 1169 | int err; |
|---|
| .. | .. |
|---|
| 1286 | 1216 | ddata->vddi = NULL; |
|---|
| 1287 | 1217 | } |
|---|
| 1288 | 1218 | |
|---|
| 1289 | | - backlight = of_parse_phandle(node, "backlight", 0); |
|---|
| 1290 | | - if (backlight) { |
|---|
| 1291 | | - ddata->extbldev = of_find_backlight_by_node(backlight); |
|---|
| 1292 | | - of_node_put(backlight); |
|---|
| 1219 | + backlight = devm_of_find_backlight(&pdev->dev); |
|---|
| 1220 | + if (IS_ERR(backlight)) |
|---|
| 1221 | + return PTR_ERR(backlight); |
|---|
| 1293 | 1222 | |
|---|
| 1294 | | - if (!ddata->extbldev) |
|---|
| 1295 | | - return -EPROBE_DEFER; |
|---|
| 1296 | | - } else { |
|---|
| 1297 | | - /* assume native backlight support */ |
|---|
| 1223 | + /* If no backlight device is found assume native backlight support */ |
|---|
| 1224 | + if (backlight) |
|---|
| 1225 | + ddata->extbldev = backlight; |
|---|
| 1226 | + else |
|---|
| 1298 | 1227 | ddata->use_dsi_backlight = true; |
|---|
| 1299 | | - } |
|---|
| 1300 | 1228 | |
|---|
| 1301 | 1229 | /* TODO: ulps */ |
|---|
| 1302 | 1230 | |
|---|
| .. | .. |
|---|
| 1330 | 1258 | |
|---|
| 1331 | 1259 | dssdev = &ddata->dssdev; |
|---|
| 1332 | 1260 | dssdev->dev = dev; |
|---|
| 1333 | | - dssdev->driver = &dsicm_ops; |
|---|
| 1334 | | - dssdev->panel.vm = ddata->vm; |
|---|
| 1261 | + dssdev->ops = &dsicm_ops; |
|---|
| 1262 | + dssdev->driver = &dsicm_dss_driver; |
|---|
| 1335 | 1263 | dssdev->type = OMAP_DISPLAY_TYPE_DSI; |
|---|
| 1264 | + dssdev->display = true; |
|---|
| 1336 | 1265 | dssdev->owner = THIS_MODULE; |
|---|
| 1266 | + dssdev->of_port = 0; |
|---|
| 1267 | + dssdev->ops_flags = OMAP_DSS_DEVICE_OP_MODES; |
|---|
| 1337 | 1268 | |
|---|
| 1338 | | - dssdev->panel.dsi_pix_fmt = OMAP_DSS_DSI_FMT_RGB888; |
|---|
| 1339 | 1269 | dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE | |
|---|
| 1340 | 1270 | OMAP_DSS_DISPLAY_CAP_TEAR_ELIM; |
|---|
| 1341 | 1271 | |
|---|
| 1342 | | - r = omapdss_register_display(dssdev); |
|---|
| 1343 | | - if (r) { |
|---|
| 1344 | | - dev_err(dev, "Failed to register panel\n"); |
|---|
| 1345 | | - goto err_reg; |
|---|
| 1346 | | - } |
|---|
| 1272 | + omapdss_display_init(dssdev); |
|---|
| 1273 | + omapdss_device_register(dssdev); |
|---|
| 1347 | 1274 | |
|---|
| 1348 | 1275 | mutex_init(&ddata->lock); |
|---|
| 1349 | 1276 | |
|---|
| .. | .. |
|---|
| 1414 | 1341 | |
|---|
| 1415 | 1342 | dev_dbg(&pdev->dev, "remove\n"); |
|---|
| 1416 | 1343 | |
|---|
| 1417 | | - omapdss_unregister_display(dssdev); |
|---|
| 1344 | + omapdss_device_unregister(dssdev); |
|---|
| 1418 | 1345 | |
|---|
| 1419 | | - dsicm_disable(dssdev); |
|---|
| 1420 | | - dsicm_disconnect(dssdev); |
|---|
| 1346 | + if (omapdss_device_is_enabled(dssdev)) |
|---|
| 1347 | + dsicm_disable(dssdev); |
|---|
| 1348 | + omapdss_device_disconnect(ddata->src, dssdev); |
|---|
| 1421 | 1349 | |
|---|
| 1422 | 1350 | sysfs_remove_group(&pdev->dev.kobj, &dsicm_attr_group); |
|---|
| 1423 | 1351 | |
|---|