From patchwork Tue Dec 1 11:34:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Guido_G=C3=BCnther?= X-Patchwork-Id: 11942717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1695EC64E7A for ; Tue, 1 Dec 2020 11:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 591EF206A5 for ; Tue, 1 Dec 2020 11:34:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 591EF206A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sigxcpu.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E63389DD5; Tue, 1 Dec 2020 11:34:13 +0000 (UTC) Received: from honk.sigxcpu.org (honk.sigxcpu.org [24.134.29.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 089D089C6B for ; Tue, 1 Dec 2020 11:34:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id 0E9DEFB02; Tue, 1 Dec 2020 12:34:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at honk.sigxcpu.org Received: from honk.sigxcpu.org ([127.0.0.1]) by localhost (honk.sigxcpu.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P6r1QewT6znn; Tue, 1 Dec 2020 12:34:08 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 051124026B; Tue, 1 Dec 2020 12:34:07 +0100 (CET) From: =?utf-8?q?Guido_G=C3=BCnther?= To: Laurentiu Palcu , Lucas Stach , Philipp Zabel , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/1] drm/imx/dcss: Add interconnect support Date: Tue, 1 Dec 2020 12:34:07 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This allows us to raise DRAM bandiwth to a high enough value for a stable picture on i.mx8mq. We pick a bandwidth that should be sufficient for 4k@60Hz. Modelled like mdp5_kms. Signed-off-by: Guido Günther --- drivers/gpu/drm/imx/dcss/dcss-dev.c | 47 +++++++++++++++++++++++++++-- drivers/gpu/drm/imx/dcss/dcss-dev.h | 3 ++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss/dcss-dev.c index c849533ca83e..e336f03448d6 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-dev.c +++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c @@ -15,6 +15,9 @@ #include "dcss-dev.h" #include "dcss-kms.h" +/* sufficient for 4K at 60 Hz */ +#define DCSS_BW_MAX GBps_to_icc(2) + static void dcss_clocks_enable(struct dcss_dev *dcss) { clk_prepare_enable(dcss->axi_clk); @@ -162,6 +165,31 @@ static void dcss_clks_release(struct dcss_dev *dcss) devm_clk_put(dcss->dev, dcss->apb_clk); } +static int dcss_init_icc(struct dcss_dev *dcss) +{ + int ret; + struct icc_path *icc_path; + + /* Optional interconnect request */ + icc_path = of_icc_get(dcss->dev, NULL); + if (IS_ERR(icc_path)) { + ret = PTR_ERR(icc_path); + if (ret == -EPROBE_DEFER) + return ret; + /* no interconnect support is not necessarily a fatal + * condition, the platform may simply not have an + * interconnect driver yet. But warn about it in case + * bootloader didn't setup bus clocks high enough for + * scanout. + */ + dev_warn(dcss->dev, "No interconnect support may cause display underflows!\n"); + return 0; + } + dcss->icc_path = icc_path; + dcss->icc_peak_bw = DCSS_BW_MAX; + return 0; +} + struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) { struct platform_device *pdev = to_platform_device(dev); @@ -190,10 +218,14 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) dcss->devtype = devtype; dcss->hdmi_output = hdmi_output; + ret = dcss_init_icc(dcss); + if (ret < 0) + goto err; + ret = dcss_clks_init(dcss); if (ret) { dev_err(dev, "clocks initialization failed\n"); - goto err; + goto icc_err; } dcss->of_port = of_graph_get_port_by_id(dev->of_node, 0); @@ -223,7 +255,8 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) clks_err: dcss_clks_release(dcss); - +icc_err: + icc_put(dcss->icc_path); err: kfree(dcss); @@ -243,6 +276,8 @@ void dcss_dev_destroy(struct dcss_dev *dcss) dcss_clks_release(dcss); + icc_put(dcss->icc_path); + kfree(dcss); } @@ -267,6 +302,8 @@ int dcss_dev_suspend(struct device *dev) dcss_clocks_disable(dcss); + icc_set_bw(dcss->icc_path, 0, 0); + return 0; } @@ -281,6 +318,8 @@ int dcss_dev_resume(struct device *dev) return 0; } + icc_set_bw(dcss->icc_path, 0, dcss->icc_peak_bw); + dcss_clocks_enable(dcss); dcss_blkctl_cfg(dcss->blkctl); @@ -307,6 +346,8 @@ int dcss_dev_runtime_suspend(struct device *dev) dcss_clocks_disable(dcss); + icc_set_bw(dcss->icc_path, 0, 0); + return 0; } @@ -314,6 +355,8 @@ int dcss_dev_runtime_resume(struct device *dev) { struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev); + icc_set_bw(dcss->icc_path, 0, dcss->icc_peak_bw); + dcss_clocks_enable(dcss); dcss_blkctl_cfg(dcss->blkctl); diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.h b/drivers/gpu/drm/imx/dcss/dcss-dev.h index c642ae17837f..1b35a6f0d0d4 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-dev.h +++ b/drivers/gpu/drm/imx/dcss/dcss-dev.h @@ -8,6 +8,7 @@ #include #include +#include #include