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

Commit a4bffefa authored by Iliya Varadzhakov's avatar Iliya Varadzhakov Committed by Ian Maund
Browse files

msm: cpp: Add bus client to cpp driver



In all platforms till msm8936, CPP driver uses ISP's
bus client to update bus bandwidth. The main reason
is that CPP does not have bus master. In platforms
msm8936 and msm8994 it has its own bus master, defined
as MSM_BUS_MASTER_CPP. In order to use it, CPP driver
has to define its own bus client and operate with it.

Change-Id: I11c62ec9ef52a17f1c177984d4aca3b8c73fe468
Signed-off-by: default avatarIliya Varadzhakov <ivarad@codeaurora.org>
Signed-off-by: default avatarShilpa Mamidi <shilpam@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: default avatarIan Maund <imaund@codeaurora.org>
parent d99e9292
Loading
Loading
Loading
Loading
+146 −10
Original line number Diff line number Diff line
@@ -94,6 +94,57 @@ static int msm_cpp_buffer_ops(struct cpp_device *cpp_dev,
			((to) ? "to" : "from"))
#define ERR_COPY_FROM_USER() ERR_USER_COPY(0)

/* CPP bus bandwidth definitions */
static struct msm_bus_vectors msm_cpp_init_vectors[] = {
	{
		.src = MSM_BUS_MASTER_CPP,
		.dst = MSM_BUS_SLAVE_EBI_CH0,
		.ab  = 0,
		.ib  = 0,
	},
};

static struct msm_bus_vectors msm_cpp_ping_vectors[] = {
	{
		.src = MSM_BUS_MASTER_CPP,
		.dst = MSM_BUS_SLAVE_EBI_CH0,
		.ab  = 0,
		.ib  = 0,
	},
};

static struct msm_bus_vectors msm_cpp_pong_vectors[] = {
	{
		.src = MSM_BUS_MASTER_CPP,
		.dst = MSM_BUS_SLAVE_EBI_CH0,
		.ab  = 0,
		.ib  = 0,
	},
};



static struct msm_bus_paths msm_cpp_bus_client_config[] = {
	{
		ARRAY_SIZE(msm_cpp_init_vectors),
		msm_cpp_init_vectors,
	},
	{
		ARRAY_SIZE(msm_cpp_ping_vectors),
		msm_cpp_ping_vectors,
	},
	{
		ARRAY_SIZE(msm_cpp_pong_vectors),
		msm_cpp_pong_vectors,
	},
};

static struct msm_bus_scale_pdata msm_cpp_bus_scale_data = {
	msm_cpp_bus_client_config,
	ARRAY_SIZE(msm_cpp_bus_client_config),
	.name = "msm_camera_cpp",
};

#define msm_dequeue(queue, member) ({	   \
	unsigned long flags;		  \
	struct msm_device_queue *__q = (queue);	 \
@@ -145,6 +196,57 @@ static int msm_cpp_is_tnr_enabled(struct cpp_device *cpp_dev,
	return 0;
}

static int msm_cpp_init_bandwidth_mgr(struct cpp_device *cpp_dev)
{
	int rc = 0;

	cpp_dev->bus_client =
		msm_bus_scale_register_client(&msm_cpp_bus_scale_data);
	if (!cpp_dev->bus_client) {
		pr_err("Fail to register bus client\n");
		return -ENOENT;
	}

	rc = msm_bus_scale_client_update_request(cpp_dev->bus_client, 1);
	if (rc < 0) {
		pr_err("Fail bus scale update %d\n", rc);
		return -EINVAL;
	}
	cpp_dev->bus_idx = 1;

	return 0;
}

static int msm_cpp_update_bandwidth(struct cpp_device *cpp_dev,
	uint64_t ab, uint64_t ib)
{

	int rc;
	struct msm_bus_paths *path;

	path = &(msm_cpp_bus_scale_data.usecase[cpp_dev->bus_idx]);
	path->vectors[0].ab = ab;
	path->vectors[0].ib = ib;

	rc = msm_bus_scale_client_update_request(cpp_dev->bus_client,
		 cpp_dev->bus_idx);
	if (rc < 0) {
		pr_err("Fail bus scale update %d\n", rc);
		return -EINVAL;
	}
	cpp_dev->bus_idx = 3 - cpp_dev->bus_idx;

	return 0;
}

void msm_cpp_deinit_bandwidth_mgr(struct cpp_device *cpp_dev)
{
	if (cpp_dev->bus_client) {
		msm_bus_scale_unregister_client(cpp_dev->bus_client);
		cpp_dev->bus_client = 0;
	}
}

