All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: stanimir.varbanov@linaro.org, agross@kernel.org,
	bjorn.andersson@linaro.org, mchehab@kernel.org,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org
Cc: bryan.odonoghue@linaro.org, dikshita@codeaurora.org,
	jonathan@marek.ca, vgarodia@codeaurora.org
Subject: [PATCH 02/25] media: venus: core,pm: Add handling for resets
Date: Mon, 22 Feb 2021 16:02:37 +0000	[thread overview]
Message-ID: <20210222160300.1811121-3-bryan.odonoghue@linaro.org> (raw)
In-Reply-To: <20210222160300.1811121-1-bryan.odonoghue@linaro.org>

From: Stanimir Varbanov <stanimir.varbanov@linaro.org>

The Venus driver has to control two reset signals related to
gcc video_axi0 and videocc mvs0c for v6. Add it.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/platform/qcom/venus/core.h      |  4 ++
 .../media/platform/qcom/venus/pm_helpers.c    | 60 +++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index a252ed32cc14..771f5bb0981e 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -24,6 +24,7 @@
 #define VIDC_CLKS_NUM_MAX		4
 #define VIDC_VCODEC_CLKS_NUM_MAX	2
 #define VIDC_PMDOMAINS_NUM_MAX		3
+#define VIDC_RESETS_NUM_MAX		2
 
 extern int venus_fw_debug;
 
