Pārlūkot izejas kodu

msm: camera: sensor: Duplicate TPG changes for Crow

Add support to skip TPG hardware operations with
"hw-no-ops" property.

CRs-Fixed: 3562223

Change-Id: I2ce3cc3d46d90567dba23e8952bb41e7b5936be4
Signed-off-by: Shadul Shaikh <[email protected]>
(cherry picked from commit a117f9910be023824aea1ad598bf59359730e1f4)
Shadul Shaikh 2 gadi atpakaļ
vecāks
revīzija
57f19ae659

+ 40 - 19
drivers/cam_sensor_module/cam_tpg/cam_tpg_core.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include "cam_tpg_core.h"
@@ -14,7 +14,8 @@ int cam_tpg_shutdown(struct cam_tpg_device *tpg_dev)
 	if (tpg_dev != NULL) {
 		CAM_INFO(CAM_TPG, "TPG[%d] shutdown cleanup.",
 				tpg_dev->soc_info.index);
-		tpg_hw_reset(&tpg_dev->tpg_hw);
+		if (!tpg_dev->hw_no_ops)
+			tpg_hw_reset(&tpg_dev->tpg_hw);
 		tpg_dev->state = CAM_TPG_STATE_INIT;
 	}
 	return 0;
@@ -149,7 +150,11 @@ static int cam_tpg_process_crm_evt(
 
 	switch(event->evt_type) {
 	case CAM_REQ_MGR_LINK_EVT_SOF_FREEZE:
-		tpg_hw_dump_status(&tpg_dev->tpg_hw);
+		if (tpg_dev->hw_no_ops) {
+			CAM_DBG(CAM_TPG, "TPG[%d] SOF Freeze hw_no_ops: %d",
+				tpg_dev->soc_info.index, tpg_dev->hw_no_ops);
+		} else
+			tpg_hw_dump_status(&tpg_dev->tpg_hw);
 		break;
 	default:
 		CAM_DBG(CAM_TPG, "Got crm event notification: %d", event->evt_type);
@@ -286,11 +291,13 @@ static int __cam_tpg_handle_release_dev(
 	if (tpg_dev->state == CAM_TPG_STATE_START) {
 		CAM_DBG(CAM_TPG, "TPG[%d] release from start state",
 						tpg_dev->soc_info.index);
-		rc = tpg_hw_stop(&tpg_dev->tpg_hw);
-		if (rc < 0) {
-			CAM_ERR(CAM_TPG, "TPG[%d] unable to stop tpg",
+		if (!tpg_dev->hw_no_ops) {
+			rc = tpg_hw_stop(&tpg_dev->tpg_hw);
+			if (rc < 0) {
+				CAM_ERR(CAM_TPG, "TPG[%d] unable to stop tpg",
 						tpg_dev->soc_info.index);
-			return rc;
+				return rc;
+			}
 		}
 	}
 	rc = tpg_hw_release(&tpg_dev->tpg_hw);
@@ -330,12 +337,16 @@ static int __cam_tpg_handle_start_dev(
 				tpg_dev->soc_info.index, tpg_dev->state);
 		return -EINVAL;
 	}
-	rc = tpg_hw_start(&tpg_dev->tpg_hw);
+	if (!tpg_dev->hw_no_ops)
+		rc = tpg_hw_start(&tpg_dev->tpg_hw);
+
 	if (rc) {
-		CAM_ERR(CAM_TPG, "TPG[%d] START_DEV failed", tpg_dev->soc_info.index);
+		CAM_ERR(CAM_TPG, "TPG[%d] START_DEV failed hw_no_ops: %d",
+				tpg_dev->soc_info.index, tpg_dev->hw_no_ops);
 	} else {
 		tpg_dev->state = CAM_TPG_STATE_START;
-		CAM_INFO(CAM_TPG, "TPG[%d] START_DEV done.", tpg_dev->soc_info.index);
+		CAM_INFO(CAM_TPG, "TPG[%d] START_DEV done hw_no_ops: %d.",
+				tpg_dev->soc_info.index, tpg_dev->hw_no_ops);
 	}
 
 	return rc;
@@ -362,12 +373,15 @@ static int __cam_tpg_handle_stop_dev(
 		CAM_WARN(CAM_TPG, "TPG[%d] not in right state[%d] to stop",
 				tpg_dev->soc_info.index, tpg_dev->state);
 	}
-	rc = tpg_hw_stop(&tpg_dev->tpg_hw);
+	if (!tpg_dev->hw_no_ops)
+		rc = tpg_hw_stop(&tpg_dev->tpg_hw);
 	if (rc) {
-		CAM_ERR(CAM_TPG, "TPG[%d] STOP_DEV failed", tpg_dev->soc_info.index);
+		CAM_ERR(CAM_TPG, "TPG[%d] STOP_DEV failed  hw_no_ops: %d",
+				tpg_dev->soc_info.index, tpg_dev->hw_no_ops);
 	} else {
 		tpg_dev->state = CAM_TPG_STATE_ACQUIRE;
-		CAM_INFO(CAM_TPG, "TPG[%d] STOP_DEV done.", tpg_dev->soc_info.index);
+		CAM_INFO(CAM_TPG, "TPG[%d] STOP_DEV done hw_no_ops: %d.",
+				tpg_dev->soc_info.index, tpg_dev->hw_no_ops);
 	}
 
 	return rc;
@@ -539,13 +553,15 @@ static int cam_tpg_cmd_buf_parse(
 			tpg_dev->tpg_hw.tpg_clock = req->global_config.tpg_clock;
 			break;
 		case TPG_CMD_TYPE_STREAM_CONFIG: {
-			if (cmd_header->cmd_version == 3) {
+			if ((cmd_header->cmd_version == 3) &&
+						(!tpg_dev->hw_no_ops)) {
 				rc = tpg_hw_add_stream_v3(&tpg_dev->tpg_hw,
 					req,
 					(struct tpg_stream_config_v3_t *)cmd_addr);
 				CAM_DBG(CAM_TPG, "Stream config v3");
-			} else if (cmd_header->cmd_version == 1 ||
-				cmd_header->cmd_version == 2) {
+			} else if ((cmd_header->cmd_version == 1 ||
+				cmd_header->cmd_version == 2) &&
+						(!tpg_dev->hw_no_ops)) {
 				rc = tpg_hw_add_stream(&tpg_dev->tpg_hw,
 					req,
 					(struct tpg_stream_config_t *)cmd_addr);
@@ -558,7 +574,9 @@ static int cam_tpg_cmd_buf_parse(
 		case TPG_CMD_TYPE_SETTINGS_CONFIG: {
 			CAM_DBG(CAM_TPG, "TPG[%d] Got TPG Settings Config",
 							tpg_dev->soc_info.index);
-			rc = tpg_hw_copy_settings_config(&tpg_dev->tpg_hw,
+			if (!tpg_dev->hw_no_ops)
+				rc = tpg_hw_copy_settings_config(
+				&tpg_dev->tpg_hw,
 				(struct tpg_settings_config_t *)cmd_addr);
 			break;
 		}
@@ -575,7 +593,8 @@ static int cam_tpg_cmd_buf_parse(
 			break;
 		}
 	}
-	tpg_hw_add_request(&tpg_dev->tpg_hw, req);
+	if (!tpg_dev->hw_no_ops)
+		tpg_hw_add_request(&tpg_dev->tpg_hw, req);
 end:
 	return rc;
 free_request:
@@ -641,7 +660,9 @@ static int cam_tpg_packet_parse(
 			CAM_ERR(CAM_TPG, "CMD buffer parse failed");
 			goto end;
 		}
-		tpg_hw_config(&tpg_dev->tpg_hw, TPG_HW_CMD_INIT_CONFIG, NULL);
+		if (!tpg_dev->hw_no_ops)
+			tpg_hw_config(&tpg_dev->tpg_hw,
+				TPG_HW_CMD_INIT_CONFIG, NULL);
 		break;
 	}
 	case CAM_TPG_PACKET_OPCODE_NOP:

+ 10 - 3
drivers/cam_sensor_module/cam_tpg/cam_tpg_dev.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include "cam_tpg_dev.h"
@@ -208,8 +208,15 @@ static int tpg_soc_info_init(struct cam_tpg_device *tpg_dev,
 	for (i = 0; i < tpg_dev->soc_info.irq_count; i++)
 		irq_data[i] = tpg_dev;
 
-	rc = cam_soc_util_request_platform_resource(
-		&tpg_dev->soc_info, cam_tpg_irq_handler, &(irq_data[0]));
+	if (!of_property_read_bool(of_node, "hw-no-ops"))
+		tpg_dev->hw_no_ops = false;
+	else
+		tpg_dev->hw_no_ops = true;
+
+	if (!tpg_dev->hw_no_ops)
+		rc = cam_soc_util_request_platform_resource(
+			&tpg_dev->soc_info, cam_tpg_irq_handler,
+			&(irq_data[0]));
 	if (rc)
 		CAM_ERR(CAM_TPG, "unable to request platfrom resources");
 	else

+ 3 - 1
drivers/cam_sensor_module/cam_tpg/cam_tpg_dev.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef __CAM_TPG_DEV_H__
@@ -112,6 +112,7 @@ struct tpg_crm_intf_params {
  * @state   : state machine states
  * @slot_id : slot index of this tpg
  * @phy_id  : phy index mapped to this tpg
+ * @hw_no_ops: To determine whether HW operations need to be disabled
  * @waiting_request_q : waiting request queue
  * @active_request_q : active request queue
  * @tpg_irq_state : tpg irq state
@@ -128,6 +129,7 @@ struct cam_tpg_device {
 	int                        state;
 	int                        slot_id;
 	int                        phy_id;
+	bool                       hw_no_ops;
 	atomic_t                   tpg_irq_state;
 	struct list_head           waiting_request_q;
 	struct list_head           active_request_q;