Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 1 | /* 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 Kalavala | adc6ce3 | 2017-07-17 17:19:11 -0700 | [diff] [blame^] | 21 | #include "cam_debug_util.h" |
Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 22 | |
| 23 | static 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 Kalavala | adc6ce3 | 2017-07-17 17:19:11 -0700 | [diff] [blame^] | 29 | CAM_ERR(CAM_ICP, "get ipe dt prop is failed"); |
Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 30 | |
| 31 | return rc; |
| 32 | } |
| 33 | |
| 34 | static 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 | |
| 46 | int 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 | |
| 63 | int cam_ipe_enable_soc_resources(struct cam_hw_soc_info *soc_info) |
| 64 | { |
| 65 | int rc = 0; |
| 66 | |
Pavan Kumar Chilamkurthi | 7e7607b | 2017-06-22 20:02:50 -0700 | [diff] [blame] | 67 | rc = cam_soc_util_enable_platform_resource(soc_info, true, |
| 68 | CAM_TURBO_VOTE, false); |
Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 69 | if (rc) { |
Lakshmi Narayana Kalavala | adc6ce3 | 2017-07-17 17:19:11 -0700 | [diff] [blame^] | 70 | CAM_ERR(CAM_ICP, "enable platform failed"); |
Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 71 | return rc; |
| 72 | } |
| 73 | |
| 74 | return rc; |
| 75 | } |
| 76 | |
| 77 | int 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 Kalavala | adc6ce3 | 2017-07-17 17:19:11 -0700 | [diff] [blame^] | 83 | CAM_ERR(CAM_ICP, "enable platform failed"); |
Lakshmi Narayana Kalavala | 85c4035 | 2017-05-15 16:19:13 -0700 | [diff] [blame] | 84 | |
| 85 | return rc; |
| 86 | } |