blob: 26dd6d239983a89f6fd5522d4f89695c1bc3f80f [file] [log] [blame]
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -07001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/io.h>
14#include <linux/of.h>
15#include <linux/platform_device.h>
16#include <linux/dma-buf.h>
17#include <media/cam_defs.h>
18#include <media/cam_icp.h>
19#include "ipe_soc.h"
20#include "cam_soc_util.h"
Lakshmi Narayana Kalavalaadc6ce32017-07-17 17:19:11 -070021#include "cam_debug_util.h"
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070022
23static int cam_ipe_get_dt_properties(struct cam_hw_soc_info *soc_info)
24{
25 int rc = 0;
26
27 rc = cam_soc_util_get_dt_properties(soc_info);
28 if (rc < 0)
Lakshmi Narayana Kalavalaadc6ce32017-07-17 17:19:11 -070029 CAM_ERR(CAM_ICP, "get ipe dt prop is failed");
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070030
31 return rc;
32}
33
34static int cam_ipe_request_platform_resource(
35 struct cam_hw_soc_info *soc_info,
36 irq_handler_t ipe_irq_handler, void *irq_data)
37{
38 int rc = 0;
39
40 rc = cam_soc_util_request_platform_resource(soc_info, ipe_irq_handler,
41 irq_data);
42
43 return rc;
44}
45
46int cam_ipe_init_soc_resources(struct cam_hw_soc_info *soc_info,
47 irq_handler_t ipe_irq_handler, void *irq_data)
48{
49 int rc = 0;
50
51 rc = cam_ipe_get_dt_properties(soc_info);
52 if (rc < 0)
53 return rc;
54
55 rc = cam_ipe_request_platform_resource(soc_info, ipe_irq_handler,
56 irq_data);
57 if (rc < 0)
58 return rc;
59
60 return rc;
61}
62
63int cam_ipe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
64{
65 int rc = 0;
66
Pavan Kumar Chilamkurthi7e7607b2017-06-22 20:02:50 -070067 rc = cam_soc_util_enable_platform_resource(soc_info, true,
68 CAM_TURBO_VOTE, false);
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070069 if (rc) {
Lakshmi Narayana Kalavalaadc6ce32017-07-17 17:19:11 -070070 CAM_ERR(CAM_ICP, "enable platform failed");
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070071 return rc;
72 }
73
74 return rc;
75}
76
77int cam_ipe_disable_soc_resources(struct cam_hw_soc_info *soc_info)
78{
79 int rc = 0;
80
81 rc = cam_soc_util_disable_platform_resource(soc_info, true, false);
82 if (rc)
Lakshmi Narayana Kalavalaadc6ce32017-07-17 17:19:11 -070083 CAM_ERR(CAM_ICP, "enable platform failed");
Lakshmi Narayana Kalavala85c40352017-05-15 16:19:13 -070084
85 return rc;
86}