فهرست منبع

msm: camera: icp: send freq to ICP firmware

ICP driver change the clk based on input request.
ICP fw needs this clock frequency to measure
processing time.

Send freq info to ICP firmware.

CRs-Fixed: 3037964
Change-Id: Iceed0bd43105da4316a023f345d46477e760b202
Signed-off-by: Alok Chauhan <[email protected]>
Alok Chauhan 4 سال پیش
والد
کامیت
e9d5f00f00

+ 6 - 0
drivers/cam_icp/fw_inc/hfi_intf.h

@@ -141,6 +141,12 @@ int hfi_set_debug_level(u64 icp_dbg_type, uint32_t lvl);
  */
 int hfi_set_fw_dump_level(uint32_t lvl);
 
+/**
+ * hfi_send_freq_info() - set firmware dump level
+ * @freq: icp freq
+ */
+int hfi_send_freq_info(int32_t freq);
+
 /**
  * hfi_enable_ipe_bps_pc() - Enable interframe pc
  * Host sends a command to firmware to enable interframe

+ 2 - 0
drivers/cam_icp/fw_inc/hfi_reg.h

@@ -278,6 +278,7 @@ struct hfi_qtbl {
  * @mutex msg_q_lock: Lock for message queue
  * @msg_q_state: State of message queue
  * @priv: device private data
+ * @dbg_lvl: debug level set to FW
  */
 struct hfi_info {
 	struct hfi_mem_info map;
@@ -291,6 +292,7 @@ struct hfi_info {
 	struct mutex msg_q_lock;
 	bool msg_q_state;
 	void *priv;
+	u64 dbg_lvl;
 };
 
 #endif /* _CAM_HFI_REG_H_ */

+ 9 - 8
drivers/cam_icp/fw_inc/hfi_sys_defs.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- *  Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ *  Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved.
  */
 
 #ifndef _HFI_DEFS_H_
@@ -169,13 +169,14 @@
 /* System  level property base offset */
 #define HFI_PROPERTY_ICP_COMMON_START  (HFI_DOMAIN_BASE_ICP + 0x0)
 
-#define HFI_PROP_SYS_DEBUG_CFG           (HFI_PROPERTY_ICP_COMMON_START + 0x1)
-#define HFI_PROP_SYS_UBWC_CFG            (HFI_PROPERTY_ICP_COMMON_START + 0x2)
-#define HFI_PROP_SYS_IMAGE_VER           (HFI_PROPERTY_ICP_COMMON_START + 0x3)
-#define HFI_PROP_SYS_SUPPORTED           (HFI_PROPERTY_ICP_COMMON_START + 0x4)
-#define HFI_PROP_SYS_IPEBPS_PC           (HFI_PROPERTY_ICP_COMMON_START + 0x5)
-#define HFI_PROP_SYS_FW_DUMP_CFG         (HFI_PROPERTY_ICP_COMMON_START + 0x8)
-#define HFI_PROPERTY_SYS_UBWC_CONFIG_EX  (HFI_PROPERTY_ICP_COMMON_START + 0x9)
+#define HFI_PROP_SYS_DEBUG_CFG             (HFI_PROPERTY_ICP_COMMON_START + 0x1)
+#define HFI_PROP_SYS_UBWC_CFG              (HFI_PROPERTY_ICP_COMMON_START + 0x2)
+#define HFI_PROP_SYS_IMAGE_VER             (HFI_PROPERTY_ICP_COMMON_START + 0x3)
+#define HFI_PROP_SYS_SUPPORTED             (HFI_PROPERTY_ICP_COMMON_START + 0x4)
+#define HFI_PROP_SYS_IPEBPS_PC             (HFI_PROPERTY_ICP_COMMON_START + 0x5)
+#define HFI_PROP_SYS_FW_DUMP_CFG           (HFI_PROPERTY_ICP_COMMON_START + 0x8)
+#define HFI_PROPERTY_SYS_UBWC_CONFIG_EX    (HFI_PROPERTY_ICP_COMMON_START + 0x9)
+#define HFI_PROPERTY_SYS_ICP_HW_FREQUENCY  (HFI_PROPERTY_ICP_COMMON_START + 0xa)
 
 /* Capabilities reported at sys init */
 #define HFI_CAPS_PLACEHOLDER_1         (HFI_COMMON_BASE + 0x1)

+ 48 - 0
drivers/cam_icp/hfi.c

@@ -38,6 +38,7 @@
 
 static struct hfi_info *g_hfi;
 unsigned int g_icp_mmu_hdl;
+
 static DEFINE_MUTEX(hfi_cmd_q_mutex);
 static DEFINE_MUTEX(hfi_msg_q_mutex);
 
@@ -460,6 +461,9 @@ int hfi_set_debug_level(u64 icp_dbg_type, uint32_t lvl)
 	if (lvl > val)
 		return -EINVAL;
 
+	if (g_hfi)
+		g_hfi->dbg_lvl = lvl;
+
 	size = sizeof(struct hfi_cmd_prop) +
 		sizeof(struct hfi_debug);
 
@@ -517,6 +521,50 @@ int hfi_set_fw_dump_level(uint32_t lvl)
 	return 0;
 }
 
