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

Commit 9e6a588f authored by Senthil kumar Rajagopal's avatar Senthil kumar Rajagopal Committed by Gerrit - the friendly Code Review server
Browse files

msm: isp: Get clock rates on run time



ISP decides to run on single VFE or dual VFE
based on the rate of pixels received, compared
with VFE's clock rate.

This change retrieves nominal and turbo clock rates of vfe
in runtime.

Change-Id: I57cd64382a01488a5850f5f289ebdc5007b3627c
Signed-off-by: default avatarSenthil Kumar Rajagopal <skrajago@codeaurora.org>
Signed-off-by: default avatarSreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
parent 1170a903
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ Required properties:
  different SoC can have same hardware version and still different QOS, VBIF,
  and DS parameters. In this case they are exported if separate SoC version
  specific dts files.
- max-nominal-clk: nominal rate of the VFE clock in Hertz.
- max-turbo-clk: turbo/high rate of the VFE clock in Hertz.

Example:

@@ -82,6 +84,8 @@ Example:
                0x44441111 0x44441111 0x44441111
                0x44441111 0x44441111 0x44441111
                0x44441111 0x00000103>;
       max-clk-nominal = <465000000>;
       max-clk-turbo = <600000000>;
   };

In version specific file one needs to move only entries that differ between
@@ -123,4 +127,6 @@ SoC versions with same VFE HW version:
			0x44441111
			0x44441111
			0x00000103>;
               max-clk-nominal = <465000000>;
               max-clk-turbo = <600000000>;
	};
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@
		0x44441111
		0x44441111
		0x00000103>;
	max-clk-nominal = <400000000>;
	max-clk-turbo = <533330000>;
};

&vfe1 {
@@ -85,4 +87,6 @@
		0x44441111
		0x44441111
		0x00000103>;
	max-clk-nominal = <400000000>;
	max-clk-turbo = <533330000>;
};
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@
		0xCCCC1111
		0xCCCC1111
		0x00000103>;
	max-clk-nominal = <465000000>;
	max-clk-turbo = <600000000>;
};

&vfe1 {
@@ -85,4 +87,6 @@
		0xCCCC1111
		0xCCCC1111
		0x00000103>;
	max-clk-nominal = <465000000>;
	max-clk-turbo = <600000000>;
};
+63 −0
Original line number Diff line number Diff line
@@ -415,6 +415,49 @@ static int msm_isp_get_max_clk_rate(struct vfe_device *vfe_dev, long *rate)
	return 0;
}

static int msm_isp_get_clk_rates(struct vfe_device *vfe_dev,
	struct msm_isp_clk_rates *rates)
{
	struct device_node *of_node;
	int32_t  rc = 0;
	uint32_t nominal = 0, turbo = 0;
	if (!vfe_dev || !rates) {
		pr_err("%s:%d failed: vfe_dev %p rates %p\n", __func__,
			__LINE__, vfe_dev, rates);
		return -EINVAL;
	}

	if (!vfe_dev->pdev) {
		pr_err("%s:%d failed: vfe_dev->pdev %p\n", __func__,
			__LINE__, vfe_dev->pdev);
		return -EINVAL;
	}

	of_node = vfe_dev->pdev->dev.of_node;

	if (!of_node) {
		pr_err("%s %d failed: of_node = %p\n", __func__,
		 __LINE__, of_node);
		return -EINVAL;
	}
	rc = of_property_read_u32(of_node, "max-clk-nominal",
		&nominal);
	if (rc < 0 || !nominal) {
		pr_err("%s: nominal rate error\n", __func__);
		return -EINVAL;
	}

	rc = of_property_read_u32(of_node, "max-clk-turbo",
		&turbo);
	if (rc < 0 || !turbo) {
		pr_err("%s: turbo rate error\n", __func__);
			return -EINVAL;
	}
	rates->nominal_rate = nominal;
	rates->high_rate = turbo;
	return 0;
}

static int msm_isp_set_clk_rate(struct vfe_device *vfe_dev, long *rate)
{
	int rc = 0;
@@ -1068,6 +1111,26 @@ static int msm_isp_send_hw_cmd(struct vfe_device *vfe_dev,

		break;
	}
	case GET_CLK_RATES: {
		int rc = 0;
		struct msm_isp_clk_rates rates;
		struct msm_isp_clk_rates *user_data =
			(struct msm_isp_clk_rates *)cfg_data;
		if (cmd_len != sizeof(struct msm_isp_clk_rates)) {
			pr_err("%s:%d failed: invalid cmd len %u exp %zu\n",
				__func__, __LINE__, cmd_len,
				sizeof(struct msm_isp_clk_rates));
			return -EINVAL;
		}
		rc = msm_isp_get_clk_rates(vfe_dev, &rates);
		if (rc < 0) {
			pr_err("%s:%d failed: rc %d\n", __func__, __LINE__, rc);
			return -EINVAL;
		}
		user_data->nominal_rate = rates.nominal_rate;
		user_data->high_rate = rates.high_rate;
		break;
	}
	case GET_ISP_ID: {
		uint32_t *isp_id = NULL;

+6 −0
Original line number Diff line number Diff line
@@ -321,6 +321,7 @@ enum msm_vfe_reg_cfg_type {
	VFE_READ_DMI_32BIT,
	VFE_READ_DMI_64BIT,
	GET_MAX_CLK_RATE,
	GET_CLK_RATES,
	GET_ISP_ID,
	VFE_HW_UPDATE_LOCK,
	VFE_HW_UPDATE_UNLOCK,
@@ -402,6 +403,11 @@ struct msm_isp_qbuf_info {
	uint32_t dirty_buf;
};

struct msm_isp_clk_rates {
	uint32_t nominal_rate;
	uint32_t high_rate;
};

struct msm_vfe_axi_src_state {
	enum msm_vfe_input_src input_src;
	uint32_t src_active;