Pārlūkot izejas kodu

msm: camera: tfe: Add epd support

This change add support for EPD mode high data
rate sensors which send EPD instead of EOT. This
change is only for CPHY EPD sensors and not applicable
to DPHY EPD sensors. For CPHY EPD sensor, EOT error masked.

CRs-Fixed: 3736696
Signed-off-by: Alok Chauhan <[email protected]>
Change-Id: I5ef0dac8e590daa1c4f3bc217f7da81a7a193dfe
Alok Chauhan 1 gadu atpakaļ
vecāks
revīzija
ec6515da0e

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c

@@ -2194,6 +2194,8 @@ static int cam_tfe_mgr_acquire_get_unified_structure_v2(
 					CAM_ISP_TFE_FLAG_SHDR_SLAVE_EN;
 	in_port->is_shdr_master  =  in->feature_flag &
 					CAM_ISP_TFE_FLAG_SHDR_MASTER_EN;
+	in_port->epd_supported  =  in->feature_flag &
+					CAM_ISP_TFE_FLAG_EPD_SUPPORT;
 
 
 	if (in_port->bayer_bin && in_port->qcfa_bin) {

+ 2 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_tfe_csid_hw_intf.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2019-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_TFE_CSID_HW_INTF_H_
@@ -93,6 +93,7 @@ struct cam_isp_tfe_in_port_generic_info {
 	uint32_t                        secure_mode;
 	bool                            shdr_en;
 	bool                            is_shdr_master;
+	bool                            epd_supported;
 	struct cam_isp_tfe_out_port_generic_info    *data;
 };
 

+ 2 - 1
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid770.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _CAM_TFE_CSID_770_H_
@@ -279,6 +279,7 @@ static struct cam_tfe_csid_csi2_rx_reg_offset
 	.csi2_irq_mask_all                            = 0xFFFFFFF,
 	.csi2_misr_enable_shift_val                   = 6,
 	.csi2_vc_mode_shift_val                       = 2,
+	.csi2_rx_epd_mode_shift_en                    = 8,
 	.csi2_capture_long_pkt_en_shift               = 0,
 	.csi2_capture_short_pkt_en_shift              = 1,
 	.csi2_capture_cphy_pkt_en_shift               = 2,

+ 24 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c

@@ -1,7 +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.
+ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/iopoll.h>
@@ -697,13 +697,14 @@ static int cam_tfe_csid_cid_reserve(struct cam_tfe_csid_hw *csid_hw,
 	const struct cam_tfe_csid_reg_offset       *csid_reg;
 
 	CAM_DBG(CAM_ISP,
-		"CSID:%d res_id:0x%x Lane type:%d lane_num:%d dt:%d vc:%d",
+		"CSID:%d res_id:0x%x Lane type:%d lane_num:%d dt:%d vc:%d, is_EPD: %d",
 		csid_hw->hw_intf->hw_idx,
 		cid_reserv->in_port->res_id,
 		cid_reserv->in_port->lane_type,
 		cid_reserv->in_port->lane_num,
 		cid_reserv->in_port->dt[0],
-		cid_reserv->in_port->vc[0]);
+		cid_reserv->in_port->vc[0],
+		cid_reserv->in_port->epd_supported);
 
 	if (cid_reserv->in_port->res_id >= CAM_ISP_TFE_IN_RES_MAX) {
 		CAM_ERR(CAM_ISP, "CSID:%d  Invalid phy sel %d",
@@ -801,6 +802,8 @@ static int cam_tfe_csid_cid_reserve(struct cam_tfe_csid_hw *csid_hw,
 			cid_reserv->in_port->lane_type;
 		csid_hw->csi2_rx_cfg.lane_num =
 			cid_reserv->in_port->lane_num;
+		if (cid_reserv->in_port->epd_supported)
+			csid_hw->csi2_rx_cfg.epd_supported = 1;
 
 		switch (cid_reserv->in_port->res_id) {
 		case CAM_ISP_TFE_IN_RES_TPG:
@@ -1101,6 +1104,10 @@ static int cam_tfe_csid_enable_csi2(
 
 	/* enable packet ecc correction */
 	val |= 1;
+	/* enable epd mode */
+	if (csid_hw->csi2_rx_cfg.epd_supported)
+		val |= (csid_hw->csi2_rx_cfg.epd_supported <<
+			csid_reg->csi2_reg->csi2_rx_epd_mode_shift_en);
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr);
 
@@ -1119,6 +1126,10 @@ static int cam_tfe_csid_enable_csi2(
 		TFE_CSID_CSI2_RX_ERROR_UNBOUNDED_FRAME |
 		TFE_CSID_CSI2_RX_ERROR_CPHY_PH_CRC;
 
+	if (csid_hw->csi2_rx_cfg.epd_supported &&
+		(csid_hw->csi2_rx_cfg.lane_type == CAM_ISP_LANE_TYPE_DPHY))
+		val &= ~TFE_CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION;
+
 	/* Enable the interrupt based on csid debug info set */
 	if (csid_hw->csid_debug & TFE_CSID_DEBUG_ENABLE_SOT_IRQ)
 		val |= TFE_CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED |
@@ -3948,8 +3959,16 @@ irqreturn_t cam_tfe_csid_irq(int irq_num, void *data)
 		}
 
 		if (irq_status[TFE_CSID_IRQ_REG_RX] &
-			TFE_CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION)
-			csid_hw->error_irq_count++;
+			TFE_CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION) {
+			if (csid_hw->csi2_rx_cfg.epd_supported)
+				CAM_DBG(CAM_ISP,
+					"CSID[%u] Rcvd Only ERROR_EOT for EPD sensor PHY type: %s(%u)",
+					csid_hw->hw_intf->hw_idx,
+					(csid_hw->csi2_rx_cfg.lane_type) ? "cphy" : "dphy",
+					csid_hw->csi2_rx_cfg.lane_type);
+			else
+				csid_hw->error_irq_count++;
+		}
 
 		if (irq_status[TFE_CSID_IRQ_REG_RX] &
 			TFE_CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION)

+ 8 - 5
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2019-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_TFE_CSID_HW_H_
@@ -246,6 +246,7 @@ struct cam_tfe_csid_csi2_rx_reg_offset {
 	uint32_t csi2_irq_mask_all;
 	uint32_t csi2_misr_enable_shift_val;
 	uint32_t csi2_vc_mode_shift_val;
+	uint32_t csi2_rx_epd_mode_shift_en;
 	uint32_t csi2_capture_long_pkt_en_shift;
 	uint32_t csi2_capture_short_pkt_en_shift;
 	uint32_t csi2_capture_cphy_pkt_en_shift;
@@ -346,10 +347,11 @@ struct cam_tfe_csid_hw_info {
 
 /**
  * struct cam_tfe_csid_csi2_rx_cfg- csid csi2 rx configuration data
- * @phy_sel:     input resource type for sensor only
- * @lane_type:   lane type: c-phy or d-phy
- * @lane_num :   active lane number
- * @lane_cfg:    lane configurations: 4 bits per lane
+ * @phy_sel:          input resource type for sensor only
+ * @lane_type:        lane type: c-phy or d-phy
+ * @lane_num :        active lane number
+ * @lane_cfg:         lane configurations: 4 bits per lane
+ * @epd_supported:    Flag to check if epd supported
  *
  */
 struct cam_tfe_csid_csi2_rx_cfg  {
@@ -357,6 +359,7 @@ struct cam_tfe_csid_csi2_rx_cfg  {
 	uint32_t                        lane_type;
 	uint32_t                        lane_num;
 	uint32_t                        lane_cfg;
+	uint32_t                        epd_supported;
 };
 
 /**

+ 2 - 1
include/uapi/camera/media/cam_tfe.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
 /*
  * Copyright (c) 2019-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 __UAPI_CAM_TFE_H__
@@ -104,6 +104,7 @@
 #define CAM_ISP_TFE_FLAG_BAYER_BIN                       BIT(1)
 #define CAM_ISP_TFE_FLAG_SHDR_MASTER_EN                  BIT(2)
 #define CAM_ISP_TFE_FLAG_SHDR_SLAVE_EN                   BIT(3)
+#define CAM_ISP_TFE_FLAG_EPD_SUPPORT                     BIT(4)
 
 /* Query devices */
 /**