From patchwork Tue Apr 24 12:44:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134097 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2195991lji; Tue, 24 Apr 2018 05:50:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+DFtm+xdH2EXhBmEDkEeJQvX9WSAs9xQUZzMmPAhumen5oTQcXd9gYGiFa9vTHwQe1YoP2 X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr24546905pla.287.1524574255892; Tue, 24 Apr 2018 05:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574255; cv=none; d=google.com; s=arc-20160816; b=RsBWscu0Fbg/+FaNoYWketLGW/vbDDtzaRolQttCoDHHaHbP0M9o/13luCVF4z5bY0 cWc9RQaw8qicro//5USm55CIxVrWBkkW0cD51kletZGOnWtiBp1lSwk/PvP9w4Am8EGI HU6BiwtL5OqyOO+BRQsYuzasQfwKooOPbOuZVUsSMKlkb2opcmud/4kzn4EZRnlglhB2 ZA5esIyc/teYnLaNfGAAibht1RZIRCq507eOeobrOZ/je7fhGmwJqF8eUqzwXff0RGHG xDoA/AHJqp3MRFtsXyTNshutgqeaZh+h1ZlejqnUOmb7oBG0MqeVzzvvnonXiSPqesIE 1gWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IBa6phthbSwC1KdR8C68yhRyMlFFwINddYldGVWb/98=; b=gnxMKzug/gp7ECSlPTRSUDFiZzMkUTSbf/hKiUEH5LhPddav2pEUqu7JSeWeEf60aH 19kkthWQn8J+okwV97/s7s8ElfkkaX1o1ryay7wdwkTGmF6jiWhCsE1Y9epI/7rkRHDl 4TisBbu4uNATenDjAx3+qYjBtkC/Emw97otklXO8whsRHJBqrqf53uu8G9ui/sztVBKf bs8EruE8RcQrP5UhlJJfuT7JRl/959As4+nPQW9IN5nX2TssQxWMsIhtLBWfFlK+A4Ab +AvGXPQKhvMvsfAYZhAuvsx9Z5XUBV+4nktTOk1rok4C6unzUhJrcSsGjTMWsVa7eyos KYIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CsLJFaRJ; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si14918948pln.598.2018.04.24.05.50.55; Tue, 24 Apr 2018 05:50:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CsLJFaRJ; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933258AbeDXMtL (ORCPT + 12 others); Tue, 24 Apr 2018 08:49:11 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52211 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757852AbeDXMpV (ORCPT ); Tue, 24 Apr 2018 08:45:21 -0400 Received: by mail-wm0-f68.google.com with SMTP id j4so692924wme.1 for ; Tue, 24 Apr 2018 05:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FwCtEwLEpmMLaiuSji/6aV0n4yMAtfTv0+KtZGSYs+o=; b=CsLJFaRJ7PIllpeT5Fn+M5kfDu5l2VLYZbdw92cVN6qNTLFgaAaG1IhxbooT38zqLV S/srp/i/MlEKWq+cxJyiSDt3W1YLVzTyVUmOklvsNP0cEt+fpMW7EnyKPTr/APDdb0A6 uT1MWbH4Fyf41y17Fzo7UTM525DK591DarXgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FwCtEwLEpmMLaiuSji/6aV0n4yMAtfTv0+KtZGSYs+o=; b=s58yd0aEwSr/QfP+InpQxGVbcR1jUD4vHqYcCn4gGFwbE6i6/nQK9Sf8tr1obxMLi7 WeAZWktj5xukbumQEJaiwGu+cjdu8PugOZNEqUTHRznO4TjxCzGjz+1B/yhVtNwHqiE8 kS+BaN9056ADg/4dV5HIHX0bC2Li6H8BYaTonevkWCijWOsmYnPSTtoljKS5e0L/kpi4 M7HmXw3MkTJ3UYk34caKWpmk70h/hBlHXkfpfdEDdawdPVUpbuGh9wFJzXWf+eqgRqHB mwBcjpqaqAh/RZa1+v5RxVseUxXcxz1Ph+ftDtrik56HYCeJ/M9YPq3k6dH89Lqn4wX+ uvPg== X-Gm-Message-State: ALQs6tCEtTxs22Hhw52NcXr3Rppf3rpDyGzNwC1hfWdwj88gs12xdkwM XHrnJ0WyA/nx5L10efUNY/eI9A== X-Received: by 10.28.228.130 with SMTP id b124mr12987247wmh.100.1524573919870; Tue, 24 Apr 2018 05:45:19 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:19 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Stanimir Varbanov Subject: [PATCH 12/28] venus: helpers: make a commmon function for power_enable Date: Tue, 24 Apr 2018 15:44:20 +0300 Message-Id: <20180424124436.26955-13-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make common function which will enable power when enabling/disabling clocks and also covers Venus 3xx/4xx versions. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 25 ++++---------- drivers/media/platform/qcom/venus/venc.c | 25 ++++---------- 4 files changed, 67 insertions(+), 36 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index d9065cc8a7d3..2b21f6ed7502 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -13,6 +13,7 @@ * */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include "core.h" #include "helpers.h" #include "hfi_helper.h" +#include "hfi_venus_io.h" struct intbuf { struct list_head list; @@ -781,3 +783,52 @@ void venus_helper_init_instance(struct venus_inst *inst) } } EXPORT_SYMBOL_GPL(venus_helper_init_instance); + +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable) +{ + void __iomem *ctrl, *stat; + u32 val; + int ret; + + if (!IS_V3(core) && !IS_V4(core)) + return -EINVAL; + + if (IS_V3(core)) { + if (session_type == VIDC_SESSION_TYPE_DEC) + ctrl = core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL; + else + ctrl = core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL; + if (enable) + writel(0, ctrl); + else + writel(1, ctrl); + + return 0; + } + + if (session_type == VIDC_SESSION_TYPE_DEC) { + ctrl = core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; + } else { + ctrl = core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; + } + + if (enable) { + writel(0, ctrl); + + ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100); + if (ret) + return ret; + } else { + writel(1, ctrl); + + ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_power_enable); diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 971392be5df5..0e64aa95624a 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -43,4 +43,6 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable); #endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index cd278a695899..0ddc2c4df934 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1131,26 +1131,21 @@ static int vdec_remove(struct platform_device *pdev) static __maybe_unused int vdec_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); if (IS_V4(core)) clk_disable_unprepare(core->core0_bus_clk); clk_disable_unprepare(core->core0_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); - return 0; + return ret; } static __maybe_unused int vdec_runtime_resume(struct device *dev) @@ -1161,20 +1156,14 @@ static __maybe_unused int vdec_runtime_resume(struct device *dev) if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); - ret = clk_prepare_enable(core->core0_clk); + ret |= clk_prepare_enable(core->core0_clk); if (IS_V4(core)) ret |= clk_prepare_enable(core->core0_bus_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); return ret; } diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index be8ea3326386..f87d891325ea 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1267,26 +1267,21 @@ static int venc_remove(struct platform_device *pdev) static __maybe_unused int venc_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); if (IS_V4(core)) clk_disable_unprepare(core->core1_bus_clk); clk_disable_unprepare(core->core1_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); - return 0; + return ret; } static __maybe_unused int venc_runtime_resume(struct device *dev) @@ -1297,20 +1292,14 @@ static __maybe_unused int venc_runtime_resume(struct device *dev) if (IS_V1(core)) return 0; - if (IS_V3(core)) - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); - ret = clk_prepare_enable(core->core1_clk); + ret |= clk_prepare_enable(core->core1_clk); if (IS_V4(core)) ret |= clk_prepare_enable(core->core1_bus_clk); - if (IS_V3(core)) - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - else if (IS_V4(core)) - writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); return ret; }