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
|
/*
* Samsung Exynos5 SoC series FIMC-IS driver
*
* exynos5 fimc-is video functions
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/version.h>
#include <linux/gpio.h>
#include <linux/clk.h>
#include <linux/regulator/consumer.h>
#include <linux/videodev2.h>
#include <linux/videodev2_exynos_camera.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <mach/regs-clock.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include <mach/tmu.h>
#include "fimc-is-resourcemgr.h"
#include "fimc-is-hw.h"
#include "fimc-is-debug.h"
#include "fimc-is-core.h"
#include "fimc-is-dvfs.h"
#include "fimc-is-clk-gate.h"
#define CLUSTER_MIN_MASK 0x0000FFFF
#define CLUSTER_MIN_SHIFT 0
#define CLUSTER_MAX_MASK 0xFFFF0000
#define CLUSTER_MAX_SHIFT 16
struct pm_qos_request exynos_isp_qos_int;
struct pm_qos_request exynos_isp_qos_mem;
struct pm_qos_request exynos_isp_qos_cam;
struct pm_qos_request exynos_isp_qos_disp;
struct pm_qos_request exynos_isp_qos_cluster0_min;
struct pm_qos_request exynos_isp_qos_cluster0_max;
struct pm_qos_request exynos_isp_qos_cluster1_min;
struct pm_qos_request exynos_isp_qos_cluster1_max;
#define C0MIN_QOS_ADD(freq) pm_qos_add_request(&exynos_isp_qos_cluster0_min, PM_QOS_CLUSTER0_FREQ_MIN, freq * 1000)
#define C0MIN_QOS_DEL() pm_qos_remove_request(&exynos_isp_qos_cluster0_min)
#define C0MIN_QOS_UPDATE(freq) pm_qos_update_request(&exynos_isp_qos_cluster0_min, freq * 1000)
#define C0MAX_QOS_ADD(freq) pm_qos_add_request(&exynos_isp_qos_cluster0_max, PM_QOS_CLUSTER0_FREQ_MAX, freq * 1000)
#define C0MAX_QOS_DEL() pm_qos_remove_request(&exynos_isp_qos_cluster0_max)
#define C0MAX_QOS_UPDATE(freq) pm_qos_update_request(&exynos_isp_qos_cluster0_max, freq * 1000)
#define C1MIN_QOS_ADD(freq) pm_qos_add_request(&exynos_isp_qos_cluster1_min, PM_QOS_CLUSTER1_FREQ_MIN, freq * 1000)
#define C1MIN_QOS_DEL() pm_qos_remove_request(&exynos_isp_qos_cluster1_min)
#define C1MIN_QOS_UPDATE(freq) pm_qos_update_request(&exynos_isp_qos_cluster1_min, freq * 1000)
#define C1MAX_QOS_ADD(freq) pm_qos_add_request(&exynos_isp_qos_cluster1_max, PM_QOS_CLUSTER1_FREQ_MAX, freq * 1000)
#define C1MAX_QOS_DEL() pm_qos_remove_request(&exynos_isp_qos_cluster1_max)
#define C1MAX_QOS_UPDATE(freq) pm_qos_update_request(&exynos_isp_qos_cluster1_max, freq * 1000)
extern struct fimc_is_sysfs_debug sysfs_debug;
static int fimc_is_resourcemgr_allocmem(struct fimc_is_resourcemgr *resourcemgr)
{
int ret = 0;
void *fw_cookie;
size_t fw_size = FIMC_IS_A5_MEM_SIZE;
#ifdef FW_SUSPEND_RESUME
fw_size += FIMC_IS_BACKUP_SIZE;
#endif
#ifdef ENABLE_ODC
fw_size += SIZE_ODC_INTERNAL_BUF * NUM_ODC_INTERNAL_BUF;
#endif
#ifdef ENABLE_VDIS
fw_size += SIZE_DIS_INTERNAL_BUF * NUM_DIS_INTERNAL_BUF;
#endif
#ifdef ENABLE_DNR
fw_size += SIZE_DNR_INTERNAL_BUF * NUM_DNR_INTERNAL_BUF;
#endif
fw_size = PAGE_ALIGN(fw_size);
dbg_core("Allocating memory for FIMC-IS firmware.\n");
fw_cookie = vb2_ion_private_alloc(resourcemgr->mem.alloc_ctx, fw_size, 1, 0);
if (IS_ERR(fw_cookie)) {
err("Allocating bitprocessor buffer failed");
fw_cookie = NULL;
ret = -ENOMEM;
goto p_err;
}
ret = vb2_ion_dma_address(fw_cookie, &resourcemgr->minfo.dvaddr);
if ((ret < 0) || (resourcemgr->minfo.dvaddr & FIMC_IS_FW_BASE_MASK)) {
err("The base memory is not aligned to 64MB.");
vb2_ion_private_free(fw_cookie);
resourcemgr->minfo.dvaddr = 0;
fw_cookie = NULL;
ret = -EIO;
goto p_err;
}
#ifdef PRINT_BUFADDR
info("[RSC] daddr = %pa, size = %08X\n", &resourcemgr->minfo.dvaddr, FIMC_IS_A5_MEM_SIZE);
#endif
resourcemgr->minfo.kvaddr = (ulong)vb2_ion_private_vaddr(fw_cookie);
if (IS_ERR((void *)resourcemgr->minfo.kvaddr)) {
err("Bitprocessor memory remap failed");
vb2_ion_private_free(fw_cookie);
resourcemgr->minfo.kvaddr = 0;
fw_cookie = NULL;
ret = -EIO;
goto p_err;
}
vb2_ion_sync_for_device(fw_cookie, 0, fw_size, DMA_BIDIRECTIONAL);
p_err:
info("[RSC] Device virtual for internal: %08lx\n", resourcemgr->minfo.kvaddr);
resourcemgr->minfo.fw_cookie = fw_cookie;
return ret;
}
static int fimc_is_resourcemgr_initmem(struct fimc_is_resourcemgr *resourcemgr)
{
int ret = 0;
u32 offset;
dbg_core("fimc_is_init_mem - ION\n");
ret = fimc_is_resourcemgr_allocmem(resourcemgr);
if (ret) {
err("Couldn't alloc for FIMC-IS firmware\n");
ret = -ENOMEM;
goto p_err;
}
offset = FW_SHARED_OFFSET;
resourcemgr->minfo.dvaddr_fshared = resourcemgr->minfo.dvaddr + offset;
resourcemgr->minfo.kvaddr_fshared = resourcemgr->minfo.kvaddr + offset;
offset = FIMC_IS_A5_MEM_SIZE - FIMC_IS_REGION_SIZE;
resourcemgr->minfo.dvaddr_region = resourcemgr->minfo.dvaddr + offset;
resourcemgr->minfo.kvaddr_region = resourcemgr->minfo.kvaddr + offset;
offset = FIMC_IS_A5_MEM_SIZE;
#ifdef FW_SUSPEND_RESUME
offset += FIMC_IS_BACKUP_SIZE;
#endif
#ifdef ENABLE_ODC
resourcemgr->minfo.dvaddr_odc = resourcemgr->minfo.dvaddr + offset;
resourcemgr->minfo.kvaddr_odc = resourcemgr->minfo.kvaddr + offset;
offset += (SIZE_ODC_INTERNAL_BUF * NUM_ODC_INTERNAL_BUF);
#else
resourcemgr->minfo.dvaddr_odc = 0;
resourcemgr->minfo.kvaddr_odc = 0;
#endif
#ifdef ENABLE_VDIS
resourcemgr->minfo.dvaddr_dis = resourcemgr->minfo.dvaddr + offset;
resourcemgr->minfo.kvaddr_dis = resourcemgr->minfo.kvaddr + offset;
offset += (SIZE_DIS_INTERNAL_BUF * NUM_DIS_INTERNAL_BUF);
#else
resourcemgr->minfo.dvaddr_dis = 0;
resourcemgr->minfo.kvaddr_dis = 0;
#endif
#ifdef ENABLE_DNR
resourcemgr->minfo.dvaddr_3dnr = resourcemgr->minfo.dvaddr + offset;
resourcemgr->minfo.kvaddr_3dnr = resourcemgr->minfo.kvaddr + offset;
offset += (SIZE_DNR_INTERNAL_BUF * NUM_DNR_INTERNAL_BUF);
#else
resourcemgr->minfo.dvaddr_3dnr = 0;
resourcemgr->minfo.kvaddr_3dnr = 0;
#endif
dbg_core("fimc_is_init_mem done\n");
p_err:
return ret;
}
#ifndef ENABLE_RESERVED_MEM
static int fimc_is_resourcemgr_deinitmem(struct fimc_is_resourcemgr *resourcemgr)
{
int ret = 0;
vb2_ion_private_free(resourcemgr->minfo.fw_cookie);
return ret;
}
#endif
int fimc_is_tmu_notifier(struct notifier_block *nb,
unsigned long state, void *data)
{
int ret = 0;
struct fimc_is_resourcemgr *resourcemgr;
resourcemgr = container_of(nb, struct fimc_is_resourcemgr, notifier);
switch (state) {
case ISP_NORMAL:
resourcemgr->tmu_state = ISP_NORMAL;
resourcemgr->limited_fps = 0;
break;
case ISP_COLD:
resourcemgr->tmu_state = ISP_COLD;
resourcemgr->limited_fps = 0;
break;
case ISP_THROTTLING1:
resourcemgr->tmu_state = ISP_THROTTLING1;
resourcemgr->limited_fps = 0;
break;
case ISP_THROTTLING2:
resourcemgr->tmu_state = ISP_THROTTLING2;
resourcemgr->limited_fps = 0;
warn("[RSC] THROTTLING2 : Unlimited FPS");
break;
case ISP_THROTTLING3:
resourcemgr->tmu_state = ISP_THROTTLING3;
resourcemgr->limited_fps = 15;
warn("[RSC] THROTTLING3 : Limited 15FPS");
break;
case ISP_THROTTLING4:
resourcemgr->tmu_state = ISP_THROTTLING4;
resourcemgr->limited_fps = 5;
warn("[RSC] THROTTLING4 : Limited 5FPS");
break;
case ISP_TRIPPING:
resourcemgr->tmu_state = ISP_TRIPPING;
resourcemgr->limited_fps = 5;
warn("[RSC] THROTTLING5 : Limited 5FPS");
break;
default:
err("[RSC] invalid tmu state(%ld)", state);
break;
}
return ret;
}
int fimc_is_resourcemgr_probe(struct fimc_is_resourcemgr *resourcemgr,
void *private_data)
{
int ret = 0;
BUG_ON(!resourcemgr);
BUG_ON(!private_data);
resourcemgr->private_data = private_data;
clear_bit(FIMC_IS_RM_COM_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_SS0_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_SS1_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_SS2_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_SS3_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_ISC_POWER_ON, &resourcemgr->state);
clear_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state);
atomic_set(&resourcemgr->rsccount, 0);
atomic_set(&resourcemgr->resource_sensor0.rsccount, 0);
atomic_set(&resourcemgr->resource_sensor1.rsccount, 0);
atomic_set(&resourcemgr->resource_ischain.rsccount, 0);
atomic_set(&resourcemgr->resource_companion.rsccount, 0);
resourcemgr->cluster0 = 0;
resourcemgr->cluster1 = 0;
resourcemgr->hal_version = IS_HAL_VER_1_0;
resourcemgr->tmu_state = ISP_NORMAL;
resourcemgr->limited_fps = 0;
resourcemgr->notifier.notifier_call = fimc_is_tmu_notifier;
resourcemgr->notifier.priority = 0;
ret = exynos_tmu_isp_add_notifier(&resourcemgr->notifier);
if (ret) {
probe_err("exynos_tmu_isp_add_notifier is fail(%d)", ret);
goto p_err;
}
#ifdef ENABLE_RESERVED_MEM
ret = fimc_is_resourcemgr_initmem(resourcemgr);
if (ret) {
probe_err("fimc_is_resourcemgr_initmem is fail(%d)", ret);
goto p_err;
}
#endif
#ifdef ENABLE_DVFS
/* dvfs controller init */
ret = fimc_is_dvfs_init(resourcemgr);
if (ret) {
probe_err("%s: fimc_is_dvfs_init failed!\n", __func__);
goto p_err;
}
#endif
p_err:
probe_info("[RSC] %s(%d)\n", __func__, ret);
return ret;
}
int fimc_is_resource_open(struct fimc_is_resourcemgr *resourcemgr, u32 rsc_type, void **device)
{
int ret = 0;
u32 stream;
void *result;
struct fimc_is_resource *resource;
struct fimc_is_core *core;
struct fimc_is_device_ischain *ischain;
BUG_ON(!resourcemgr);
BUG_ON(!resourcemgr->private_data);
BUG_ON(rsc_type >= RESOURCE_TYPE_MAX);
resource = GET_RESOURCE(resourcemgr, rsc_type);
core = (struct fimc_is_core *)resourcemgr->private_data;
result = NULL;
switch (rsc_type) {
case RESOURCE_TYPE_COMPANION:
result = &core->companion;
resource->pdev = core->companion.pdev;
break;
case RESOURCE_TYPE_SENSOR0:
result = &core->sensor[RESOURCE_TYPE_SENSOR0];
resource->pdev = core->sensor[RESOURCE_TYPE_SENSOR0].pdev;
break;
case RESOURCE_TYPE_SENSOR1:
result = &core->sensor[RESOURCE_TYPE_SENSOR1];
resource->pdev = core->sensor[RESOURCE_TYPE_SENSOR1].pdev;
break;
case RESOURCE_TYPE_ISCHAIN:
for (stream = 0; stream < FIMC_IS_STREAM_COUNT; ++stream) {
ischain = &core->ischain[stream];
if (!test_bit(FIMC_IS_ISCHAIN_OPEN, &ischain->state)) {
result = ischain;
resource->pdev = ischain->pdev;
break;
}
}
break;
default:
err("invalid resource type(%d)", rsc_type);
ret = -EINVAL;
goto p_err;
break;
}
if (device)
*device = result;
p_err:
dbg_resource("%s(0x%p)\n", __func__, *device);
return ret;
}
int fimc_is_resource_get(struct fimc_is_resourcemgr *resourcemgr, u32 rsc_type)
{
int ret = 0;
u32 rsccount;
struct fimc_is_resource *resource;
struct fimc_is_core *core;
BUG_ON(!resourcemgr);
BUG_ON(!resourcemgr->private_data);
BUG_ON(rsc_type >= RESOURCE_TYPE_MAX);
resource = GET_RESOURCE(resourcemgr, rsc_type);
core = (struct fimc_is_core *)resourcemgr->private_data;
rsccount = atomic_read(&core->rsccount);
if (!core->pdev) {
err("[RSC] pdev is NULL");
ret = -EMFILE;
goto p_err;
}
if (rsccount >= (FIMC_IS_STREAM_COUNT + FIMC_IS_VIDEO_SS3_NUM)) {
err("[RSC] Invalid rsccount(%d)", rsccount);
ret = -EMFILE;
goto p_err;
}
if (rsccount == 0) {
pm_stay_awake(&core->pdev->dev);
resourcemgr->cluster0 = 0;
resourcemgr->cluster1 = 0;
#ifdef ENABLE_DVFS
/* dvfs controller init */
ret = fimc_is_dvfs_init(resourcemgr);
if (ret) {
err("%s: fimc_is_dvfs_init failed!\n", __func__);
goto p_err;
}
#endif
}
if (atomic_read(&resource->rsccount) == 0) {
switch (rsc_type) {
case RESOURCE_TYPE_COMPANION:
#if defined(CONFIG_PM_RUNTIME)
pm_runtime_get_sync(&resource->pdev->dev);
#else
fimc_is_companion_runtime_resume(&resource->pdev->dev);
#endif
set_bit(FIMC_IS_RM_COM_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_SENSOR0:
#ifdef CONFIG_PM_RUNTIME
pm_runtime_get_sync(&resource->pdev->dev);
#else
fimc_is_sensor_runtime_resume(&resource->pdev->dev);
#endif
set_bit(FIMC_IS_RM_SS0_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_SENSOR1:
#ifdef CONFIG_PM_RUNTIME
pm_runtime_get_sync(&resource->pdev->dev);
#else
fimc_is_sensor_runtime_resume(&resource->pdev->dev);
#endif
set_bit(FIMC_IS_RM_SS1_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_ISCHAIN:
if (test_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state)) {
err("all resource is not power off(%lX)", resourcemgr->state);
ret = -EINVAL;
goto p_err;
}
#ifndef ENABLE_RESERVED_MEM
ret = fimc_is_resourcemgr_initmem(resourcemgr);
if (ret) {
err("fimc_is_resourcemgr_initmem is fail(%d)\n", ret);
goto p_err;
}
#endif
ret = fimc_is_debug_open(&resourcemgr->minfo);
if (ret) {
err("fimc_is_debug_open is fail(%d)", ret);
goto p_err;
}
ret = fimc_is_interface_open(&core->interface);
if (ret) {
err("fimc_is_interface_open is fail(%d)", ret);
goto p_err;
}
ret = fimc_is_ischain_power(&core->ischain[0], 1);
if (ret) {
err("fimc_is_ischain_power is fail(%d)", ret);
fimc_is_ischain_power(&core->ischain[0], 0);
goto p_err;
}
/* W/A for a lower version MCUCTL */
fimc_is_interface_reset(&core->interface);
#ifdef ENABLE_CLOCK_GATE
if (sysfs_debug.en_clk_gate &&
sysfs_debug.clk_gate_mode == CLOCK_GATE_MODE_HOST)
fimc_is_clk_gate_init(core);
#endif
set_bit(FIMC_IS_RM_ISC_POWER_ON, &resourcemgr->state);
set_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state);
break;
default:
err("[RSC] resource type(%d) is invalid", rsc_type);
BUG();
break;
}
}
atomic_inc(&resource->rsccount);
atomic_inc(&core->rsccount);
p_err:
info("[RSC] rsctype : %d, rsccount : %d\n", rsc_type, rsccount + 1);
return ret;
}
int fimc_is_resource_put(struct fimc_is_resourcemgr *resourcemgr, u32 rsc_type)
{
int ret = 0;
u32 rsccount;
struct fimc_is_resource *resource;
struct fimc_is_core *core;
BUG_ON(!resourcemgr);
BUG_ON(!resourcemgr->private_data);
BUG_ON(rsc_type >= RESOURCE_TYPE_MAX);
resource = GET_RESOURCE(resourcemgr, rsc_type);
core = (struct fimc_is_core *)resourcemgr->private_data;
rsccount = atomic_read(&core->rsccount);
if (!core->pdev) {
err("[RSC] pdev is NULL");
ret = -EMFILE;
goto p_err;
}
if (rsccount == 0) {
err("[RSC] Invalid rsccount(%d)\n", rsccount);
ret = -EMFILE;
goto p_err;
}
/* local update */
if (atomic_read(&resource->rsccount) == 1) {
/* clear hal version, default 1.0 */
resourcemgr->hal_version = IS_HAL_VER_1_0;
switch (rsc_type) {
case RESOURCE_TYPE_COMPANION:
#if defined(CONFIG_PM_RUNTIME)
pm_runtime_put_sync(&resource->pdev->dev);
#else
fimc_is_companion_runtime_suspend(&resource->pdev->dev);
#endif
clear_bit(FIMC_IS_RM_COM_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_SENSOR0:
#if defined(CONFIG_PM_RUNTIME)
pm_runtime_put_sync(&resource->pdev->dev);
#else
fimc_is_sensor_runtime_suspend(&resource->pdev->dev);
#endif
clear_bit(FIMC_IS_RM_SS0_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_SENSOR1:
#if defined(CONFIG_PM_RUNTIME)
pm_runtime_put_sync(&resource->pdev->dev);
#else
fimc_is_sensor_runtime_suspend(&resource->pdev->dev);
#endif
clear_bit(FIMC_IS_RM_SS1_POWER_ON, &resourcemgr->state);
break;
case RESOURCE_TYPE_ISCHAIN:
ret = fimc_is_itf_power_down(&core->interface);
if (ret)
err("power down cmd is fail(%d)", ret);
ret = fimc_is_ischain_power(&core->ischain[0], 0);
if (ret)
err("fimc_is_ischain_power is fail(%d)", ret);
ret = fimc_is_interface_close(&core->interface);
if (ret)
err("fimc_is_interface_close is fail(%d)", ret);
ret = fimc_is_debug_close();
if (ret)
err("fimc_is_debug_close is fail(%d)", ret);
#ifndef ENABLE_RESERVED_MEM
ret = fimc_is_resourcemgr_deinitmem(resourcemgr);
if (ret)
err("fimc_is_resourcemgr_deinitmem is fail(%d)", ret);
#endif
clear_bit(FIMC_IS_RM_ISC_POWER_ON, &resourcemgr->state);
break;
default:
err("[RSC] resource type(%d) is invalid", rsc_type);
BUG();
break;
}
}
/* global update */
if (atomic_read(&core->rsccount) == 1) {
u32 current_min, current_max;
current_min = (resourcemgr->cluster0 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
current_max = (resourcemgr->cluster0 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
if (current_min) {
C0MIN_QOS_DEL();
warn("[RSC] cluster0 minfreq is not removed(%dMhz)\n", current_min);
}
if (current_max) {
C0MAX_QOS_DEL();
warn("[RSC] cluster0 maxfreq is not removed(%dMhz)\n", current_max);
}
current_min = (resourcemgr->cluster1 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
current_max = (resourcemgr->cluster1 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
if (current_min) {
C1MIN_QOS_DEL();
warn("[RSC] cluster1 minfreq is not removed(%dMhz)\n", current_min);
}
if (current_max) {
C1MAX_QOS_DEL();
warn("[RSC] cluster1 maxfreq is not removed(%dMhz)\n", current_max);
}
resourcemgr->cluster0 = 0;
resourcemgr->cluster1 = 0;
ret = fimc_is_runtime_suspend_post(NULL);
if (ret)
err("fimc_is_runtime_suspend_post is fail(%d)", ret);
pm_relax(&core->pdev->dev);
clear_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state);
}
atomic_dec(&resource->rsccount);
atomic_dec(&core->rsccount);
p_err:
info("[RSC] rsctype : %d, rsccount : %d\n", rsc_type, rsccount - 1);
return ret;
}
int fimc_is_resource_ioctl(struct fimc_is_resourcemgr *resourcemgr, struct v4l2_control *ctrl)
{
int ret = 0;
BUG_ON(!resourcemgr);
BUG_ON(!ctrl);
switch (ctrl->id) {
/* APOLLO CPU0~3 */
case V4L2_CID_IS_DVFS_CLUSTER0:
{
u32 current_min, current_max;
u32 request_min, request_max;
current_min = (resourcemgr->cluster0 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
current_max = (resourcemgr->cluster0 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
request_min = (ctrl->value & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
request_max = (ctrl->value & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
if (current_min) {
if (request_min)
C0MIN_QOS_UPDATE(request_min);
else
C0MIN_QOS_DEL();
} else {
if (request_min)
C0MIN_QOS_ADD(request_min);
}
if (current_max) {
if (request_max)
C0MAX_QOS_UPDATE(request_max);
else
C0MAX_QOS_DEL();
} else {
if (request_max)
C0MAX_QOS_ADD(request_max);
}
info("[RSC] cluster0 minfreq : %dMhz\n", request_min);
info("[RSC] cluster0 maxfreq : %dMhz\n", request_max);
resourcemgr->cluster0 = (request_max << CLUSTER_MAX_SHIFT) | request_min;
}
break;
/* ATLAS CPU4~7 */
case V4L2_CID_IS_DVFS_CLUSTER1:
{
u32 current_min, current_max;
u32 request_min, request_max;
current_min = (resourcemgr->cluster1 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
current_max = (resourcemgr->cluster1 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
request_min = (ctrl->value & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT;
request_max = (ctrl->value & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT;
if (current_min) {
if (request_min)
C1MIN_QOS_UPDATE(request_min);
else
C1MIN_QOS_DEL();
} else {
if (request_min)
C1MIN_QOS_ADD(request_min);
}
if (current_max) {
if (request_max)
C1MAX_QOS_UPDATE(request_max);
else
C1MAX_QOS_DEL();
} else {
if (request_max)
C1MAX_QOS_ADD(request_max);
}
info("[RSC] cluster1 minfreq : %dMhz\n", request_min);
info("[RSC] cluster1 maxfreq : %dMhz\n", request_max);
resourcemgr->cluster1 = (request_max << CLUSTER_MAX_SHIFT) | request_min;
}
break;
}
return ret;
}
int fimc_is_logsync(struct fimc_is_interface *itf, u32 sync_id, u32 msg_test_id)
{
int ret = 0;
/* print kernel sync log */
log_sync(sync_id);
#ifdef ENABLE_FW_SYNC_LOG
ret = fimc_is_hw_msg_test(itf, sync_id, msg_test_id);
if (ret)
err("fimc_is_hw_msg_test(%d)", ret);
#endif
return ret;
}
|