forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Generic DSI Command Mode panel driver
34 *
45 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
56 * 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.
107 */
118
129 /* #define DEBUG */
....@@ -23,6 +20,8 @@
2320 #include <linux/workqueue.h>
2421 #include <linux/of_device.h>
2522 #include <linux/regulator/consumer.h>
23
+
24
+#include <drm/drm_connector.h>
2625
2726 #include <video/mipi_display.h>
2827 #include <video/of_display_timing.h>
....@@ -41,7 +40,7 @@
4140
4241 struct panel_drv_data {
4342 struct omap_dss_device dssdev;
44
- struct omap_dss_device *in;
43
+ struct omap_dss_device *src;
4544
4645 struct videomode vm;
4746
....@@ -142,11 +141,11 @@
142141
143142 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
144143 {
145
- struct omap_dss_device *in = ddata->in;
144
+ struct omap_dss_device *src = ddata->src;
146145 int r;
147146 u8 buf[1];
148147
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);
150149
151150 if (r < 0)
152151 return r;
....@@ -158,29 +157,30 @@
158157
159158 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
160159 {
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);
163163 }
164164
165165 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
166166 {
167
- struct omap_dss_device *in = ddata->in;
167
+ struct omap_dss_device *src = ddata->src;
168168 u8 buf[2] = { dcs_cmd, param };
169169
170
- return in->ops.dsi->dcs_write(in, ddata->channel, buf, 2);
170
+ return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2);
171171 }
172172
173173 static int dsicm_sleep_in(struct panel_drv_data *ddata)
174174
175175 {
176
- struct omap_dss_device *in = ddata->in;
176
+ struct omap_dss_device *src = ddata->src;
177177 u8 cmd;
178178 int r;
179179
180180 hw_guard_wait(ddata);
181181
182182 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);
184184 if (r)
185185 return r;
186186
....@@ -228,7 +228,7 @@
228228 static int dsicm_set_update_window(struct panel_drv_data *ddata,
229229 u16 x, u16 y, u16 w, u16 h)
230230 {
231
- struct omap_dss_device *in = ddata->in;
231
+ struct omap_dss_device *src = ddata->src;
232232 int r;
233233 u16 x1 = x;
234234 u16 x2 = x + w - 1;
....@@ -242,7 +242,7 @@
242242 buf[3] = (x2 >> 8) & 0xff;
243243 buf[4] = (x2 >> 0) & 0xff;
244244
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));
246246 if (r)
247247 return r;
248248
....@@ -252,11 +252,11 @@
252252 buf[3] = (y2 >> 8) & 0xff;
253253 buf[4] = (y2 >> 0) & 0xff;
254254
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));
256256 if (r)
257257 return r;
258258
259
- in->ops.dsi->bta_sync(in, ddata->channel);
259
+ src->ops->dsi.bta_sync(src, ddata->channel);
260260
261261 return r;
262262 }
....@@ -275,7 +275,7 @@
275275
276276 static int dsicm_enter_ulps(struct panel_drv_data *ddata)
277277 {
278
- struct omap_dss_device *in = ddata->in;
278
+ struct omap_dss_device *src = ddata->src;
279279 int r;
280280
281281 if (ddata->ulps_enabled)
....@@ -290,7 +290,7 @@
290290 if (ddata->ext_te_gpio)
291291 disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
292292
293
- in->ops.dsi->disable(in, false, true);
293
+ src->ops->dsi.disable(src, false, true);
294294
295295 ddata->ulps_enabled = true;
296296
....@@ -309,19 +309,14 @@
309309
310310 static int dsicm_exit_ulps(struct panel_drv_data *ddata)
311311 {
312
- struct omap_dss_device *in = ddata->in;
312
+ struct omap_dss_device *src = ddata->src;
313313 int r;
314314
315315 if (!ddata->ulps_enabled)
316316 return 0;
317317
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);
325320
326321 r = _dsicm_enable_te(ddata, true);
327322 if (r) {
....@@ -347,7 +342,7 @@
347342 enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
348343 ddata->ulps_enabled = false;
349344 }
350
-err1:
345
+
351346 dsicm_queue_ulps_work(ddata);
352347
353348 return r;
....@@ -366,7 +361,7 @@
366361 static int dsicm_bl_update_status(struct backlight_device *dev)
367362 {
368363 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;
370365 int r = 0;
371366 int level;
372367
....@@ -381,13 +376,13 @@
381376 mutex_lock(&ddata->lock);
382377
383378 if (ddata->enabled) {
384
- in->ops.dsi->bus_lock(in);
379
+ src->ops->dsi.bus_lock(src);
385380
386381 r = dsicm_wake_up(ddata);
387382 if (!r)
388383 r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
389384
390
- in->ops.dsi->bus_unlock(in);
385
+ src->ops->dsi.bus_unlock(src);
391386 }
392387
393388 mutex_unlock(&ddata->lock);
....@@ -412,23 +407,22 @@
412407 static ssize_t dsicm_num_errors_show(struct device *dev,
413408 struct device_attribute *attr, char *buf)
414409 {
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;
418412 u8 errors = 0;
419413 int r;
420414
421415 mutex_lock(&ddata->lock);
422416
423417 if (ddata->enabled) {
424
- in->ops.dsi->bus_lock(in);
418
+ src->ops->dsi.bus_lock(src);
425419
426420 r = dsicm_wake_up(ddata);
427421 if (!r)
428422 r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
429423 &errors);
430424
431
- in->ops.dsi->bus_unlock(in);
425
+ src->ops->dsi.bus_unlock(src);
432426 } else {
433427 r = -ENODEV;
434428 }
....@@ -444,22 +438,21 @@
444438 static ssize_t dsicm_hw_revision_show(struct device *dev,
445439 struct device_attribute *attr, char *buf)
446440 {
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;
450443 u8 id1, id2, id3;
451444 int r;
452445
453446 mutex_lock(&ddata->lock);
454447
455448 if (ddata->enabled) {
456
- in->ops.dsi->bus_lock(in);
449
+ src->ops->dsi.bus_lock(src);
457450
458451 r = dsicm_wake_up(ddata);
459452 if (!r)
460453 r = dsicm_get_id(ddata, &id1, &id2, &id3);
461454
462
- in->ops.dsi->bus_unlock(in);
455
+ src->ops->dsi.bus_unlock(src);
463456 } else {
464457 r = -ENODEV;
465458 }
....@@ -476,9 +469,8 @@
476469 struct device_attribute *attr,
477470 const char *buf, size_t count)
478471 {
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;
482474 unsigned long t;
483475 int r;
484476
....@@ -489,14 +481,14 @@
489481 mutex_lock(&ddata->lock);
490482
491483 if (ddata->enabled) {
492
- in->ops.dsi->bus_lock(in);
484
+ src->ops->dsi.bus_lock(src);
493485
494486 if (t)
495487 r = dsicm_enter_ulps(ddata);
496488 else
497489 r = dsicm_wake_up(ddata);
498490
499
- in->ops.dsi->bus_unlock(in);
491
+ src->ops->dsi.bus_unlock(src);
500492 }
501493
502494 mutex_unlock(&ddata->lock);
....@@ -511,8 +503,7 @@
511503 struct device_attribute *attr,
512504 char *buf)
513505 {
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);
516507 unsigned int t;
517508
518509 mutex_lock(&ddata->lock);
....@@ -526,9 +517,8 @@
526517 struct device_attribute *attr,
527518 const char *buf, size_t count)
528519 {
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;
532522 unsigned long t;
533523 int r;
534524
....@@ -541,9 +531,9 @@
541531
542532 if (ddata->enabled) {
543533 /* dsicm_wake_up will restart the timer */
544
- in->ops.dsi->bus_lock(in);
534
+ src->ops->dsi.bus_lock(src);
545535 r = dsicm_wake_up(ddata);
546
- in->ops.dsi->bus_unlock(in);
536
+ src->ops->dsi.bus_unlock(src);
547537 }
548538
549539 mutex_unlock(&ddata->lock);
....@@ -558,8 +548,7 @@
558548 struct device_attribute *attr,
559549 char *buf)
560550 {
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);
563552 unsigned int t;
564553
565554 mutex_lock(&ddata->lock);
....@@ -603,7 +592,7 @@
603592
604593 static int dsicm_power_on(struct panel_drv_data *ddata)
605594 {
606
- struct omap_dss_device *in = ddata->in;
595
+ struct omap_dss_device *src = ddata->src;
607596 u8 id1, id2, id3;
608597 int r;
609598 struct omap_dss_dsi_config dsi_config = {
....@@ -635,7 +624,7 @@
635624 }
636625
637626 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);
639628 if (r) {
640629 dev_err(&ddata->pdev->dev,
641630 "failed to configure DSI pins\n");
....@@ -643,21 +632,17 @@
643632 }
644633 }
645634
646
- r = in->ops.dsi->set_config(in, &dsi_config);
635
+ r = src->ops->dsi.set_config(src, &dsi_config);
647636 if (r) {
648637 dev_err(&ddata->pdev->dev, "failed to configure DSI\n");
649638 goto err_vddi;
650639 }
651640
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);
657642
658643 dsicm_hw_reset(ddata);
659644
660
- in->ops.dsi->enable_hs(in, ddata->channel, false);
645
+ src->ops->dsi.enable_hs(src, ddata->channel, false);
661646
662647 r = dsicm_sleep_out(ddata);
663648 if (r)
....@@ -689,11 +674,11 @@
689674 if (r)
690675 goto err;
691676
692
- r = in->ops.dsi->enable_video_output(in, ddata->channel);
677
+ r = src->ops->dsi.enable_video_output(src, ddata->channel);
693678 if (r)
694679 goto err;
695680
696
- ddata->enabled = 1;
681
+ ddata->enabled = true;
697682
698683 if (!ddata->intro_printed) {
699684 dev_info(&ddata->pdev->dev, "panel revision %02x.%02x.%02x\n",
....@@ -701,7 +686,7 @@
701686 ddata->intro_printed = true;
702687 }
703688
704
- in->ops.dsi->enable_hs(in, ddata->channel, true);
689
+ src->ops->dsi.enable_hs(src, ddata->channel, true);
705690
706691 return 0;
707692 err:
....@@ -709,7 +694,7 @@
709694
710695 dsicm_hw_reset(ddata);
711696
712
- in->ops.dsi->disable(in, true, false);
697
+ src->ops->dsi.disable(src, true, false);
713698 err_vddi:
714699 if (ddata->vddi)
715700 regulator_disable(ddata->vddi);
....@@ -722,10 +707,10 @@
722707
723708 static void dsicm_power_off(struct panel_drv_data *ddata)
724709 {
725
- struct omap_dss_device *in = ddata->in;
710
+ struct omap_dss_device *src = ddata->src;
726711 int r;
727712
728
- in->ops.dsi->disable_video_output(in, ddata->channel);
713
+ src->ops->dsi.disable_video_output(src, ddata->channel);
729714
730715 r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_OFF);
731716 if (!r)
....@@ -737,14 +722,14 @@
737722 dsicm_hw_reset(ddata);
738723 }
739724
740
- in->ops.dsi->disable(in, true, false);
725
+ src->ops->dsi.disable(src, true, false);
741726
742727 if (ddata->vddi)
743728 regulator_disable(ddata->vddi);
744729 if (ddata->vpnl)
745730 regulator_disable(ddata->vpnl);
746731
747
- ddata->enabled = 0;
732
+ ddata->enabled = false;
748733 }
749734
750735 static int dsicm_panel_reset(struct panel_drv_data *ddata)
....@@ -756,116 +741,71 @@
756741 return dsicm_power_on(ddata);
757742 }
758743
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)
760746 {
761
- struct panel_drv_data *ddata = to_panel_data(dssdev);
747
+ struct panel_drv_data *ddata = to_panel_data(dst);
762748 struct device *dev = &ddata->pdev->dev;
763
- struct omap_dss_device *in;
764749 int r;
765750
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);
782752 if (r) {
783753 dev_err(dev, "failed to get virtual channel\n");
784
- goto err_req_vc;
754
+ return r;
785755 }
786756
787
- r = in->ops.dsi->set_vc_id(in, ddata->channel, TCH);
757
+ r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH);
788758 if (r) {
789759 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;
791762 }
792763
793
- ddata->in = in;
764
+ ddata->src = src;
794765 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;
803766 }
804767
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)
806770 {
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);
809772
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;
818775 }
819776
820
-static int dsicm_enable(struct omap_dss_device *dssdev)
777
+static void dsicm_enable(struct omap_dss_device *dssdev)
821778 {
822779 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;
824781 int r;
825
-
826
- dev_dbg(&ddata->pdev->dev, "enable\n");
827782
828783 mutex_lock(&ddata->lock);
829784
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);
841786
842787 r = dsicm_power_on(ddata);
843788
844
- in->ops.dsi->bus_unlock(in);
789
+ src->ops->dsi.bus_unlock(src);
845790
846791 if (r)
847792 goto err;
848
-
849
- dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
850793
851794 mutex_unlock(&ddata->lock);
852795
853796 dsicm_bl_power(ddata, true);
854797
855
- return 0;
798
+ return;
856799 err:
857
- dev_dbg(&ddata->pdev->dev, "enable failed\n");
800
+ dev_dbg(&ddata->pdev->dev, "enable failed (%d)\n", r);
858801 mutex_unlock(&ddata->lock);
859
- return r;
860802 }
861803
862804 static void dsicm_disable(struct omap_dss_device *dssdev)
863805 {
864806 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;
866808 int r;
867
-
868
- dev_dbg(&ddata->pdev->dev, "disable\n");
869809
870810 dsicm_bl_power(ddata, false);
871811
....@@ -873,17 +813,13 @@
873813
874814 dsicm_cancel_ulps_work(ddata);
875815
876
- in->ops.dsi->bus_lock(in);
816
+ src->ops->dsi.bus_lock(src);
877817
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);
883821
884
- in->ops.dsi->bus_unlock(in);
885
-
886
- dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
822
+ src->ops->dsi.bus_unlock(src);
887823
888824 mutex_unlock(&ddata->lock);
889825 }
....@@ -891,16 +827,16 @@
891827 static void dsicm_framedone_cb(int err, void *data)
892828 {
893829 struct panel_drv_data *ddata = data;
894
- struct omap_dss_device *in = ddata->in;
830
+ struct omap_dss_device *src = ddata->src;
895831
896832 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);
898834 }
899835
900836 static irqreturn_t dsicm_te_isr(int irq, void *data)
901837 {
902838 struct panel_drv_data *ddata = data;
903
- struct omap_dss_device *in = ddata->in;
839
+ struct omap_dss_device *src = ddata->src;
904840 int old;
905841 int r;
906842
....@@ -909,7 +845,7 @@
909845 if (old) {
910846 cancel_delayed_work(&ddata->te_timeout_work);
911847
912
- r = in->ops.dsi->update(in, ddata->channel, dsicm_framedone_cb,
848
+ r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb,
913849 ddata);
914850 if (r)
915851 goto err;
....@@ -918,7 +854,7 @@
918854 return IRQ_HANDLED;
919855 err:
920856 dev_err(&ddata->pdev->dev, "start update failed\n");
921
- in->ops.dsi->bus_unlock(in);
857
+ src->ops->dsi.bus_unlock(src);
922858 return IRQ_HANDLED;
923859 }
924860
....@@ -926,25 +862,25 @@
926862 {
927863 struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
928864 te_timeout_work.work);
929
- struct omap_dss_device *in = ddata->in;
865
+ struct omap_dss_device *src = ddata->src;
930866
931867 dev_err(&ddata->pdev->dev, "TE not received for 250ms!\n");
932868
933869 atomic_set(&ddata->do_update, 0);
934
- in->ops.dsi->bus_unlock(in);
870
+ src->ops->dsi.bus_unlock(src);
935871 }
936872
937873 static int dsicm_update(struct omap_dss_device *dssdev,
938874 u16 x, u16 y, u16 w, u16 h)
939875 {
940876 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;
942878 int r;
943879
944880 dev_dbg(&ddata->pdev->dev, "update %d, %d, %d x %d\n", x, y, w, h);
945881
946882 mutex_lock(&ddata->lock);
947
- in->ops.dsi->bus_lock(in);
883
+ src->ops->dsi.bus_lock(src);
948884
949885 r = dsicm_wake_up(ddata);
950886 if (r)
....@@ -956,9 +892,8 @@
956892 }
957893
958894 /* 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);
962897 if (r)
963898 goto err;
964899
....@@ -967,17 +902,17 @@
967902 msecs_to_jiffies(250));
968903 atomic_set(&ddata->do_update, 1);
969904 } 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,
971906 ddata);
972907 if (r)
973908 goto err;
974909 }
975910
976
- /* note: no bus_unlock here. unlock is in framedone_cb */
911
+ /* note: no bus_unlock here. unlock is src framedone_cb */
977912 mutex_unlock(&ddata->lock);
978913 return 0;
979914 err:
980
- in->ops.dsi->bus_unlock(in);
915
+ src->ops->dsi.bus_unlock(src);
981916 mutex_unlock(&ddata->lock);
982917 return r;
983918 }
....@@ -985,13 +920,13 @@
985920 static int dsicm_sync(struct omap_dss_device *dssdev)
986921 {
987922 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;
989924
990925 dev_dbg(&ddata->pdev->dev, "sync\n");
991926
992927 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);
995930 mutex_unlock(&ddata->lock);
996931
997932 dev_dbg(&ddata->pdev->dev, "sync done\n");
....@@ -1001,7 +936,7 @@
1001936
1002937 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
1003938 {
1004
- struct omap_dss_device *in = ddata->in;
939
+ struct omap_dss_device *src = ddata->src;
1005940 int r;
1006941
1007942 if (enable)
....@@ -1010,7 +945,7 @@
1010945 r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF);
1011946
1012947 if (!ddata->ext_te_gpio)
1013
- in->ops.dsi->enable_te(in, enable);
948
+ src->ops->dsi.enable_te(src, enable);
1014949
1015950 /* possible panel bug */
1016951 msleep(100);
....@@ -1021,7 +956,7 @@
1021956 static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable)
1022957 {
1023958 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;
1025960 int r;
1026961
1027962 mutex_lock(&ddata->lock);
....@@ -1029,7 +964,7 @@
1029964 if (ddata->te_enabled == enable)
1030965 goto end;
1031966
1032
- in->ops.dsi->bus_lock(in);
967
+ src->ops->dsi.bus_lock(src);
1033968
1034969 if (ddata->enabled) {
1035970 r = dsicm_wake_up(ddata);
....@@ -1043,13 +978,13 @@
1043978
1044979 ddata->te_enabled = enable;
1045980
1046
- in->ops.dsi->bus_unlock(in);
981
+ src->ops->dsi.bus_unlock(src);
1047982 end:
1048983 mutex_unlock(&ddata->lock);
1049984
1050985 return 0;
1051986 err:
1052
- in->ops.dsi->bus_unlock(in);
987
+ src->ops->dsi.bus_unlock(src);
1053988 mutex_unlock(&ddata->lock);
1054989
1055990 return r;
....@@ -1072,7 +1007,7 @@
10721007 u16 x, u16 y, u16 w, u16 h)
10731008 {
10741009 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;
10761011 int r;
10771012 int first = 1;
10781013 int plen;
....@@ -1089,9 +1024,9 @@
10891024 }
10901025
10911026 size = min((u32)w * h * 3,
1092
- dssdev->panel.vm.hactive * dssdev->panel.vm.vactive * 3);
1027
+ ddata->vm.hactive * ddata->vm.vactive * 3);
10931028
1094
- in->ops.dsi->bus_lock(in);
1029
+ src->ops->dsi.bus_lock(src);
10951030
10961031 r = dsicm_wake_up(ddata);
10971032 if (r)
....@@ -1107,7 +1042,7 @@
11071042
11081043 dsicm_set_update_window(ddata, x, y, w, h);
11091044
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);
11111046 if (r)
11121047 goto err2;
11131048
....@@ -1115,7 +1050,7 @@
11151050 u8 dcs_cmd = first ? 0x2e : 0x3e;
11161051 first = 0;
11171052
1118
- r = in->ops.dsi->dcs_read(in, ddata->channel, dcs_cmd,
1053
+ r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd,
11191054 buf + buf_used, size - buf_used);
11201055
11211056 if (r < 0) {
....@@ -1141,9 +1076,9 @@
11411076 r = buf_used;
11421077
11431078 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);
11451080 err2:
1146
- in->ops.dsi->bus_unlock(in);
1081
+ src->ops->dsi.bus_unlock(src);
11471082 err1:
11481083 mutex_unlock(&ddata->lock);
11491084 return r;
....@@ -1154,7 +1089,7 @@
11541089 struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
11551090 ulps_work.work);
11561091 struct omap_dss_device *dssdev = &ddata->dssdev;
1157
- struct omap_dss_device *in = ddata->in;
1092
+ struct omap_dss_device *src = ddata->src;
11581093
11591094 mutex_lock(&ddata->lock);
11601095
....@@ -1163,37 +1098,40 @@
11631098 return;
11641099 }
11651100
1166
- in->ops.dsi->bus_lock(in);
1101
+ src->ops->dsi.bus_lock(src);
11671102
11681103 dsicm_enter_ulps(ddata);
11691104
1170
- in->ops.dsi->bus_unlock(in);
1105
+ src->ops->dsi.bus_unlock(src);
11711106 mutex_unlock(&ddata->lock);
11721107 }
11731108
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)
11761111 {
11771112 struct panel_drv_data *ddata = to_panel_data(dssdev);
11781113
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);
11801118 }
11811119
11821120 static int dsicm_check_timings(struct omap_dss_device *dssdev,
1183
- struct videomode *vm)
1121
+ struct drm_display_mode *mode)
11841122 {
11851123 struct panel_drv_data *ddata = to_panel_data(dssdev);
11861124 int ret = 0;
11871125
1188
- if (vm->hactive != ddata->vm.hactive)
1126
+ if (mode->hdisplay != ddata->vm.hactive)
11891127 ret = -EINVAL;
11901128
1191
- if (vm->vactive != ddata->vm.vactive)
1129
+ if (mode->vdisplay != ddata->vm.vactive)
11921130 ret = -EINVAL;
11931131
11941132 if (ret) {
11951133 dev_warn(dssdev->dev, "wrong resolution: %d x %d",
1196
- vm->hactive, vm->vactive);
1134
+ mode->hdisplay, mode->vdisplay);
11971135 dev_warn(dssdev->dev, "panel resolution: %d x %d",
11981136 ddata->vm.hactive, ddata->vm.vactive);
11991137 }
....@@ -1201,28 +1139,20 @@
12011139 return ret;
12021140 }
12031141
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 = {
12141143 .connect = dsicm_connect,
12151144 .disconnect = dsicm_disconnect,
12161145
12171146 .enable = dsicm_enable,
12181147 .disable = dsicm_disable,
12191148
1149
+ .get_modes = dsicm_get_modes,
1150
+ .check_timings = dsicm_check_timings,
1151
+};
1152
+
1153
+static const struct omap_dss_driver dsicm_dss_driver = {
12201154 .update = dsicm_update,
12211155 .sync = dsicm_sync,
1222
-
1223
- .get_timings = dsicm_get_timings,
1224
- .check_timings = dsicm_check_timings,
1225
- .get_size = dsicm_get_size,
12261156
12271157 .enable_te = dsicm_enable_te,
12281158 .get_te = dsicm_get_te,
....@@ -1233,7 +1163,7 @@
12331163 static int dsicm_probe_of(struct platform_device *pdev)
12341164 {
12351165 struct device_node *node = pdev->dev.of_node;
1236
- struct device_node *backlight;
1166
+ struct backlight_device *backlight;
12371167 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
12381168 struct display_timing timing;
12391169 int err;
....@@ -1286,17 +1216,15 @@
12861216 ddata->vddi = NULL;
12871217 }
12881218
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);
12931222
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
12981227 ddata->use_dsi_backlight = true;
1299
- }
13001228
13011229 /* TODO: ulps */
13021230
....@@ -1330,20 +1258,19 @@
13301258
13311259 dssdev = &ddata->dssdev;
13321260 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;
13351263 dssdev->type = OMAP_DISPLAY_TYPE_DSI;
1264
+ dssdev->display = true;
13361265 dssdev->owner = THIS_MODULE;
1266
+ dssdev->of_port = 0;
1267
+ dssdev->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
13371268
1338
- dssdev->panel.dsi_pix_fmt = OMAP_DSS_DSI_FMT_RGB888;
13391269 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
13401270 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
13411271
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);
13471274
13481275 mutex_init(&ddata->lock);
13491276
....@@ -1414,10 +1341,11 @@
14141341
14151342 dev_dbg(&pdev->dev, "remove\n");
14161343
1417
- omapdss_unregister_display(dssdev);
1344
+ omapdss_device_unregister(dssdev);
14181345
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);
14211349
14221350 sysfs_remove_group(&pdev->dev.kobj, &dsicm_attr_group);
14231351