static void msm_queue_init(struct msm_device_queue *queue, const char *name)
{
	CPP_DBG("E\n");
@@ -832,6 +934,10 @@ static int cpp_init_hardware(struct cpp_device *cpp_dev)
	uint32_t msm_cpp_core_clk_idx;
	uint32_t msm_micro_iface_idx;
	uint32_t vbif_version;

	if (cpp_dev->bus_master_flag)
		rc = msm_cpp_init_bandwidth_mgr(cpp_dev);
	else
		rc = msm_isp_init_bandwidth_mgr(ISP_CPP);
	if (rc < 0) {
		pr_err("%s: Bandwidth registration Failed!\n", __func__);
@@ -1006,6 +1112,9 @@ clk_failed:
	regulator_disable(cpp_dev->fs_cpp);
	regulator_put(cpp_dev->fs_cpp);
fs_failed:
		if (cpp_dev->bus_master_flag)
			msm_cpp_deinit_bandwidth_mgr(cpp_dev);
		else
			msm_isp_deinit_bandwidth_mgr(ISP_CPP);
bus_scale_register_failed:
	return rc;
@@ -1036,9 +1145,15 @@ static void cpp_release_hardware(struct cpp_device *cpp_dev)
	cpp_dev->fs_cpp = NULL;
	if (cpp_dev->stream_cnt > 0) {
		pr_err("error: stream count active\n");
		msm_isp_update_bandwidth(ISP_CPP, 0, 0);
		if (cpp_dev->bus_master_flag)
			rc = msm_cpp_update_bandwidth(cpp_dev, 0, 0);
		else
			rc = msm_isp_update_bandwidth(ISP_CPP, 0, 0);
	}
	cpp_dev->stream_cnt = 0;
	if (cpp_dev->bus_master_flag)
		msm_cpp_deinit_bandwidth_mgr(cpp_dev);
	else
		msm_isp_deinit_bandwidth_mgr(ISP_CPP);
}

@@ -2126,7 +2241,12 @@ STREAM_BUFF_END:
			cpp_dev->stream_cnt--;
			pr_info("stream_cnt:%d\n", cpp_dev->stream_cnt);
			if (cpp_dev->stream_cnt == 0) {
				rc = msm_isp_update_bandwidth(ISP_CPP, 0, 0);
				if (cpp_dev->bus_master_flag)
					rc = msm_cpp_update_bandwidth(cpp_dev,
						 0, 0);
				else
					rc = msm_isp_update_bandwidth(ISP_CPP,
						 0, 0);
				if (rc < 0)
					pr_err("Bandwidth Reset Failed!\n");
				cpp_dev->state = CPP_STATE_IDLE;
@@ -2200,13 +2320,22 @@ STREAM_BUFF_END:
				pr_err(" Fail to get clock index\n");
				return -EINVAL;
			}
			if (cpp_dev->bus_master_flag)
				rc = msm_cpp_update_bandwidth(cpp_dev,
					clock_settings.avg,
					clock_settings.inst);
			else
				rc = msm_isp_update_bandwidth(ISP_CPP,
					clock_settings.avg,
					clock_settings.inst);

			if (rc < 0) {
				pr_err("Bandwidth Set Failed!\n");
				msm_isp_update_bandwidth(ISP_CPP, 0, 0);
				if (cpp_dev->bus_master_flag)
					rc = msm_cpp_update_bandwidth(cpp_dev,
						0, 0);
				else
					rc = msm_isp_update_bandwidth(ISP_CPP,
						0, 0);
				mutex_unlock(&cpp_dev->mutex);
				return -EINVAL;
			}
@@ -3006,6 +3135,13 @@ static int cpp_probe(struct platform_device *pdev)
		goto iommu_err;
	}

	if (pdev->dev.of_node)
		rc = of_property_read_u32(pdev->dev.of_node, "bus_master",
			&cpp_dev->bus_master_flag);
	if (rc)
		cpp_dev->bus_master_flag = 0;
	pr_err("Bus master %d\n", cpp_dev->bus_master_flag);

	rc = cpp_init_hardware(cpp_dev);
	if (rc < 0)
		goto cpp_probe_init_error;
+3 −0
Original line number Diff line number Diff line
@@ -241,5 +241,8 @@ struct cpp_device {
	uint32_t stripe_base;
	uint32_t stripe_size;
	uint32_t stripe_info_offset;
	uint32_t bus_client;
	uint32_t bus_idx;
	uint32_t bus_master_flag;
};
#endif /* __MSM_CPP_H__ */