Jelajahi Sumber

Merge "msm: camera: csiphy: Add work queue to trigger the status register" into camera-kernel.lnx.5.0

Savita Patted 4 tahun lalu
induk
melakukan
97a5608106

+ 47 - 23
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c

@@ -1316,7 +1316,7 @@ int cam_csiphy_util_update_aon_ops(
 	return rc;
 }
 
-static int __cam_csiphy_read_2phase_bist_debug_status(
+static void __cam_csiphy_read_2phase_bist_debug_status(
 	struct csiphy_device *csiphy_dev)
 {
 	int i = 0;
@@ -1337,10 +1337,10 @@ static int __cam_csiphy_read_2phase_bist_debug_status(
 		}
 	}
 
-	return 0;
+	return;
 }
 
-static int __cam_csiphy_poll_2phase_pattern_status(
+static void __cam_csiphy_poll_2phase_pattern_status(
 	struct csiphy_device *csiphy_dev)
 {
 	int i = 0;
@@ -1363,7 +1363,7 @@ static int __cam_csiphy_poll_2phase_pattern_status(
 			}
 
 			if (status != 0) {
-				CAM_INFO(CAM_CSIPHY, "Pattern Test is completed");
+				CAM_INFO(CAM_CSIPHY, "PN9 Pattern Test is completed");
 				break;
 			}
 		}
@@ -1381,17 +1381,15 @@ static int __cam_csiphy_poll_2phase_pattern_status(
 		}
 	}
 
-	if (status == csiphy_dev->ctrl_reg->csiphy_bist_reg->expected_status_val) {
-		CAM_INFO(CAM_CSIPHY, "Pattern is received correctly");
-		return 0;
-	} else {
+	if (status == csiphy_dev->ctrl_reg->csiphy_bist_reg->expected_status_val)
+		CAM_INFO(CAM_CSIPHY, "PN9 Pattern received successfully");
+	else
 		__cam_csiphy_read_2phase_bist_debug_status(csiphy_dev);
-	}
 
-	return 0;
+	return;
 }
 
-static int __cam_csiphy_read_3phase_bist_debug_status(
+static void __cam_csiphy_read_3phase_bist_debug_status(
 	struct csiphy_device *csiphy_dev)
 {
 	int i = 0;
@@ -1412,10 +1410,10 @@ static int __cam_csiphy_read_3phase_bist_debug_status(
 		}
 	}
 
-	return 0;
+	return;
 }
 
-static int __cam_csiphy_poll_3phase_pattern_status(
+static void __cam_csiphy_poll_3phase_pattern_status(
 	struct csiphy_device *csiphy_dev)
 {
 	int i = 0;
@@ -1437,7 +1435,7 @@ static int __cam_csiphy_poll_3phase_pattern_status(
 			break;
 			}
 			if (status1 != 0) {
-				CAM_INFO(CAM_CSIPHY, "Pattern Test is completed");
+				CAM_INFO(CAM_CSIPHY, "PN9 Pattern test is completed");
 				break;
 			}
 		}
@@ -1455,17 +1453,15 @@ static int __cam_csiphy_poll_3phase_pattern_status(
 		}
 	}
 
-	if (status1 == csiphy_dev->ctrl_reg->csiphy_bist_reg->expected_status_val) {
-		CAM_INFO(CAM_CSIPHY, "Pattern is received correctly");
-		return 0;
-	} else {
+	if (status1 == csiphy_dev->ctrl_reg->csiphy_bist_reg->expected_status_val)
+		CAM_INFO(CAM_CSIPHY, "PN9 Pattern received successfully");
+	else
 		__cam_csiphy_read_3phase_bist_debug_status(csiphy_dev);
-	}
 
-	return 0;
+	return;
 }
 