+int hfi_send_freq_info(int32_t freq)
+{
+	uint8_t *prop = NULL;
+	struct hfi_cmd_prop *dbg_prop = NULL;
+	uint32_t size = 0;
+
+	if (!g_hfi) {
+		CAM_ERR(CAM_HFI, "HFI interface not setup");
+		return -ENODEV;
+	}
+
+	if (!(g_hfi->dbg_lvl & HFI_DEBUG_MSG_PERF))
+		return -EINVAL;
+
+	size = sizeof(struct hfi_cmd_prop) + sizeof(freq);
+	prop = kzalloc(size, GFP_KERNEL);
+	if (!prop)
+		return -ENOMEM;
+
+	dbg_prop = (struct hfi_cmd_prop *)prop;
+	dbg_prop->size = size;
+	dbg_prop->pkt_type = HFI_CMD_SYS_SET_PROPERTY;
+	dbg_prop->num_prop = 1;
+	dbg_prop->prop_data[0] = HFI_PROPERTY_SYS_ICP_HW_FREQUENCY;
+	dbg_prop->prop_data[1] = freq;
+
+	CAM_DBG(CAM_HFI, "prop->size = %d\n"
+			 "prop->pkt_type = %d\n"
+			 "prop->num_prop = %d\n"
+			 "prop->prop_data[0] = %d\n"
+			 "prop->prop_data[1] = %d\n"
+			 "dbg_lvl = 0x%x\n",
+			 dbg_prop->size,
+			 dbg_prop->pkt_type,
+			 dbg_prop->num_prop,
+			 dbg_prop->prop_data[0],
+			 dbg_prop->prop_data[1],
+			 g_hfi->dbg_lvl);
+
+	hfi_write_cmd(prop);
+	kfree(prop);
+	return 0;
+}
+
 void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size)
 {
 	switch (type) {

+ 17 - 2
drivers/cam_icp/icp_hw/a5_hw/a5_soc.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/io.h>
@@ -11,6 +11,7 @@
 #include "a5_soc.h"
 #include "cam_soc_util.h"
 #include "cam_debug_util.h"
+#include "hfi_intf.h"
 
 static int cam_a5_get_dt_properties(struct cam_hw_soc_info *soc_info)
 {
@@ -192,6 +193,12 @@ int cam_a5_enable_soc_resources(struct cam_hw_soc_info *soc_info)
 		CAM_SVS_VOTE, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "enable platform failed");
+	else {
+		int32_t clk_rate = 0;
+
+		clk_rate = clk_get_rate(soc_info->clk[soc_info->src_clk_idx]);
+		hfi_send_freq_info(clk_rate);
+	}
 
 	return rc;
 }
@@ -203,6 +210,8 @@ int cam_a5_disable_soc_resources(struct cam_hw_soc_info *soc_info)
 	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "disable platform failed");
+	else
+		hfi_send_freq_info(0);
 
 	return rc;
 }
@@ -212,6 +221,7 @@ int cam_a5_update_clk_rate(struct cam_hw_soc_info *soc_info,
 {
 	int32_t src_clk_idx = 0;
 	int32_t clk_rate = 0;
+	int rc = 0;
 
 	if (!soc_info) {
 		CAM_ERR(CAM_ICP, "Invalid args");
@@ -248,5 +258,10 @@ int cam_a5_update_clk_rate(struct cam_hw_soc_info *soc_info,
 		clk_rate = soc_info->clk_rate[CAM_TURBO_VOTE][src_clk_idx];
 	}
 
-	return cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
+	rc = cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
+	if (rc)
+		return rc;
+
+	hfi_send_freq_info(clk_rate);
+	return 0;
 }

+ 16 - 1
drivers/cam_icp/icp_hw/lx7_hw/lx7_soc.c

@@ -9,6 +9,7 @@
 #include "cam_debug_util.h"
 #include "cam_soc_util.h"
 #include "lx7_soc.h"
+#include "hfi_intf.h"
 
 static int __ubwc_config_get(struct device_node *np, char *name, uint32_t *cfg)
 {
@@ -141,6 +142,12 @@ int cam_lx7_soc_resources_enable(struct cam_hw_soc_info *soc_info)
 						CAM_SVS_VOTE, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "failed to enable soc resources rc=%d", rc);
+	else {
+		int32_t clk_rate = 0;
+
+		clk_rate = clk_get_rate(soc_info->clk[soc_info->src_clk_idx]);
+		hfi_send_freq_info(clk_rate);
+	}
 
 	return rc;
 }
@@ -152,6 +159,8 @@ int cam_lx7_soc_resources_disable(struct cam_hw_soc_info *soc_info)
 	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "failed to disable soc resources rc=%d", rc);
+	else
+		hfi_send_freq_info(0);
 
 	return rc;
 }
@@ -161,6 +170,7 @@ int cam_lx7_update_clk_rate(struct cam_hw_soc_info *soc_info,
 {
 	int32_t src_clk_idx = 0;
 	int32_t clk_rate = 0;
+	int rc = 0;
 
 	if (!soc_info) {
 		CAM_ERR(CAM_ICP, "Invalid args");
@@ -197,5 +207,10 @@ int cam_lx7_update_clk_rate(struct cam_hw_soc_info *soc_info,
 		clk_rate = soc_info->clk_rate[CAM_TURBO_VOTE][src_clk_idx];
 	}
 
-	return cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
+	rc = cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
+	if (rc)
+		return rc;
+
+	hfi_send_freq_info(clk_rate);
+	return 0;
 }