/
0008-omap4iss-Fix-multiple-bugs-and-use-device-tree.patch
949 lines (890 loc) · 27.7 KB
/
0008-omap4iss-Fix-multiple-bugs-and-use-device-tree.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
From a93e24bdba0c257c4855605c6e44fa984e634c58 Mon Sep 17 00:00:00 2001
From: Michael Allwright <allsey87@gmail.com>
Date: Fri, 3 Aug 2018 14:48:13 +0200
Subject: [PATCH] omap4iss: Fix multiple bugs and use device tree
---
arch/arm/boot/dts/omap4.dtsi | 28 ++-
drivers/staging/media/omap4iss/Kconfig | 1 +
drivers/staging/media/omap4iss/iss.c | 363 +++++++++++++++------------
drivers/staging/media/omap4iss/iss.h | 20 +-
drivers/staging/media/omap4iss/iss_csi2.c | 1 +
drivers/staging/media/omap4iss/iss_csiphy.c | 15 +-
drivers/staging/media/omap4iss/iss_csiphy.h | 2 +-
drivers/staging/media/omap4iss/iss_ipipe.c | 1 +
drivers/staging/media/omap4iss/iss_ipipeif.c | 1 +
drivers/staging/media/omap4iss/iss_resizer.c | 1 +
drivers/staging/media/omap4iss/iss_video.c | 7 -
drivers/staging/media/omap4iss/omap4iss.h | 74 ++++++
include/linux/platform_data/media/omap4iss.h | 66 -----
13 files changed, 329 insertions(+), 251 deletions(-)
create mode 100644 drivers/staging/media/omap4iss/omap4iss.h
delete mode 100644 include/linux/platform_data/media/omap4iss.h
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 4759048..661e094 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -748,7 +748,6 @@
target-module@52000000 {
compatible = "ti,sysc-omap4", "ti,sysc";
- ti,hwmods = "iss";
reg = <0x52000000 0x4>,
<0x52000010 0x4>;
reg-names = "rev", "sysc";
@@ -762,13 +761,32 @@
<SYSC_IDLE_SMART>,
<SYSC_IDLE_SMART_WKUP>;
ti,sysc-delay-us = <2>;
- clocks = <&iss_clkctrl OMAP4_ISS_CLKCTRL 0>;
- clock-names = "fck";
+ clocks = <&iss_clkctrl OMAP4_ISS_CLKCTRL 0>,
+ <&iss_clkctrl OMAP4_ISS_CLKCTRL 8>;
+ clock-names = "fck","ick";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x52000000 0x1000000>;
-
- /* No child device binding, driver in staging */
+ iss: iss@0 {
+ compatible = "ti,omap4iss";
+ reg = <0x0000 0x200>, /* top */
+ <0x1000 0x170>, /* csi2_a_regs1 */
+ <0x1170 0x020>, /* camerarx_core1 */
+ <0x1400 0x170>, /* csi2_b_regs1 */
+ <0x1570 0x020>, /* camerarx_core2 */
+ <0x2000 0x200>, /* bte */
+ <0x10000 0x0a0>, /* isp_sys1 */
+ <0x10400 0x400>, /* isp_resizer */
+ <0x10800 0x800>, /* isp_ipipe */
+ <0x11000 0x200>, /* isp_isif */
+ <0x11200 0x080>; /* isp_ipipeif */
+ syscon = <&omap4_padconf_global>;
+ status = "ok";
+ ti,hwmods = "iss";
+ interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&sdma 9>, <&sdma 10>, <&sdma 12>, <&sdma 13>;
+ dma-names = "1", "2", "3", "4";
+ };
};
mmu_ipu: mmu@55082000 {
diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig
index 4618346..80f7144 100644
--- a/drivers/staging/media/omap4iss/Kconfig
+++ b/drivers/staging/media/omap4iss/Kconfig
@@ -4,5 +4,6 @@ config VIDEO_OMAP4
depends on HAS_DMA
select MFD_SYSCON
select VIDEOBUF2_DMA_CONTIG
+ select V4L2_FWNODE
---help---
Driver for an OMAP 4 ISS controller.
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index b1036ba..c508fd8 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -14,6 +14,7 @@
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
+#include <linux/of_device.h>
#include <linux/dma-mapping.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
@@ -25,9 +26,12 @@
#include <linux/vmalloc.h>
#include <media/v4l2-common.h>
+#include <media/v4l2-fwnode.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
+#include <linux/pm_runtime.h>
+
#include "iss.h"
#include "iss_regs.h"
@@ -563,6 +567,8 @@ static int iss_reset(struct iss_device *iss)
iss_reg_set(iss, OMAP4_ISS_MEM_TOP, ISS_HL_SYSCONFIG,
ISS_HL_SYSCONFIG_SOFTRESET);
+ msleep(50);
+
timeout = iss_poll_condition_timeout(
!(iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_SYSCONFIG) &
ISS_HL_SYSCONFIG_SOFTRESET), 1000, 10, 100);
@@ -792,56 +798,17 @@ void omap4iss_isp_subclk_disable(struct iss_device *iss,
__iss_isp_subclk_update(iss);
}
-/*
- * iss_enable_clocks - Enable ISS clocks
- * @iss: OMAP4 ISS device
- *
- * Return 0 if successful, or clk_enable return value if any of tthem fails.
- */
-static int iss_enable_clocks(struct iss_device *iss)
+int omap4iss_runtime_suspend(struct device *dev)
{
- int ret;
-
- ret = clk_enable(iss->iss_fck);
- if (ret) {
- dev_err(iss->dev, "clk_enable iss_fck failed\n");
- return ret;
- }
-
- ret = clk_enable(iss->iss_ctrlclk);
- if (ret) {
- dev_err(iss->dev, "clk_enable iss_ctrlclk failed\n");
- clk_disable(iss->iss_fck);
- return ret;
- }
-
+ struct iss_device *iss = (struct iss_device *)dev_get_drvdata(dev);
+ pm_qos_update_request(&iss->pm_qos, PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE);
return 0;
}
-/*
- * iss_disable_clocks - Disable ISS clocks
- * @iss: OMAP4 ISS device
- */
-static void iss_disable_clocks(struct iss_device *iss)
-{
- clk_disable(iss->iss_ctrlclk);
- clk_disable(iss->iss_fck);
-}
-
-static int iss_get_clocks(struct iss_device *iss)
+int omap4iss_runtime_resume(struct device *dev)
{
- iss->iss_fck = devm_clk_get(iss->dev, "iss_fck");
- if (IS_ERR(iss->iss_fck)) {
- dev_err(iss->dev, "Unable to get iss_fck clock info\n");
- return PTR_ERR(iss->iss_fck);
- }
-
- iss->iss_ctrlclk = devm_clk_get(iss->dev, "iss_ctrlclk");
- if (IS_ERR(iss->iss_ctrlclk)) {
- dev_err(iss->dev, "Unable to get iss_ctrlclk clock info\n");
- return PTR_ERR(iss->iss_ctrlclk);
- }
-
+ struct iss_device *iss = (struct iss_device *)dev_get_drvdata(dev);
+ pm_qos_update_request(&iss->pm_qos, 800000);
return 0;
}
@@ -866,10 +833,7 @@ struct iss_device *omap4iss_get(struct iss_device *iss)
if (iss->ref_count > 0)
goto out;
- if (iss_enable_clocks(iss) < 0) {
- __iss = NULL;
- goto out;
- }
+ pm_runtime_resume(iss->dev);
iss_enable_interrupts(iss);
@@ -903,7 +867,7 @@ void omap4iss_put(struct iss_device *iss)
*/
if (!media_entity_enum_empty(&iss->crashed))
iss_reset(iss);
- iss_disable_clocks(iss);
+ pm_runtime_suspend(iss->dev);
}
mutex_unlock(&iss->iss_mutex);
}
@@ -933,59 +897,8 @@ static void iss_unregister_entities(struct iss_device *iss)
media_device_unregister(&iss->media_dev);
}
-/*
- * iss_register_subdev_group - Register a group of subdevices
- * @iss: OMAP4 ISS device
- * @board_info: I2C subdevs board information array
- *
- * Register all I2C subdevices in the board_info array. The array must be
- * terminated by a NULL entry, and the first entry must be the sensor.
- *
- * Return a pointer to the sensor media entity if it has been successfully
- * registered, or NULL otherwise.
- */
-static struct v4l2_subdev *
-iss_register_subdev_group(struct iss_device *iss,
- struct iss_subdev_i2c_board_info *board_info)
-{
- struct v4l2_subdev *sensor = NULL;
- unsigned int first;
-
- if (!board_info->board_info)
- return NULL;
-
- for (first = 1; board_info->board_info; ++board_info, first = 0) {
- struct v4l2_subdev *subdev;
- struct i2c_adapter *adapter;
-
- adapter = i2c_get_adapter(board_info->i2c_adapter_id);
- if (!adapter) {
- dev_err(iss->dev,
- "%s: Unable to get I2C adapter %d for device %s\n",
- __func__, board_info->i2c_adapter_id,
- board_info->board_info->type);
- continue;
- }
-
- subdev = v4l2_i2c_new_subdev_board(&iss->v4l2_dev, adapter,
- board_info->board_info, NULL);
- if (!subdev) {
- dev_err(iss->dev, "Unable to register subdev %s\n",
- board_info->board_info->type);
- continue;
- }
-
- if (first)
- sensor = subdev;
- }
-
- return sensor;
-}
-
static int iss_register_entities(struct iss_device *iss)
{
- struct iss_platform_data *pdata = iss->pdata;
- struct iss_v4l2_subdevs_group *subdevs;
int ret;
iss->media_dev.dev = iss->dev;
@@ -993,12 +906,7 @@ static int iss_register_entities(struct iss_device *iss)
sizeof(iss->media_dev.model));
iss->media_dev.hw_revision = iss->revision;
iss->media_dev.ops = &iss_media_ops;
- ret = media_device_register(&iss->media_dev);
- if (ret < 0) {
- dev_err(iss->dev, "Media device registration failed (%d)\n",
- ret);
- return ret;
- }
+ media_device_init(&iss->media_dev);
iss->v4l2_dev.mdev = &iss->media_dev;
ret = v4l2_device_register(iss->dev, &iss->v4l2_dev);
@@ -1029,53 +937,6 @@ static int iss_register_entities(struct iss_device *iss)
if (ret < 0)
goto done;
- /* Register external entities */
- for (subdevs = pdata->subdevs; subdevs && subdevs->subdevs; ++subdevs) {
- struct v4l2_subdev *sensor;
- struct media_entity *input;
- unsigned int flags;
- unsigned int pad;
-
- sensor = iss_register_subdev_group(iss, subdevs->subdevs);
- if (!sensor)
- continue;
-
- sensor->host_priv = subdevs;
-
- /* Connect the sensor to the correct interface module.
- * CSI2a receiver through CSIPHY1, or
- * CSI2b receiver through CSIPHY2
- */
- switch (subdevs->interface) {
- case ISS_INTERFACE_CSI2A_PHY1:
- input = &iss->csi2a.subdev.entity;
- pad = CSI2_PAD_SINK;
- flags = MEDIA_LNK_FL_IMMUTABLE
- | MEDIA_LNK_FL_ENABLED;
- break;
-
- case ISS_INTERFACE_CSI2B_PHY2:
- input = &iss->csi2b.subdev.entity;
- pad = CSI2_PAD_SINK;
- flags = MEDIA_LNK_FL_IMMUTABLE
- | MEDIA_LNK_FL_ENABLED;
- break;
-
- default:
- dev_err(iss->dev, "invalid interface type %u\n",
- subdevs->interface);
- ret = -EINVAL;
- goto done;
- }
-
- ret = media_create_pad_link(&sensor->entity, 0, input, pad,
- flags);
- if (ret < 0)
- goto done;
- }
-
- ret = v4l2_device_register_subdev_nodes(&iss->v4l2_dev);
-
done:
if (ret < 0)
iss_unregister_entities(iss);
@@ -1200,16 +1061,157 @@ static int iss_initialize_modules(struct iss_device *iss)
return ret;
}
+static int iss_link_entity(struct iss_device *iss,
+ struct media_entity *entity,
+ enum iss_interface_type interface)
+{
+ struct media_entity *input;
+ unsigned int flags;
+ unsigned int pad;
+ unsigned int i;
+
+ switch (interface) {
+ case ISS_INTERFACE_CSI2A_PHY1:
+ input = &iss->csi2a.subdev.entity;
+ pad = CSI2_PAD_SINK;
+ flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED;
+ break;
+ case ISS_INTERFACE_CSI2B_PHY2:
+ input = &iss->csi2b.subdev.entity;
+ pad = CSI2_PAD_SINK;
+ flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED;
+ break;
+ default:
+ dev_err(iss->dev, "%s: invalid interface type %u\n", __func__, interface);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < entity->num_pads; i++) {
+ if (entity->pads[i].flags & MEDIA_PAD_FL_SOURCE)
+ break;
+ }
+ if (i == entity->num_pads) {
+ dev_err(iss->dev, "%s: no source pad in external entity\n", __func__);
+ return -EINVAL;
+ }
+
+ return media_create_pad_link(entity, i, input, pad, flags);
+}
+
+static int iss_fwnode_parse(struct device *dev,
+ struct v4l2_fwnode_endpoint *vep,
+ struct v4l2_async_subdev *asd)
+{
+ struct iss_async_subdev *isd =
+ container_of(asd, struct iss_async_subdev, asd);
+ struct iss_bus_cfg *buscfg = &isd->bus;
+ unsigned int i, lanes;
+
+ dev_dbg(dev, "parsing endpoint %pOF, interface %u\n",
+ to_of_node(vep->base.local_fwnode), vep->base.port);
+
+ switch (vep->base.port)
+ {
+ case ISS_INTERFACE_CSI2A_PHY1:
+ buscfg->interface = ISS_INTERFACE_CSI2A_PHY1;
+ lanes = ISS_CSIPHY1_NUM_DATA_LANES;
+ break;
+ case ISS_INTERFACE_CSI2B_PHY2:
+ buscfg->interface = ISS_INTERFACE_CSI2B_PHY2;
+ lanes = ISS_CSIPHY2_NUM_DATA_LANES;
+ break;
+ default:
+ dev_warn(dev, "parsing endpoint: invalid interface %u\n", vep->base.port);
+ return -EINVAL;
+ }
+
+ buscfg->bus.csi2.lanecfg.clk.pos = vep->bus.mipi_csi2.clock_lane;
+ buscfg->bus.csi2.lanecfg.clk.pol =
+ vep->bus.mipi_csi2.lane_polarities[0];
+ dev_info(dev, "clock lane polarity %u, pos %u\n",
+ buscfg->bus.csi2.lanecfg.clk.pol,
+ buscfg->bus.csi2.lanecfg.clk.pos);
+
+ for (i = 0; i < lanes; i++)
+ {
+ buscfg->bus.csi2.lanecfg.data[i].pos =
+ vep->bus.mipi_csi2.data_lanes[i];
+ buscfg->bus.csi2.lanecfg.data[i].pol =
+ vep->bus.mipi_csi2.lane_polarities[i + 1];
+ dev_info(dev, "data lane %u polarity %u, pos %u\n", i,
+ buscfg->bus.csi2.lanecfg.data[i].pol,
+ buscfg->bus.csi2.lanecfg.data[i].pos);
+ }
+
+ /*
+ * FIXME: now we assume the CRC is always there.
+ * Implement a way to obtain this information from the
+ * sensor. Frame descriptors, perhaps?
+ */
+ buscfg->bus.csi2.crc = 0;
+
+ return 0;
+}
+
+static int iss_subdev_notifier_bound(struct v4l2_async_notifier *async,
+ struct v4l2_subdev *subdev,
+ struct v4l2_async_subdev *asd)
+{
+ struct iss_device *iss = container_of(async, struct iss_device, notifier);
+ struct iss_async_subdev *isd = container_of(asd, struct iss_async_subdev, asd);
+ int ret;
+
+ ret = iss_link_entity(iss, &subdev->entity, isd->bus.interface);
+ if (ret < 0)
+ return ret;
+
+ isd->sd = subdev;
+ isd->sd->host_priv = &isd->bus;
+
+ return ret;
+}
+
+static int iss_subdev_notifier_complete(struct v4l2_async_notifier *async)
+{
+ struct iss_device *iss = container_of(async, struct iss_device, notifier);
+
+ int ret;
+ /*
+ struct v4l2_device *v4l2_dev = &iss->v4l2_dev;
+ struct v4l2_subdev *sd;
+
+ ret = media_entity_enum_init(&iss->crashed, &iss->media_dev);
+ if (ret)
+ return ret;
+
+ list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
+ if (sd->notifier != &iss->notifier)
+ continue;
+
+ ret = iss_link_entity(iss, &sd->entity, v4l2_subdev_to_bus_cfg(sd)->interface);
+ if (ret < 0)
+ return ret;
+ }
+ */
+
+ ret = v4l2_device_register_subdev_nodes(&iss->v4l2_dev);
+ if (ret < 0)
+ return ret;
+
+ return media_device_register(&iss->media_dev);
+}
+
+static const struct v4l2_async_notifier_operations iss_subdev_notifier_ops = {
+ .complete = iss_subdev_notifier_complete,
+ .bound = iss_subdev_notifier_bound,
+};
+
static int iss_probe(struct platform_device *pdev)
{
- struct iss_platform_data *pdata = pdev->dev.platform_data;
struct iss_device *iss;
unsigned int i;
int ret;
- if (!pdata)
- return -EINVAL;
-
iss = devm_kzalloc(&pdev->dev, sizeof(*iss), GFP_KERNEL);
if (!iss)
return -ENOMEM;
@@ -1217,19 +1219,23 @@ static int iss_probe(struct platform_device *pdev)
mutex_init(&iss->iss_mutex);
iss->dev = &pdev->dev;
- iss->pdata = pdata;
iss->raw_dmamask = DMA_BIT_MASK(32);
iss->dev->dma_mask = &iss->raw_dmamask;
iss->dev->coherent_dma_mask = DMA_BIT_MASK(32);
platform_set_drvdata(pdev, iss);
+ dev_set_drvdata(&pdev->dev, iss);
- /*
- * TODO: When implementing DT support switch to syscon regmap lookup by
- * phandle.
- */
- iss->syscon = syscon_regmap_lookup_by_compatible("syscon");
+ pm_qos_add_request(&iss->pm_qos, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE);
+
+ ret = v4l2_async_notifier_parse_fwnode_endpoints(
+ &pdev->dev, &iss->notifier, sizeof(struct iss_async_subdev),
+ iss_fwnode_parse);
+ if (ret < 0)
+ goto error;
+
+ iss->syscon = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,"syscon");
if (IS_ERR(iss->syscon)) {
ret = PTR_ERR(iss->syscon);
goto error;
@@ -1240,17 +1246,18 @@ static int iss_probe(struct platform_device *pdev)
if (ret < 0)
goto error;
- ret = iss_get_clocks(iss);
- if (ret < 0)
- goto error;
+ pm_runtime_enable(iss->dev);
+ pm_runtime_get_sync(&pdev->dev);
if (!omap4iss_get(iss))
goto error;
+ /* TODO --- reset should be handled by parent node sysc --- */
ret = iss_reset(iss);
if (ret < 0)
goto error_iss;
+ /* TODO --- revision should also be handled by parent node sysc --- */
iss->revision = iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_REVISION);
dev_info(iss->dev, "Revision %08x found\n", iss->revision);
@@ -1310,6 +1317,12 @@ static int iss_probe(struct platform_device *pdev)
if (ret < 0)
goto error_entities;
+ iss->notifier.ops = &iss_subdev_notifier_ops;
+
+ ret = v4l2_async_notifier_register(&iss->v4l2_dev, &iss->notifier);
+ if (ret)
+ goto error_entities;
+
omap4iss_put(iss);
return 0;
@@ -1321,7 +1334,9 @@ static int iss_probe(struct platform_device *pdev)
iss_cleanup_modules(iss);
error_iss:
omap4iss_put(iss);
+ pm_qos_remove_request(&iss->pm_qos);
error:
+ v4l2_async_notifier_cleanup(&iss->notifier);
mutex_destroy(&iss->iss_mutex);
return ret;
@@ -1334,6 +1349,7 @@ static int iss_remove(struct platform_device *pdev)
iss_unregister_entities(iss);
media_entity_enum_cleanup(&iss->crashed);
iss_cleanup_modules(iss);
+ pm_qos_remove_request(&iss->pm_qos);
return 0;
}
@@ -1344,12 +1360,25 @@ static const struct platform_device_id omap4iss_id_table[] = {
};
MODULE_DEVICE_TABLE(platform, omap4iss_id_table);
+static const struct of_device_id omap4iss_of_table[] = {
+ { .compatible = "ti,omap4iss" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, omap4iss_of_table);
+
+static const struct dev_pm_ops omap4iss_pm_ops = {
+ .runtime_suspend = omap4iss_runtime_suspend,
+ .runtime_resume = omap4iss_runtime_resume,
+};
+
static struct platform_driver iss_driver = {
.probe = iss_probe,
.remove = iss_remove,
.id_table = omap4iss_id_table,
.driver = {
.name = "omap4iss",
+ .pm = &omap4iss_pm_ops,
+ .of_match_table = of_match_ptr(omap4iss_of_table),
},
};
diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h
index 760ee27..00d3315 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -16,14 +16,16 @@
#include <media/v4l2-device.h>
#include <media/v4l2-mc.h>
+#include <media/v4l2-async.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/wait.h>
-#include <linux/platform_data/media/omap4iss.h>
+#include <linux/pm_qos.h>
+#include "omap4iss.h"
#include "iss_regs.h"
#include "iss_csiphy.h"
#include "iss_csi2.h"
@@ -88,6 +90,7 @@ struct iss_reg {
*/
struct iss_device {
struct v4l2_device v4l2_dev;
+ struct v4l2_async_notifier notifier;
struct media_device media_dev;
struct device *dev;
u32 revision;
@@ -121,8 +124,23 @@ struct iss_device {
unsigned int subclk_resources;
unsigned int isp_subclk_resources;
+
+#define ISS_MAX_SUBDEVS 2
+ struct v4l2_subdev *subdevs[ISS_MAX_SUBDEVS];
+
+ struct pm_qos_request pm_qos;
+};
+
+struct iss_async_subdev {
+ struct v4l2_async_subdev asd;
+ struct iss_bus_cfg bus;
+
+ struct v4l2_subdev *sd;
};
+#define v4l2_subdev_to_bus_cfg(sd) \
+ (&container_of((sd)->asd, struct iss_async_subdev, asd)->bus)
+
#define v4l2_dev_to_iss_device(dev) \
container_of(dev, struct iss_device, v4l2_dev)
diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
index f6acc54..d6487d7 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -1275,6 +1275,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
pads[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
+ me->function = MEDIA_ENT_F_IO_V4L;
me->ops = &csi2_media_ops;
ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads);
if (ret < 0)
diff --git a/drivers/staging/media/omap4iss/iss_csiphy.c b/drivers/staging/media/omap4iss/iss_csiphy.c
index 748607f..a8cf24e 100644
--- a/drivers/staging/media/omap4iss/iss_csiphy.c
+++ b/drivers/staging/media/omap4iss/iss_csiphy.c
@@ -121,7 +121,7 @@ int omap4iss_csiphy_config(struct iss_device *iss,
{
struct iss_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
struct iss_pipeline *pipe = to_iss_pipeline(&csi2_subdev->entity);
- struct iss_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+ struct iss_bus_cfg *buscfg = pipe->external->host_priv;
struct iss_csiphy_dphy_cfg csi2phy;
int csi2_ddrclk_khz;
struct iss_csiphy_lanes_cfg *lanes;
@@ -129,7 +129,14 @@ int omap4iss_csiphy_config(struct iss_device *iss,
u32 cam_rx_ctrl;
unsigned int i;
- lanes = &subdevs->bus.csi2.lanecfg;
+ if (!buscfg) {
+ struct iss_async_subdev *isd =
+ container_of(pipe->external->asd,
+ struct iss_async_subdev, asd);
+ buscfg = &isd->bus;
+ }
+
+ lanes = &buscfg->bus.csi2.lanecfg;
/*
* SCM.CONTROL_CAMERA_RX
@@ -147,7 +154,7 @@ int omap4iss_csiphy_config(struct iss_device *iss,
*/
regmap_read(iss->syscon, 0x68, &cam_rx_ctrl);
- if (subdevs->interface == ISS_INTERFACE_CSI2A_PHY1) {
+ if (buscfg->interface == ISS_INTERFACE_CSI2A_PHY1) {
cam_rx_ctrl &= ~(OMAP4_CAMERARX_CSI21_LANEENABLE_MASK |
OMAP4_CAMERARX_CSI21_CAMMODE_MASK);
/* NOTE: Leave CSIPHY1 config to 0x0: D-PHY mode */
@@ -158,7 +165,7 @@ int omap4iss_csiphy_config(struct iss_device *iss,
cam_rx_ctrl |= OMAP4_CAMERARX_CSI21_CTRLCLKEN_MASK;
}
- if (subdevs->interface == ISS_INTERFACE_CSI2B_PHY2) {
+ if (buscfg->interface == ISS_INTERFACE_CSI2B_PHY2) {
cam_rx_ctrl &= ~(OMAP4_CAMERARX_CSI22_LANEENABLE_MASK |
OMAP4_CAMERARX_CSI22_CAMMODE_MASK);
/* NOTE: Leave CSIPHY2 config to 0x0: D-PHY mode */
diff --git a/drivers/staging/media/omap4iss/iss_csiphy.h b/drivers/staging/media/omap4iss/iss_csiphy.h
index a0f2d97..f41b980 100644
--- a/drivers/staging/media/omap4iss/iss_csiphy.h
+++ b/drivers/staging/media/omap4iss/iss_csiphy.h
@@ -14,7 +14,7 @@
#ifndef OMAP4_ISS_CSI_PHY_H
#define OMAP4_ISS_CSI_PHY_H
-#include <linux/platform_data/media/omap4iss.h>
+#include "omap4iss.h"
struct iss_csi2_device;
diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c
index d86ef8a..39cf657 100644
--- a/drivers/staging/media/omap4iss/iss_ipipe.c
+++ b/drivers/staging/media/omap4iss/iss_ipipe.c
@@ -515,6 +515,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe)
pads[IPIPE_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE;
+ me->function = MEDIA_ENT_F_VID_IF_BRIDGE;
me->ops = &ipipe_media_ops;
ret = media_entity_pads_init(me, IPIPE_PADS_NUM, pads);
if (ret < 0)
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c
index cb88b2b..d5b798e 100644
--- a/drivers/staging/media/omap4iss/iss_ipipeif.c
+++ b/drivers/staging/media/omap4iss/iss_ipipeif.c
@@ -747,6 +747,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)
pads[IPIPEIF_PAD_SOURCE_ISIF_SF].flags = MEDIA_PAD_FL_SOURCE;
pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE;
+ me->function = MEDIA_ENT_F_VID_IF_BRIDGE;
me->ops = &ipipeif_media_ops;
ret = media_entity_pads_init(me, IPIPEIF_PADS_NUM, pads);
if (ret < 0)
diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c
index 4bbfa20..afd147b 100644
--- a/drivers/staging/media/omap4iss/iss_resizer.c
+++ b/drivers/staging/media/omap4iss/iss_resizer.c
@@ -789,6 +789,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)
pads[RESIZER_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
pads[RESIZER_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE;
+ me->function = MEDIA_ENT_F_PROC_VIDEO_SCALER;
me->ops = &resizer_media_ops;
ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads);
if (ret < 0)
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index a3a8342..f08d67a 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -893,9 +893,6 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
if (ret)
goto err_graph_walk_init;
- if (video->iss->pdata->set_constraints)
- video->iss->pdata->set_constraints(video->iss, true);
-
ret = media_pipeline_start(entity, &pipe->pipe);
if (ret < 0)
goto err_media_pipeline_start;
@@ -987,8 +984,6 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
err_iss_video_check_format:
media_pipeline_stop(&video->video.entity);
err_media_pipeline_start:
- if (video->iss->pdata->set_constraints)
- video->iss->pdata->set_constraints(video->iss, false);
video->queue = NULL;
media_graph_walk_cleanup(&graph);
@@ -1037,8 +1032,6 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
media_entity_enum_cleanup(&pipe->ent_enum);
- if (video->iss->pdata->set_constraints)
- video->iss->pdata->set_constraints(video->iss, false);
media_pipeline_stop(&video->video.entity);
done:
diff --git a/drivers/staging/media/omap4iss/omap4iss.h b/drivers/staging/media/omap4iss/omap4iss.h
new file mode 100644
index 0000000..5d85417
--- /dev/null
+++ b/drivers/staging/media/omap4iss/omap4iss.h
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef ARCH_ARM_PLAT_OMAP4_ISS_H
+#define ARCH_ARM_PLAT_OMAP4_ISS_H
+
+#include <linux/i2c.h>
+
+struct iss_device;
+
+enum iss_interface_type {
+ ISS_INTERFACE_CSI2A_PHY1,
+ ISS_INTERFACE_CSI2B_PHY2,
+};
+
+/**
+ * struct iss_csiphy_lane: CSI2 lane position and polarity
+ * @pos: position of the lane
+ * @pol: polarity of the lane
+ */
+struct iss_csiphy_lane {
+ u8 pos;
+ u8 pol;
+};
+
+#define ISS_CSIPHY1_NUM_DATA_LANES 4
+#define ISS_CSIPHY2_NUM_DATA_LANES 1
+
+/**
+ * struct iss_csiphy_lanes_cfg - CSI2 lane configuration
+ * @data: Configuration of one or two data lanes
+ * @clk: Clock lane configuration
+ */
+struct iss_csiphy_lanes_cfg {
+ struct iss_csiphy_lane data[ISS_CSIPHY1_NUM_DATA_LANES];
+ struct iss_csiphy_lane clk;
+};
+
+/**
+ * struct iss_csi2_platform_data - CSI2 interface platform data
+ * @crc: Enable the cyclic redundancy check
+ * @vpclk_div: Video port output clock control
+ */
+struct iss_csi2_platform_data {
+ unsigned crc:1;
+ unsigned vpclk_div:2;
+ struct iss_csiphy_lanes_cfg lanecfg;
+};
+
+struct iss_subdev_i2c_board_info {
+ struct i2c_board_info *board_info;
+ int i2c_adapter_id;
+};
+
+struct iss_v4l2_subdevs_group {
+ struct iss_subdev_i2c_board_info *subdevs;
+ enum iss_interface_type interface;
+ union {
+ struct iss_csi2_platform_data csi2;
+ } bus; /* gcc < 4.6.0 chokes on anonymous union initializers */
+};
+
+struct iss_bus_cfg {
+ enum iss_interface_type interface;
+ union {
+ struct iss_csi2_platform_data csi2;
+ } bus; /* gcc < 4.6.0 chokes on anonymous union initializers */
+};
+
+struct iss_platform_subdev {
+ struct i2c_board_info *board_info;
+ int i2c_adapter_id;
+ struct iss_bus_cfg *bus;
+};
+
+#endif
diff --git a/include/linux/platform_data/media/omap4iss.h b/include/linux/platform_data/media/omap4iss.h
deleted file mode 100644
index 2a511a8..0000000
--- a/include/linux/platform_data/media/omap4iss.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef ARCH_ARM_PLAT_OMAP4_ISS_H
-#define ARCH_ARM_PLAT_OMAP4_ISS_H
-
-#include <linux/i2c.h>
-
-struct iss_device;
-
-enum iss_interface_type {
- ISS_INTERFACE_CSI2A_PHY1,
- ISS_INTERFACE_CSI2B_PHY2,
-};
-
-/**
- * struct iss_csiphy_lane: CSI2 lane position and polarity
- * @pos: position of the lane
- * @pol: polarity of the lane
- */
-struct iss_csiphy_lane {
- u8 pos;
- u8 pol;
-};
-
-#define ISS_CSIPHY1_NUM_DATA_LANES 4
-#define ISS_CSIPHY2_NUM_DATA_LANES 1
-
-/**
- * struct iss_csiphy_lanes_cfg - CSI2 lane configuration
- * @data: Configuration of one or two data lanes
- * @clk: Clock lane configuration
- */
-struct iss_csiphy_lanes_cfg {
- struct iss_csiphy_lane data[ISS_CSIPHY1_NUM_DATA_LANES];
- struct iss_csiphy_lane clk;
-};
-
-/**
- * struct iss_csi2_platform_data - CSI2 interface platform data
- * @crc: Enable the cyclic redundancy check
- * @vpclk_div: Video port output clock control
- */
-struct iss_csi2_platform_data {
- unsigned crc:1;
- unsigned vpclk_div:2;
- struct iss_csiphy_lanes_cfg lanecfg;
-};
-
-struct iss_subdev_i2c_board_info {
- struct i2c_board_info *board_info;
- int i2c_adapter_id;
-};
-
-struct iss_v4l2_subdevs_group {
- struct iss_subdev_i2c_board_info *subdevs;
- enum iss_interface_type interface;
- union {
- struct iss_csi2_platform_data csi2;
- } bus; /* gcc < 4.6.0 chokes on anonymous union initializers */
-};
-
-struct iss_platform_data {
- struct iss_v4l2_subdevs_group *subdevs;
- void (*set_constraints)(struct iss_device *iss, bool enable);
-};
-
-#endif
--
2.7.4