@@ -64,6 +65,8 @@ struct venus_resources {
 	unsigned int vcodec_pmdomains_num;
 	const char **opp_pmdomain;
 	unsigned int vcodec_num;
+	const char * const resets[VIDC_RESETS_NUM_MAX];
+	unsigned int resets_num;
 	enum hfi_version hfi_version;
 	u32 max_load;
 	unsigned int vmem_id;
@@ -130,6 +133,7 @@ struct venus_core {
 	struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
 	struct device_link *opp_dl_venus;
 	struct device *opp_pmdomain;
+	struct reset_control *resets[VIDC_RESETS_NUM_MAX];
 	struct video_device *vdev_dec;
 	struct video_device *vdev_enc;
 	struct v4l2_device v4l2_dev;
diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index e349d01422c5..4f5d42662963 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -11,6 +11,7 @@
 #include <linux/pm_domain.h>
 #include <linux/pm_opp.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/types.h>
 #include <media/v4l2-mem2mem.h>
 
@@ -830,6 +831,52 @@ static void vcodec_domains_put(struct venus_core *core)
 	dev_pm_opp_detach_genpd(core->opp_table);
 }
 
+static int core_resets_reset(struct venus_core *core)
+{
+	const struct venus_resources *res = core->res;
+	unsigned char i;
+	int ret;
+
+	if (!res->resets_num)
+		return 0;
+
+	for (i = 0; i < res->resets_num; i++) {
+		ret = reset_control_assert(core->resets[i]);
+		if (ret)
+			goto err;
+
+		usleep_range(150, 250);
+		ret = reset_control_deassert(core->resets[i]);
+		if (ret)
+			goto err;
+	}
+
+err:
+	return ret;
+}
+
+static int core_resets_get(struct venus_core *core)
+{
+	struct device *dev = core->dev;
+	const struct venus_resources *res = core->res;
+	unsigned char i;
+	int ret;
+
+	if (!res->resets_num)
+		return 0;
+
+	for (i = 0; i < res->resets_num; i++) {
+		core->resets[i] =
+			devm_reset_control_get_exclusive(dev, res->resets[i]);
+		if (IS_ERR(core->resets[i])) {
+			ret = PTR_ERR(core->resets[i]);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 static int core_get_v4(struct venus_core *core)
 {
 	struct device *dev = core->dev;
@@ -853,6 +900,10 @@ static int core_get_v4(struct venus_core *core)
 	if (ret)
 		return ret;
 
+	ret = core_resets_get(core);
+	if (ret)
+		return ret;
+
 	if (legacy_binding)
 		return 0;
 
@@ -912,6 +963,13 @@ static int core_power_v4(struct venus_core *core, int on)
 			}
 		}
 
+		ret = core_resets_reset(core);
+		if (ret) {
+			if (pmctrl)
+				pm_runtime_put_sync(pmctrl);
+			return ret;
+		}
+
 		ret = core_clks_enable(core);
 		if (ret < 0 && pmctrl)
 			pm_runtime_put_sync(pmctrl);
@@ -922,6 +980,8 @@ static int core_power_v4(struct venus_core *core, int on)
 
 		core_clks_disable(core);
 
+		ret = core_resets_reset(core);
+
 		if (pmctrl)
 			pm_runtime_put_sync(pmctrl);
 	}
-- 
2.29.2


  parent reply	other threads:[~2021-02-22 16:02 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 16:02 [PATCH 00/25] media: venus: Enable 6xx support Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 01/25] media: venus: Update v6 buffer descriptors Bryan O'Donoghue
2021-02-23 13:11   ` Stanimir Varbanov
2021-02-22 16:02 ` Bryan O'Donoghue [this message]
2021-02-22 16:02 ` [PATCH 03/25] media: venus: core: add sm8250 DT compatible and resource data Bryan O'Donoghue
2021-02-23 13:48   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 04/25] media: venus: core,pm: Vote for min clk freq during venus boot Bryan O'Donoghue
2021-02-23 13:25   ` Stanimir Varbanov
2021-03-06 15:01     ` Stanimir Varbanov
2021-03-06 16:48       ` Bryan O'Donoghue
2021-03-07 10:44         ` Stanimir Varbanov
2021-03-10 17:33       ` Bryan O'Donoghue
2021-03-10 22:02         ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 05/25] media: venus: core: Add io base variables for each block Bryan O'Donoghue
2021-02-23 13:28   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 06/25] media: venus: hfi,pm,firmware: Convert to block relative addressing Bryan O'Donoghue
2021-02-23 13:31   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 07/25] media: venus: hfi: Define block offsets for V6 hardware Bryan O'Donoghue
2021-02-23 13:32   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 08/25] media: venus: hfi: Define additional 6xx registers Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 09/25] media: venus: core: Add differentiator IS_V6(core) Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 10/25] media: venus: core: Add an io base for TZ wrapper regs Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 11/25] media: venus: core: Add an io base for AON regs Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 12/25] media: venus: core: Hook to V6 base registers when appropriate Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 13/25] media: venus: hfi: Add a 6xx boot logic Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 14/25] media: venus: hfi: Add 6xx interrupt support Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 15/25] media: venus: hfi: Read WRAPPER_TZ_CPU_STATUS_V6 on 6xx Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 16/25] media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 17/25] media: venus: pm: Hook 6xx pm ops into 4xx pm ops Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 18/25] media: venus: hfi: Add 6xx AXI halt logic Bryan O'Donoghue
2021-02-25  7:29   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 19/25] media: venus: pm: Toggle 6xx wrapper power in vcodec_control Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 20/25] media: venus: firmware: Do not toggle WRAPPER_A9SS_SW_RESET on 6xx Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 21/25] media: venus: helpers: Add internal buffer list for v6 Bryan O'Donoghue
2021-02-25  7:57   ` Stanimir Varbanov
2021-02-22 16:02 ` [PATCH 22/25] media: venus: helpers, hfi, vdec: Set actual plane constraints to FW Bryan O'Donoghue
2021-02-25  8:00   ` Stanimir Varbanov
2021-03-12  2:58     ` Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 23/25] media: venus: hfi: Increase plat_buf_v6 o/p buffer count Bryan O'Donoghue
2021-02-22 16:02 ` [PATCH 24/25] media: venus: helper: Decide work mode Bryan O'Donoghue
2021-02-22 16:03 ` [PATCH 25/25] media: venus: vdec: Fix decoder cmd STOP issue Bryan O'Donoghue
2021-02-26 10:25   ` Stanimir Varbanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222160300.1811121-3-bryan.odonoghue@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=dikshita@codeaurora.org \
    --cc=jonathan@marek.ca \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stanimir.varbanov@linaro.org \
    --cc=vgarodia@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.