From patchwork Fri Jun 1 20:26:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikash Garodia X-Patchwork-Id: 10444367 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B73A601E9 for ; Fri, 1 Jun 2018 20:28:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4182B287A7 for ; Fri, 1 Jun 2018 20:28:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3462F28C46; Fri, 1 Jun 2018 20:28:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2BC3287A7 for ; Fri, 1 Jun 2018 20:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753774AbeFAU1x (ORCPT ); Fri, 1 Jun 2018 16:27:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53338 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753532AbeFAU0x (ORCPT ); Fri, 1 Jun 2018 16:26:53 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 803D5605BD; Fri, 1 Jun 2018 20:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527884812; bh=N7OS/YzCJUTzvn0VF9ivYaujXuAybjtGHHJzGQvtxrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=APNiJBUxiIxhb7CcT4WqTG+nBN4aKpbRkzFpcHDXCnFAKYc1iyWHEtQAslfaixp9t pvNER5wpqd0zhw1mYsuy/so0mRA+a8379X6vgJYu84MORleRmLMr71LYQPrDnd1EFo GVymt4hAjemMio1MVQoQD0LbBBPzsUlPmxT7GSFI= Received: from vgarodia-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vgarodia@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id AD68660646; Fri, 1 Jun 2018 20:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527884811; bh=N7OS/YzCJUTzvn0VF9ivYaujXuAybjtGHHJzGQvtxrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KKgk0QUtNpoFqJeoJpEDwL9b90Quamr1nWTLzyB1yZ8il0HrdJeY3KQtJJzDkxohY CqdM123Oi54L8x0DtdntvyEM7rHvirUTM/IjpLiFI/bFguq+re0o7HEzXgB6s5qHwU Y/GtZ2smwffLi+hFvInmOpV00NWK4pYh7/5bxk70= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AD68660646 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vgarodia@codeaurora.org From: Vikash Garodia To: hverkuil@xs4all.nl, mchehab@kernel.org, robh@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, bjorn.andersson@linaro.org, stanimir.varbanov@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, vgarodia@codeaurora.org, acourbot@chromium.org Subject: [PATCH v2 2/5] media: venus: add a routine to set venus state Date: Sat, 2 Jun 2018 01:56:05 +0530 Message-Id: <1527884768-22392-3-git-send-email-vgarodia@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> References: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new routine which abstracts the TZ call to set the video hardware state. Signed-off-by: Vikash Garodia --- drivers/media/platform/qcom/venus/core.h | 5 +++++ drivers/media/platform/qcom/venus/firmware.c | 28 +++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/firmware.h | 1 + drivers/media/platform/qcom/venus/hfi_venus.c | 13 ++++--------- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 85e66e2..e7bfb63 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -35,6 +35,11 @@ struct reg_val { u32 value; }; +enum tzbsp_video_state { + TZBSP_VIDEO_SUSPEND = 0, + TZBSP_VIDEO_RESUME +}; + struct venus_resources { u64 dma_mask; const struct freq_tbl *freq_tbl; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 7d89b5a..b4664ed 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -53,6 +53,34 @@ static void venus_reset_hw(struct venus_core *core) /* Bring Arm9 out of reset */ writel_relaxed(0, reg_base + WRAPPER_A9SS_SW_RESET); } + +int venus_set_hw_state(enum tzbsp_video_state state, struct venus_core *core) +{ + int ret; + struct device *dev = core->dev; + void __iomem *reg_base = core->base; + + switch (state) { + case TZBSP_VIDEO_SUSPEND: + if (qcom_scm_is_available()) + ret = qcom_scm_set_remote_state(TZBSP_VIDEO_SUSPEND, 0); + else + writel_relaxed(1, reg_base + WRAPPER_A9SS_SW_RESET); + break; + case TZBSP_VIDEO_RESUME: + if (qcom_scm_is_available()) + ret = qcom_scm_set_remote_state(TZBSP_VIDEO_RESUME, 0); + else + venus_reset_hw(core); + break; + default: + dev_err(dev, "invalid state\n"); + break; + } + return ret; +} +EXPORT_SYMBOL_GPL(venus_set_hw_state); + int venus_boot(struct device *dev, const char *fwname) { const struct firmware *mdt; diff --git a/drivers/media/platform/qcom/venus/firmware.h b/drivers/media/platform/qcom/venus/firmware.h index 428efb5..1336729 100644 --- a/drivers/media/platform/qcom/venus/firmware.h +++ b/drivers/media/platform/qcom/venus/firmware.h @@ -18,5 +18,6 @@ int venus_boot(struct device *dev, const char *fwname); int venus_shutdown(struct device *dev); +int venus_set_hw_state(enum tzbsp_video_state, struct venus_core *core); #endif diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index f61d34b..797a9f5 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "core.h" @@ -27,6 +26,7 @@ #include "hfi_msgs.h" #include "hfi_venus.h" #include "hfi_venus_io.h" +#include "firmware.h" #define HFI_MASK_QHDR_TX_TYPE 0xff000000 #define HFI_MASK_QHDR_RX_TYPE 0x00ff0000 @@ -55,11 +55,6 @@ #define IFACEQ_VAR_LARGE_PKT_SIZE 512 #define IFACEQ_VAR_HUGE_PKT_SIZE (1024 * 12) -enum tzbsp_video_state { - TZBSP_VIDEO_STATE_SUSPEND = 0, - TZBSP_VIDEO_STATE_RESUME -}; - struct hfi_queue_table_header { u32 version; u32 size; @@ -574,7 +569,7 @@ static int venus_power_off(struct venus_hfi_device *hdev) if (!hdev->power_enabled) return 0; - ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0); + ret = venus_set_hw_state(TZBSP_VIDEO_SUSPEND, hdev->core); if (ret) return ret; @@ -594,7 +589,7 @@ static int venus_power_on(struct venus_hfi_device *hdev) if (hdev->power_enabled) return 0; - ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0); + ret = venus_set_hw_state(TZBSP_VIDEO_RESUME, hdev->core); if (ret) goto err; @@ -607,7 +602,7 @@ static int venus_power_on(struct venus_hfi_device *hdev) return 0; err_suspend: - qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0); + venus_set_hw_state(TZBSP_VIDEO_SUSPEND, hdev->core); err: hdev->power_enabled = false; return ret;