Эх сурвалжийг харах

msm: camera: isp: Rearrange the rt-wrapper-base property

Rearrange the rt-wrapper property in order to
not request for the ioremap for the rt-wrapper region
unnecessarily and also to make the code more general
for upcoming targets.

CRs-Fixed: 3060818
Change-Id: I45da335c1e1c372229388350612f659720326066
Signed-off-by: Jigar Agrawal <[email protected]>
Jigar Agrawal 3 жил өмнө
parent
commit
132e366145

+ 17 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_common.c

@@ -682,6 +682,7 @@ int cam_ife_csid_get_base(struct cam_hw_soc_info *soc_info,
 	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
 	size_t                           size = 0;
 	uint32_t                          mem_base = 0;
+	struct cam_csid_soc_private      *soc_private;
 
 
 	if (arg_size != sizeof(struct cam_isp_hw_get_cmd_update)) {
@@ -689,11 +690,17 @@ int cam_ife_csid_get_base(struct cam_hw_soc_info *soc_info,
 		return -EINVAL;
 	}
 
-	if (!cdm_args || !cdm_args->res) {
+	if (!cdm_args || !cdm_args->res || !soc_info) {
 		CAM_ERR(CAM_ISP, "Error, Invalid args");
 		return -EINVAL;
 	}
 
+	soc_private = soc_info->soc_private;
+	if (!soc_private) {
+		CAM_ERR(CAM_ISP, "soc_private is null");
+		return -EINVAL;
+	}
+
 	cdm_util_ops =
 		(struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
 
@@ -711,14 +718,19 @@ int cam_ife_csid_get_base(struct cam_hw_soc_info *soc_info,
 	}
 
 	mem_base = CAM_SOC_GET_REG_MAP_CAM_BASE(soc_info, base_id);
-	if (cdm_args->cdm_id == CAM_CDM_RT)
-		mem_base -= CAM_SOC_GET_REG_MAP_CAM_BASE(soc_info, RT_BASE_IDX);
+	if (cdm_args->cdm_id == CAM_CDM_RT) {
+		if (!soc_private->rt_wrapper_base) {
+			CAM_ERR(CAM_ISP, "rt_wrapper_base_addr is null");
+			return -EINVAL;
+		}
+
+		mem_base -= soc_private->rt_wrapper_base;
+	}
 
 	CAM_DBG(CAM_ISP, "core %d mem_base 0x%x, cdm_id:%u",
 		soc_info->index, mem_base, cdm_args->cdm_id);
 
-	cdm_util_ops->cdm_write_changebase(
-	cdm_args->cmd.cmd_buf_addr, mem_base);
+	cdm_util_ops->cdm_write_changebase(cdm_args->cmd.cmd_buf_addr, mem_base);
 	cdm_args->cmd.used_bytes = (size * 4);
 
 	return 0;

+ 8 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c

@@ -37,6 +37,14 @@ static int cam_ife_csid_get_dt_properties(struct cam_hw_soc_info *soc_info)
 		soc_private->is_ife_csid_lite = true;
 	}
 
+	rc = of_property_read_u32(of_node, "rt-wrapper-base", &soc_private->rt_wrapper_base);
+	if (rc) {
+		soc_private->rt_wrapper_base = 0;
+		CAM_DBG(CAM_ISP, "rc: %d Error reading rt_wrapper_base for core_idx: %u",
+			rc, soc_info->index);
+		rc = 0;
+	}
+
 	return rc;
 }
 

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h

@@ -16,12 +16,14 @@
  * @cpas_handle:             Handle returned on registering with CPAS driver.
  *                           This handle is used for all further interface
  *                           with CPAS.
+ * @rt_wrapper_base:        Base address of the RT-Wrapper if the hw is in rt-wrapper
  * @is_ife_csid_lite:        Flag to indicate Whether a full csid or a Lite csid
  * @max_width_enabled:       Flag to enable max width restriction
  * @max_width:               Maxinum allowed width
  */
 struct cam_csid_soc_private {
 	uint32_t cpas_handle;
+	uint32_t rt_wrapper_base;
 	bool     is_ife_csid_lite;
 	bool     max_width_enabled;
 	uint32_t max_width;

+ 0 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_sfe_hw_intf.h

@@ -11,7 +11,6 @@
 #include "cam_cpas_api.h"
 
 #define SFE_CORE_BASE_IDX           0
-#define SFE_RT_CDM_BASE_IDX         1
 #define CAM_SFE_HW_NUM_MAX          2
 
 enum cam_sfe_core_id {

+ 9 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_soc.c

@@ -21,6 +21,15 @@ static int cam_sfe_get_dt_properties(struct cam_hw_soc_info *soc_info)
 		goto end;
 	}
 
+	rc = of_property_read_u32(pdev->dev.of_node, "rt-wrapper-base",
+		&soc_private->rt_wrapper_base);
+	if (rc) {
+		soc_private->rt_wrapper_base = 0;
+		CAM_DBG(CAM_ISP, "rc: %d Error reading rt_wrapper_base for core_idx: %u",
+			rc, soc_info->index);
+		rc = 0;
+	}
+
 	soc_private->num_pid = 0;
 	num_pid = of_property_count_u32_elems(pdev->dev.of_node, "cam_hw_pid");
 	CAM_DBG(CAM_SFE, "sfe:%d pid count %d", soc_info->index, num_pid);

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_soc.h

@@ -18,12 +18,14 @@
  *                           This handle is used for all further interface
  *                           with CPAS.
  * @cpas_version:            CPAS version
+ * @* @rt_wrapper_base:      Base address of the RT-Wrapper if the hw is in rt-wrapper
  * @num_pid:                 Number of pids of sfe
  * @pid:                     SFE pid values list
  */
 struct cam_sfe_soc_private {
 	uint32_t    cpas_handle;
 	uint32_t    cpas_version;
+	uint32_t    rt_wrapper_base;
 	uint32_t    num_pid;
 	uint32_t    pid[CAM_ISP_HW_MAX_PID_VAL];
 };

+ 15 - 6
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.c

@@ -637,6 +637,7 @@ static int cam_sfe_top_get_base(
 	uint32_t                          mem_base = 0;
 	struct cam_isp_hw_get_cmd_update *cdm_args  = cmd_args;
 	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
+	struct cam_sfe_soc_private       *soc_private;
 
 	if (arg_size != sizeof(struct cam_isp_hw_get_cmd_update)) {
 		CAM_ERR(CAM_SFE, "Invalid cmd size");
@@ -649,6 +650,12 @@ static int cam_sfe_top_get_base(
 		return -EINVAL;
 	}
 
+	soc_private = top_priv->common_data.soc_info->soc_private;
+	if (!soc_private) {
+		CAM_ERR(CAM_ISP, "soc_private is null");
+		return -EINVAL;
+	}
+
 	cdm_util_ops =
 		(struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
 
@@ -668,17 +675,19 @@ static int cam_sfe_top_get_base(
 		top_priv->common_data.soc_info,
 		SFE_CORE_BASE_IDX);
 
-	if (cdm_args->cdm_id == CAM_CDM_RT)
-		mem_base -= CAM_SOC_GET_REG_MAP_CAM_BASE(
-			top_priv->common_data.soc_info,
-			SFE_RT_CDM_BASE_IDX);
+	if (cdm_args->cdm_id == CAM_CDM_RT) {
+		if (!soc_private->rt_wrapper_base) {
+			CAM_ERR(CAM_ISP, "rt_wrapper_base_addr is null");
+			return -EINVAL;
+		}
+		mem_base -= soc_private->rt_wrapper_base;
+	}
 
 	CAM_DBG(CAM_SFE, "core %d mem_base 0x%x, CDM Id: %d",
 		top_priv->common_data.soc_info->index, mem_base,
 		cdm_args->cdm_id);
 
-	cdm_util_ops->cdm_write_changebase(
-	cdm_args->cmd.cmd_buf_addr, mem_base);
+	cdm_util_ops->cdm_write_changebase(cdm_args->cmd.cmd_buf_addr, mem_base);
 	cdm_args->cmd.used_bytes = (size * 4);
 
 	return 0;

+ 8 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c

@@ -51,6 +51,14 @@ static int cam_vfe_get_dt_properties(struct cam_hw_soc_info *soc_info)
 		return rc;
 	}
 
+	rc = of_property_read_u32(of_node, "rt-wrapper-base", &vfe_soc_private->rt_wrapper_base);
+	if (rc) {
+		vfe_soc_private->rt_wrapper_base = 0;
+		CAM_DBG(CAM_ISP, "rc: %d Error reading rt_wrapper_base for core_idx: %u",
+			rc, soc_info->index);
+		rc = 0;
+	}
+
 	vfe_soc_private->is_ife_lite = false;
 	if (strnstr(soc_info->compatible, "lite",
 		strlen(soc_info->compatible)) != NULL) {

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.h

@@ -22,6 +22,7 @@
  *                           This handle is used for all further interface
  *                           with CPAS.
  * @cpas_version:            Has cpas version read from Hardware
+ * @rt_wrapper_base:         Base address of the RT-Wrapper if the hw is in rt-wrapper
  * @dsp_clk_index:           DSP clk index in optional clocks
  * @ubwc_static_ctrl:        UBWC static control configuration
  * @is_ife_lite:             Flag to indicate full vs lite IFE
@@ -32,6 +33,7 @@
 struct cam_vfe_soc_private {
 	uint32_t    cpas_handle;
 	uint32_t    cpas_version;
+	uint32_t    rt_wrapper_base;
 	int32_t     dsp_clk_index;
 	uint32_t    ubwc_static_ctrl[UBWC_STATIC_CONFIG_MAX];
 	bool        is_ife_lite;

+ 16 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver4.c

@@ -182,6 +182,7 @@ static int cam_vfe_top_ver4_mux_get_base(struct cam_vfe_top_ver4_priv *top_priv,
 	uint32_t                          mem_base = 0;
 	struct cam_isp_hw_get_cmd_update *cdm_args  = cmd_args;
 	struct cam_cdm_utils_ops         *cdm_util_ops = NULL;
+	struct cam_vfe_soc_private       *soc_private;
 
 	if (arg_size != sizeof(struct cam_isp_hw_get_cmd_update)) {
 		CAM_ERR(CAM_ISP, "Error, Invalid cmd size");
@@ -194,6 +195,12 @@ static int cam_vfe_top_ver4_mux_get_base(struct cam_vfe_top_ver4_priv *top_priv,
 		return -EINVAL;
 	}
 
+	soc_private = top_priv->top_common.soc_info->soc_private;
+	if (!soc_private) {
+		CAM_ERR(CAM_ISP, "soc_private is null");
+		return -EINVAL;
+	}
+
 	cdm_util_ops =
 		(struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
 
@@ -212,16 +219,20 @@ static int cam_vfe_top_ver4_mux_get_base(struct cam_vfe_top_ver4_priv *top_priv,
 
 	mem_base = CAM_SOC_GET_REG_MAP_CAM_BASE(
 		top_priv->top_common.soc_info, VFE_CORE_BASE_IDX);
-	if (cdm_args->cdm_id == CAM_CDM_RT)
-		mem_base -= CAM_SOC_GET_REG_MAP_CAM_BASE(
-			top_priv->top_common.soc_info, RT_BASE_IDX);
+	if (cdm_args->cdm_id == CAM_CDM_RT) {
+		if (!soc_private->rt_wrapper_base) {
+			CAM_ERR(CAM_ISP, "rt_wrapper_base_addr is null");
+			return -EINVAL;
+		}
+
+		mem_base -= soc_private->rt_wrapper_base;
+	}
 
 	CAM_DBG(CAM_ISP, "core %d mem_base 0x%x, cdm_id: %u",
 		top_priv->top_common.soc_info->index, mem_base,
 		cdm_args->cdm_id);
 
-	cdm_util_ops->cdm_write_changebase(
-		cdm_args->cmd.cmd_buf_addr, mem_base);
+	cdm_util_ops->cdm_write_changebase(cdm_args->cmd.cmd_buf_addr, mem_base);
 	cdm_args->cmd.used_bytes = (size * 4);
 
 	return 0;