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
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
|
/* linux/drivers/video/exynos/decon/vpp/vpp_drv.c
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* Samsung EXYNOS5 SoC series VPP driver
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 2 of the License,
* or (at your option) any later version.
*/
#include <linux/module.h>
#include <linux/clk-provider.h>
#include <linux/clk.h>
#include <linux/clk-private.h>
#include <linux/of.h>
#include <linux/exynos_iovmm.h>
#include <linux/smc.h>
#include <plat/cpu.h>
#include <mach/devfreq.h>
#include "vpp_core.h"
#include "../decon_helper.h"
/*
* Gscaler constraints
* This is base of without rotation.
*/
#define SRC_OFFSET_MULTIPLE 2
#define SRC_SIZE_MULTIPLE 2
#define SRC_WIDTH_MAX 8190
#define SRC_HEIGHT_MAX 4096
#define SRC_WIDTH_MIN 64
#define SRC_HEIGHT_MIN 32
#define IMG_SIZE_MULTIPLE 2
#define IMG_WIDTH_MAX 4096
#define IMG_HEIGHT_MAX 4096
#define IMG_WIDTH_MIN 64
#define IMG_HEIGHT_MIN 32
#define BLK_WIDTH_MAX 4096
#define BLK_HEIGHT_MAX 4096
#define BLK_WIDTH_MIN 144
#define BLK_HEIGHT_MIN 10
#define SCALED_SIZE_MULTIPLE 2
#define SCALED_WIDTH_MAX 4096
#define SCALED_HEIGHT_MAX 4096
#define SCALED_WIDTH_MIN 32
#define SCALED_HEIGHT_MIN 16
#define check_align(width, height, align)\
(IS_ALIGNED(width, align) && IS_ALIGNED(height, align))
#define is_err_irq(irq) ((irq == VG_IRQ_DEADLOCK_STATUS) ||\
(irq == VG_IRQ_READ_SLAVE_ERROR))
#define MIF_LV1 (2912000/2)
#define INT_LV7 (400000)
#define MEM_FAULT_VPP_MASTER 0
#define MEM_FAULT_VPP_CFW 1
#define MEM_FAULT_PROT_EXCEPT_0 2
#define MEM_FAULT_PROT_EXCEPT_1 3
#define MEM_FAULT_PROT_EXCEPT_2 4
#define MEM_FAULT_PROT_EXCEPT_3 5
static struct vpp_dev *vpp_for_decon;
static void vpp_dump_cfw_register(void)
{
u32 smc_val;
smc_val = exynos_smc(0x810000DE, MEM_FAULT_VPP_MASTER, 0, 0);
pr_err("=== vpp_master:0x%x \n", smc_val);
smc_val = exynos_smc(0x810000DE, MEM_FAULT_VPP_CFW, 0, 0);
pr_err("=== vpp_cfw:0x%x \n", smc_val);
smc_val = exynos_smc(0x810000DE, MEM_FAULT_PROT_EXCEPT_0, 0, 0);
pr_err("=== vpp_except_0:0x%x \n", smc_val);
smc_val = exynos_smc(0x810000DE, MEM_FAULT_PROT_EXCEPT_1, 0, 0);
pr_err("=== vpp_except_1:0x%x \n", smc_val);
smc_val = exynos_smc(0x810000DE, MEM_FAULT_PROT_EXCEPT_2, 0, 0);
pr_err("=== vpp_except_2:0x%x \n", smc_val);
smc_val = exynos_smc(0x810000DE, MEM_FAULT_PROT_EXCEPT_3, 0, 0);
pr_err("=== vpp_except_3:0x%x \n", smc_val);
}
static void vpp_dump_registers(struct vpp_dev *vpp)
{
unsigned long flags;
dev_info(DEV, "=== VPP%d SFR DUMP ===\n", vpp->id);
dev_info(DEV, "start count : %d, done count : %d\n",
vpp->start_count, vpp->done_count);
if (!test_bit(VPP_RUNNING, &vpp->state)) {
dev_err(DEV, "vpp clocks are disabled\n");
return;
}
spin_lock_irqsave(&vpp->slock, flags);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32, 4,
vpp->regs, 0xB0, false);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32, 4,
vpp->regs + 0x5B0, 0x20, false);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32, 4,
vpp->regs + 0xA48, 0x10, false);
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32, 4,
vpp->regs + 0xB00, 0xB0, false);
vpp_dump_cfw_register();
spin_unlock_irqrestore(&vpp->slock, flags);
}
void vpp_op_timer_handler(unsigned long arg)
{
struct vpp_dev *vpp = (struct vpp_dev *)arg;
vpp_dump_registers(vpp);
dev_info(DEV, "VPP[%d] irq hasn't been occured", vpp->id);
}
static int vpp_wait_for_update(struct vpp_dev *vpp)
{
int update_cnt;
int ret;
if (test_bit(VPP_POWER_ON, &vpp->state)) {
update_cnt = vpp->update_cnt_prev;
ret = wait_event_interruptible_timeout(vpp->update_queue,
(update_cnt != vpp->update_cnt),
msecs_to_jiffies(17));
if (ret == 0) {
dev_err(DEV, "timeout of shadow update(%d, %d)\n",
update_cnt, vpp->update_cnt);
return -ETIMEDOUT;
}
DISP_SS_EVENT_LOG(DISP_EVT_VPP_UPDATE_DONE, vpp->sd, ktime_set(0, 0));
}
return 0;
}
static void vpp_get_align_variant(struct decon_win_config *config,
u32 *offs, u32 *src_f, u32 *src_cr, u32 *dst_cr)
{
if (is_rotation(config)) {
if (is_yuv(config)) {
*offs = *src_f = 4;
*src_cr = 2;
*dst_cr = 1;
} else {
*offs = *src_f = 2;
*src_cr = *dst_cr = 1;
}
} else {
if (is_yuv(config)) {
*offs = *src_f = 2;
*src_cr = 2;
*dst_cr = 1;
} else {
*offs = *src_f = 1;
*src_cr = *dst_cr = 1;
}
}
}
static void vpp_get_min_max_variant(struct decon_win_config *config,
u32 *max_src, u32 *min_src_w, u32 *min_src_h,
u32 *max_dst, u32 *min_dst_w, u32 *min_dst_h)
{
if (is_rotation(config)) {
if (is_yuv(config)) {
*max_src = 2560;
*max_dst = 4096;
*min_src_w = 32;
*min_src_h = 64;
*min_dst_w = 16;
*min_dst_h = 8;
} else {
*max_src = 2560;
*max_dst = 4096;
*min_src_w = 16;
*min_src_h = 32;
*min_dst_w = 16;
*min_dst_h = 8;
}
} else {
if (is_yuv(config)) {
*max_src = 4096;
*max_dst = 4096;
*min_src_w = 64;
*min_src_h = 32;
*min_dst_w = 16;
*min_dst_h = 8;
} else {
*max_src = 4096;
*max_dst = 4096;
*min_src_w = 32;
*min_src_h = 16;
*min_dst_w = 16;
*min_dst_h = 8;
}
}
}
static void vpp_separate_fraction_value(struct vpp_dev *vpp,
int *integer, u32 *fract_val)
{
/*
* [30:15] : fraction val, [14:0] : integer val.
*/
*fract_val = (*integer >> 15) << 4;
if (*fract_val & ~VG_POSITION_F_MASK) {
dev_warn(DEV, "%d is unsupported value",
*fract_val);
*fract_val &= VG_POSITION_F_MASK;
}
*integer = (*integer & 0x7fff);
}
static void vpp_set_initial_phase(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
struct decon_frame *src = &config->src;
struct vpp_fraction *fr = &vpp->fract_val;
if (is_fraction(src->x)) {
vpp_separate_fraction_value(vpp, &src->x, &fr->y_x);
fr->c_x = fr->y_x >> 1;
}
if (is_fraction(src->y)) {
vpp_separate_fraction_value(vpp, &src->y, &fr->y_y);
fr->c_y = fr->y_y >> 1;
}
if (is_fraction(src->w)) {
vpp_separate_fraction_value(vpp, &src->w, &fr->w);
src->w++;
}
if (is_fraction(src->h)) {
vpp_separate_fraction_value(vpp, &src->h, &fr->h);
src->h++;
}
}
static int vpp_check_size(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
struct decon_frame *src = &config->src;
struct decon_frame *dst = &config->dst;
u32 offs, src_f, src_cr, dst_cr;
u32 max_src, min_src_w, min_src_h;
u32 max_dst, min_dst_w, min_dst_h;
vpp_get_align_variant(config, &offs, &src_f,
&src_cr, &dst_cr);
vpp_get_min_max_variant(config, &max_src, &min_src_w,
&min_src_h, &max_dst, &min_dst_w, &min_dst_h);
if ((!check_align(src->x, src->y, offs)) ||
(!check_align(src->f_w, src->f_h, src_f)) ||
(!check_align(src->w, src->h, src_cr)) ||
(!check_align(dst->w, dst->h, dst_cr))) {
dev_err(DEV, "Alignment error\n");
goto err;
}
if (src->w > max_src || src->w < min_src_w ||
src->h > max_src || src->h < min_src_h) {
dev_err(DEV, "Unsupported source size\n");
goto err;
}
if (dst->w > max_dst || dst->w < min_dst_w ||
dst->h > max_dst || dst->h < min_dst_h) {
dev_err(DEV, "Unsupported dest size\n");
goto err;
}
return 0;
err:
dev_err(DEV, "offset x : %d, offset y: %d\n", src->x, src->y);
dev_err(DEV, "src f_w : %d, src f_h: %d\n", src->f_w, src->f_h);
dev_err(DEV, "src w : %d, src h: %d\n", src->w, src->h);
dev_err(DEV, "dst w : %d, dst h: %d\n", dst->w, dst->h);
return -EINVAL;
}
static int vpp_check_scale_ratio(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
struct decon_frame *src = &config->src;
struct decon_frame *dst = &config->dst;
u32 sc_up_max_w;
u32 sc_up_max_h;
u32 sc_down_min_w;
u32 sc_down_min_h;
if (is_rotation(config)) {
sc_up_max_w = config->dst.h << 1;
sc_up_max_h = config->dst.w << 1;
sc_down_min_w = config->src.h >> 3;
sc_down_min_h = config->src.w >> 3;
} else {
sc_up_max_w = config->dst.w << 1;
sc_up_max_h = config->dst.h << 1;
sc_down_min_w = config->src.w >> 3;
sc_down_min_h = config->src.h >> 3;
}
if (src->w > sc_up_max_w || src->h > sc_up_max_h) {
dev_err(DEV, "Unsupported max(2x) scale ratio\n");
goto err;
}
if (dst->w < sc_down_min_w || dst->h < sc_down_min_h) {
dev_err(DEV, "Unsupported min(1/8x) scale ratio\n");
goto err;
}
return 0;
err:
dev_err(DEV, "src w : %d, src h: %d\n", src->w, src->h);
dev_err(DEV, "dst w : %d, dst h: %d\n", dst->w, dst->h);
return -EINVAL;
}
static int vpp_set_scale_info(struct vpp_dev *vpp)
{
if (vpp_check_scale_ratio(vpp))
return -EINVAL;
vpp_hw_set_scale_ratio(vpp);
return 0;
}
static int vpp_check_rotation(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
enum vpp_rotate rot = config->vpp_parm.rot;
if (!is_vgr(vpp) && (rot > VPP_ROT_NORMAL)) {
dev_err(DEV, "vpp-%d can't rotate\n", vpp->id);
return -EINVAL;
}
return 0;
}
static int vpp_clk_enable(struct vpp_dev *vpp)
{
int ret;
ret = clk_enable(vpp->res.gate);
if (ret) {
dev_err(DEV, "Failed res.gate clk enable\n");
return ret;
}
ret = clk_enable(vpp->res.pclk_vpp);
if (ret) {
dev_err(DEV, "Failed res.pclk clk enable\n");
goto err_0;
}
ret = clk_enable(vpp->res.lh_vpp);
if (ret) {
dev_err(DEV, "Failed res.pclk clk enable\n");
goto err_1;
}
if (is_vpp0_series(vpp)) {
ret = clk_enable(vpp->res.aclk_vpp_sfw0);
if(ret) {
dev_err(DEV, "Failed res.aclk_vpp_sfw0 clk enable\n");
goto err_2;
}
ret = clk_enable(vpp->res.pclk_vpp_sfw0);
if(ret) {
dev_err(DEV, "Failed res.pclk_vpp_sfw0 clk enable\n");
goto err_3;
}
} else {
ret = clk_enable(vpp->res.aclk_vpp_sfw1);
if(ret) {
dev_err(DEV, "Failed res.aclk_vpp_sfw1 clk enable\n");
goto err_2;
}
ret = clk_enable(vpp->res.pclk_vpp_sfw1);
if(ret) {
dev_err(DEV, "Failed res.pclk_vpp_sfw1 clk enable\n");
goto err_3;
}
}
return 0;
err_3:
if (is_vpp0_series(vpp))
clk_disable(vpp->res.aclk_vpp_sfw0);
else
clk_disable(vpp->res.aclk_vpp_sfw1);
err_2:
clk_disable(vpp->res.lh_vpp);
err_1:
clk_disable(vpp->res.pclk_vpp);
err_0:
clk_disable(vpp->res.gate);
return ret;
}
static void vpp_clk_disable(struct vpp_dev *vpp)
{
clk_disable(vpp->res.gate);
clk_disable(vpp->res.pclk_vpp);
clk_disable(vpp->res.lh_vpp);
if (is_vpp0_series(vpp)) {
clk_disable(vpp->res.aclk_vpp_sfw0);
clk_disable(vpp->res.pclk_vpp_sfw0);
} else {
clk_disable(vpp->res.aclk_vpp_sfw1);
clk_disable(vpp->res.pclk_vpp_sfw1);
}
}
static int vpp_init(struct vpp_dev *vpp)
{
int ret = 0;
ret = vpp_clk_enable(vpp);
if (ret)
return ret;
vpp_hw_set_realtime_path(vpp);
vpp_hw_set_framedone_irq(vpp, false);
vpp_hw_set_deadlock_irq(vpp, false);
vpp_hw_set_read_slave_err_irq(vpp, false);
vpp_hw_set_hw_reset_done_mask(vpp, false);
vpp_hw_set_sfr_update_done_irq(vpp, false);
vpp_hw_set_enable_interrupt(vpp);
vpp_hw_set_lookup_table(vpp);
vpp_hw_set_rgb_type(vpp);
vpp_hw_set_dynamic_clock_gating(vpp);
vpp_hw_set_plane_alpha_fixed(vpp);
vpp->h_ratio = vpp->v_ratio = 0;
vpp->fract_val.y_x = vpp->fract_val.y_y = 0;
vpp->fract_val.c_x = vpp->fract_val.c_y = 0;
vpp->start_count = 0;
vpp->done_count = 0;
vpp->prev_read_order = SYSMMU_PBUFCFG_ASCENDING;
set_bit(VPP_POWER_ON, &vpp->state);
return 0;
}
#ifdef CONFIG_PM_DEVFREQ
#define MULTI_FACTOR (1 << 10)
static void vpp_get_bts_scale_factor(struct vpp_dev *vpp, bool is_mif)
{
struct decon_win_config *config = vpp->config;
struct decon_frame *src = &config->src;
struct decon_frame *dst = &config->dst;
u32 src_w = is_rotation(config) ? src->h : src->w;
u32 src_h = is_rotation(config) ? src->w : src->h;
if (is_mif) {
vpp->sc_w = MULTI_FACTOR * src_w / dst->w;
vpp->sc_h = MULTI_FACTOR * src_h / dst->h;
} else {
vpp->sc_w = (src_w <= dst->w) ?
MULTI_FACTOR : MULTI_FACTOR * src_w / dst->w;
vpp->sc_h = (src_h <= dst->h) ?
MULTI_FACTOR : MULTI_FACTOR * src_h / dst->h;
}
}
static int vpp_get_min_int_lock(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
struct decon_frame *dst = &config->dst;
struct decon_device *decon = get_decon_drvdata(0);
u32 vclk_mic = (u32) ((clk_get_rate(decon->res.vclk) / MHZ) * 2);
u32 lcd_width = decon->lcd_info->xres;
int ret = 0;
vpp_get_bts_scale_factor(vpp, false);
if ((vpp->sc_w == MULTI_FACTOR) && (vpp->sc_h == MULTI_FACTOR)) {
vpp->cur_int = vclk_mic / 2 * KHZ;
} else {
u64 scale_factor = ((u64) vclk_mic * vpp->sc_w * vpp->sc_h) / 2;
u64 dst_factor = ((u64) dst->w * MULTI_FACTOR) / lcd_width ;
vpp->cur_int = (scale_factor * dst_factor * KHZ) /
(MULTI_FACTOR * MULTI_FACTOR * MULTI_FACTOR);
if (vpp->cur_int > INT_LV7) {
dev_err(DEV, "Bandwidth has exceeded 400MHz %s\n", __func__);
dev_err(DEV, "scale_factor %lld, dst_factor %lld, cur_int %d \n"
,scale_factor, dst_factor, vpp->cur_int);
ret = -ERANGE;
}
}
dev_dbg(DEV, "vpp-%d int get: %d\n", vpp->id, vpp->cur_int);
return ret;
}
static void vpp_set_min_int_lock(struct vpp_dev *vpp, bool enable)
{
if (enable) {
pm_qos_update_request(&vpp->vpp_int_qos,
vpp_get_int_freq(vpp->cur_int));
} else {
pm_qos_update_request(&vpp->vpp_int_qos, 0);
vpp->prev_int = vpp->cur_int = 0;
}
dev_dbg(DEV, "vpp-%d int set : %d\n", vpp->id, vpp->cur_int);
}
static void vpp_get_min_mif_lock(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
struct decon_device *decon = get_decon_drvdata(0);
u32 vclk_mic = (u32) ((clk_get_rate(decon->res.vclk) / MHZ) * 2);
u8 bpl, rot_factor = 0;
u32 scale_factor = 0;
rot_factor = is_rotation(config) ? 4 : 1;
if (is_rgb(config))
bpl = is_rgb16(config) ? 4 : 8;
else if (is_yuv422(config))
bpl = 4;
else
bpl = 3;
vpp_get_bts_scale_factor(vpp, true);
scale_factor = ((vclk_mic * vpp->sc_w * vpp->sc_h) /
(MULTI_FACTOR * MULTI_FACTOR) * bpl) / 2;
vpp->cur_bw = scale_factor * rot_factor * KHZ;
dev_dbg(DEV, "vpp-%d bw get: %d\n", vpp->id, vpp->cur_bw);
}
static void vpp_set_min_mif_lock(struct vpp_dev *vpp, bool enable)
{
struct decon_win_config *config = vpp->config;
u8 vpp_type;
enum vpp_bw_type bw_type;
if (is_rotation(config)){
if (config->src.w * config->src.h >= FULLHD_SRC)
bw_type = BW_FULLHD_ROT;
else
bw_type = BW_ROT;
} else {
bw_type = BW_DEFAULT;
}
vpp_type = vpp->id + 2;
if (enable) {
exynos7_update_media_scenario(vpp_type, vpp->cur_bw,
bw_type);
} else {
exynos7_update_media_scenario(vpp_type, 0, BW_DEFAULT);
vpp->prev_bw = vpp->cur_bw = 0;
}
dev_dbg(DEV, "vpp-%d bw set: %d\n", vpp->id, vpp->cur_bw);
}
#else
#define vpp_get_min_mif_lock(vpp) do {} while (0)
#define vpp_get_min_int_lock(vpp) do {} while (0)
#define vpp_set_min_mif_lock(vpp, enalbe) do {} while (0)
#define vpp_set_min_int_lock(vpp, enalbe) do {} while (0)
#endif
static int vpp_deinit(struct vpp_dev *vpp, bool do_sw_reset)
{
unsigned int vpp_irq = 0;
clear_bit(VPP_POWER_ON, &vpp->state);
vpp_irq = vpp_hw_get_irq_status(vpp);
vpp_hw_clear_irq(vpp, vpp_irq);
vpp_hw_set_framedone_irq(vpp, true);
vpp_hw_set_deadlock_irq(vpp, true);
vpp_hw_set_read_slave_err_irq(vpp, true);
vpp_hw_set_hw_reset_done_mask(vpp, true);
vpp_hw_set_sfr_update_done_irq(vpp, true);
if (do_sw_reset)
vpp_hw_set_sw_reset(vpp);
vpp_clk_disable(vpp);
return 0;
}
static bool vpp_check_block_mode(struct vpp_dev *vpp)
{
struct decon_win_config *config = vpp->config;
u32 b_w = config->block_area.w;
u32 b_h = config->block_area.h;
if (config->vpp_parm.rot != VPP_ROT_NORMAL)
return false;
if (is_scaling(vpp))
return false;
if (!is_rgb(config))
return false;
if (b_w < BLK_WIDTH_MIN || b_h < BLK_HEIGHT_MIN)
return false;
return true;
}
static int vpp_set_read_order(struct vpp_dev *vpp)
{
int ret = 0;
u32 cur_read_order;
switch (vpp->config->vpp_parm.rot) {
case VPP_ROT_NORMAL:
case VPP_ROT_YFLIP:
case VPP_ROT_90_YFLIP:
case VPP_ROT_270:
cur_read_order = SYSMMU_PBUFCFG_ASCENDING;
break;
case VPP_ROT_XFLIP:
case VPP_ROT_180:
case VPP_ROT_90:
case VPP_ROT_90_XFLIP:
cur_read_order = SYSMMU_PBUFCFG_DESCENDING;
break;
default:
BUG();
}
if (cur_read_order != vpp->prev_read_order) {
struct device *dev = &vpp->pdev->dev;
u32 ipoption[vpp->pbuf_num];
ipoption[0] = SYSMMU_PBUFCFG_ASCENDING_INPUT;
ipoption[2] = SYSMMU_PBUFCFG_ASCENDING_INPUT;
if (cur_read_order == SYSMMU_PBUFCFG_ASCENDING) {
ipoption[1] = SYSMMU_PBUFCFG_ASCENDING_INPUT;
ipoption[3] = SYSMMU_PBUFCFG_ASCENDING_INPUT;
} else {
ipoption[1] = SYSMMU_PBUFCFG_DESCENDING_INPUT;
ipoption[3] = SYSMMU_PBUFCFG_DESCENDING_INPUT;
}
pm_qos_update_request(&vpp->vpp_mif_qos, MIF_LV1);
ret = sysmmu_set_prefetch_buffer_property(dev,
vpp->pbuf_num, 0, ipoption, NULL);
if (ret)
dev_err(DEV, "failed set pbuf\n");
} else {
pm_qos_update_request(&vpp->vpp_mif_qos, 0);
}
vpp->prev_read_order = cur_read_order;
return ret;
}
static int vpp_set_config(struct vpp_dev *vpp)
{
int ret = -EINVAL;
unsigned long flags;
if (test_bit(VPP_STOPPING, &vpp->state)) {
dev_warn(DEV, "vpp is ongoing stop(%d)\n", vpp->id);
return 0;
}
if (!test_bit(VPP_RUNNING, &vpp->state)) {
dev_dbg(DEV, "vpp start(%d)\n", vpp->id);
ret = pm_runtime_get_sync(DEV);
if (ret < 0) {
dev_err(DEV, "Failed runtime_get(), %d\n", ret);
return ret;
}
spin_lock_irqsave(&vpp->slock, flags);
ret = vpp_init(vpp);
if (ret < 0) {
dev_err(DEV, "Failed to initiailze clk\n");
spin_unlock_irqrestore(&vpp->slock, flags);
pm_runtime_put_sync(DEV);
return ret;
}
/* The state need to be set here to handle err case */
set_bit(VPP_RUNNING, &vpp->state);
spin_unlock_irqrestore(&vpp->slock, flags);
enable_irq(vpp->irq);
}
ret = vpp_hw_set_in_format(vpp);
if (ret)
goto err;
vpp_set_initial_phase(vpp);
ret = vpp_check_size(vpp);
if (ret)
goto err;
ret = vpp_check_rotation(vpp);
if (ret)
goto err;
DISP_SS_EVENT_LOG(DISP_EVT_VPP_WINCON, vpp->sd, ktime_set(0, 0));
vpp_hw_set_in_size(vpp);
vpp_hw_set_out_size(vpp);
vpp_hw_set_rotation(vpp);
if (is_vgr(vpp)) {
ret = vpp_set_read_order(vpp);
if (ret)
goto err;
}
vpp_hw_set_in_buf_addr(vpp);
vpp_hw_set_smart_if_pix_num(vpp);
ret = vpp_set_scale_info(vpp);
if (ret)
goto err;
if (vpp_check_block_mode(vpp))
vpp_hw_set_in_block_size(vpp, true);
else
vpp_hw_set_in_block_size(vpp, false);
vpp->op_timer.expires = (jiffies + 1 * HZ);
mod_timer(&vpp->op_timer, vpp->op_timer.expires);
vpp->start_count++;
vpp->update_cnt_prev = vpp->update_cnt;
return 0;
err:
dev_err(DEV, "failed to set config\n");
return ret;
}
static long vpp_subdev_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
struct vpp_dev *vpp = v4l2_get_subdevdata(sd);
int ret = 0;
unsigned long flags;
unsigned long state = (unsigned long)arg;
bool need_reset;
BUG_ON(!vpp);
mutex_lock(&vpp->mlock);
switch (cmd) {
case VPP_WIN_CONFIG:
vpp->config = (struct decon_win_config *)arg;
ret = vpp_set_config(vpp);
if (ret)
dev_err(DEV, "Failed vpp-%d configuration\n",
vpp->id);
break;
case VPP_STOP:
if (!test_bit(VPP_RUNNING, &vpp->state)) {
dev_warn(DEV, "vpp-%d is already stopped\n",
vpp->id);
goto err;
}
set_bit(VPP_STOPPING, &vpp->state);
if (state != VPP_STOP_ERR) {
ret = vpp_hw_wait_op_status(vpp);
if (ret < 0) {
dev_err(DEV, "%s : vpp-%d is working\n",
__func__, vpp->id);
goto err;
}
}
need_reset = (state > 0) ? true : false;
DISP_SS_EVENT_LOG(DISP_EVT_VPP_STOP, vpp->sd, ktime_set(0, 0));
clear_bit(VPP_RUNNING, &vpp->state);
disable_irq(vpp->irq);
spin_lock_irqsave(&vpp->slock, flags);
del_timer(&vpp->op_timer);
vpp_deinit(vpp, need_reset);
spin_unlock_irqrestore(&vpp->slock, flags);
vpp_set_min_mif_lock(vpp, 0);
vpp_set_min_int_lock(vpp, 0);
pm_qos_update_request(&vpp->vpp_mif_qos, 0);
pm_runtime_put_sync(DEV);
dev_dbg(DEV, "vpp stop(%d)\n", vpp->id);
clear_bit(VPP_STOPPING, &vpp->state);
break;
case VPP_GET_BTS_VAL:
vpp->config = (struct decon_win_config *)arg;
vpp_get_min_mif_lock(vpp);
ret = vpp_get_min_int_lock(vpp);
break;
case VPP_SET_BW:
vpp->config = (struct decon_win_config *)arg;
vpp_set_min_mif_lock(vpp, true);
break;
case VPP_SET_MIN_INT:
vpp->config = (struct decon_win_config *)arg;
vpp_set_min_int_lock(vpp, true);
break;
case VPP_WAIT_FOR_UPDATE:
vpp_wait_for_update(vpp);
break;
case VPP_DUMP:
vpp_dump_registers(vpp);
break;
case VPP_WAIT_IDLE:
vpp_hw_wait_idle(vpp);
break;
default:
break;
}
err:
mutex_unlock(&vpp->mlock);
return ret;
}
static int vpp_sd_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct vpp_dev *vpp = v4l2_get_subdevdata(sd);
dev_dbg(DEV, "vpp%d is opened\n", vpp->id);
return 0;
}
static int vpp_sd_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct vpp_dev *vpp = v4l2_get_subdevdata(sd);
dev_dbg(DEV, "vpp%d is closed\n", vpp->id);
return 0;
}
static int vpp_link_setup(struct media_entity *entity,
const struct media_pad *local,
const struct media_pad *remote, u32 flags)
{
return 0;
}
static const struct media_entity_operations vpp_media_ops = {
.link_setup = vpp_link_setup,
};
static const struct v4l2_subdev_internal_ops vpp_internal_ops = {
.open = vpp_sd_open,
.close = vpp_sd_close,
};
static const struct v4l2_subdev_core_ops vpp_subdev_core_ops = {
.ioctl = vpp_subdev_ioctl,
};
static struct v4l2_subdev_ops vpp_subdev_ops = {
.core = &vpp_subdev_core_ops,
};
static int check_mdev_for_output(struct device *dev, void *id)
{
struct platform_device *pdev = to_platform_device(dev);
unsigned int *data = (unsigned int *) id;
if (pdev->id == (int)(*data))
return -1;
return 0;
}
static int vpp_find_media_device(struct vpp_dev *vpp)
{
struct device_driver *driver;
struct device *dev;
struct exynos_md *md;
unsigned int id = MDEV_OUTPUT;
driver = driver_find(MDEV_MODULE_NAME, &platform_bus_type);
if (likely(driver)) {
dev = driver_find_device(driver, NULL, &id,
check_mdev_for_output);
md = (struct exynos_md *)dev_get_drvdata(dev);
vpp->mdev = md;
} else {
dev_err(DEV, "failed to find output media device\n");
return -EINVAL;
}
return 0;
}
static int vpp_create_subdev(struct vpp_dev *vpp)
{
struct v4l2_subdev *sd;
int ret;
sd = kzalloc(sizeof(*sd), GFP_KERNEL);
if (!sd)
return -ENOMEM;
v4l2_subdev_init(sd, &vpp_subdev_ops);
vpp->pad.flags = MEDIA_PAD_FL_SOURCE;
sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
snprintf(sd->name, sizeof(sd->name), "%s.%d", "vpp-sd", vpp->id);
sd->grp_id = vpp->id;
ret = media_entity_init(&sd->entity, VPP_PADS_NUM,
&vpp->pad, 0);
if (ret) {
dev_err(DEV, "Failed to initialize VPP media entity");
goto error;
}
sd->entity.ops = &vpp_media_ops;
sd->internal_ops = &vpp_internal_ops;
ret = v4l2_device_register_subdev(&vpp->mdev->v4l2_dev, sd);
if (ret) {
media_entity_cleanup(&sd->entity);
goto error;
}
vpp->mdev->vpp_sd[vpp->id] = sd;
vpp->mdev->vpp_dev[vpp->id] = &vpp->pdev->dev;
dev_info(DEV, "vpp_sd[%d] = %08lx\n", vpp->id,
(ulong)vpp->mdev->vpp_sd[vpp->id]);
vpp->sd = sd;
v4l2_set_subdevdata(sd, vpp);
return 0;
error:
kfree(sd);
return ret;
}
static int vpp_resume(struct device *dev)
{
return 0;
}
static int vpp_suspend(struct device *dev)
{
return 0;
}
static irqreturn_t vpp_irq_handler(int irq, void *priv)
{
struct vpp_dev *vpp = priv;
int vpp_irq = 0;
DISP_SS_EVENT_START();
spin_lock(&vpp->slock);
if (test_bit(VPP_POWER_ON, &vpp->state)) {
vpp->aclk_vpp[vpp->clk_cnt] =
readl(EXYNOS7420_ENABLE_ACLK_VPP);
vpp->pclk_vpp[vpp->clk_cnt] =
readl(EXYNOS7420_ENABLE_PCLK_VPP);
vpp->bus_vpp[vpp->clk_cnt] =
readl(EXYNOS7420_ENABLE_ACLK_BUS0);
vpp->clk_cnt++;
if (vpp->clk_cnt == 10)
vpp->clk_cnt = 0;
vpp_irq = vpp_hw_get_irq_status(vpp);
vpp_hw_clear_irq(vpp, vpp_irq);
if (is_err_irq(vpp_irq)) {
dev_err(DEV, "Error interrupt (0x%x)\n", vpp_irq);
vpp_dump_registers(vpp);
exynos_sysmmu_show_status(&vpp->pdev->dev);
goto err;
}
}
if (vpp_irq & VG_IRQ_FRAMEDONE) {
vpp->done_count++;
DISP_SS_EVENT_LOG(DISP_EVT_VPP_FRAMEDONE, vpp->sd, start);
}
if (vpp_irq & VG_IRQ_SFR_UPDATE_DONE) {
vpp->update_cnt++;
wake_up_interruptible_all(&vpp->update_queue);
DISP_SS_EVENT_LOG(DISP_EVT_VPP_SHADOW_UPDATE, vpp->sd, ktime_set(0, 0));
}
dev_dbg(DEV, "irq status : 0x%x\n", vpp_irq);
err:
del_timer(&vpp->op_timer);
spin_unlock(&vpp->slock);
return IRQ_HANDLED;
}
static void vpp_clk_info(struct vpp_dev *vpp)
{
dev_info(DEV, "%s: %ld Mhz\n", __clk_get_name(vpp->res.gate),
clk_get_rate(vpp->res.gate) / MHZ);
dev_info(DEV, "%s: %ld Mhz\n", __clk_get_name(vpp->res.pclk_vpp),
clk_get_rate(vpp->res.pclk_vpp) / MHZ);
dev_info(DEV, "%s: %ld Mhz\n", __clk_get_name(vpp->res.lh_vpp),
clk_get_rate(vpp->res.lh_vpp) / MHZ);
}
static int vpp_clk_get(struct vpp_dev *vpp)
{
struct device *dev = &vpp->pdev->dev;
int ret;
vpp->res.gate = devm_clk_get(dev, "gate");
if (IS_ERR(vpp->res.gate)) {
dev_err(dev, "vpp-%d clock get failed\n", vpp->id);
return PTR_ERR(vpp->res.gate);
}
vpp->res.pclk_vpp = devm_clk_get(dev, "pclk_vpp");
if (IS_ERR(vpp->res.pclk_vpp)) {
dev_err(dev, "vpp-%d clock pclk_vpp get failed\n", vpp->id);
return PTR_ERR(vpp->res.pclk_vpp);
}
if (is_vpp0_series(vpp)) {
vpp->res.lh_vpp = devm_clk_get(dev, "aclk_lh_vpp0");
if (IS_ERR(vpp->res.lh_vpp)) {
dev_err(dev, "vpp-%d clock lh_vpp get failed\n", vpp->id);
return PTR_ERR(vpp->res.lh_vpp);
}
} else {
vpp->res.lh_vpp = devm_clk_get(dev, "aclk_lh_vpp1");
if (IS_ERR(vpp->res.lh_vpp)) {
dev_err(dev, "vpp-%d clock lh_vpp get failed\n", vpp->id);
return PTR_ERR(vpp->res.lh_vpp);
}
}
if (is_vpp0_series(vpp)) {
vpp->res.aclk_vpp_sfw0 = devm_clk_get(dev, "aclk_smmu_vpp_sfw0");
if(IS_ERR(vpp->res.aclk_vpp_sfw0 )) {
dev_err(dev, "vpp-%d clock aclk_smmu_vpp_sfw0 get failed\n", vpp->id);
return PTR_ERR(vpp->res.aclk_vpp_sfw0);
}
vpp->res.pclk_vpp_sfw0 = devm_clk_get(dev, "pclk_smmu_vpp_sfw0");
if(IS_ERR(vpp->res.pclk_vpp_sfw0 )) {
dev_err(dev, "vpp-%d clock pclk_smmu_vpp_sfw0 get failed\n", vpp->id);
return PTR_ERR(vpp->res.pclk_vpp_sfw0);
}
} else {
vpp->res.aclk_vpp_sfw1 = devm_clk_get(dev, "aclk_smmu_vpp_sfw1");
if(IS_ERR(vpp->res.aclk_vpp_sfw1 )) {
dev_err(dev, "vpp-%d clock aclk_smmu_vpp_sfw1 get failed\n", vpp->id);
return PTR_ERR(vpp->res.aclk_vpp_sfw1);
}
vpp->res.pclk_vpp_sfw1 = devm_clk_get(dev, "pclk_smmu_vpp_sfw1");
if(IS_ERR(vpp->res.pclk_vpp_sfw1 )) {
dev_err(dev, "vpp-%d clock pclk_smmu_vpp_sfw1 get failed\n", vpp->id);
return PTR_ERR(vpp->res.pclk_vpp_sfw1);
}
}
decon_clk_set_rate(dev, "d_pclk_vpp", 134 * MHZ);
ret = clk_prepare(vpp->res.gate);
if (ret < 0) {
dev_err(dev, "vpp-%d clock prepare failed\n", vpp->id);
return ret;
}
ret = clk_prepare(vpp->res.pclk_vpp);
if (ret < 0) {
dev_err(dev, "vpp-%d pclk_vpp clock prepare failed\n", vpp->id);
goto err_0;
}
ret = clk_prepare(vpp->res.lh_vpp);
if (ret < 0) {
dev_err(dev, "vpp-%d lh_vpp clock prepare failed\n", vpp->id);
goto err_1;
}
if (is_vpp0_series(vpp)) {
ret = clk_prepare(vpp->res.aclk_vpp_sfw0);
if(ret < 0) {
dev_err(dev, "vpp-%d aclk_smmu_vpp_sfw0 clock prepare failed\n", vpp->id);
goto err_2;
}
ret = clk_prepare(vpp->res.pclk_vpp_sfw0);
if(ret < 0) {
dev_err(dev, "vpp-%d pclk_smmu_vpp_sfw0 clock prepare failed\n", vpp->id);
goto err_3;
}
} else {
ret = clk_prepare(vpp->res.aclk_vpp_sfw1);
if(ret < 0) {
dev_err(dev, "vpp-%d aclk_smmu_vpp_sfw1 clock prepare failed\n", vpp->id);
goto err_2;
}
ret = clk_prepare(vpp->res.pclk_vpp_sfw1);
if(ret < 0) {
dev_err(dev, "vpp-%d pclk_smmu_vpp_sfw1 clock prepare failed\n", vpp->id);
goto err_3;
}
}
return 0;
err_3:
if (is_vpp0_series(vpp))
clk_unprepare(vpp->res.aclk_vpp_sfw0);
else
clk_unprepare(vpp->res.aclk_vpp_sfw1);
err_2:
clk_unprepare(vpp->res.lh_vpp);
err_1:
clk_unprepare(vpp->res.pclk_vpp);
err_0:
clk_unprepare(vpp->res.gate);
return ret;
}
static void vpp_clk_put(struct vpp_dev *vpp)
{
clk_unprepare(vpp->res.gate);
clk_put(vpp->res.gate);
clk_put(vpp->res.d_pclk_vpp);
clk_unprepare(vpp->res.pclk_vpp);
clk_put(vpp->res.pclk_vpp);
clk_unprepare(vpp->res.lh_vpp);
clk_put(vpp->res.lh_vpp);
}
static int vpp_sysmmu_fault_handler(struct iommu_domain *domain,
struct device *dev, unsigned long iova, int flags, void *token)
{
struct vpp_dev *vpp = dev_get_drvdata(dev);
if (test_bit(VPP_POWER_ON, &vpp->state)) {
dev_info(DEV, "vpp%d sysmmu fault handler\n", vpp->id);
vpp_dump_registers(vpp);
}
return 0;
}
static int vpp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct vpp_dev *vpp;
struct resource *res;
int irq;
int ret = 0;
vpp = devm_kzalloc(dev, sizeof(*vpp), GFP_KERNEL);
if (!vpp) {
dev_err(dev, "Failed to allocate local vpp mem\n");
return -ENOMEM;
}
vpp_for_decon = vpp;
vpp->id = of_alias_get_id(dev->of_node, "vpp");
ret = of_property_read_u32(dev->of_node, "#pb-id-cells",
&vpp->pbuf_num);
if (ret) {
dev_err(DEV, "failed to get PB info\n");
return ret;
}
vpp->pdev = pdev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
vpp->regs = devm_request_and_ioremap(dev, res);
if (!vpp->regs) {
dev_err(DEV, "Failed to map registers\n");
ret = -EADDRNOTAVAIL;
goto probe_err_kfree;
}
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_err(DEV, "Failed to get IRQ resource\n");
goto probe_err_kfree;
}
ret = devm_request_irq(dev, irq, vpp_irq_handler,
0, pdev->name, vpp);
if (ret) {
dev_err(DEV, "Failed to install irq\n");
goto probe_err_kfree;
}
vpp->irq = irq;
disable_irq(vpp->irq);
ret = vpp_find_media_device(vpp);
if (ret) {
dev_err(DEV, "Failed find media device\n");
goto probe_err_kfree;
}
ret = vpp_create_subdev(vpp);
if (ret) {
dev_err(DEV, "Failed create sub-device\n");
goto probe_err_kfree;
}
ret = vpp_clk_get(vpp);
if (ret) {
dev_err(DEV, "Failed to get clk\n");
goto probe_err_kfree;
}
vpp_clk_info(vpp);
init_waitqueue_head(&vpp->stop_queue);
init_waitqueue_head(&vpp->update_queue);
platform_set_drvdata(pdev, vpp);
pm_runtime_enable(dev);
ret = iovmm_activate(dev);
if (ret < 0) {
dev_err(DEV, "failed to reactivate vmm\n");
goto probe_err_clk_put;
}
setup_timer(&vpp->op_timer, vpp_op_timer_handler,
(unsigned long)vpp);
if (IS_ENABLED(CONFIG_PM_DEVFREQ)) {
pm_qos_add_request(&vpp->vpp_int_qos,
PM_QOS_DEVICE_THROUGHPUT, 0);
pm_qos_add_request(&vpp->vpp_mif_qos,
PM_QOS_BUS_THROUGHPUT, 0);
}
mutex_init(&vpp->mlock);
spin_lock_init(&vpp->slock);
vpp->clk_cnt = 0;
iovmm_set_fault_handler(dev, vpp_sysmmu_fault_handler, NULL);
dev_info(DEV, "VPP%d is probed successfully\n", vpp->id);
return ret;
probe_err_clk_put:
vpp_clk_put(vpp);
probe_err_kfree:
kfree(vpp);
return ret;
}
static int vpp_remove(struct platform_device *pdev)
{
struct vpp_dev *vpp =
(struct vpp_dev *)platform_get_drvdata(pdev);
iovmm_deactivate(&vpp->pdev->dev);
vpp_clk_put(vpp);
if (IS_ENABLED(CONFIG_PM_DEVFREQ)) {
pm_qos_remove_request(&vpp->vpp_int_qos);
pm_qos_remove_request(&vpp->vpp_mif_qos);
}
dev_info(DEV, "%s driver unloaded\n", pdev->name);
return 0;
}
static const struct of_device_id vpp_device_table[] = {
{
.compatible = "samsung,exynos7-vpp",
},
{},
};
static const struct dev_pm_ops vpp_pm_ops = {
.suspend = vpp_suspend,
.resume = vpp_resume,
};
static struct platform_driver vpp_driver __refdata = {
.probe = vpp_probe,
.remove = vpp_remove,
.driver = {
.name = "exynos-vpp",
.owner = THIS_MODULE,
.pm = &vpp_pm_ops,
.of_match_table = of_match_ptr(vpp_device_table),
.suppress_bind_attrs = true,
}
};
static int vpp_register(void)
{
return platform_driver_register(&vpp_driver);
}
device_initcall_sync(vpp_register);
MODULE_AUTHOR("Sungchun, Kang <sungchun.kang@samsung.com>");
MODULE_DESCRIPTION("Samsung EXYNOS Soc VPP driver");
MODULE_LICENSE("GPL");
|