Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1450304pxu; Thu, 17 Dec 2020 10:11:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNfP4hW3EJky59e/YHsfNh96CAuw79VOva3Nrk/e4tb7pd4GxlbzcWQF7j97bi5jVM3ujw X-Received: by 2002:aa7:d74f:: with SMTP id a15mr609062eds.344.1608228663944; Thu, 17 Dec 2020 10:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608228663; cv=none; d=google.com; s=arc-20160816; b=vIlMhRci5j0s53kZGCu6AbdXyweZ3P10UkFqjcSbKm/LLF96diSiij/fOFEmGYwu+X cpTaejKRhOie9Rryhlhpy17d6N8V2sgIOqQM5TVkO0h5uJlCP2MNWkTq3PMCVKxGqE6/ 5hzugZXUh50M4oa8rmEfIubq/HT2WwGSZtI3KNKvkhT0UmD9NTYocK6oMD94B34xfCOr tnOLTnT26E7bMCwIWouY/IWD5oP2mozkcNB+vmbvIQJv7B3knpthk15uUPeWVLGz9BJY H60JzzsSgBer8OqfblkTEINHz28yYcdnQOno2zwB29vq9pLBxjy+hA1UBU8m0u1FMgnv RWSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LuC35it5WgcMsywJnTS7GhOmGsdjUUBuqpGFnra9j0o=; b=1DXQQ0H5OEgHUeMIX24FY4BDCv1kP8QwrnUDhrbIXCSAEs0/puu82Ivp1VyITB5S/V wGQWrIzC2Gi5gJmkcxqKW30WvvAOvQnVoX5MEkJRZBQs2D6Bg81Ln7q2E1p0TdTGWilQ wKilB1sl1EFRlC9ReiG723SVr/7yYGZlWCs2lTWuvrpmrMZqNWbcyz55cYS5bbrXb7yK E0RrcL9onJrz6G0xQnxs0VlT7nvRaaIL1u0jSCpYSifpOutzEuwXX4Yx6KxisLdIvn1r bYXgwZ7H4SYISDFgmpb4nP1rULKtsUaN3SYB7+mY3Y+0XVs1ZhnF9MAXHVRjYX+/67wL IMwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ofn5aE6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq19si87995edb.81.2020.12.17.10.10.40; Thu, 17 Dec 2020 10:11:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ofn5aE6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731133AbgLQSJX (ORCPT + 99 others); Thu, 17 Dec 2020 13:09:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgLQSJN (ORCPT ); Thu, 17 Dec 2020 13:09:13 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD95C061143; Thu, 17 Dec 2020 10:08:07 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id 23so59806917lfg.10; Thu, 17 Dec 2020 10:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LuC35it5WgcMsywJnTS7GhOmGsdjUUBuqpGFnra9j0o=; b=ofn5aE6LcF1l+cvGsQpC/Czx+zpDlTH4WYhoLgcDxiNIlJrd/1vIn6bGZz2hQ/f9nB MyRDocob5zetQFAJhMMJaVoxDjpOQBUdRPMdm+yxT4eeqWLPbXFX4VykL8nMf1nPXBcq NR/UVaUVIzTw8x6vQPaz7o6WfrvBTd7NX7416xc+ff0Qta1oLw0bsxGrIIDREH7IvMJZ afLchL/8XovRs02r/+s8IKz+hp4L1OLRUN1lOzuWuLoBtv+wE4g0xGiSYdPeqRV1MxuK VIij6fhi0IHEJaXoyP4kpXJHwpK4c+YLTRhRwF0dByC3ZB9pLcpmNs8SR2Z6JOhSboeE kFqw== 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:mime-version:content-transfer-encoding; bh=LuC35it5WgcMsywJnTS7GhOmGsdjUUBuqpGFnra9j0o=; b=IuVDK9xY95f+j+ywaGAixZSaF9bJyAi1CYGVEXNzLr1/W28yHvJZMDke3WO4z/cEKg ravnkB2BO/R2I2QcOLg2lru5ns9SX2Uxlb8+0R9+oQQn0RqHPLpUaf+Gr9jZUHkUSVT9 OS1YE9WPFjKxmGjpnq9V6yqiuU3uYgXtcYcd0a6hZ9+ePytwrajITdQetq3d7mCfN7Kb Cp/1ZZSqBdD6iDN2u9UorvuqQ+xDdu1ZGWQIyfQCUJDiU71416QgGv3rYHJgY00phmsE FZxd9ikWMWmXc2pxCNO2470sQbdo340PdyaF1J+38esQbtBDfjAC87w/6i3WiSywwmhN n+uw== X-Gm-Message-State: AOAM5335fCyOMGAVaoE4YjMUpgQeJxYhLovd7acVMR7nEcLCXVZpjCl0 FgM619JYpgb+oXM5Nndbl/U= X-Received: by 2002:ac2:5c46:: with SMTP id s6mr9280354lfp.207.1608228486221; Thu, 17 Dec 2020 10:08:06 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:08:05 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 40/48] media: staging: tegra-vde: Support OPP and generic power domain Date: Thu, 17 Dec 2020 21:06:30 +0300 Message-Id: <20201217180638.22748-41-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add OPP and generic power domain support to the video decoder driver. This allows us to utilize a modern GENPD API for newer device-trees and support DVFS of the decoder hardware. Note that older DTBs will continue to work like they did it before this patch. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko --- drivers/staging/media/tegra-vde/vde.c | 63 ++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index 28845b5bafaf..5be26b9bd5d8 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -15,11 +15,14 @@ #include #include #include +#include +#include #include #include #include #include +#include #include #include "uapi.h" @@ -918,13 +921,17 @@ static __maybe_unused int tegra_vde_runtime_suspend(struct device *dev) struct tegra_vde *vde = dev_get_drvdata(dev); int err; - err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC); - if (err) { - dev_err(dev, "Failed to power down HW: %d\n", err); - return err; + if (!dev->pm_domain) { + err = tegra_powergate_power_off(TEGRA_POWERGATE_VDEC); + if (err) { + dev_err(dev, "Failed to power down HW: %d\n", err); + return err; + } } clk_disable_unprepare(vde->clk); + reset_control_release(vde->rst); + dev_pm_opp_set_rate(dev, 0); return 0; } @@ -934,18 +941,44 @@ static __maybe_unused int tegra_vde_runtime_resume(struct device *dev) struct tegra_vde *vde = dev_get_drvdata(dev); int err; - err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC, - vde->clk, vde->rst); + err = dev_pm_opp_set_rate(dev, clk_get_rate(vde->clk)); + if (err) { + dev_err(dev, "Failed to prepare OPP: %d\n", err); + return err; + } + + err = reset_control_acquire(vde->rst); if (err) { - dev_err(dev, "Failed to power up HW : %d\n", err); + dev_err(dev, "Failed to acquire reset: %d\n", err); return err; } + if (!dev->pm_domain) { + err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_VDEC, + vde->clk, vde->rst); + if (err) { + dev_err(dev, "Failed to power up HW : %d\n", err); + goto release_reset; + } + } + + err = clk_prepare_enable(vde->clk); + if (err) { + dev_err(dev, "Failed to enable clock: %d\n", err); + goto release_reset; + } + return 0; + +release_reset: + reset_control_release(vde->rst); + + return err; } static int tegra_vde_probe(struct platform_device *pdev) { + struct tegra_core_opp_params opp_params = {}; struct device *dev = &pdev->dev; struct tegra_vde *vde; int irq, err; @@ -999,7 +1032,7 @@ static int tegra_vde_probe(struct platform_device *pdev) return err; } - vde->rst = devm_reset_control_get(dev, NULL); + vde->rst = devm_reset_control_get_exclusive_released(dev, NULL); if (IS_ERR(vde->rst)) { err = PTR_ERR(vde->rst); dev_err(dev, "Could not get VDE reset %d\n", err); @@ -1024,6 +1057,12 @@ static int tegra_vde_probe(struct platform_device *pdev) return err; } + opp_params.init_state = true; + + err = devm_tegra_core_dev_init_opp_table(dev, &opp_params); + if (err && err != -ENODEV) + return err; + vde->iram_pool = of_gen_pool_get(dev->of_node, "iram", 0); if (!vde->iram_pool) { dev_err(dev, "Could not get IRAM pool\n"); @@ -1117,8 +1156,12 @@ static void tegra_vde_shutdown(struct platform_device *pdev) * On some devices bootloader isn't ready to a power-gated VDE on * a warm-reboot, machine will hang in that case. */ - if (pm_runtime_status_suspended(&pdev->dev)) - tegra_vde_runtime_resume(&pdev->dev); + if (pm_runtime_status_suspended(&pdev->dev)) { + if (pdev->dev.pm_domain) + dev_pm_genpd_resume(&pdev->dev); + else + tegra_vde_runtime_resume(&pdev->dev); + } } static __maybe_unused int tegra_vde_pm_suspend(struct device *dev) -- 2.29.2