linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] remoteproc: qcom: Venus firmware loader support for msm8996
@ 2016-11-08 17:57 Avaneesh Kumar Dwivedi
  2016-11-08 17:58 ` [PATCH 1/2] remoteproc: qcom: Private data support for venus rproc driver Avaneesh Kumar Dwivedi
  2016-11-08 17:58 ` [PATCH 2/2] remoteproc: qcom: Add clock init and enable support if needed Avaneesh Kumar Dwivedi
  0 siblings, 2 replies; 3+ messages in thread
From: Avaneesh Kumar Dwivedi @ 2016-11-08 17:57 UTC (permalink / raw)
  To: bjorn.andersson; +Cc: linux-arm-msm, Avaneesh Kumar Dwivedi

This Patch Series is based on https://patchwork.kernel.org/patch/9415585/

This patch series add necessary routine and data structure to support standalone
venus firmware load on msm8996. 
patch 1- It bind a private data structure to device structure so that there are minimal code
changes as new version of venus driver is supported.
patch 2- It provide clock initialization and enable/disable functionality.

below is console log on msm8996 platform with above change, this is standalone test log 
without video driver enablement.

[    2.612011]  remoteproc0: soc:vidc_tzpil@0 is available
[    2.616939]  remoteproc0: Note: remoteproc is still under development and considered experimental.
[    2.621963]  remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed.
[    2.631037] qcom-tz-pil soc:vidc_tzpil@0: Venus rproc probe done
[    2.641463]  remoteproc0: powering up soc:vidc_tzpil@0
[    2.641468]  remoteproc0: Booting fw image venus.mdt, size 6812
[    2.698127]  remoteproc0: remote processor soc:vidc_tzpil@0 is now up

Avaneesh Kumar Dwivedi (2):
  remoteproc: qcom: Private data support for venus rproc driver.
  remoteproc: qcom: Add clock init and enable support if needed.

 .../devicetree/bindings/remoteproc/qcom,venus.txt  |   3 +-
 drivers/remoteproc/qcom_venus_pil.c                | 103 ++++++++++++++++++++-
 2 files changed, 104 insertions(+), 2 deletions(-)

-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] remoteproc: qcom: Private data support for venus rproc driver.
  2016-11-08 17:57 [PATCH 0/2] remoteproc: qcom: Venus firmware loader support for msm8996 Avaneesh Kumar Dwivedi
@ 2016-11-08 17:58 ` Avaneesh Kumar Dwivedi
  2016-11-08 17:58 ` [PATCH 2/2] remoteproc: qcom: Add clock init and enable support if needed Avaneesh Kumar Dwivedi
  1 sibling, 0 replies; 3+ messages in thread
From: Avaneesh Kumar Dwivedi @ 2016-11-08 17:58 UTC (permalink / raw)
  To: bjorn.andersson; +Cc: linux-arm-msm, Avaneesh Kumar Dwivedi

venus remoteproc driver being able to boot standalone venus firmware,
need to initialize and enable clock resource. So providing private data
binding to device structure so that each new venus remoteproc driver
can manage its own clock.

Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
---
 .../devicetree/bindings/remoteproc/qcom,venus.txt  |  3 ++-
 drivers/remoteproc/qcom_venus_pil.c                | 31 +++++++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt b/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt
index 2d73ba1..9d7865e 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,venus.txt
@@ -6,7 +6,8 @@ on the Qualcomm Venus remote processor core.
 - compatible:
 	Usage: required
 	Value type: <string>
-	Definition: must contain "qcom,venus-pil"
+	Definition: must contain "qcom,venus-pil" or
+		 "qcom,venus-8996-pil"
 
 - memory-region:
 	Usage: required
diff --git a/drivers/remoteproc/qcom_venus_pil.c b/drivers/remoteproc/qcom_venus_pil.c
index 6d4e55b..5b4ea10 100644
--- a/drivers/remoteproc/qcom_venus_pil.c
+++ b/drivers/remoteproc/qcom_venus_pil.c
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/qcom_scm.h>
 #include <linux/remoteproc.h>
