瀏覽代碼

FF: Merge tag camera-kernel.lnx.5.0-211203.1 into camera-kernel.lnx.6.0

* origin/camera-kernel.lnx.5.0:
  msm: camera: csiphy: update phy hw reg vers 2.1.3
  msm: camera: cdm: Fix deadlock issue in CDM handle error
  msm: camera: sensor: Add component support for i2c driver
  msm: camera: isp: Fix PPI index based on the phy selection
  msm: camera: isp: Enable error recovery block for PPP
  msm: camera: isp: Handle IRQ delays for offline streams
  msm: camera: isp: Handle deferred buf done for bubble case
  msm: camera: tfe: Update arguments to addIO util
  msm: camera: flash: Correct log location
  msm: camera: sensor: Add support for CSIPHY fuse
  msm: camera: utils: Use mmrm api to check if mmrm is supported
  msm: camera: isp: Add more deferred buf done support
  msm: camera: csiphy: Enhance csiphy logs
  msm: camera: isp: Update 780 LITE header

Change-Id: I705b7b8293d5c40d9bc59771ce68a02bccde82b2
Signed-off-by: Savita Patted <[email protected]>
Savita Patted 3 年之前
父節點
當前提交
fdd4d2fbb1
共有 32 個文件被更改,包括 1370 次插入363 次删除
  1. 0 2
      drivers/cam_cdm/cam_cdm_hw_core.c
  2. 113 18
      drivers/cam_isp/cam_isp_context.c
  3. 2 2
      drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c
  4. 2 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid680.h
  5. 2 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid780.h
  6. 3 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite780.h
  7. 7 25
      drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_core.c
  8. 2 2
      drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_core.h
  9. 1 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h
  10. 1 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid640.h
  11. 8 2
      drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c
  12. 1 0
      drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.h
  13. 108 59
      drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c
  14. 2 2
      drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.h
  15. 57 30
      drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
  16. 11 0
      drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
  17. 1 1
      drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
  18. 656 95
      drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h
  19. 70 12
      drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
  20. 3 1
      drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
  21. 82 36
      drivers/cam_sensor_module/cam_flash/cam_flash_dev.c
  22. 1 1
      drivers/cam_sensor_module/cam_flash/cam_flash_dev.h
  23. 66 16
      drivers/cam_sensor_module/cam_ois/cam_ois_dev.c
  24. 3 1
      drivers/cam_sensor_module/cam_ois/cam_ois_dev.h
  25. 95 41
      drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c
  26. 1 1
      drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h
  27. 3 3
      drivers/cam_sensor_module/cam_tpg/cam_tpg_dev.c
  28. 37 4
      drivers/cam_utils/cam_compat.c
  29. 2 0
      drivers/cam_utils/cam_debug_util.h
  30. 10 7
      drivers/cam_utils/cam_soc_util.c
  31. 18 1
      drivers/camera_main.h
  32. 2 1
      dt-bindings/msm-camera.h

+ 0 - 2
drivers/cam_cdm/cam_cdm_hw_core.c

