فهرست منبع

msm: camera: icp: Dump ICP fault/CSR registers on HFI init failure

If HFI init times out, log ICP status and CSR registers.

CRs-Fixed: 3110947
Change-Id: I611c29ee1b48f210f76750e57f38e260278b6812
Signed-off-by: Karthik Anantha Ram <[email protected]>
Karthik Anantha Ram 3 سال پیش
والد
کامیت
d2767102cc

+ 8 - 1
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -128,15 +128,17 @@ static const char *cam_icp_dev_type_to_name(
 
 static inline void cam_icp_dump_debug_info(bool skip_dump)
 {
+	uint32_t dump_type;
 	struct cam_hw_intf *icp_dev_intf = icp_hw_mgr.icp_dev_intf;
 
 	if (skip_dump)
 		return;
 
+	dump_type = CAM_ICP_DUMP_STATUS_REGISTERS;
 	cam_icp_mgr_process_dbg_buf(icp_hw_mgr.icp_dbg_lvl);
 	cam_hfi_queue_dump(false);
 	icp_dev_intf->hw_ops.process_cmd(
-		icp_dev_intf->hw_priv, CAM_ICP_CMD_HW_REG_DUMP, NULL, 0x0);
+		icp_dev_intf->hw_priv, CAM_ICP_CMD_HW_REG_DUMP, &dump_type, sizeof(dump_type));
 }
 
 static int cam_icp_send_ubwc_cfg(struct cam_icp_hw_mgr *hw_mgr)
@@ -4309,6 +4311,7 @@ static int cam_icp_mgr_hw_open(void *hw_mgr_priv, void *download_fw_args)
 {
 	struct cam_icp_hw_mgr *hw_mgr = hw_mgr_priv;
 	bool icp_pc = false;
+	uint32_t dump_type;
 	int rc = 0;
 
 	if (!hw_mgr) {
@@ -4349,6 +4352,10 @@ static int cam_icp_mgr_hw_open(void *hw_mgr_priv, void *download_fw_args)
 	rc = cam_icp_mgr_hfi_init(hw_mgr);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "Failed in hfi init, rc %d", rc);
+
+		dump_type = (CAM_ICP_DUMP_STATUS_REGISTERS | CAM_ICP_DUMP_CSR_REGISTERS);
+		hw_mgr->icp_dev_intf->hw_ops.process_cmd(hw_mgr->icp_dev_intf->hw_priv,
+			CAM_ICP_CMD_HW_REG_DUMP, &dump_type, sizeof(dump_type));
 		goto hfi_init_failed;
 	}
 

+ 3 - 0
drivers/cam_icp/icp_hw/icp_hw_mgr/include/cam_icp_hw_intf.h

@@ -20,6 +20,9 @@
 #define PC_POLL_DELAY_US 100
 #define PC_POLL_TIMEOUT_US 10000
 
+#define CAM_ICP_DUMP_STATUS_REGISTERS BIT(0)
+#define CAM_ICP_DUMP_CSR_REGISTERS    BIT(1)
+
 enum cam_icp_hw_type {
 	CAM_ICP_DEV_A5,
 	CAM_ICP_DEV_LX7,

+ 38 - 11
drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c

@@ -700,19 +700,38 @@ static int cam_lx7_shutdown(struct cam_hw_info *lx7_info)
 	return rc;
 }
 