+#include <linux/of_device.h>
 
 #include "qcom_mdt_loader.h"
 #include "remoteproc_internal.h"
@@ -30,6 +31,11 @@
 #define VENUS_PAS_ID			9
 #define VENUS_FW_MEM_SIZE		SZ_8M
 
+struct qcom_venus_rproc_res {
+	char **venus_clks;
+	int venus_clk_cnt;
+	int *venus_clk_rate;
+};
 struct qcom_venus {
 	struct device *dev;
 	struct rproc *rproc;
@@ -37,6 +43,8 @@ struct qcom_venus {
 	phys_addr_t mem_phys;
 	void *mem_va;
 	size_t mem_size;
+	const struct qcom_venus_rproc_res *venus_rproc_res;
+	struct clk **venus_clks;
 };
 
 static int venus_load(struct rproc *rproc, const struct firmware *fw)
@@ -128,8 +136,13 @@ static int venus_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct qcom_venus *venus;
 	struct rproc *rproc;
+	const struct qcom_venus_rproc_res *desc;
 	int ret;
 
+	desc = of_device_get_match_data(&pdev->dev);
+	if (!desc)
+		return -EINVAL;
+
 	if (!qcom_scm_is_available())
 		return -EPROBE_DEFER;
 
@@ -158,6 +171,7 @@ static int venus_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, venus);
 
+	venus->venus_rproc_res = desc;
 	venus->mem_va = dma_alloc_coherent(dev, venus->mem_size,
 					   &venus->mem_phys, GFP_KERNEL);
 	if (!venus->mem_va) {
@@ -194,8 +208,23 @@ static int venus_remove(struct platform_device *pdev)
 	return 0;
 }
 
+char *venus_clk_str[] = {"core_clk", "iface_clk", "bus_clk", "maxi_clk"};
+int venus_clk_rate[] = {19200000, 19200000, 19200000, 80000000};
+static const struct qcom_venus_rproc_res venus_8996_res = {
+	.venus_clks = venus_clk_str,
+	.venus_clk_cnt = 4,
+	.venus_clk_rate = venus_clk_rate,
+};
+
+static const struct qcom_venus_rproc_res venus_8916_res = {
+	.venus_clks = NULL,
+	.venus_clk_cnt = 0,
+	.venus_clk_rate = NULL,
+};
+
 static const struct of_device_id venus_of_match[] = {
-	{ .compatible = "qcom,venus-pil" },
+	{ .compatible = "qcom,venus-8996-pil", .data = &venus_8996_res },
+	{ .compatible = "qcom,venus-pil", .data = &venus_8916_res},
 	{ },
 };
 
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] remoteproc: qcom: Add clock init and enable support if needed.
  2016-11-08 17:57 [PATCH 0/2] remoteproc: qcom: Venus firmware loader support for msm8996 Avaneesh Kumar Dwivedi
  2016-11-08 17:58 ` [PATCH 1/2] remoteproc: qcom: Private data support for venus rproc driver Avaneesh Kumar Dwivedi
@ 2016-11-08 17:58 ` Avaneesh Kumar Dwivedi
  1 sibling, 0 replies; 3+ messages in thread
From: Avaneesh Kumar Dwivedi @ 2016-11-08 17:58 UTC (permalink / raw)
  To: bjorn.andersson; +Cc: linux-arm-msm, Avaneesh Kumar Dwivedi

To bring venus firmware module standalone on msm8996, it need
certain multimedia clocks to be enabled. Adding support for
initialization and enable disable of such clocks.

Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
---
 drivers/remoteproc/qcom_venus_pil.c | 72 +++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/drivers/remoteproc/qcom_venus_pil.c b/drivers/remoteproc/qcom_venus_pil.c
index 5b4ea10..1a41a23 100644
--- a/drivers/remoteproc/qcom_venus_pil.c
+++ b/drivers/remoteproc/qcom_venus_pil.c
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 #include <linux/qcom_scm.h>
 #include <linux/remoteproc.h>
 #include <linux/of_device.h>
