msm: camera: utils: Migrate SCM calls
Migrate secure world calls to qcom scm driver. CRs-Fixed: 2564857 Change-Id: I8eb7498e4f80ff7ac1e22b7dcd364048e5338746 Signed-off-by: Elliot Berman <eberman@codeaurora.org> Signed-off-by: Karthik Jayakumar <kjayakum@codeaurora.org>
This commit is contained in:

committed by
Karthik Jayakumar

parent
50c8c09ead
commit
10891f6916
@@ -7,8 +7,7 @@
|
||||
#include <linux/timer.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <soc/qcom/scm.h>
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_cpas_hw_intf.h"
|
||||
#include "cam_cpas_hw.h"
|
||||
#include "cam_cpastop_hw.h"
|
||||
@@ -519,7 +518,7 @@ done:
|
||||
|
||||
static int cam_cpastop_poweron(struct cam_hw_info *cpas_hw)
|
||||
{
|
||||
int i, reg_val;
|
||||
int i;
|
||||
struct cam_cpas_hw_errata_wa_list *errata_wa_list =
|
||||
camnoc_info->errata_wa_list;
|
||||
struct cam_cpas_hw_errata_wa *errata_wa =
|
||||
@@ -546,9 +545,7 @@ static int cam_cpastop_poweron(struct cam_hw_info *cpas_hw)
|
||||
}
|
||||
|
||||
if (errata_wa->enable) {
|
||||
reg_val = scm_io_read(errata_wa->data.reg_info.offset);
|
||||
reg_val |= errata_wa->data.reg_info.value;
|
||||
scm_io_write(errata_wa->data.reg_info.offset, reg_val);
|
||||
cam_cpastop_scm_write(errata_wa);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -8,10 +8,10 @@
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include <soc/qcom/scm.h>
|
||||
#include <media/cam_custom.h>
|
||||
#include <media/cam_sync.h>
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_sync_api.h"
|
||||
#include "cam_smmu_api.h"
|
||||
#include "cam_req_mgr_workq.h"
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include <soc/qcom/scm.h>
|
||||
#include <media/cam_isp.h>
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_smmu_api.h"
|
||||
#include "cam_req_mgr_workq.h"
|
||||
#include "cam_isp_hw_mgr_intf.h"
|
||||
@@ -28,8 +28,6 @@
|
||||
|
||||
#define CAM_IFE_HW_ENTRIES_MAX 20
|
||||
|
||||
#define TZ_SVC_SMMU_PROGRAM 0x15
|
||||
#define TZ_SAFE_SYSCALL_ID 0x3
|
||||
#define CAM_IFE_SAFE_DISABLE 0
|
||||
#define CAM_IFE_SAFE_ENABLE 1
|
||||
#define SMMU_SE_IFE 0
|
||||
@@ -172,38 +170,6 @@ static int cam_ife_mgr_handle_reg_dump(struct cam_ife_hw_mgr_ctx *ctx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_ife_notify_safe_lut_scm(bool safe_trigger)
|
||||
{
|
||||
uint32_t camera_hw_version, rc = 0;
|
||||
struct scm_desc desc = {0};
|
||||
|
||||
rc = cam_cpas_get_cpas_hw_version(&camera_hw_version);
|
||||
if (!rc) {
|
||||
switch (camera_hw_version) {
|
||||
case CAM_CPAS_TITAN_170_V100:
|
||||
case CAM_CPAS_TITAN_170_V110:
|
||||
case CAM_CPAS_TITAN_175_V100:
|
||||
|
||||
desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL);
|
||||
desc.args[0] = SMMU_SE_IFE;
|
||||
desc.args[1] = safe_trigger;
|
||||
|
||||
CAM_DBG(CAM_ISP, "Safe scm call %d", safe_trigger);
|
||||
if (scm_call2(SCM_SIP_FNID(TZ_SVC_SMMU_PROGRAM,
|
||||
TZ_SAFE_SYSCALL_ID), &desc)) {
|
||||
CAM_ERR(CAM_ISP,
|
||||
"scm call to Enable Safe failed");
|
||||
rc = -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_ife_mgr_get_hw_caps(void *hw_mgr_priv,
|
||||
void *hw_caps_args)
|
||||
{
|
||||
|
@@ -10,10 +10,6 @@
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if KERNEL_VERSION(5, 4, 0) > LINUX_VERSION_CODE
|
||||
#include <linux/ion_kernel.h>
|
||||
#endif
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_req_mgr_util.h"
|
||||
#include "cam_mem_mgr.h"
|
||||
|
@@ -4,21 +4,17 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <dt-bindings/msm/msm-camera.h>
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_csiphy_core.h"
|
||||
#include "cam_csiphy_dev.h"
|
||||
#include "cam_csiphy_soc.h"
|
||||
#include "cam_common_util.h"
|
||||
#include "cam_packet_util.h"
|
||||
|
||||
#include <dt-bindings/msm/msm-camera.h>
|
||||
|
||||
#include <soc/qcom/scm.h>
|
||||
#include <cam_mem_mgr.h>
|
||||
#include <cam_cpas_api.h>
|
||||
|
||||
#define SCM_SVC_CAMERASS 0x18
|
||||
#define SECURE_SYSCALL_ID 0x6
|
||||
#define SECURE_SYSCALL_ID_2 0x7
|
||||
#include "cam_mem_mgr.h"
|
||||
#include "cam_cpas_api.h"
|
||||
|
||||
#define LANE_MASK_2PH 0x1F
|
||||
#define LANE_MASK_3PH 0x7
|
||||
@@ -26,29 +22,6 @@
|
||||
static int csiphy_dump;
|
||||
module_param(csiphy_dump, int, 0644);
|
||||
|
||||
static int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
|
||||
bool protect, int32_t offset)
|
||||
{
|
||||
struct scm_desc desc = {0};
|
||||
|
||||
if (offset >= CSIPHY_MAX_INSTANCES) {
|
||||
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL);
|
||||
desc.args[0] = protect;
|
||||
desc.args[1] = csiphy_dev->csiphy_cpas_cp_reg_mask[offset];
|
||||
|
||||
if (scm_call2(SCM_SIP_FNID(SCM_SVC_CAMERASS, SECURE_SYSCALL_ID_2),
|
||||
&desc)) {
|
||||
CAM_ERR(CAM_CSIPHY, "scm call to hypervisor failed");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t cam_csiphy_get_instance_offset(
|
||||
struct csiphy_device *csiphy_dev,
|
||||
int32_t dev_handle)
|
||||
|
@@ -15,8 +15,6 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/genalloc.h>
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include <soc/qcom/scm.h>
|
||||
#include <soc/qcom/secure_buffer.h>
|
||||
|
||||
#include <media/cam_req_mgr.h>
|
||||
|
@@ -8,8 +8,9 @@
|
||||
|
||||
#include "cam_compat.h"
|
||||
#include "cam_debug_util.h"
|
||||
#include "cam_cpas_api.h"
|
||||
|
||||
#if KERNEL_VERSION(5, 4, 0) >= LINUX_VERSION_CODE
|
||||
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE
|
||||
int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -47,6 +48,54 @@ void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length)
|
||||
{
|
||||
iounmap(icp_fw->fw_kva);
|
||||
}
|
||||
|
||||
int cam_ife_notify_safe_lut_scm(bool safe_trigger)
|
||||
{
|
||||
const uint32_t smmu_se_ife = 0;
|
||||
uint32_t camera_hw_version, rc = 0;
|
||||
|
||||
rc = cam_cpas_get_cpas_hw_version(&camera_hw_version);
|
||||
if (!rc && qcom_scm_smmu_notify_secure_lut(smmu_se_ife, safe_trigger)) {
|
||||
switch (camera_hw_version) {
|
||||
case CAM_CPAS_TITAN_170_V100:
|
||||
case CAM_CPAS_TITAN_170_V110:
|
||||
case CAM_CPAS_TITAN_175_V100:
|
||||
CAM_ERR(CAM_ISP, "scm call to enable safe failed");
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
|
||||
bool protect, int32_t offset)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (offset >= CSIPHY_MAX_INSTANCES) {
|
||||
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
|
||||
rc = -EINVAL;
|
||||
} else if (qcom_scm_camera_protect_phy_lanes(protect,
|
||||
csiphy_dev->csiphy_cpas_cp_reg_mask[offset])) {
|
||||
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa)
|
||||
{
|
||||
int reg_val;
|
||||
|
||||
qcom_scm_io_readl(errata_wa->data.reg_info.offset, ®_val);
|
||||
reg_val |= errata_wa->data.reg_info.value;
|
||||
qcom_scm_io_writel(errata_wa->data.reg_info.offset, reg_val);
|
||||
}
|
||||
#else
|
||||
int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length)
|
||||
{
|
||||
@@ -68,4 +117,61 @@ void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length)
|
||||
dma_free_coherent(icp_fw->fw_dev, fw_length, icp_fw->fw_kva,
|
||||
icp_fw->fw_hdl);
|
||||
}
|
||||
|
||||
int cam_ife_notify_safe_lut_scm(bool safe_trigger)
|
||||
{
|
||||
const uint32_t smmu_se_ife = 0;
|
||||
uint32_t camera_hw_version, rc = 0;
|
||||
struct scm_desc description = {
|
||||
.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL),
|
||||
.args[0] = smmu_se_ife,
|
||||
.args[1] = safe_trigger,
|
||||
};
|
||||
|
||||
rc = cam_cpas_get_cpas_hw_version(&camera_hw_version);
|
||||
if (!rc && scm_call2(SCM_SIP_FNID(0x15, 0x3), &description)) {
|
||||
switch (camera_hw_version) {
|
||||
case CAM_CPAS_TITAN_170_V100:
|
||||
case CAM_CPAS_TITAN_170_V110:
|
||||
case CAM_CPAS_TITAN_175_V100:
|
||||
CAM_ERR(CAM_ISP, "scm call to enable safe failed");
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
|
||||
bool protect, int32_t offset)
|
||||
{
|
||||
int rc = 0;
|
||||
struct scm_desc description = {
|
||||
.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL),
|
||||
.args[0] = protect,
|
||||
.args[1] = csiphy_dev->csiphy_cpas_cp_reg_mask[offset],
|
||||
};
|
||||
|
||||
if (offset >= CSIPHY_MAX_INSTANCES) {
|
||||
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
|
||||
rc = -EINVAL;
|
||||
} else if (scm_call2(SCM_SIP_FNID(0x18, 0x7), &description)) {
|
||||
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa)
|
||||
{
|
||||
int reg_val;
|
||||
|
||||
reg_val = scm_io_read(errata_wa->data.reg_info.offset);
|
||||
reg_val |= errata_wa->data.reg_info.value;
|
||||
scm_io_write(errata_wa->data.reg_info.offset, reg_val);
|
||||
}
|
||||
#endif
|
||||
|
@@ -8,15 +8,20 @@
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if KERNEL_VERSION(5, 4, 0) >= LINUX_VERSION_CODE
|
||||
#include "cam_csiphy_dev.h"
|
||||
#include "cam_cpastop_hw.h"
|
||||
|
||||
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE
|
||||
|
||||
#include <linux/msm_ion.h>
|
||||
#include <linux/ion.h>
|
||||
#include <linux/qcom_scm.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <linux/msm_ion.h>
|
||||
#include <linux/ion_kernel.h>
|
||||
#include <soc/qcom/scm.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,5 +33,9 @@ struct cam_fw_alloc_info {
|
||||
|
||||
int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length);
|
||||
void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length);
|
||||
void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa);
|
||||
int cam_ife_notify_safe_lut_scm(bool safe_trigger);
|
||||
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
|
||||
bool protect, int32_t offset);
|
||||
|
||||
#endif /* _CAM_COMPAT_H_ */
|
||||
|
Reference in New Issue
Block a user