msm: camera: csiphy: Refine MINK API usage for secure camera

Use MINK API for all the targets that support domain ID and
use legacy API for all other targets. In addition, use a
target based macro to not compile the MINK API for the
older targets where those APIs are not defined.

Change-Id: I0d8f05df6ca8126db1e3ad8456fe78aa77a33ebf
CRs-Fixed: 3529425
Signed-off-by: Vijay Kumar Tumati <quic_vtumati@quicinc.com>
This commit is contained in:
Vijay Kumar Tumati
2023-06-13 11:45:12 -07:00
committed by Camera Software Integration
parent a795d64c87
commit db988fcff4
6 changed files with 21 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ ccflags-y += -DCONFIG_SPECTRA_SENSOR=1
ccflags-y += -DCONFIG_SPECTRA_LLCC_STALING=1 ccflags-y += -DCONFIG_SPECTRA_LLCC_STALING=1
ccflags-y += -DCONFIG_SPECTRA_USE_RPMH_DRV_API=1 ccflags-y += -DCONFIG_SPECTRA_USE_RPMH_DRV_API=1
ccflags-y += -DCONFIG_SPECTRA_USE_CLK_CRM_API=1 ccflags-y += -DCONFIG_SPECTRA_USE_CLK_CRM_API=1
ccflags-y += -DCONFIG_DOMAIN_ID_SECURE_CAMERA=1
# External Dependencies # External Dependencies
KBUILD_CPPFLAGS += -DCONFIG_MSM_MMRM=1 KBUILD_CPPFLAGS += -DCONFIG_MSM_MMRM=1

View File

@@ -1019,6 +1019,7 @@ end:
return rc; return rc;
} }
#ifdef CONFIG_DOMAIN_ID_SECURE_CAMERA
static int cam_cpas_parse_domain_id_mapping(struct device_node *of_node, static int cam_cpas_parse_domain_id_mapping(struct device_node *of_node,
struct cam_cpas_private_soc *soc_private) struct cam_cpas_private_soc *soc_private)
{ {
@@ -1103,6 +1104,7 @@ err:
soc_private->domain_id_info.domain_id_entries = NULL; soc_private->domain_id_info.domain_id_entries = NULL;
return rc; return rc;
} }
#endif
static int cam_cpas_get_domain_id_support_clks(struct device_node *of_node, static int cam_cpas_get_domain_id_support_clks(struct device_node *of_node,
struct cam_hw_soc_info *soc_info, struct cam_cpas_private_soc *soc_private) struct cam_hw_soc_info *soc_info, struct cam_cpas_private_soc *soc_private)
@@ -1195,10 +1197,17 @@ int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw,
cam_cpas_get_hw_features(pdev, soc_private); cam_cpas_get_hw_features(pdev, soc_private);
#ifdef CONFIG_DOMAIN_ID_SECURE_CAMERA
/* get domain id mapping info */ /* get domain id mapping info */
rc = cam_cpas_parse_domain_id_mapping(of_node, soc_private); rc = cam_cpas_parse_domain_id_mapping(of_node, soc_private);
if (rc) if (rc)
return rc; return rc;
/* check if the domain ID configuration is available in the DTSI */
if (soc_private->domain_id_info.domain_id_supported == false) {
CAM_ERR(CAM_CPAS, "Domain ID configuration is expected for this target");
return -EINVAL;
}
#endif
soc_private->camnoc_axi_min_ib_bw = 0; soc_private->camnoc_axi_min_ib_bw = 0;
rc = of_property_read_u64(of_node, rc = of_property_read_u64(of_node,

View File

@@ -5333,7 +5333,7 @@ int cam_ife_csid_ver2_start(void *hw_priv, void *args,
*/ */
if ((csid_hw->sync_mode != CAM_ISP_HW_SYNC_SLAVE) && if ((csid_hw->sync_mode != CAM_ISP_HW_SYNC_SLAVE) &&
start_args->is_secure && start_args->is_secure &&
cam_is_mink_api_available()) csid_hw->flags.domain_id_security)
cam_ife_csid_ver2_send_secure_info(start_args, csid_hw); cam_ife_csid_ver2_send_secure_info(start_args, csid_hw);
/* /*

View File

@@ -487,10 +487,8 @@ static int cam_csiphy_update_secure_info(struct csiphy_device *csiphy_dev, int32
uint32_t cpas_version; uint32_t cpas_version;
int rc; int rc;
if (cam_is_mink_api_available()) { if (csiphy_dev->domain_id_security) {
CAM_DBG(CAM_CSIPHY, "Using MINK API for CSIPHY [%u], skipping legacy update", CAM_DBG(CAM_CSIPHY, "Target supports domain ID security, skipping legacy update");
csiphy_dev->soc_info.index);
return 0; return 0;
} }
@@ -1314,14 +1312,18 @@ static int cam_csiphy_program_secure_mode(struct csiphy_device *csiphy_dev,
} }
rc = cam_cpas_enable_clks_for_domain_id(true); rc = cam_cpas_enable_clks_for_domain_id(true);
if (rc) if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed to enable the Domain ID clocks");
return rc; return rc;
}
} }
rc = cam_csiphy_notify_secure_mode(csiphy_dev, protect, offset, is_shutdown); rc = cam_csiphy_notify_secure_mode(csiphy_dev, protect, offset, is_shutdown);
if (csiphy_dev->domain_id_security) { if (csiphy_dev->domain_id_security) {
cam_cpas_enable_clks_for_domain_id(false); if (cam_cpas_enable_clks_for_domain_id(false))
CAM_ERR(CAM_CSIPHY, "Failed to disable the Domain ID clocks");
if (!protect) if (!protect)
csiphy_dev->csiphy_info[offset].secure_info_updated = false; csiphy_dev->csiphy_info[offset].secure_info_updated = false;
} }

View File

@@ -318,15 +318,7 @@ void cam_free_clear(const void * ptr)
} }
#endif #endif
bool cam_is_mink_api_available(void) #ifdef CONFIG_DOMAIN_ID_SECURE_CAMERA
{
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
return true;
#else
return false;
#endif
}
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset, bool is_shutdown) bool protect, int32_t offset, bool is_shutdown)
{ {

View File

@@ -44,7 +44,7 @@
MODULE_IMPORT_NS(DMA_BUF); MODULE_IMPORT_NS(DMA_BUF);
#endif #endif
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE #ifdef CONFIG_DOMAIN_ID_SECURE_CAMERA
#include <linux/smcinvoke.h> #include <linux/smcinvoke.h>
#include <linux/IClientEnv.h> #include <linux/IClientEnv.h>
#include <linux/ITrustedCameraDriver.h> #include <linux/ITrustedCameraDriver.h>