@@ -86,11 +87,47 @@ static int venus_load(struct rproc *rproc, const struct firmware *fw)
 	.load = venus_load,
 };
 
+static int qcom_venus_clk_enable(struct qcom_venus *venus)
+{
+	int i, ret;
+
+	if (!venus->venus_clks)
+		return 0;
+
+	for (i = 0; i < venus->venus_rproc_res->venus_clk_cnt; i++) {
+		ret = clk_prepare_enable(venus->venus_clks[i]);
+		if (ret) {
+			for (; i > 0; i--) {
+				clk_disable_unprepare(venus->venus_clks[i]);
+				return ret;
+			}
+		}
+	}
+	return 0;
+}
+
+static void qcom_venus_clk_disable(struct qcom_venus *venus)
+{
+	int i;
+
+	if (!venus->venus_clks)
+		return;
+
+	for (i = venus->venus_rproc_res->venus_clk_cnt-1; i >= 0; i--)
+		clk_disable_unprepare(venus->venus_clks[i]);
+}
+
 static int venus_start(struct rproc *rproc)
 {
 	struct qcom_venus *venus = rproc->priv;
 	int ret;
 
+	ret = qcom_venus_clk_enable(venus);
+	if (ret) {
+		dev_err(venus->dev, "failed to enable venus_clk\n");
+		return ret;
+	}
+
 	ret = qcom_scm_pas_auth_and_reset(VENUS_PAS_ID);
 	if (ret)
 		dev_err(venus->dev,
@@ -109,6 +146,8 @@ static int venus_stop(struct rproc *rproc)
 	if (ret)
 		dev_err(venus->dev, "failed to shutdown: %d\n", ret);
 
+	qcom_venus_clk_disable(venus);
+
 	return ret;
 }
 
@@ -131,6 +170,34 @@ static void *venus_da_to_va(struct rproc *rproc, u64 da, int len)
 	.da_to_va = venus_da_to_va,
 };
 
+static int qcom_venus_init_clocks(struct qcom_venus *venus)
+{
+	struct clk **clk_arr;
+	int i;
+
+	if (venus->venus_rproc_res->venus_clk_cnt) {
+		clk_arr = devm_kzalloc(venus->dev,
+		sizeof(clk_arr) * venus->venus_rproc_res->venus_clk_cnt,
+		GFP_KERNEL);
+
+		for (i = 0; i < venus->venus_rproc_res->venus_clk_cnt; i++) {
+			clk_arr[i] = devm_clk_get(venus->dev,
+			venus->venus_rproc_res->venus_clks[i]);
+
+			if (IS_ERR(clk_arr[i])) {
+				dev_err(venus->dev, "failed to get %s clock\n",
+				venus->venus_rproc_res->venus_clks[i]);
+				return PTR_ERR(clk_arr[i]);
+			}
+			clk_set_rate(clk_arr[i], clk_round_rate(clk_arr[i],
+				venus->venus_rproc_res->venus_clk_rate[i]));
+		}
+		venus->venus_clks = clk_arr;
+	}
+	venus->venus_clks = NULL;
+	return 0;
+}
+
 static int venus_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -172,6 +239,11 @@ static int venus_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, venus);
 
 	venus->venus_rproc_res = desc;
+
+	ret = qcom_venus_init_clocks(venus);
+	if (ret)
+		goto free_rproc;
+
 	venus->mem_va = dma_alloc_coherent(dev, venus->mem_size,
 					   &venus->mem_phys, GFP_KERNEL);
 	if (!venus->mem_va) {
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-08 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-08 17:57 [PATCH 0/2] remoteproc: qcom: Venus firmware loader support for msm8996 Avaneesh Kumar Dwivedi
2016-11-08 17:58 ` [PATCH 1/2] remoteproc: qcom: Private data support for venus rproc driver Avaneesh Kumar Dwivedi
2016-11-08 17:58 ` [PATCH 2/2] remoteproc: qcom: Add clock init and enable support if needed Avaneesh Kumar Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).