@@ -1803,11 +1803,9 @@ int cam_hw_cdm_handle_error_info(
 
 	if (node != NULL) {
 		if (node->request_type == CAM_HW_CDM_BL_CB_CLIENT) {
-			mutex_lock(&cdm_hw->hw_mutex);
 			cam_cdm_notify_clients(cdm_hw,
 					CAM_CDM_CB_STATUS_HW_ERROR,
 					(void *)node);
-			mutex_unlock(&cdm_hw->hw_mutex);
 		} else if (node->request_type == CAM_HW_CDM_BL_CB_INTERNAL) {
 			CAM_ERR(CAM_CDM, "Invalid node=%pK %d", node,
 					node->request_type);

+ 113 - 18
drivers/cam_isp/cam_isp_context.c

@@ -1683,10 +1683,47 @@ static int __cam_isp_handle_deferred_buf_done(
 		}
 	}
 
+	CAM_DBG(CAM_ISP,
+		"ctx[%d] : Req %llu : Handled %d deferred buf_dones num_acked=%d, num_fence_map_out=%d",
+		ctx->ctx_id, req->request_id, req_isp->num_deferred_acks,
+		req_isp->num_acked, req_isp->num_fence_map_out);
+
 	req_isp->num_deferred_acks = 0;
 
 	return rc;
 }
+
+static int __cam_isp_ctx_handle_deferred_buf_done_in_bubble(
+	struct cam_isp_context *ctx_isp,
+	struct cam_ctx_request  *req)
+{
+	int                     rc = 0;
+	struct cam_context     *ctx = ctx_isp->base;
+	struct cam_isp_ctx_req *req_isp;
+
+	req_isp = (struct cam_isp_ctx_req *)req->req_priv;
+
+	if (req_isp->num_deferred_acks)
+		rc = __cam_isp_handle_deferred_buf_done(ctx_isp, req,
+			req_isp->bubble_report,
+			CAM_SYNC_STATE_SIGNALED_ERROR,
+			CAM_SYNC_ISP_EVENT_BUBBLE);
+
+	if (req_isp->num_acked > req_isp->num_fence_map_out) {
+		/* Should not happen */
+		CAM_ERR(CAM_ISP,
+			"WARNING: req_id %lld num_acked %d > map_out %d, ctx %u",
+			req->request_id, req_isp->num_acked,
+			req_isp->num_fence_map_out, ctx->ctx_id);
+		WARN_ON(req_isp->num_acked > req_isp->num_fence_map_out);
+	}
+
+	if (req_isp->num_acked == req_isp->num_fence_map_out)
+		rc = __cam_isp_ctx_handle_buf_done_for_req_list(ctx_isp, req);
+
+	return rc;
+}
+
 static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr(
 	struct cam_isp_context *ctx_isp,
 	struct cam_ctx_request  *req,
@@ -2006,17 +2043,16 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 	struct cam_ctx_request *req;
 	struct cam_ctx_request *next_req = NULL;
 	struct cam_context *ctx = ctx_isp->base;
-	bool  req_in_wait_list = false;
+	struct cam_isp_ctx_req *req_isp;
+	bool  req_in_pending_wait_list = false;
 
 	if (list_empty(&ctx->active_req_list)) {
 
 		if (!list_empty(&ctx->wait_req_list)) {
-			struct cam_isp_ctx_req *req_isp;
-
 			req = list_first_entry(&ctx->wait_req_list,
 				struct cam_ctx_request, list);
 
-			req_in_wait_list = true;
+			req_in_pending_wait_list = true;
 			if (ctx_isp->last_applied_req_id !=
 				ctx_isp->last_bufdone_err_apply_req_id) {
 				CAM_WARN(CAM_ISP,
@@ -2030,6 +2066,39 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 
 			req_isp = (struct cam_isp_ctx_req *) req->req_priv;
 
+			/*
+			 * Verify consumed address for this request to make sure
+			 * we are handling the buf_done for the correct
+			 * buffer. Also defer actual buf_done handling, i.e
+			 * do not signal the fence as this request may go into
+			 * Bubble state eventully.
+			 */
+			rc =
+			__cam_isp_ctx_handle_buf_done_for_request_verify_addr(
+				ctx_isp, req, done, bubble_state, true, true);
+		} else if (!list_empty(&ctx->pending_req_list)) {
+			/*
+			 * We saw the case that the hw config is blocked due to
+			 * some reason, the we get the reg upd and buf done before
+			 * the req is added to wait req list.
+			 */
+			req = list_first_entry(&ctx->pending_req_list,
+				struct cam_ctx_request, list);
+
+			req_in_pending_wait_list = true;
+			if (ctx_isp->last_applied_req_id !=
+				ctx_isp->last_bufdone_err_apply_req_id) {
+				CAM_WARN(CAM_ISP,
+					"Buf done with no active request but with req in pending list, req %llu last apply id:%lld last err id:%lld",
+					req->request_id,
+					ctx_isp->last_applied_req_id,
+					ctx_isp->last_bufdone_err_apply_req_id);
+				ctx_isp->last_bufdone_err_apply_req_id =
+					ctx_isp->last_applied_req_id;
+			}
+
+			req_isp = (struct cam_isp_ctx_req *) req->req_priv;
+
 			/*
 			 * Verify consumed address for this request to make sure
 			 * we are handling the buf_done for the correct
@@ -2042,7 +2111,7 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 				ctx_isp, req, done, bubble_state, true, true);
 		}
 
-		if (!req_in_wait_list  && (ctx_isp->last_applied_req_id !=
+		if (!req_in_pending_wait_list  && (ctx_isp->last_applied_req_id !=
 			ctx_isp->last_bufdone_err_apply_req_id)) {
 			CAM_WARN(CAM_ISP,
 				"Buf done with no active request bubble_state=%d last_applied_req_id:%lld ",
@@ -2237,18 +2306,31 @@ static int __cam_isp_ctx_offline_epoch_in_activated_state(
 	CAM_DBG(CAM_ISP, "SOF frame %lld ctx %u", ctx_isp->frame_id,
 		ctx->ctx_id);
 
-	list_for_each_entry_safe(req, req_temp, &ctx->active_req_list, list) {
-		if (req->request_id > ctx_isp->reported_req_id) {
-			request_id = req->request_id;
-			ctx_isp->reported_req_id = request_id;
-			break;
+	/*
+	 * For offline it is not possible for epoch to be generated without
+	 * RUP done. IRQ scheduling delays can possibly cause this.
+	 */
+	if (list_empty(&ctx->active_req_list)) {
+		CAM_WARN(CAM_ISP, "Active list empty on ctx: %u - EPOCH serviced before RUP",
+			ctx->ctx_id);
+	} else {
+		list_for_each_entry_safe(req, req_temp, &ctx->active_req_list, list) {
+			if (req->request_id > ctx_isp->reported_req_id) {
+				request_id = req->request_id;
+				ctx_isp->reported_req_id = request_id;
+				break;
+			}
 		}
 	}
 
 	__cam_isp_ctx_schedule_apply_req_offline(ctx_isp);
 
-	__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
-		CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+	/*
+	 * If no valid request, wait for RUP shutter posted after buf done
+	 */
+	if (request_id)
+		__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+			CAM_REQ_MGR_SOF_EVENT_SUCCESS);
 
 	__cam_isp_ctx_update_state_monitor_array(ctx_isp,
 		CAM_ISP_STATE_CHANGE_TRIGGER_EPOCH,
@@ -2606,23 +2688,26 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
 	req_isp->bubble_detected = true;
 	req_isp->reapply_type = CAM_CONFIG_REAPPLY_IO;
 	req_isp->cdm_reset_before_apply = false;
+	atomic_set(&ctx_isp->process_bubble, 1);
 
 	CAM_INFO_RATE_LIMIT(CAM_ISP, "ctx:%d Report Bubble flag %d req id:%lld",
 		ctx->ctx_id, req_isp->bubble_report, req->request_id);
+
+	__cam_isp_ctx_handle_deferred_buf_done_in_bubble(
+		ctx_isp, req);
+
 	if (req_isp->bubble_report) {
 		__cam_isp_ctx_notify_error_util(CAM_TRIGGER_POINT_SOF, CRM_KMD_ERR_BUBBLE,
 			req->request_id, ctx_isp);
 		trace_cam_log_event("Bubble", "Rcvd epoch in applied state",
 			req->request_id, ctx->ctx_id);
-		atomic_set(&ctx_isp->process_bubble, 1);
 	} else {
 		req_isp->bubble_report = 0;
 		CAM_DBG(CAM_ISP, "Skip bubble recovery for req %lld ctx %u",
 			req->request_id, ctx->ctx_id);
+
 		if (ctx_isp->active_req_cnt <= 1)
 			__cam_isp_ctx_notify_trigger_util(CAM_TRIGGER_POINT_SOF, ctx_isp);
-
-		atomic_set(&ctx_isp->process_bubble, 1);
 	}
 
 	/*
@@ -2687,6 +2772,16 @@ end:
 	return 0;
 }
 
+static int __cam_isp_ctx_buf_done_in_sof(struct cam_isp_context *ctx_isp,
+	void *evt_data)
+{
+	int rc = 0;
+	struct cam_isp_hw_done_event_data *done =
+		(struct cam_isp_hw_done_event_data *) evt_data;
+
+	rc = __cam_isp_ctx_handle_buf_done_in_activated_state(ctx_isp, done, 0);
+	return rc;
+}
 
 static int __cam_isp_ctx_buf_done_in_applied(struct cam_isp_context *ctx_isp,
 	void *evt_data)
@@ -3548,7 +3643,7 @@ static struct cam_isp_ctx_irq_ops
 			__cam_isp_ctx_reg_upd_in_sof,
 			__cam_isp_ctx_notify_sof_in_activated_state,
 			__cam_isp_ctx_notify_eof_in_activated_state,
-			NULL,
+			__cam_isp_ctx_buf_done_in_sof,
 			__cam_isp_ctx_handle_secondary_events,
 		},
 	},
@@ -3708,7 +3803,7 @@ static struct cam_isp_ctx_irq_ops
 			__cam_isp_ctx_handle_error,
 			__cam_isp_ctx_sof_in_activated_state,
 			__cam_isp_ctx_reg_upd_in_applied_state,
-			NULL,
+			__cam_isp_ctx_offline_epoch_in_activated_state,
 			NULL,
 			__cam_isp_ctx_buf_done_in_applied,
 		},
@@ -3717,7 +3812,7 @@ static struct cam_isp_ctx_irq_ops
 	{
 		.irq_ops = {
 			__cam_isp_ctx_handle_error,
-			NULL,
+			__cam_isp_ctx_sof_in_activated_state,
 			NULL,
 			__cam_isp_ctx_offline_epoch_in_activated_state,
 			NULL,

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

@@ -4355,7 +4355,7 @@ static int cam_tfe_mgr_prepare_hw_update(void *hw_mgr_priv,
 	struct cam_isp_prepare_hw_update_data   *prepare_hw_data;
 	struct cam_isp_frame_header_info         frame_header_info;
 	struct cam_isp_change_base_args          change_base_info = {0};
-	struct cam_isp_check_sfe_fe_io_cfg       sfe_fe_chk_cfg = {0};
+	struct cam_isp_check_io_cfg_for_scratch  check_for_scratch = {0};
 
 	if (!hw_mgr_priv || !prepare_hw_update_args) {
 		CAM_ERR(CAM_ISP, "Invalid args");
@@ -4441,7 +4441,7 @@ static int cam_tfe_mgr_prepare_hw_update(void *hw_mgr_priv,
 			NULL, CAM_ISP_TFE_OUT_RES_BASE,
 			CAM_TFE_HW_OUT_RES_MAX, fill_fence,
 			CAM_ISP_HW_TYPE_TFE,
-			&frame_header_info, &sfe_fe_chk_cfg);
+			&frame_header_info, &check_for_scratch);
 
 		if (rc) {
 			CAM_ERR(CAM_ISP,

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid680.h

@@ -525,6 +525,8 @@ static struct cam_ife_csid_ver2_path_reg_info
 		.drop_h_en_shift_val              = 10,
 		.format_measure_en_shift_val      = 8,
 		.timestamp_en_shift_val           = 9,
+		.overflow_ctrl_en                 = 1,
+		.overflow_ctrl_mode_val           = 0x8,
 		.min_hbi_shift_val                = 4,
 		.start_master_sel_shift_val       = 4,
 		.lut_bank_0_sel_val               = 0,

+ 2 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid780.h

@@ -556,6 +556,8 @@ static struct cam_ife_csid_ver2_path_reg_info
 		.drop_h_en_shift_val              = 10,
 		.format_measure_en_shift_val      = 8,
 		.timestamp_en_shift_val           = 6,
+		.overflow_ctrl_en                 = 1,
+		.overflow_ctrl_mode_val           = 0x8,
 		.min_hbi_shift_val                = 4,
 		.start_master_sel_shift_val       = 4,
 		.lut_bank_0_sel_val               = 0,

+ 3 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite780.h

@@ -734,6 +734,7 @@ static struct cam_ife_csid_ver2_path_reg_info
 		.resume_frame_boundary               = 1,
 		.overflow_ctrl_en                    = 1,
 		.overflow_ctrl_mode_val              = 0x8,
+		.mipi_pack_supported                 = 1,
 		.packing_fmt_shift_val               = 15,
 		.plain_alignment_shift_val           = 11,
 		.plain_fmt_shift_val                 = 12,
@@ -821,6 +822,7 @@ static struct cam_ife_csid_ver2_path_reg_info
 		.resume_frame_boundary               = 1,
 		.overflow_ctrl_en                    = 1,
 		.overflow_ctrl_mode_val              = 0x8,
+		.mipi_pack_supported                 = 1,
 		.packing_fmt_shift_val               = 15,
 		.plain_alignment_shift_val           = 11,
 		.plain_fmt_shift_val                 = 12,
@@ -908,6 +910,7 @@ static struct cam_ife_csid_ver2_path_reg_info
 		.resume_frame_boundary               = 1,
 		.overflow_ctrl_en                    = 1,
 		.overflow_ctrl_mode_val              = 0x8,
+		.mipi_pack_supported                 = 1,
 		.packing_fmt_shift_val               = 15,
 		.plain_alignment_shift_val           = 11,
 		.plain_fmt_shift_val                 = 12,

+ 7 - 25
drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_core.c

@@ -162,9 +162,7 @@ static int cam_csid_ppi_init_hw(void *hw_priv, void *init_args,
 {
 	int i, rc = 0;
 	uint32_t num_lanes;
-	uint32_t lanes[CAM_CSID_PPI_HW_MAX] = {0, 0, 0, 0};
 	uint32_t cphy;
-	bool dl0, dl1;
 	uint32_t ppi_cfg_val = 0;
 	struct cam_csid_ppi_hw                *ppi_hw;
 	struct cam_hw_info                    *ppi_hw_info;
@@ -179,7 +177,6 @@ static int cam_csid_ppi_init_hw(void *hw_priv, void *init_args,
 		goto end;
 	}
 
-	dl0 = dl1 = false;
 	ppi_hw_info = (struct cam_hw_info *)hw_priv;
 	ppi_hw      = (struct cam_csid_ppi_hw *)ppi_hw_info->core_info;
 	ppi_reg     = ppi_hw->ppi_info->ppi_reg;
@@ -194,31 +191,16 @@ static int cam_csid_ppi_init_hw(void *hw_priv, void *init_args,
 	CAM_DBG(CAM_ISP, "lane_cfg  0x%x | num_lanes  0x%x | lane_type 0x%x",
 		ppi_cfg.lane_cfg, num_lanes, cphy);
 
-	for (i = 0; i < num_lanes; i++) {
-		lanes[i] = ppi_cfg.lane_cfg & (0x3 << (4 * i));
-		(lanes[i] < 2) ? (dl0 = true) : (dl1 = true);
-		CAM_DBG(CAM_ISP, "lanes[%d] %d", i, lanes[i]);
-	}
-
-	if (num_lanes) {
-		if (cphy) {
-			for (i = 0; i < num_lanes; i++) {
-				ppi_cfg_val |= PPI_CFG_CPHY_DLX_SEL(lanes[i]);
-				ppi_cfg_val |= PPI_CFG_CPHY_DLX_EN(lanes[i]);
-			}
-		} else {
-			if (dl0)
-				ppi_cfg_val |= PPI_CFG_CPHY_DLX_EN(0);
-			if (dl1)
-				ppi_cfg_val |= PPI_CFG_CPHY_DLX_EN(1);
-		}
+	if (cphy) {
+		ppi_cfg_val |= PPI_CFG_CPHY_DLX_SEL(0);
+		ppi_cfg_val |= PPI_CFG_CPHY_DLX_SEL(1);
 	} else {
-		CAM_ERR(CAM_ISP,
-			"Number of lanes to enable is cannot be zero");
-		rc = -1;
-		goto end;
+		ppi_cfg_val = 0;
 	}
 
+	for (i = 0; i < CAM_CSID_PPI_LANES_MAX; i++)
+		ppi_cfg_val |= PPI_CFG_CPHY_DLX_EN(i);
+
 	CAM_DBG(CAM_ISP, "ppi_cfg_val 0x%x", ppi_cfg_val);
 	soc_info = &ppi_hw->hw_info->soc_info;
 	cam_io_w_mb(ppi_cfg_val, soc_info->reg_map[0].mem_base +

+ 2 - 2
drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_core.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _CAM_CSID_PPI_HW_H_
@@ -25,7 +25,7 @@
 /*
  * Select the PHY (CPHY set '1' or DPHY set '0')
  */
-#define PPI_CFG_CPHY_DLX_SEL(X)            ((X < 2) ? BIT(X) : 0)
+#define PPI_CFG_CPHY_DLX_SEL(X)            BIT(X)
 
 #define PPI_CFG_CPHY_DLX_EN(X)             BIT(4+X)
 

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h

@@ -144,6 +144,7 @@ static struct cam_tfe_csid_csi2_rx_reg_offset
 	.csid_csi2_rx_irq_set_addr                    = 0x2c,
 
 	/*CSI2 rx control */
+	.phy_sel_base                                 = 1,
 	.csid_csi2_rx_cfg0_addr                       = 0x100,
 	.csid_csi2_rx_cfg1_addr                       = 0x104,
 	.csid_csi2_rx_capture_ctrl_addr               = 0x108,

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid640.h

@@ -182,6 +182,7 @@ static struct cam_tfe_csid_csi2_rx_reg_offset
 	.csid_csi2_rx_irq_set_addr                    = 0x2c,
 
 	/*CSI2 rx control */
+	.phy_sel_base                                 = 1,
 	.csid_csi2_rx_cfg0_addr                       = 0x100,
 	.csid_csi2_rx_cfg1_addr                       = 0x104,
 	.csid_csi2_rx_capture_ctrl_addr               = 0x108,

+ 8 - 2
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c

@@ -1022,8 +1022,14 @@ static int cam_tfe_csid_enable_csi2(
 
 	cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
 		csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr);
+	/*
+	 * There is one to one mapping for ppi index with phy index
+	 * we do not always update phy sel equal to phy number,for some
+	 * targets "phy_sel = phy_num + 1", and for some targets it is
+	 * "phy_sel = phy_num", ppi_index should be updated accordingly
+	 */
+	ppi_index = csid_hw->csi2_rx_cfg.phy_sel - csid_reg->csi2_reg->phy_sel_base;
 
-	ppi_index = csid_hw->csi2_rx_cfg.phy_sel;
 	if (csid_hw->ppi_hw_intf[ppi_index] && csid_hw->ppi_enable) {
 		ppi_lane_cfg.lane_type = csid_hw->csi2_rx_cfg.lane_type;
 		ppi_lane_cfg.lane_num  = csid_hw->csi2_rx_cfg.lane_num;
@@ -1067,7 +1073,7 @@ static int cam_tfe_csid_disable_csi2(
 	cam_io_w_mb(0, soc_info->reg_map[0].mem_base +
 		csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr);
 
-	ppi_index = csid_hw->csi2_rx_cfg.phy_sel;
+	ppi_index = csid_hw->csi2_rx_cfg.phy_sel - csid_reg->csi2_reg->phy_sel_base;
 	if (csid_hw->ppi_hw_intf[ppi_index] && csid_hw->ppi_enable) {
 		/* De-Initialize the PPI bridge */
 		CAM_DBG(CAM_ISP, "ppi_index to de-init %d\n", ppi_index);

+ 1 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.h

@@ -217,6 +217,7 @@ struct cam_tfe_csid_csi2_rx_reg_offset {
 
 	/*configurations */
 	uint32_t phy_tpg_base_id;
+	uint32_t phy_sel_base;
 	uint32_t csi2_rst_srb_all;
 	uint32_t csi2_rst_done_shift_val;
 	uint32_t csi2_irq_mask_all;

+ 108 - 59
drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c

@@ -160,26 +160,21 @@ static int cam_actuator_init_subdev(struct cam_actuator_ctrl_t *a_ctrl)
 	return rc;
 }
 
-static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
+static int cam_actuator_i2c_component_bind(struct device *dev,
+	struct device *master_dev, void *data)
 {
-	int32_t                         rc = 0;
-	int32_t                         i = 0;
+	int32_t                          rc = 0;
+	int32_t                          i = 0;
+	struct i2c_client               *client;
 	struct cam_actuator_ctrl_t      *a_ctrl;
 	struct cam_hw_soc_info          *soc_info = NULL;
 	struct cam_actuator_soc_private *soc_private = NULL;
 
-	if (client == NULL || id == NULL) {
-		CAM_ERR(CAM_ACTUATOR, "Invalid Args client: %pK id: %pK",
-			client, id);
-		return -EINVAL;
-	}
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CAM_ERR(CAM_ACTUATOR, "%s :: i2c_check_functionality failed",
-			 client->name);
-		rc = -EFAULT;
-		return rc;
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_ACTUATOR,
+			"Failed to get i2c client");
+		return -EFAULT;
 	}
 
 	/* Create sensor control structure */
@@ -252,7 +247,83 @@ free_ctrl:
 	return rc;
 }
 
-static int cam_actuator_component_bind(struct device *dev,
+static void cam_actuator_i2c_component_unbind(struct device *dev,
+	struct device *master_dev, void *data)
+{
+	struct i2c_client               *client = NULL;
+	struct cam_actuator_ctrl_t      *a_ctrl = NULL;
+	struct cam_actuator_soc_private *soc_private;
+	struct cam_sensor_power_ctrl_t  *power_info;
+
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_ACTUATOR,
+			"Failed to get i2c client");
+		return;
+	}
+
+	a_ctrl = i2c_get_clientdata(client);
+	/* Handle I2C Devices */
+	if (!a_ctrl) {
+		CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
+		return;
+	}
+
+	CAM_INFO(CAM_ACTUATOR, "i2c remove invoked");
+	mutex_lock(&(a_ctrl->actuator_mutex));
+	cam_actuator_shutdown(a_ctrl);
+	mutex_unlock(&(a_ctrl->actuator_mutex));
+	cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
+	soc_private =
+		(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
+	power_info = &soc_private->power_info;
+
+	/*Free Allocated Mem */
+	kfree(a_ctrl->i2c_data.per_frame);
+	a_ctrl->i2c_data.per_frame = NULL;
+	a_ctrl->soc_info.soc_private = NULL;
+	v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
+	kfree(a_ctrl);
+}
+
+const static struct component_ops cam_actuator_i2c_component_ops = {
+	.bind = cam_actuator_i2c_component_bind,
+	.unbind = cam_actuator_i2c_component_unbind,
+};
+
+static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int rc = 0;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_ACTUATOR, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_ACTUATOR, "%s :: i2c_check_functionality failed",
+			 client->name);
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_ACTUATOR, "Adding sensor actuator component");
+	rc = component_add(&client->dev, &cam_actuator_i2c_component_ops);
+	if (rc)
+		CAM_ERR(CAM_ACTUATOR, "failed to add component rc: %d", rc);
+
+	return rc;
+}
+
+static int32_t cam_actuator_driver_i2c_remove(
+	struct i2c_client *client)
+{
+	component_del(&client->dev, &cam_actuator_i2c_component_ops);
+	return 0;
+}
+
+static int cam_actuator_platform_component_bind(struct device *dev,
 	struct device *master_dev, void *data)
 {
 	int32_t                          rc = 0;
@@ -330,7 +401,8 @@ static int cam_actuator_component_bind(struct device *dev,
 
 	platform_set_drvdata(pdev, a_ctrl);
 	a_ctrl->cam_act_state = CAM_ACTUATOR_INIT;
-	CAM_DBG(CAM_ACTUATOR, "Component bound successfully");
+	CAM_DBG(CAM_ACTUATOR, "Component bound successfully %d",
+		a_ctrl->soc_info.index);
 
 	return rc;
 
@@ -345,7 +417,7 @@ free_ctrl:
 	return rc;
 }
 
-static void cam_actuator_component_unbind(struct device *dev,
+static void cam_actuator_platform_component_unbind(struct device *dev,
 	struct device *master_dev, void *data)
 {
 	struct cam_actuator_ctrl_t      *a_ctrl;
@@ -380,47 +452,15 @@ static void cam_actuator_component_unbind(struct device *dev,
 	CAM_INFO(CAM_ACTUATOR, "Actuator component unbinded");
 }
 
-const static struct component_ops cam_actuator_component_ops = {
-	.bind = cam_actuator_component_bind,
-	.unbind = cam_actuator_component_unbind,
+const static struct component_ops cam_actuator_platform_component_ops = {
+	.bind = cam_actuator_platform_component_bind,
+	.unbind = cam_actuator_platform_component_unbind,
 };
 
 static int32_t cam_actuator_platform_remove(
 	struct platform_device *pdev)
 {
-	component_del(&pdev->dev, &cam_actuator_component_ops);
-	return 0;
-}
-
-static int32_t cam_actuator_driver_i2c_remove(struct i2c_client *client)
-{
-	struct cam_actuator_ctrl_t      *a_ctrl =
-		i2c_get_clientdata(client);
-	struct cam_actuator_soc_private *soc_private;
-	struct cam_sensor_power_ctrl_t  *power_info;
-
-	/* Handle I2C Devices */
-	if (!a_ctrl) {
-		CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
-		return -EINVAL;
-	}
-
-	CAM_INFO(CAM_ACTUATOR, "i2c remove invoked");
-	mutex_lock(&(a_ctrl->actuator_mutex));
-	cam_actuator_shutdown(a_ctrl);
-	mutex_unlock(&(a_ctrl->actuator_mutex));
-	cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
-	soc_private =
-		(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
-	power_info = &soc_private->power_info;
-
-	/*Free Allocated Mem */
-	kfree(a_ctrl->i2c_data.per_frame);
-	a_ctrl->i2c_data.per_frame = NULL;
-	a_ctrl->soc_info.soc_private = NULL;
-	v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
-	kfree(a_ctrl);
-
+	component_del(&pdev->dev, &cam_actuator_platform_component_ops);
 	return 0;
 }
 
@@ -435,9 +475,9 @@ static int32_t cam_actuator_driver_platform_probe(
 	int rc = 0;
 
 	CAM_DBG(CAM_ACTUATOR, "Adding sensor actuator component");
-	rc = component_add(&pdev->dev, &cam_actuator_component_ops);
+	rc = component_add(&pdev->dev, &cam_actuator_platform_component_ops);
 	if (rc)
-		CAM_ERR(CAM_ICP, "failed to add component rc: %d", rc);
+		CAM_ERR(CAM_ACTUATOR, "failed to add component rc: %d", rc);
 
 	return rc;
 }
@@ -460,12 +500,21 @@ static const struct i2c_device_id i2c_id[] = {
 	{ }
 };
 
-static struct i2c_driver cam_actuator_driver_i2c = {
+static const struct of_device_id cam_actuator_i2c_driver_dt_match[] = {
+	{.compatible = "qcom,cam-i2c-actuator"},
+	{}
+};
+MODULE_DEVICE_TABLE(of, cam_actuator_i2c_driver_dt_match);
+
+struct i2c_driver cam_actuator_i2c_driver = {
 	.id_table = i2c_id,
 	.probe  = cam_actuator_driver_i2c_probe,
 	.remove = cam_actuator_driver_i2c_remove,
 	.driver = {
+		.of_match_table = cam_actuator_i2c_driver_dt_match,
+		.owner = THIS_MODULE,
 		.name = ACTUATOR_DRIVER_I2C,
+		.suppress_bind_attrs = true,
 	},
 };
 
@@ -479,7 +528,7 @@ int cam_actuator_driver_init(void)
 			"platform_driver_register failed rc = %d", rc);
 		return rc;
 	}
-	rc = i2c_add_driver(&cam_actuator_driver_i2c);
+	rc = i2c_add_driver(&cam_actuator_i2c_driver);
 	if (rc)
 		CAM_ERR(CAM_ACTUATOR, "i2c_add_driver failed rc = %d", rc);
 
@@ -489,7 +538,7 @@ int cam_actuator_driver_init(void)
 void cam_actuator_driver_exit(void)
 {
 	platform_driver_unregister(&cam_actuator_platform_driver);
-	i2c_del_driver(&cam_actuator_driver_i2c);
+	i2c_del_driver(&cam_actuator_i2c_driver);
 }
 
 MODULE_DESCRIPTION("cam_actuator_driver");

+ 2 - 2
drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.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.
  */
 
 
@@ -30,7 +30,7 @@
 #define NUM_MASTERS 2
 #define NUM_QUEUES 2
 
-#define ACTUATOR_DRIVER_I2C "i2c_actuator"
+#define ACTUATOR_DRIVER_I2C "cam-i2c-actuator"
 #define CAMX_ACTUATOR_DEV_NAME "cam-actuator-driver"
 
 #define MSM_ACTUATOR_MAX_VREGS (10)

+ 57 - 30
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c

@@ -124,8 +124,9 @@ static inline int cam_csiphy_release_from_reset_state(struct csiphy_device *csip
 	bool                                                 config_found = false;
 
 	if (!csiphy_dev || !csiphybase) {
-		CAM_ERR(CAM_CSIPHY, "Invalid input params: csiphy_dev: %p, csiphybase: %p",
-			csiphy_dev, csiphybase);
+		CAM_ERR(CAM_CSIPHY, "Invalid input params: csiphy_dev: %s, csiphybase: %s",
+			CAM_IS_NULL_TO_STR(csiphy_dev),
+			CAM_IS_NULL_TO_STR(csiphybase));
 		return -EINVAL;
 	}
 
@@ -1929,33 +1930,35 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		}
 
 		if (!csiphy_dev->acquire_count) {
-			g_phy_data[csiphy_dev->soc_info.index].is_3phase =
-					csiphy_acq_params.csiphy_3phase;
+			g_phy_data[soc_info->index].is_3phase = csiphy_acq_params.csiphy_3phase;
 			CAM_DBG(CAM_CSIPHY,
 					"g_csiphy data is updated for index: %d is_3phase: %u",
-					csiphy_dev->soc_info.index,
-					g_phy_data[csiphy_dev->soc_info.index].is_3phase);
+					soc_info->index,
+					g_phy_data[soc_info->index].is_3phase);
 		}
 
-		if (g_phy_data[csiphy_dev->soc_info.index].enable_aon_support) {
-			rc = cam_csiphy_util_update_aon_ops(true, csiphy_dev->soc_info.index);
+		if (g_phy_data[soc_info->index].enable_aon_support) {
+			rc = cam_csiphy_util_update_aon_ops(true, soc_info->index);
 			if (rc) {
 				CAM_ERR(CAM_CSIPHY,
 					"Error in setting up AON operation for phy_idx: %d, rc: %d",
-					csiphy_dev->soc_info.index, rc);
+					soc_info->index, rc);
 				goto release_mutex;
 			}
 		}
 
 		csiphy_dev->acquire_count++;
-		CAM_DBG(CAM_CSIPHY, "ACQUIRE_CNT: %d",
-			csiphy_dev->acquire_count);
 
 		if (csiphy_dev->csiphy_state == CAM_CSIPHY_INIT)
 			csiphy_dev->csiphy_state = CAM_CSIPHY_ACQUIRE;
 
 		CAM_INFO(CAM_CSIPHY,
-			"CAM_ACQUIRE_DEV: CSIPHY_IDX: %d", csiphy_dev->soc_info.index);
+			"CAM_ACQUIRE_DEV: %u Type: %s acquire_count: %d combo: %u cphy+dphy combo: %u",
+			soc_info->index,
+			g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY",
+			csiphy_dev->acquire_count,
+			csiphy_dev->combo_mode,
+			csiphy_dev->cphy_dphy_combo_mode);
 	}
 		break;
 	case CAM_QUERY_CAP: {
@@ -1974,7 +1977,6 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		int32_t offset, rc = 0;
 		struct cam_start_stop_dev_cmd config;
 
-		CAM_DBG(CAM_CSIPHY, "STOP_DEV CALLED");
 		rc = copy_from_user(&config, (void __user *)cmd->handle,
 					sizeof(config));
 		if (rc < 0) {
@@ -1984,7 +1986,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 
 		if (csiphy_dev->csiphy_state != CAM_CSIPHY_START) {
 			CAM_ERR(CAM_CSIPHY, "Csiphy:%d Not in right state to stop : %d",
-				csiphy_dev->soc_info.index, csiphy_dev->csiphy_state);
+				soc_info->index, csiphy_dev->csiphy_state);
 			goto release_mutex;
 		}
 
@@ -1997,8 +1999,6 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		}
 
 		if (--csiphy_dev->start_dev_count) {
-			CAM_DBG(CAM_CSIPHY, "Stop Dev ref Cnt: %d",
-				csiphy_dev->start_dev_count);
 			if (csiphy_dev->csiphy_info[offset].secure_mode)
 				cam_csiphy_notify_secure_mode(
 					csiphy_dev,
@@ -2010,6 +2010,16 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 				= 0;
 
 			cam_csiphy_update_lane(csiphy_dev, offset, false);
+
+			CAM_INFO(CAM_CSIPHY,
+				"CAM_STOP_PHYDEV: %d, Type: %s, dev_cnt: %u, slot: %d, Datarate: %llu, Settletime: %llu",
+				soc_info->index,
+				g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY",
+				csiphy_dev->start_dev_count,
+				offset,
+				csiphy_dev->csiphy_info[offset].data_rate,
+				csiphy_dev->csiphy_info[offset].settle_time);
+
 			goto release_mutex;
 		}
 
@@ -2043,12 +2053,13 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 			rc = -EFAULT;
 		}
 
-		CAM_DBG(CAM_CSIPHY, "All PHY devices stopped");
 		csiphy_dev->csiphy_state = CAM_CSIPHY_ACQUIRE;
 
 		CAM_INFO(CAM_CSIPHY,
-			"CAM_STOP_PHYDEV: CSIPHY_IDX: %d, Device_slot: %d, Datarate: %llu, Settletime: %llu",
-			csiphy_dev->soc_info.index, offset,
+			"CAM_STOP_PHYDEV: %u, Type: %s, slot: %d, Datarate: %llu, Settletime: %llu",
+			soc_info->index,
+			g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY",
+			offset,
 			csiphy_dev->csiphy_info[offset].data_rate,
 			csiphy_dev->csiphy_info[offset].settle_time);
 	}
@@ -2057,8 +2068,6 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		int32_t offset;
 		struct cam_release_dev_cmd release;
 
-		CAM_DBG(CAM_CSIPHY, "RELEASE_DEV Called");
-
 		if (!csiphy_dev->acquire_count) {
 			CAM_ERR(CAM_CSIPHY, "No valid devices to release");
 			rc = -EINVAL;
@@ -2107,8 +2116,8 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 
 		if (csiphy_dev->acquire_count == 0) {
 			CAM_DBG(CAM_CSIPHY, "All PHY devices released");
-			if (g_phy_data[csiphy_dev->soc_info.index].enable_aon_support) {
-				rc = cam_csiphy_util_update_aon_ops(false, csiphy_dev->soc_info.index);
+			if (g_phy_data[soc_info->index].enable_aon_support) {
+				rc = cam_csiphy_util_update_aon_ops(false, soc_info->index);
 				if (rc) {
 					CAM_WARN(CAM_CSIPHY,
 						"Error in releasing AON operation for phy_idx: %d, rc: %d",
@@ -2120,6 +2129,10 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 			csiphy_dev->csiphy_state = CAM_CSIPHY_INIT;
 		}
 
+		CAM_DBG(CAM_CSIPHY, "CAM_RELEASE_PHYDEV: %u Type: %s",
+			soc_info->index,
+			g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY");
+
 		break;
 	}
 	case CAM_CONFIG_DEV: {
@@ -2228,6 +2241,19 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 				cam_csiphy_reg_dump(&csiphy_dev->soc_info);
 
 			csiphy_dev->start_dev_count++;
+
+			CAM_INFO(CAM_CSIPHY,
+				"CAM_START_PHYDEV: %d, Type: %s, dev_cnt: %u, slot: %d, combo: %u, cphy+dphy: %u, sec_mode: %d, Datarate: %llu, Settletime: %llu",
+				soc_info->index,
+				g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY",
+				csiphy_dev->start_dev_count,
+				offset,
+				csiphy_dev->combo_mode,
+				csiphy_dev->cphy_dphy_combo_mode,
+				csiphy_dev->csiphy_info[offset].secure_mode,
+				csiphy_dev->csiphy_info[offset].data_rate,
+				csiphy_dev->csiphy_info[offset].settle_time);
+
 			goto release_mutex;
 		}
 
@@ -2283,7 +2309,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 
 		cam_csiphy_release_from_reset_state(csiphy_dev, csiphybase, offset);
 
-		if (g_phy_data[csiphy_dev->soc_info.index].is_3phase && status_reg_ptr) {
+		if (g_phy_data[soc_info->index].is_3phase && status_reg_ptr) {
 			for (i = 0; i < CAM_CSIPHY_MAX_CPHY_LANES; i++) {
 				if (status_reg_ptr->cphy_lane_status[i]) {
 					cphy_trio_status = cam_io_r_mb(csiphybase +
@@ -2315,17 +2341,18 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		}
 
 		csiphy_dev->start_dev_count++;
-
-		CAM_DBG(CAM_CSIPHY, "START DEV CNT: %d",
-			csiphy_dev->start_dev_count);
 		csiphy_dev->csiphy_state = CAM_CSIPHY_START;
 
 		CAM_INFO(CAM_CSIPHY,
-			"CAM_START_PHYDEV: CSIPHY_IDX: %d, Device_slot: %d, cp_mode: %d, Datarate: %llu, Settletime: %llu",
-			csiphy_dev->soc_info.index, offset,
+			"CAM_START_PHYDEV: %d, Type: %s, slot: %d, sec_mode: %d, Datarate: %llu, Settletime: %llu, combo: %u, cphy+dphy: %u",
+			soc_info->index,
+			g_phy_data[soc_info->index].is_3phase ? "CPHY" : "DPHY",
+			offset,
 			csiphy_dev->csiphy_info[offset].secure_mode,
 			csiphy_dev->csiphy_info[offset].data_rate,
-			csiphy_dev->csiphy_info[offset].settle_time);
+			csiphy_dev->csiphy_info[offset].settle_time,
+			csiphy_dev->combo_mode,
+			csiphy_dev->cphy_dphy_combo_mode);
 	}
 		break;
 	case CAM_CONFIG_DEV_EXTERNAL: {

+ 11 - 0
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c

@@ -9,6 +9,7 @@
 #include "cam_csiphy_core.h"
 #include <media/cam_sensor.h>
 #include "camera_main.h"
+#include <dt-bindings/msm-camera.h>
 
 #define CSIPHY_DEBUGFS_NAME_MAX_SIZE 10
 static struct dentry *root_dentry;
@@ -248,6 +249,16 @@ static int cam_csiphy_component_bind(struct device *dev,
 		goto csiphy_no_resource;
 	}
 
+	/* validate PHY fuse only for CSIPHY4 */
+	if ((new_csiphy_dev->soc_info.index == 4) &&
+		!cam_cpas_is_feature_supported(
+			CAM_CPAS_CSIPHY_FUSE,
+			(1 << new_csiphy_dev->soc_info.index), NULL)) {
+		CAM_ERR(CAM_CSIPHY, "PHY%d is not supported",
+			new_csiphy_dev->soc_info.index);
+		goto csiphy_no_resource;
+	}
+
 	new_csiphy_dev->v4l2_dev_str.internal_ops =
 		&csiphy_subdev_intern_ops;
 	new_csiphy_dev->v4l2_dev_str.ops =

+ 1 - 1
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h

@@ -34,7 +34,7 @@
 
 #define MAX_LANES                   5
 #define MAX_SETTINGS_PER_LANE       50
-#define MAX_DATA_RATES              12
+#define MAX_DATA_RATES              25
 #define MAX_DATA_RATE_REGS          30
 
 #define CAMX_CSIPHY_DEV_NAME "cam-csiphy-driver"

File diff suppressed because it is too large
+ 656 - 95
drivers/cam_sensor_module/cam_csiphy/include/cam_csiphy_2_1_3_hwreg.h


+ 70 - 12
drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c

@@ -177,17 +177,20 @@ static int cam_eeprom_init_subdev(struct cam_eeprom_ctrl_t *e_ctrl)
 	return rc;
 }
 
-static int cam_eeprom_i2c_driver_probe(struct i2c_client *client,
-	 const struct i2c_device_id *id)
+static int cam_eeprom_i2c_component_bind(struct device *dev,
+	struct device *master_dev, void *data)
 {
 	int                             rc = 0;
+	struct i2c_client              *client = NULL;
 	struct cam_eeprom_ctrl_t       *e_ctrl = NULL;
 	struct cam_eeprom_soc_private  *soc_private = NULL;
 	struct cam_hw_soc_info         *soc_info = NULL;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CAM_ERR(CAM_EEPROM, "i2c_check_functionality failed");
-		goto probe_failure;
+	client = container_of(dev, struct i2c_client, dev);
+	if (client == NULL) {
+		CAM_ERR(CAM_OIS, "Invalid Args client: %pK",
+			client);
+		return -EINVAL;
 	}
 
 	e_ctrl = kzalloc(sizeof(*e_ctrl), GFP_KERNEL);
@@ -253,30 +256,40 @@ probe_failure:
 	return rc;
 }
 
-static int cam_eeprom_i2c_driver_remove(struct i2c_client *client)
+static void cam_eeprom_i2c_component_unbind(struct device *dev,
+	struct device *master_dev, void *data)
 {
 	int                             i;
+	struct i2c_client              *client = NULL;
 	struct v4l2_subdev             *sd = i2c_get_clientdata(client);
 	struct cam_eeprom_ctrl_t       *e_ctrl;
 	struct cam_eeprom_soc_private  *soc_private;
 	struct cam_hw_soc_info         *soc_info;
 
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_EEPROM,
+			"Failed to get i2c client");
+		return;
+	}
+
+	sd = i2c_get_clientdata(client);
 	if (!sd) {
 		CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
-		return -EINVAL;
+		return;
 	}
 
 	e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
 	if (!e_ctrl) {
 		CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
-		return -EINVAL;
+		return;
 	}
 
 	soc_private =
 		(struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
 	if (!soc_private) {
 		CAM_ERR(CAM_EEPROM, "soc_info.soc_private is NULL");
-		return -EINVAL;
+		return;
 	}
 
 	CAM_INFO(CAM_EEPROM, "i2c driver remove invoked");
@@ -292,6 +305,41 @@ static int cam_eeprom_i2c_driver_remove(struct i2c_client *client)
 	kfree(soc_private);
 	v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, NULL);
 	kfree(e_ctrl);
+}
+
+const static struct component_ops cam_eeprom_i2c_component_ops = {
+	.bind = cam_eeprom_i2c_component_bind,
+	.unbind = cam_eeprom_i2c_component_unbind,
+};
+
+static int cam_eeprom_i2c_driver_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int rc = 0;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_EEPROM, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_EEPROM, "%s :: i2c_check_functionality failed",
+			client->name);
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_EEPROM, "Adding sensor eeprom component");
+	rc = component_add(&client->dev, &cam_eeprom_i2c_component_ops);
+	if (rc)
+		CAM_ERR(CAM_EEPROM, "failed to add component rc: %d", rc);
+
+	return rc;
+}
+
+static int cam_eeprom_i2c_driver_remove(struct i2c_client *client)
+{
+	component_del(&client->dev, &cam_eeprom_i2c_component_ops);
 
 	return 0;
 }
@@ -585,16 +633,26 @@ struct platform_driver cam_eeprom_platform_driver = {
 };
 
 static const struct i2c_device_id cam_eeprom_i2c_id[] = {
-	{ "msm_eeprom", (kernel_ulong_t)NULL},
+	{ EEPROM_DRIVER_I2C, (kernel_ulong_t)NULL},
 	{ }
 };
 
-static struct i2c_driver cam_eeprom_i2c_driver = {
+static const struct of_device_id cam_eeprom_i2c_dt_match[] = {
+	{ .compatible = "qcom,cam-i2c-eeprom" },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, cam_eeprom_i2c_dt_match);
+
+struct i2c_driver cam_eeprom_i2c_driver = {
 	.id_table = cam_eeprom_i2c_id,
 	.probe  = cam_eeprom_i2c_driver_probe,
 	.remove = cam_eeprom_i2c_driver_remove,
 	.driver = {
-		.name = "msm_eeprom",
+		.name = EEPROM_DRIVER_I2C,
+		.owner = THIS_MODULE,
+		.of_match_table = cam_eeprom_i2c_dt_match,
+		.suppress_bind_attrs = true,
 	},
 };
 

+ 3 - 1
drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.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 _CAM_EEPROM_DEV_H_
 #define _CAM_EEPROM_DEV_H_
@@ -33,6 +33,8 @@
 #define MSM_EEPROM_MAX_MEM_MAP_CNT             100
 #define MSM_EEPROM_MEM_MAP_PROPERTIES_CNT      8
 
+#define EEPROM_DRIVER_I2C "cam-i2c-eeprom"
+
 enum cam_eeprom_state {
 	CAM_EEPROM_INIT,
 	CAM_EEPROM_ACQUIRE,

+ 82 - 36
drivers/cam_sensor_module/cam_flash/cam_flash_dev.c

@@ -35,9 +35,6 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
 		struct cam_sensor_acquire_dev flash_acq_dev;
 		struct cam_create_dev_hdl bridge_params;
 
-		CAM_INFO(CAM_FLASH, "CAM_ACQUIRE_DEV for dev_hdl: 0x%x",
-			fctrl->bridge_intf.device_hdl);
-
 		if (fctrl->flash_state != CAM_FLASH_STATE_INIT) {
 			CAM_ERR(CAM_FLASH,
 				"Cannot apply Acquire dev: Prev state: %d",
@@ -84,6 +81,9 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
 			goto release_mutex;
 		}
 		fctrl->flash_state = CAM_FLASH_STATE_ACQUIRE;
+
+		CAM_INFO(CAM_FLASH, "CAM_ACQUIRE_DEV for dev_hdl: 0x%x",
+			fctrl->bridge_intf.device_hdl);
 		break;
 	}
 	case CAM_RELEASE_DEV: {
@@ -353,24 +353,6 @@ static long cam_flash_subdev_do_ioctl(struct v4l2_subdev *sd,
 }
 #endif
 
-static int32_t cam_flash_i2c_driver_remove(struct i2c_client *client)
-{
-	int32_t rc = 0;
-	struct cam_flash_ctrl *fctrl = i2c_get_clientdata(client);
-	/* Handle I2C Devices */
-	if (!fctrl) {
-		CAM_ERR(CAM_FLASH, "Flash device is NULL");
-		return -EINVAL;
-	}
-
-	CAM_INFO(CAM_FLASH, "i2c driver remove invoked");
-	/*Free Allocated Mem */
-	kfree(fctrl->i2c_data.per_frame);
-	fctrl->i2c_data.per_frame = NULL;
-	kfree(fctrl);
-	return rc;
-}
-
 static struct v4l2_subdev_core_ops cam_flash_subdev_core_ops = {
 	.ioctl = cam_flash_subdev_ioctl,
 #ifdef CONFIG_COMPAT
@@ -581,29 +563,21 @@ static int32_t cam_flash_platform_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
+static int cam_flash_i2c_component_bind(struct device *dev,
+	struct device *master_dev, void *data)
 {
 	int32_t rc = 0, i = 0;
-	struct cam_flash_ctrl *fctrl;
+	struct i2c_client      *client = NULL;
+	struct cam_flash_ctrl  *fctrl = NULL;
 	struct cam_hw_soc_info *soc_info = NULL;
 
+	client = container_of(dev, struct i2c_client, dev);
 	if (client == NULL) {
 		CAM_ERR(CAM_FLASH, "Invalid Args client: %pK",
 			client);
 		return -EINVAL;
 	}
 
-	if (id == NULL) {
-		CAM_DBG(CAM_FLASH, "device id is Null");
-	}
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CAM_ERR(CAM_FLASH, "%s :: i2c_check_functionality failed",
-			 client->name);
-		return -EFAULT;
-	}
-
 	/* Create sensor control structure */
 	fctrl = kzalloc(sizeof(*fctrl), GFP_KERNEL);
 	if (!fctrl)
@@ -708,6 +682,70 @@ free_ctrl:
 	return rc;
 }
 
+static void cam_flash_i2c_component_unbind(struct device *dev,
+	struct device *master_dev, void *data)
+{
+	struct i2c_client     *client = NULL;
+	struct cam_flash_ctrl *fctrl = NULL;
+
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_FLASH,
+			"Failed to get i2c client");
+		return;
+	}
+
+	fctrl = i2c_get_clientdata(client);
+	/* Handle I2C Devices */
+	if (!fctrl) {
+		CAM_ERR(CAM_FLASH, "Flash device is NULL");
+		return;
+	}
+
+	CAM_INFO(CAM_FLASH, "i2c driver remove invoked");
+	/*Free Allocated Mem */
+	kfree(fctrl->i2c_data.per_frame);
+	fctrl->i2c_data.per_frame = NULL;
+	kfree(fctrl);
+}
+
+const static struct component_ops cam_flash_i2c_component_ops = {
+	.bind = cam_flash_i2c_component_bind,
+	.unbind = cam_flash_i2c_component_unbind,
+};
+
+static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int rc = 0;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_FLASH, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_FLASH, "%s :: i2c_check_functionality failed",
+			client->name);
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_FLASH, "Adding sensor flash component");
+	rc = component_add(&client->dev, &cam_flash_i2c_component_ops);
+	if (rc)
+		CAM_ERR(CAM_FLASH, "failed to add component rc: %d", rc);
+
+	return rc;
+}
+
+static int32_t cam_flash_i2c_driver_remove(struct i2c_client *client)
+{
+	component_del(&client->dev, &cam_flash_i2c_component_ops);
+
+	return 0;
+}
+
 MODULE_DEVICE_TABLE(of, cam_flash_dt_match);
 
 struct platform_driver cam_flash_platform_driver = {
@@ -721,18 +759,26 @@ struct platform_driver cam_flash_platform_driver = {
 	},
 };
 
+static const struct of_device_id cam_flash_i2c_dt_match[] = {
+	{.compatible = "qcom,cam-i2c-flash", .data = NULL},
+	{}
+};
+MODULE_DEVICE_TABLE(of, cam_flash_i2c_dt_match);
+
 static const struct i2c_device_id i2c_id[] = {
 	{FLASH_DRIVER_I2C, (kernel_ulong_t)NULL},
 	{ }
 };
 
-static struct i2c_driver cam_flash_i2c_driver = {
+struct i2c_driver cam_flash_i2c_driver = {
 	.id_table = i2c_id,
 	.probe  = cam_flash_i2c_driver_probe,
 	.remove = cam_flash_i2c_driver_remove,
 	.driver = {
+		.owner = THIS_MODULE,
 		.name = FLASH_DRIVER_I2C,
-		.of_match_table = cam_flash_dt_match,
+		.of_match_table = cam_flash_i2c_dt_match,
+		.suppress_bind_attrs = true,
 	},
 };
 

+ 1 - 1
drivers/cam_sensor_module/cam_flash/cam_flash_dev.h

@@ -40,7 +40,7 @@
 
 #define CAM_FLASH_PIPELINE_DELAY 1
 
-#define FLASH_DRIVER_I2C "i2c_flash"
+#define FLASH_DRIVER_I2C "cam-i2c-flash"
 
 #define CAM_FLASH_PACKET_OPCODE_INIT                 0
 #define CAM_FLASH_PACKET_OPCODE_SET_OPS              1

+ 66 - 16
drivers/cam_sensor_module/cam_ois/cam_ois_dev.c

@@ -173,24 +173,21 @@ static int cam_ois_init_subdev_param(struct cam_ois_ctrl_t *o_ctrl)
 	return rc;
 }
 
-static int cam_ois_i2c_driver_probe(struct i2c_client *client,
-	 const struct i2c_device_id *id)
+static int cam_ois_i2c_component_bind(struct device *dev,
+	struct device *master_dev, void *data)
 {
 	int                          rc = 0;
+	struct i2c_client           *client = NULL;
 	struct cam_ois_ctrl_t       *o_ctrl = NULL;
 	struct cam_ois_soc_private  *soc_private = NULL;
 
-	if (client == NULL || id == NULL) {
-		CAM_ERR(CAM_OIS, "Invalid Args client: %pK id: %pK",
-			client, id);
+	client = container_of(dev, struct i2c_client, dev);
+	if (client == NULL) {
+		CAM_ERR(CAM_OIS, "Invalid Args client: %pK",
+			client);
 		return -EINVAL;
 	}
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CAM_ERR(CAM_OIS, "i2c_check_functionality failed");
-		goto probe_failure;
-	}
-
 	o_ctrl = kzalloc(sizeof(*o_ctrl), GFP_KERNEL);
 	if (!o_ctrl) {
 		CAM_ERR(CAM_OIS, "kzalloc failed");
@@ -236,17 +233,27 @@ probe_failure:
 	return rc;
 }
 
-static int cam_ois_i2c_driver_remove(struct i2c_client *client)
+static void cam_ois_i2c_component_unbind(struct device *dev,
+	struct device *master_dev, void *data)
 {
 	int                             i;
-	struct cam_ois_ctrl_t          *o_ctrl = i2c_get_clientdata(client);
+	struct i2c_client              *client = NULL;
+	struct cam_ois_ctrl_t          *o_ctrl = NULL;
 	struct cam_hw_soc_info         *soc_info;
 	struct cam_ois_soc_private     *soc_private;
 	struct cam_sensor_power_ctrl_t *power_info;
 
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_OIS,
+			"Failed to get i2c client");
+		return;
+	}
+
+	o_ctrl = i2c_get_clientdata(client);
 	if (!o_ctrl) {
 		CAM_ERR(CAM_OIS, "ois device is NULL");
-		return -EINVAL;
+		return;
 	}
 
 	CAM_INFO(CAM_OIS, "i2c driver remove invoked");
@@ -267,6 +274,41 @@ static int cam_ois_i2c_driver_remove(struct i2c_client *client)
 	kfree(o_ctrl->soc_info.soc_private);
 	v4l2_set_subdevdata(&o_ctrl->v4l2_dev_str.sd, NULL);
 	kfree(o_ctrl);
+}
+
+const static struct component_ops cam_ois_i2c_component_ops = {
+	.bind = cam_ois_i2c_component_bind,
+	.unbind = cam_ois_i2c_component_unbind,
+};
+
+static int cam_ois_i2c_driver_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int rc = 0;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_OIS, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_OIS, "%s :: i2c_check_functionality failed",
+			client->name);
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_OIS, "Adding sensor ois component");
+	rc = component_add(&client->dev, &cam_ois_i2c_component_ops);
+	if (rc)
+		CAM_ERR(CAM_OIS, "failed to add component rc: %d", rc);
+
+	return rc;
+}
+
+static int cam_ois_i2c_driver_remove(struct i2c_client *client)
+{
+	component_del(&client->dev, &cam_ois_i2c_component_ops);
 
 	return 0;
 }
