Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f6f3366 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera_v2: Add CPP HW reset at camera close."

parents 35aa3c53 cf6aa373
Loading
Loading
Loading
Loading
+44 −16
Original line number Diff line number Diff line
@@ -1455,8 +1455,9 @@ static int cpp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
		VBIF_CLIENT_CPP, cpp_vbif_error_handler);

	if (cpp_dev->cpp_open_cnt == 1) {
		rc = cpp_init_hardware(cpp_dev);
		rc = cpp_init_mem(cpp_dev);
		if (rc < 0) {
			pr_err("Error: init memory fail\n");
			cpp_dev->cpp_open_cnt--;
			cpp_dev->cpp_subscribe_list[i].active = 0;
			cpp_dev->cpp_subscribe_list[i].vfh = NULL;
@@ -1464,16 +1465,14 @@ static int cpp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
			return rc;
		}

		rc = cpp_init_mem(cpp_dev);
		rc = cpp_init_hardware(cpp_dev);
		if (rc < 0) {
			pr_err("Error: init memory fail\n");
			cpp_dev->cpp_open_cnt--;
			cpp_dev->cpp_subscribe_list[i].active = 0;
			cpp_dev->cpp_subscribe_list[i].vfh = NULL;
			mutex_unlock(&cpp_dev->mutex);
			return rc;
		}

		cpp_dev->state = CPP_STATE_IDLE;

	}
@@ -1568,25 +1567,54 @@ static int cpp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x88));
		pr_debug("DEBUG_R1: 0x%x\n",
			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x8C));

		/* mask IRQ status */
		msm_camera_io_w(0xB, cpp_dev->cpp_hw_base + 0xC);

		while (counter < MSM_CPP_AXI_RESET_RETRIES) {
		/* clear IRQ status */
		msm_camera_io_w(0xFFFFF, cpp_dev->cpp_hw_base + 0x14);

		/* MMSS_A_CPP_AXI_CMD = 0x16C, reset 0x1*/
		msm_camera_io_w(0x1, cpp_dev->cpp_hw_base + 0x16C);
			usleep_range(100, 200);
			result = msm_camera_io_r(cpp_dev->cpp_hw_base + 0x16C);
			if (result & 0x1) {
				pr_debug("CPP AXI reset successful result %d",
					 result);

		while (counter < MSM_CPP_POLL_RETRIES) {
			result = msm_camera_io_r(cpp_dev->cpp_hw_base + 0x10);
			if (result & 0x2)
				break;
			}
			/*
			 * Below usleep values are chosen based on experiments
			 * and this was the smallest number which works. This
			 * sleep is needed to leave enough time for hardware
			 * to update status register.
			 */
			usleep_range(200, 250);
			counter++;
		}

		if (!(result & 0x1))
			pr_err("CPP AXI reset un-successful result %d",
				 result);
		pr_debug("CPP AXI done counter %d result 0x%x\n",
			counter, result);

		/* clear IRQ status */
		msm_camera_io_w(0xFFFFF, cpp_dev->cpp_hw_base + 0x14);
		counter = 0;
		/* MMSS_A_CPP_RST_CMD_0 = 0x8, firmware reset = 0x3DF77 */
		msm_camera_io_w(0x3DF77, cpp_dev->cpp_hw_base + 0x8);

		while (counter < MSM_CPP_POLL_RETRIES) {
			result = msm_camera_io_r(cpp_dev->cpp_hw_base + 0x10);
			if (result & 0x1)
				break;
			/*
			 * Below usleep values are chosen based on experiments
			 * and this was the smallest number which works. This
			 * sleep is needed to leave enough time for hardware
			 * to update status register.
			 */
			usleep_range(200, 250);
			counter++;
		}
		pr_debug("CPP reset done counter %d result 0x%x\n",
			counter, result);

		msm_camera_io_w(0x0, cpp_dev->base + MSM_CPP_MICRO_CLKEN_CTL);
		msm_cpp_clear_timer(cpp_dev);
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@
#define MSM_CPP_START_ADDRESS		0x0
#define MSM_CPP_END_ADDRESS			0x3F00

#define MSM_CPP_AXI_RESET_RETRIES	5
#define MSM_CPP_POLL_RETRIES		200
#define MSM_CPP_TASKLETQ_SIZE		16
#define MSM_CPP_TX_FIFO_LEVEL		16