-static int __cam_csiphy_poll_preamble_status(
+static void __cam_csiphy_poll_preamble_status(
 	struct csiphy_device *csiphy_dev, int offset)
 {
 	bool is_3phase = false;
@@ -1477,7 +1473,24 @@ static int __cam_csiphy_poll_preamble_status(
 	else
 		__cam_csiphy_poll_2phase_pattern_status(csiphy_dev);
 
-	return 0;
+	return;
+}
+
+static void csiphy_work_queue_ops(struct work_struct *work)
+{
+	struct csiphy_work_queue *wq = NULL;
+	struct csiphy_device *csiphy_dev = NULL;
+	int32_t offset = -1;
+
+	wq = container_of(work, struct csiphy_work_queue, work);
+	if (wq) {
+		csiphy_dev = wq->csiphy_dev;
+		offset = wq->acquire_idx;
+
+		__cam_csiphy_poll_preamble_status(csiphy_dev, offset);
+	}
+
+	kfree(wq);
 }
 
 int32_t cam_csiphy_core_cfg(void *phy_dev,
@@ -1799,6 +1812,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 	}
 	case CAM_START_DEV: {
 		struct cam_start_stop_dev_cmd config;
+		struct csiphy_work_queue *wq;
 		int32_t offset;
 		int clk_vote_level = -1;
 
@@ -1949,8 +1963,18 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		csiphy_dev->csiphy_state = CAM_CSIPHY_START;
 
 		if (csiphy_dev->preamble_enable) {
-			__cam_csiphy_poll_preamble_status(csiphy_dev, offset);
+			wq = kzalloc(sizeof(struct csiphy_work_queue),
+				GFP_ATOMIC);
+			if (wq) {
+				INIT_WORK((struct work_struct *)
+					&wq->work, csiphy_work_queue_ops);
+				wq->csiphy_dev = csiphy_dev;
+				wq->acquire_idx = offset;
+				queue_work(csiphy_dev->work_queue,
+					&wq->work);
+			}
 		}
+
 		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,

+ 19 - 2
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c

@@ -198,6 +198,8 @@ static int cam_csiphy_component_bind(struct device *dev,
 	struct csiphy_device *new_csiphy_dev;
 	int32_t               rc = 0;
 	struct platform_device *pdev = to_platform_device(dev);
+	char wq_name[32];
+
 	int i;
 
 	new_csiphy_dev = devm_kzalloc(&pdev->dev,
@@ -230,8 +232,10 @@ static int cam_csiphy_component_bind(struct device *dev,
 		&csiphy_subdev_intern_ops;
 	new_csiphy_dev->v4l2_dev_str.ops =
 		&csiphy_subdev_ops;
-	strlcpy(new_csiphy_dev->device_name, CAMX_CSIPHY_DEV_NAME,
-		sizeof(new_csiphy_dev->device_name));
+	snprintf(new_csiphy_dev->device_name,
+		CAM_CTX_DEV_NAME_MAX_LENGTH,
+		"%s%d", CAMX_CSIPHY_DEV_NAME,
+		new_csiphy_dev->soc_info.index);
 	new_csiphy_dev->v4l2_dev_str.name =
 		new_csiphy_dev->device_name;
 	new_csiphy_dev->v4l2_dev_str.sd_flags =
@@ -286,6 +290,19 @@ static int cam_csiphy_component_bind(struct device *dev,
 		cpas_parms.client_handle);
 	new_csiphy_dev->cpas_handle = cpas_parms.client_handle;
 
+	snprintf(wq_name, 32, "%s%d%s", "csiphy",
+		new_csiphy_dev->soc_info.index, "_wq");
+
+	new_csiphy_dev->work_queue = alloc_workqueue("wq_name",
+		WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+	if (!new_csiphy_dev->work_queue) {
+		CAM_ERR(CAM_CSIPHY,
+			"Error allocating workqueue for csiphy: %d",
+			new_csiphy_dev->soc_info.index);
+		rc = -ENOMEM;
+		goto csiphy_unregister_subdev;
+	}
+
 	cam_csiphy_register_baseaddress(new_csiphy_dev);
 
 

+ 8 - 0
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h

@@ -270,6 +270,12 @@ struct cam_csiphy_param {
 	struct csiphy_hdl_tbl      hdl_data;
 };
 
+struct csiphy_work_queue {
+	struct csiphy_device *csiphy_dev;
+	int32_t acquire_idx;
+	struct work_struct work;
+};
+
 /**
  * struct csiphy_device
  * @device_name                : Device name
@@ -300,6 +306,7 @@ struct cam_csiphy_param {
  * @enable_irq_dump            : Debugfs flag to enable hw IRQ register dump
  * @en_status_reg_dump         : Debugfs flag to enable cphy/dphy specific
  * @preamble_enable            : To enable preamble pattern
+ * @work_queue                 : Work queue to offload the work
  */
 struct csiphy_device {
 	char                           device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
@@ -332,6 +339,7 @@ struct csiphy_device {
 	bool                           enable_irq_dump;
 	bool                           en_status_reg_dump;
 	uint16_t                       preamble_enable;
+	struct workqueue_struct       *work_queue;
 };
 
 /**