@@ -409,8 +451,13 @@ static const struct of_device_id cam_ois_dt_match[] = {
 	{ }
 };
 
+static const struct of_device_id cam_ois_i2c_dt_match[] = {
+	{ .compatible = "qcom,cam-i2c-ois" },
+	{ }
+};
 
 MODULE_DEVICE_TABLE(of, cam_ois_dt_match);
+MODULE_DEVICE_TABLE(of, cam_ois_i2c_dt_match);
 
 struct platform_driver cam_ois_platform_driver = {
 	.driver = {
@@ -422,16 +469,19 @@ struct platform_driver cam_ois_platform_driver = {
 	.remove = cam_ois_platform_driver_remove,
 };
 static const struct i2c_device_id cam_ois_i2c_id[] = {
-	{ "msm_ois", (kernel_ulong_t)NULL},
+	{ OIS_DRIVER_I2C, (kernel_ulong_t)NULL},
 	{ }
 };
 
-static struct i2c_driver cam_ois_i2c_driver = {
+struct i2c_driver cam_ois_i2c_driver = {
 	.id_table = cam_ois_i2c_id,
 	.probe  = cam_ois_i2c_driver_probe,
 	.remove = cam_ois_i2c_driver_remove,
 	.driver = {
-		.name = "msm_ois",
+		.name = OIS_DRIVER_I2C,
+		.owner = THIS_MODULE,
+		.of_match_table = cam_ois_i2c_dt_match,
+		.suppress_bind_attrs = true,
 	},
 };
 

+ 3 - 1
drivers/cam_sensor_module/cam_ois/cam_ois_dev.h

@@ -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.
  */
 #ifndef _CAM_OIS_DEV_H_
 #define _CAM_OIS_DEV_H_
@@ -25,6 +25,8 @@
 #define DEFINE_MSM_MUTEX(mutexname) \
 	static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
 
+#define OIS_DRIVER_I2C "cam-i2c-ois"
+
 enum cam_ois_state {
 	CAM_OIS_INIT,
 	CAM_OIS_ACQUIRE,

+ 95 - 41
drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c

@@ -153,18 +153,20 @@ static int cam_sensor_init_subdev_params(struct cam_sensor_ctrl_t *s_ctrl)
 	return rc;
 }
 
-static int32_t cam_sensor_driver_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
+static int cam_sensor_i2c_component_bind(struct device *dev,
+	struct device *master_dev, void *data)
 {
-	int32_t rc = 0;
-	int i = 0;
+	int32_t                   rc = 0;
+	int                       i = 0;
+	struct i2c_client        *client = NULL;
 	struct cam_sensor_ctrl_t *s_ctrl = NULL;
 	struct cam_hw_soc_info   *soc_info = NULL;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CAM_ERR(CAM_SENSOR,
-			"%s :i2c_check_functionality failed", client->name);
-		return -EFAULT;
+	client = container_of(dev, struct i2c_client, dev);
+	if (client == NULL) {
+		CAM_ERR(CAM_SENSOR, "Invalid Args client: %pK",
+			client);
+		return -EINVAL;
 	}
 
 	/* Create sensor control structure */
@@ -243,6 +245,76 @@ free_s_ctrl:
 	return rc;
 }
 
+static void cam_sensor_i2c_component_unbind(struct device *dev,
+	struct device *master_dev, void *data)
+{
+	struct i2c_client         *client = NULL;
+	struct cam_sensor_ctrl_t  *s_ctrl = NULL;
+	struct cam_hw_soc_info    *soc_info = NULL;
+
+	client = container_of(dev, struct i2c_client, dev);
+	if (!client) {
+		CAM_ERR(CAM_SENSOR,
+			"Failed to get i2c client");
+		return;
+	}
+
+	s_ctrl = i2c_get_clientdata(client);
+	if (!s_ctrl) {
+		CAM_ERR(CAM_SENSOR, "sensor device is NULL");
+		return;
+	}
+
+	CAM_DBG(CAM_SENSOR, "i2c remove invoked");
+	mutex_lock(&(s_ctrl->cam_sensor_mutex));
+	cam_sensor_shutdown(s_ctrl);
+	mutex_unlock(&(s_ctrl->cam_sensor_mutex));
+	cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
+	soc_info = &s_ctrl->soc_info;
+
+	kfree(s_ctrl->i2c_data.per_frame);
+	kfree(s_ctrl->i2c_data.frame_skip);
+	v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
+	kfree(s_ctrl);
+}
+
+const static struct component_ops cam_sensor_i2c_component_ops = {
+	.bind = cam_sensor_i2c_component_bind,
+	.unbind = cam_sensor_i2c_component_unbind,
+};
+
+static int cam_sensor_i2c_driver_probe(struct i2c_client *client,
+	const struct i2c_device_id *id)
+{
+	int rc = 0;
+
+	if (client == NULL || id == NULL) {
+		CAM_ERR(CAM_SENSOR, "Invalid Args client: %pK id: %pK",
+			client, id);
+		return -EINVAL;
+	}
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		CAM_ERR(CAM_SENSOR, "%s :: i2c_check_functionality failed",
+			client->name);
+		return -EFAULT;
+	}
+
+	CAM_DBG(CAM_SENSOR, "Adding sensor component");
+	rc = component_add(&client->dev, &cam_sensor_i2c_component_ops);
+	if (rc)
+		CAM_ERR(CAM_SENSOR, "failed to add component rc: %d", rc);
+
+	return rc;
+}
+
+static int cam_sensor_i2c_driver_remove(struct i2c_client *client)
+{
+	component_del(&client->dev, &cam_sensor_i2c_component_ops);
+
+	return 0;
+}
+
 static int cam_sensor_component_bind(struct device *dev,
 	struct device *master_dev, void *data)
 {
@@ -378,34 +450,6 @@ static int cam_sensor_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static int cam_sensor_driver_i2c_remove(struct i2c_client *client)
-{
-	int                        i;
-	struct cam_sensor_ctrl_t  *s_ctrl = i2c_get_clientdata(client);
-	struct cam_hw_soc_info    *soc_info;
-
-	if (!s_ctrl) {
-		CAM_ERR(CAM_SENSOR, "sensor device is NULL");
-		return 0;
-	}
-
-	CAM_DBG(CAM_SENSOR, "i2c remove invoked");
-	mutex_lock(&(s_ctrl->cam_sensor_mutex));
-	cam_sensor_shutdown(s_ctrl);
-	mutex_unlock(&(s_ctrl->cam_sensor_mutex));
-	cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
-	soc_info = &s_ctrl->soc_info;
-	for (i = 0; i < soc_info->num_clk; i++)
-		devm_clk_put(soc_info->dev, soc_info->clk[i]);
-
-	kfree(s_ctrl->i2c_data.per_frame);
-	kfree(s_ctrl->i2c_data.frame_skip);
-	v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
-	kfree(s_ctrl);
-
-	return 0;
-}
-
 static const struct of_device_id cam_sensor_driver_dt_match[] = {
 	{.compatible = "qcom,cam-sensor"},
 	{}
@@ -437,17 +481,27 @@ struct platform_driver cam_sensor_platform_driver = {
 	.remove = cam_sensor_platform_remove,
 };
 
+static const struct of_device_id cam_sensor_i2c_driver_dt_match[] = {
+	{.compatible = "qcom,cam-i2c-sensor"},
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, cam_sensor_i2c_driver_dt_match);
+
 static const struct i2c_device_id i2c_id[] = {
 	{SENSOR_DRIVER_I2C, (kernel_ulong_t)NULL},
 	{ }
 };
 
-static struct i2c_driver cam_sensor_driver_i2c = {
+struct i2c_driver cam_sensor_i2c_driver = {
 	.id_table = i2c_id,
-	.probe = cam_sensor_driver_i2c_probe,
-	.remove = cam_sensor_driver_i2c_remove,
+	.probe = cam_sensor_i2c_driver_probe,
+	.remove = cam_sensor_i2c_driver_remove,
 	.driver = {
 		.name = SENSOR_DRIVER_I2C,
+		.owner = THIS_MODULE,
+		.of_match_table = cam_sensor_i2c_driver_dt_match,
+		.suppress_bind_attrs = true,
 	},
 };
 
@@ -462,7 +516,7 @@ int cam_sensor_driver_init(void)
 		return rc;
 	}
 
-	rc = i2c_add_driver(&cam_sensor_driver_i2c);
+	rc = i2c_add_driver(&cam_sensor_i2c_driver);
 	if (rc)
 		CAM_ERR(CAM_SENSOR, "i2c_add_driver failed rc = %d", rc);
 
@@ -472,7 +526,7 @@ int cam_sensor_driver_init(void)
 void cam_sensor_driver_exit(void)
 {
 	platform_driver_unregister(&cam_sensor_platform_driver);
-	i2c_del_driver(&cam_sensor_driver_i2c);
+	i2c_del_driver(&cam_sensor_i2c_driver);
 }
 
 MODULE_DESCRIPTION("cam_sensor_driver");

+ 1 - 1
drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h

@@ -35,7 +35,7 @@
 #define CDBG(fmt, args...) pr_debug(fmt, ##args)
 #endif
 
-#define SENSOR_DRIVER_I2C "i2c_camera"
+#define SENSOR_DRIVER_I2C "cam-i2c-sensor"
 #define CAMX_SENSOR_DEV_NAME "cam-sensor-driver"
 
 enum cam_sensor_state_t {

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

@@ -314,6 +314,8 @@ static int cam_tpg_component_bind(struct device *dev,
 		goto release_subdev;
 	}
 
+	platform_set_drvdata(pdev, tpg_dev);
+
 	return rc;
 
 release_subdev:
@@ -327,9 +329,7 @@ static void cam_tpg_component_unbind(struct device *dev,
 	struct device *master_dev, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
-
-	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
-	struct cam_tpg_device *tpg_dev = v4l2_get_subdevdata(subdev);
+	struct cam_tpg_device  *tpg_dev = platform_get_drvdata(pdev);
 
 	CAM_INFO(CAM_TPG, "Unbind TPG component");
 	cam_cpas_unregister_client(tpg_dev->cpas_handle);

+ 37 - 4
drivers/cam_utils/cam_compat.c

@@ -104,6 +104,11 @@ static int camera_platform_compare_dev(struct device *dev, const void *data)
 {
 	return platform_bus_type.match(dev, (struct device_driver *) data);
 }
+
+static int camera_i2c_compare_dev(struct device *dev, const void *data)
+{
+	return i2c_bus_type.match(dev, (struct device_driver *) data);
+}
 #else
 int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length)
 {
@@ -188,6 +193,11 @@ static int camera_platform_compare_dev(struct device *dev, void *data)
 {
 	return platform_bus_type.match(dev, (struct device_driver *) data);
 }
+
+static int camera_i2c_compare_dev(struct device *dev, void *data)
+{
+	return i2c_bus_type.match(dev, (struct device_driver *) data);
+}
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
@@ -214,6 +224,7 @@ int camera_component_match_add_drivers(struct device *master_dev,
 {
 	int i, rc = 0;
 	struct platform_device *pdev = NULL;
+	struct i2c_client *client = NULL;
 	struct device *start_dev = NULL, *match_dev = NULL;
 
 	if (!master_dev || !match_list) {
@@ -222,13 +233,13 @@ int camera_component_match_add_drivers(struct device *master_dev,
 		goto end;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(cam_component_drivers); i++) {
+	for (i = 0; i < ARRAY_SIZE(cam_component_platform_drivers); i++) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
 		struct device_driver const *drv =
-			&cam_component_drivers[i]->driver;
+			&cam_component_platform_drivers[i]->driver;
 		const void *drv_ptr = (const void *)drv;
 #else
-		struct device_driver *drv = &cam_component_drivers[i]->driver;
+		struct device_driver *drv = &cam_component_platform_drivers[i]->driver;
 		void *drv_ptr = (void *)drv;
 #endif
 		start_dev = NULL;
@@ -244,6 +255,28 @@ int camera_component_match_add_drivers(struct device *master_dev,
 		put_device(start_dev);
 	}
 
+	for (i = 0; i < ARRAY_SIZE(cam_component_i2c_drivers); i++) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
+		struct device_driver const *drv =
+			&cam_component_i2c_drivers[i]->driver;
+		const void *drv_ptr = (const void *)drv;
+#else
+		struct device_driver *drv = &cam_component_i2c_drivers[i]->driver;
+		void *drv_ptr = (void *)drv;
+#endif
+		start_dev = NULL;
+		while ((match_dev = bus_find_device(&i2c_bus_type,
+			start_dev, drv_ptr, &camera_i2c_compare_dev))) {
+			put_device(start_dev);
+			client = to_i2c_client(match_dev);
+			CAM_DBG(CAM_UTIL, "Adding matched component:%s", client->name);
+			component_match_add(master_dev, match_list,
+				camera_component_compare_dev, match_dev);
+			start_dev = match_dev;
+		}
+		put_device(start_dev);
+	}
+
 end:
 	return rc;
 }
@@ -366,4 +399,4 @@ int cam_get_ddr_type(void)
 {
 	return of_fdt_get_ddrtype();
 }
-#endif
+#endif

+ 2 - 0
drivers/cam_utils/cam_debug_util.h

@@ -14,6 +14,8 @@ extern unsigned long long debug_mdl;
 extern unsigned int debug_type;
 extern unsigned int debug_priority;
 
+#define CAM_IS_NULL_TO_STR(ptr) ((ptr) ? "Non-NULL" : "NULL")
+
 /* Module IDs used for debug logging */
 enum cam_debug_module_id {
 	CAM_CDM,                 /* bit 0 */

+ 10 - 7
drivers/cam_utils/cam_soc_util.c

@@ -14,7 +14,6 @@
 #include "cam_mem_mgr.h"
 #include "cam_presil_hw_access.h"
 
-
 #define CAM_TO_MASK(bitn)          (1 << (int)(bitn))
 #define CAM_IS_BIT_SET(mask, bit)  ((mask) & CAM_TO_MASK(bit))
 #define CAM_SET_BIT(mask, bit)     ((mask) |= CAM_TO_MASK(bit))
@@ -86,11 +85,14 @@ static LIST_HEAD(wrapper_clk_list);
 #if IS_REACHABLE(CONFIG_MSM_MMRM)
 bool cam_is_mmrm_supported_on_current_chip(void)
 {
-	/*
-	 * Enable on chipsets where mmrm does the resource management.
-	 * Either based on query API from mmrm or based on camera dt flag.
-	 */
-	return true;
+	bool is_supported;
+
+	is_supported = mmrm_client_check_scaling_supported(MMRM_CLIENT_CLOCK,
+			MMRM_CLIENT_DOMAIN_CAMERA);
+	CAM_DBG(CAM_UTIL, "is mmrm supported: %s",
+			CAM_BOOL_TO_YESNO(is_supported));;
+
+	return is_supported;
 }
 
 int cam_mmrm_notifier_callback(
@@ -1289,7 +1291,8 @@ int cam_soc_util_clk_disable(struct cam_hw_soc_info *soc_info,
 			"Dev %s clk %s Disabling Shared clk, set 0 rate",
 			soc_info->dev_name, clk_name);
 		cam_soc_util_clk_wrapper_set_clk_rate(clk_id, soc_info, clk, 0);
-	} else if ((!skip_mmrm_set_rate) && (soc_info->src_clk_idx == clk_idx)) {
+	} else if (soc_info->mmrm_handle && (!skip_mmrm_set_rate) &&
+			(soc_info->src_clk_idx == clk_idx)) {
 		CAM_DBG(CAM_UTIL,
 			"Dev %s Disabling %s clk, set 0 rate", soc_info->dev_name, clk_name);
 		cam_soc_util_set_rate_through_mmrm(

+ 18 - 1
drivers/camera_main.h

@@ -7,6 +7,7 @@
 #define CAMERA_MAIN_H
 
 #include <linux/platform_device.h>
+#include <linux/i2c.h>
 #include <linux/component.h>
 
 extern struct platform_driver cam_sync_driver;
@@ -35,6 +36,11 @@ extern struct platform_driver cam_sensor_platform_driver;
 extern struct platform_driver cam_eeprom_platform_driver;
 extern struct platform_driver cam_ois_platform_driver;
 extern struct platform_driver cam_tpg_driver;
+extern struct i2c_driver cam_actuator_i2c_driver;
+extern struct i2c_driver cam_flash_i2c_driver;
+extern struct i2c_driver cam_ois_i2c_driver;
+extern struct i2c_driver cam_eeprom_i2c_driver;
+extern struct i2c_driver cam_sensor_i2c_driver;
 #if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
 	IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
 extern struct platform_driver cam_flash_platform_driver;
@@ -78,7 +84,7 @@ extern struct platform_driver custom_driver;
  * Drivers to be bound by component framework in this order with
  * CRM as master
  */
-static struct platform_driver *const cam_component_drivers[] = {
+static struct platform_driver *const cam_component_platform_drivers[] = {
 /* BASE */
 	&cam_sync_driver,
 	&cam_smmu_driver,
@@ -146,4 +152,15 @@ static struct platform_driver *const cam_component_drivers[] = {
 #endif
 };
 
+
+static struct i2c_driver *const cam_component_i2c_drivers[] = {
+#ifdef CONFIG_SPECTRA_SENSOR
+	&cam_actuator_i2c_driver,
+	&cam_flash_i2c_driver,
+	&cam_ois_i2c_driver,
+	&cam_eeprom_i2c_driver,
+	&cam_sensor_i2c_driver,
+#endif
+};
+
 #endif /* CAMERA_MAIN_H */

+ 2 - 1
dt-bindings/msm-camera.h

@@ -91,7 +91,8 @@
 #define CAM_CPAS_ISP_FUSE      4
 #define CAM_CPAS_ISP_PIX_FUSE  5
 #define CAM_CPAS_ISP_LITE_FUSE 6
-#define CAM_CPAS_FUSE_FEATURE_MAX 7
+#define CAM_CPAS_CSIPHY_FUSE   7
+#define CAM_CPAS_FUSE_FEATURE_MAX 8
 
 #define CCI_MASTER_0         0
 #define CCI_MASTER_1         1

Some files were not shown because too many files changed in this diff