Browse Source

msm: camera: isp: Update clock value during init based on blob

Take the clock blob value into consideration during tfe init phase.
Set default clock in absence of clock blob from UMD.

CRs-Fixed: 3247771
Change-Id: I6d5b17b69066fa42293bcb8192c833cb57be0206
Signed-off-by: Ayush Kumar <[email protected]>
Ayush Kumar 1 year ago
parent
commit
c64744b09d

+ 9 - 3
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c

@@ -2572,7 +2572,8 @@ int cam_tfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
 	struct cam_tfe_hw_core_info       *core_info = NULL;
 	struct cam_tfe_top_priv           *top_priv;
 	void __iomem                      *mem_base;
-	int rc = 0;
+	int i, rc = 0;
+	unsigned long                      max_clk_rate = 0;
 	uint32_t                           reset_core_args =
 					CAM_TFE_HW_RESET_HW_AND_REG;
 
@@ -2595,9 +2596,14 @@ int cam_tfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
 		return 0;
 	}
 	mutex_unlock(&tfe_hw->hw_mutex);
+	/* read clock value based on clock blob received */
+	for (i = 0; i < CAM_TFE_TOP_IN_PORT_MAX; i++) {
+		if (top_priv->req_clk_rate[i] > max_clk_rate)
+			max_clk_rate = top_priv->req_clk_rate[i];
+	}
 
 	/* Turn ON Regulators, Clocks and other SOC resources */
-	rc = cam_tfe_enable_soc_resources(soc_info);
+	rc = cam_tfe_enable_soc_resources(soc_info, max_clk_rate);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Enable SOC failed");
 		rc = -EFAULT;
@@ -2616,7 +2622,7 @@ int cam_tfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
 		goto disable_soc;
 	}
 
-	top_priv->hw_clk_rate = 0;
+	top_priv->hw_clk_rate = max_clk_rate;
 	core_info->irq_err_config_cnt = 0;
 	core_info->irq_err_config = false;
 	rc = core_info->tfe_bus->hw_ops.init(core_info->tfe_bus->bus_priv,

+ 13 - 2
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_soc.c

@@ -144,12 +144,15 @@ int cam_tfe_deinit_soc_resources(struct cam_hw_soc_info *soc_info)
 	return rc;
 }
 
-int cam_tfe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
+int cam_tfe_enable_soc_resources(
+	struct cam_hw_soc_info  *soc_info,
+	unsigned long           max_clk_rate)
 {
 	int                               rc = 0;
 	struct cam_tfe_soc_private       *soc_private;
 	struct cam_ahb_vote               ahb_vote;
 	struct cam_axi_vote               axi_vote = {0};
+	int32_t                           apply_level = CAM_LOWSVS_VOTE;
 
 	if (!soc_info) {
 		CAM_ERR(CAM_ISP, "Error! Invalid params");
@@ -174,8 +177,16 @@ int cam_tfe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
 		goto end;
 	}
 
+	if (max_clk_rate) {
+		rc = cam_soc_util_get_clk_level(soc_info, max_clk_rate, soc_info->src_clk_idx,
+			&apply_level);
+		if (rc)
+			CAM_ERR(CAM_ISP, "Error! getting clk level");
+	}
+
 	rc = cam_soc_util_enable_platform_resource(soc_info, CAM_CLK_SW_CLIENT_IDX, true,
-		CAM_LOWSVS_VOTE, true);
+		apply_level, true);
+
 	if (rc) {
 		CAM_ERR(CAM_ISP, "Error! enable platform failed rc=%d", rc);
 		goto stop_cpas;

+ 5 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_soc.h

@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _CAM_TFE_SOC_H_
@@ -72,10 +73,13 @@ int cam_tfe_deinit_soc_resources(struct cam_hw_soc_info *soc_info);
  *
  * @soc_info:                Device soc information
  *
+ * @max_clk_rate:            Max clock rate value
+ *
  * @Return:                  0: Success
  *                           Non-zero: Failure
  */
-int cam_tfe_enable_soc_resources(struct cam_hw_soc_info *soc_info);
+int cam_tfe_enable_soc_resources(struct cam_hw_soc_info *soc_info,
+	unsigned long max_clk_rate);
 
 /*
  * cam_tfe_disable_soc_resources()