-static inline void __cam_lx7_core_reg_dump(
-	struct cam_hw_info *lx7_info)
+static void __cam_lx7_core_reg_dump(
+	struct cam_hw_info *lx7_info, uint32_t dump_type)
 {
+	int i;
+	size_t len = 0;
+	char log_info[512];
 	void __iomem *cirq_base = lx7_info->soc_info.reg_map[LX7_CIRQ_BASE].mem_base;
 	void __iomem *csr_base = lx7_info->soc_info.reg_map[LX7_CSR_BASE].mem_base;
+	void __iomem *csr_gp_base =  csr_base + LX7_GEN_PURPOSE_REG_OFFSET;
+
+	if (dump_type & CAM_ICP_DUMP_STATUS_REGISTERS)
+		CAM_INFO(CAM_ICP,
+			"CIRQ IB_status0:0x%x IB_Status1:0x%x PFault:0x%x CSR debug_status:0x%x debug_ctrl:0x%x",
+			cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_IB_STATUS0),
+			cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_IB_STATUS1),
+			cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_PFAULT_INFO),
+			cam_io_r_mb(csr_base + LX7_CSR_DBG_STATUS_REG_OFFSET),
+			cam_io_r_mb(csr_base + LX7_CSR_DBG_CTRL_REG_OFFSET));
+
+	if (dump_type & CAM_ICP_DUMP_CSR_REGISTERS) {
+		for (i = 0; i < LX7_CSR_GP_REG_COUNT;) {
+			CAM_INFO_BUF(CAM_ICP, log_info, 512, &len,
+				"GP_%d: 0x%x GP_%d: 0x%x GP_%d: 0x%x GP_%d: 0x%x",
+				i, cam_io_r_mb(csr_gp_base + (i << 2)),
+				(i + 1), cam_io_r_mb(csr_gp_base + ((i + 1) << 2)),
+				(i + 2), cam_io_r_mb(csr_gp_base + ((i + 2) << 2)),
+				(i + 3), cam_io_r_mb(csr_gp_base + ((i + 3) << 2)));
+			i += 4;
+		}
 
-	CAM_INFO(CAM_ICP,
-		"CIRQ IB_status0:0x%x IB_Status1:0x%x PFault:0x%x CSR debug_status:0x%x debug_ctrl:0x%x",
-		cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_IB_STATUS0),
-		cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_IB_STATUS1),
-		cam_io_r_mb(cirq_base + ICP_LX7_CIRQ_PFAULT_INFO),
-		cam_io_r_mb(csr_base + LX7_CSR_DBG_STATUS_REG_OFFSET),
-		cam_io_r_mb(csr_base + LX7_CSR_DBG_CTRL_REG_OFFSET));
+		CAM_INFO(CAM_ICP, "ICP CSR GP registers - %s", log_info);
+	}
 }
 
 /* API controls collapse/resume of ICP */
@@ -730,7 +749,7 @@ static int cam_lx7_core_control(
 			CAM_ERR(CAM_ICP,
 				"remote state set to %s failed rc=%d",
 				(state == TZ_STATE_RESUME ? "resume" : "suspend"), rc);
-			__cam_lx7_core_reg_dump(lx7_info);
+			__cam_lx7_core_reg_dump(lx7_info, CAM_ICP_DUMP_STATUS_REGISTERS);
 		}
 	} else {
 		if (state == TZ_STATE_RESUME) {
@@ -896,7 +915,15 @@ int cam_lx7_process_cmd(void *priv, uint32_t cmd_type,
 		break;
 	}
 	case CAM_ICP_CMD_HW_REG_DUMP: {
-		__cam_lx7_core_reg_dump(lx7_info);
+		uint32_t dump_type;
+
+		if (!args) {
+			CAM_ERR(CAM_ICP, "Invalid args");
+			break;
+		}
+
+		dump_type = *(uint32_t *) args;
+		__cam_lx7_core_reg_dump(lx7_info, dump_type);
 		rc = 0;
 		break;
 	}

+ 1 - 0
drivers/cam_icp/icp_hw/lx7_hw/lx7_reg.h

@@ -11,6 +11,7 @@
 #define LX7_GEN_PURPOSE_REG_OFFSET     0x20
 #define LX7_CSR_DBG_STATUS_REG_OFFSET  0xC0
 #define LX7_CSR_DBG_CTRL_REG_OFFSET    0xC4
+#define LX7_CSR_GP_REG_COUNT           0x18
 
 /* ICP_SYS - Protected reg space defined in AC policy */
 #define ICP_LX7_SYS_RESET      0x0