Received: by 10.192.165.148 with SMTP id m20csp4733415imm; Tue, 24 Apr 2018 07:35:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+tkJm7FJtSWaEoBX2lWKlY+Gas+OvDHoJaHMVHsP9ZdTcWZbWip3fP01lmReDm8GGadkBl X-Received: by 10.99.123.83 with SMTP id k19mr20564811pgn.146.1524580533496; Tue, 24 Apr 2018 07:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524580533; cv=none; d=google.com; s=arc-20160816; b=ymKvPZM0vPaMPZrTcadXzyUV8A5oDvfIRCS++2gT/feZ9hjjEkDHLvLvjqiQ1xEJBu 2gktLL8RkTz3B7Mu738SuhretMKkTGdkCAJMa+dVPxiSqcejMqK+n8XtZ11uCD1Hx3KQ b6DYLKWUzF52NlOxPoz65Iuyhd3z+UpXicTLsPvaCl0+4uAHPH8rp/axHZTA4d4UiHmy CLun95hC4n/25UeSF7cWHuSIsu/XE0MWQ5DS6QEAovHzhbgLvKc0ivwMu0mxL2kXEGPo uKxT/CFL5fqxI7nOnt/VlhowtUS3T+KoKbxnJwX8eIPLCNPEq1VZEIoYtJizCAP78kJL /Zcw== 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=FwCtEwLEpmMLaiuSji/6aV0n4yMAtfTv0+KtZGSYs+o=; b=aCS/kzrjhEGIn5Hk0YyusXnKKMKK3j575YPNmVnuTQRtmWZu8QjWe00OS1gXDld9FR ChQTEq1Yv5VrGRJc/09puPEZrmMgBM3AN9DzYyW6PbBaGbfL7kb9aaMgy7HUXg1vGo5o IKY7Pbo4JpTZVp2YymcXI3IXkJnx6AyIEDruq40mKLiuLWpl+oDJco19TzXcBrNfOzIy tv+EphAxS8Pj39LS9Zq3O7luBGTUIkLRx9dLOUrsigW0GSuggU7TB54DkuT8vKrWBYOX 9tUgMVz2TPwx66+ljTYgfUnUzr5uB4cSrmXGq5lXjIy2ooNhIaxwqMAUOHPfhDm5Thbm M3iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsLJFaRJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 bc6-v6si14642132plb.302.2018.04.24.07.35.19; Tue, 24 Apr 2018 07:35:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsLJFaRJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757742AbeDXMxF (ORCPT + 99 others); Tue, 24 Apr 2018 08:53:05 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54370 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757850AbeDXMpV (ORCPT ); Tue, 24 Apr 2018 08:45:21 -0400 Received: by mail-wm0-f66.google.com with SMTP id f6so688538wmc.4 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=FSLLpcAaz/uKp9Qc8AVLzb7yZal9rtaqZ5GJb5Q68jP/CaPGU+rXPwUrldHIT3Ksjn pie41iuuOzRmoxMFiZ9ZAql9+1+W3dU2ums2sC876US63HrIObMuocmW/Aalj0rIOwwC dYlL2nU7tLHooIAZ2ubrX7xlcZIgj4Xue7aVEjhmH1g7qABkaoIRbMmBhYmsda7Whp2V 7/OsMufCx0C4L0JtEOrdU0a2nT2a45nw+MNtj108XGkGIkZpOmuHxeYDN/5csubt1A2i iGun3PLOvYysv5YkK9HfqP7pNIapmor49mXvDAwaHA8B/YvpY7Z7bN2ZFbozYBoUD32S oLYQ== X-Gm-Message-State: ALQs6tBdMmi+tTqZ9FKsWs6lJ3sizpX7QHj6m0Woa0AZIxhyeoVSDuL/ gyCG5cPTl2i7Z3BkZ7OKOUHNYQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; } -- 2.14.1