msm: camera: cpas: Domain-id mapping based on DT
This change involves the parsing of domain-id mapping from DT and storage of this information in struct cam_cpas_private_soc. This information will be relayed to userspace in an ioctl call, and also exposed to the IFE driver within the kernel. CRs-Fixed: 3215167 Change-Id: I68d914fd4b84bc029edccd5cd1d2e2733fa32fcd Signed-off-by: Li Sha Lim <quic_lishlim@quicinc.com>
This commit is contained in:

committed by
Camera Software Integration

parent
f0bb6bd5aa
commit
96c42c1a2b
@@ -865,6 +865,82 @@ end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_cpas_parse_domain_id_mapping(struct device_node *of_node,
|
||||
struct cam_cpas_private_soc *soc_private)
|
||||
{
|
||||
int count, i, rc = 0;
|
||||
|
||||
soc_private->domain_id_info.num_domain_ids = 0;
|
||||
soc_private->domain_id_info.domain_id_supported = false;
|
||||
soc_private->domain_id_info.domain_id_entries = NULL;
|
||||
count = of_property_count_u32_elems(of_node, "domain-id");
|
||||
if (count <= 0) {
|
||||
CAM_DBG(CAM_CPAS, "No domain-id mapping found, count: %d", count);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* This property will always be specified in pairs */
|
||||
if (count % 2) {
|
||||
CAM_ERR(CAM_CPAS,
|
||||
"Mismatch in domain-id mapping, found %d number of entries", count);
|
||||
rc = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
soc_private->domain_id_info.num_domain_ids = count / 2;
|
||||
soc_private->domain_id_info.domain_id_entries =
|
||||
kcalloc(soc_private->domain_id_info.num_domain_ids,
|
||||
sizeof(struct cam_cpas_domain_id_mapping), GFP_KERNEL);
|
||||
if (!soc_private->domain_id_info.domain_id_entries) {
|
||||
CAM_ERR(CAM_CPAS,
|
||||
"Error allocating memory for %u domain-id mapping(s)",
|
||||
soc_private->domain_id_info.num_domain_ids);
|
||||
rc = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < soc_private->domain_id_info.num_domain_ids; i++) {
|
||||
struct cam_cpas_domain_id_mapping *domain_id_entry =
|
||||
&soc_private->domain_id_info.domain_id_entries[i];
|
||||
|
||||
rc = of_property_read_u32_index(of_node, "domain-id",
|
||||
(i * 2), &domain_id_entry->domain_type);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_CPAS, "Error reading domain-id type entry at pos %d", i);
|
||||
rc = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (domain_id_entry->domain_type > CAM_CPAS_NON_SECURE_DOMAIN) {
|
||||
CAM_ERR(CAM_CPAS, "Unexpected domain id type: %u",
|
||||
domain_id_entry->domain_type);
|
||||
rc = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = of_property_read_u32_index(of_node, "domain-id",
|
||||
((i * 2) + 1), &domain_id_entry->mapping_id);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_CPAS, "Error reading domain-id mapping id at pos %d", i);
|
||||
rc = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_CPAS, "Domain-id type: %u, mapping: %u at pos: %d",
|
||||
domain_id_entry->domain_type, domain_id_entry->mapping_id, i);
|
||||
}
|
||||
|
||||
soc_private->domain_id_info.domain_id_supported = true;
|
||||
|
||||
return rc;
|
||||
|
||||
err:
|
||||
soc_private->domain_id_info.num_domain_ids = 0;
|
||||
kfree(soc_private->domain_id_info.domain_id_entries);
|
||||
soc_private->domain_id_info.domain_id_entries = NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw,
|
||||
struct platform_device *pdev, struct cam_cpas_private_soc *soc_private)
|
||||
{
|
||||
@@ -892,6 +968,11 @@ int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw,
|
||||
|
||||
cam_cpas_get_hw_features(pdev, soc_private);
|
||||
|
||||
/* get domain id mapping info */
|
||||
rc = cam_cpas_parse_domain_id_mapping(of_node, soc_private);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
soc_private->camnoc_axi_min_ib_bw = 0;
|
||||
rc = of_property_read_u64(of_node,
|
||||
"camnoc-axi-min-ib-bw",
|
||||
@@ -1353,6 +1434,8 @@ int cam_cpas_soc_deinit_resources(struct cam_hw_soc_info *soc_info)
|
||||
CAM_ERR(CAM_CPAS, "Error Put optional clk failed rc=%d", rc);
|
||||
}
|
||||
|
||||
kfree(soc_private->domain_id_info.domain_id_entries);
|
||||
|
||||
rc = cam_soc_util_release_platform_resource(soc_info);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_CPAS, "release platform failed, rc=%d", rc);
|
||||
|
@@ -121,6 +121,31 @@ struct cam_cpas_smart_qos_info {
|
||||
struct cam_cpas_tree_node *rt_wr_niu_node[CAM_CPAS_MAX_RT_WR_NIU_NODES];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cam_cpas_domain_id_mapping : Domain id mapping
|
||||
*
|
||||
* @domain_type: Domain type, currently defined as two,
|
||||
* secure/non-secure. This will be expanded
|
||||
* later to more types, and correspnding ID
|
||||
* @mapping_id: ID of domain type
|
||||
*/
|
||||
struct cam_cpas_domain_id_mapping {
|
||||
uint32_t domain_type;
|
||||
uint32_t mapping_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cam_cpas_domain_id_info : Stores all information related
|
||||
* to domain-id support
|
||||
* @domain_id_entries: Stores mapping between domain types and their IDs
|
||||
* @num_domain_ids: Num of domain id types found from dtsi
|
||||
* @domain_id_supported: Whether domain id is supported
|
||||
*/
|
||||
struct cam_cpas_domain_id_info {
|
||||
struct cam_cpas_domain_id_mapping *domain_id_entries;
|
||||
uint32_t num_domain_ids;
|
||||
bool domain_id_supported;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cam_cpas_private_soc : CPAS private DT info
|
||||
@@ -151,6 +176,7 @@ struct cam_cpas_smart_qos_info {
|
||||
* @enable_cam_ddr_drv: Whether to enable Camera DDR DRV on current chipset
|
||||
* @smart_qos_info: Pointer to smart qos info
|
||||
* @icp_clk_index: Index of optional icp clk
|
||||
* @domain_id_info: Stores all information related to domain id support
|
||||
*/
|
||||
struct cam_cpas_private_soc {
|
||||
const char *arch_compat;
|
||||
@@ -177,6 +203,7 @@ struct cam_cpas_private_soc {
|
||||
bool enable_cam_ddr_drv;
|
||||
struct cam_cpas_smart_qos_info *smart_qos_info;
|
||||
int32_t icp_clk_index;
|
||||
struct cam_cpas_domain_id_info domain_id_info;
|
||||
};
|
||||
|
||||
void cam_cpas_util_debug_parse_data(struct cam_cpas_private_soc *soc_private);
|
||||
|
@@ -122,4 +122,8 @@
|
||||
#define CAM_CPAS_PORT_DRV_2 3
|
||||
#define CAM_CPAS_PORT_DRV_DYN 32
|
||||
|
||||
/* Domain ID types */
|
||||
#define CAM_CPAS_SECURE_DOMAIN 0
|
||||
#define CAM_CPAS_NON_SECURE_DOMAIN 1
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user