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>
此提交包含在:
Elliot Berman
2019-10-14 10:05:54 -07:00
提交者 Karthik Jayakumar
父節點 50c8c09ead
當前提交 10891f6916
共有 8 個檔案被更改,包括 128 行新增83 行删除

查看文件

@@ -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, &reg_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