Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1734721ybe; Tue, 3 Sep 2019 02:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgT2yuHaDkFZqx2EbkuWpcIZQK1ULzOa14Gupv/AiaZE/b1yL8/oDNWgUnt63qLFAe0Dge X-Received: by 2002:a17:902:ab86:: with SMTP id f6mr14997536plr.15.1567503705465; Tue, 03 Sep 2019 02:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567503705; cv=none; d=google.com; s=arc-20160816; b=AOgT+k3/rWzJBY0FgLfpudluc0qJhp3UAbt56oI3AmjHAHp6s3N25kFzyfxNLVlhLX VXMK51tdxBOp8zmofSr+k0KXKPP8yXoDvWEr72i1j36lD0ZzkAZENlBL1DH1TB0nO1Xf O9sI/Mj2gS1dMDRiaEslqmidYRA4QLIWr27rGD4Syiz5x/5AEOVqVOA7HBzyYXy58/Kb LuQ8/H8Jq2XXmVi7IcmCSK8lJFNIbQMGoS4QZ1uJg/iI3jNOMk5LpdvkWvFLZBiaKSjs 6UQvI0nx9en63go2h3cUKFTKdjdmNC3sJrPTw1j+zwXQly0FfMKgP2RSbKeTJeUDo28C L5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ncc5KwOQjM8ycuOKtxuOTknW3v4Yw8IuEkXomerAYkw=; b=NxKtalYYZilp8IiKKDmT4nCJZE0Bj/hTrILqdQhL4xN6TX3GMeRgf9lyp6P1Mvn8J7 fDa8wu0wzzpU383NKyYjgImONR40nCES9IEtBQTKznCGIug40tnL+Peh+neYmdAPNWOT sfO8mNjen1+PmbAyDKjmHISjojX4dE0Vm/fm6eKWcbi9cDuRc15nqKqwEJdXxxbecFWD gDyMFRT/pPEQka0mWb685q3RSjwFdf/2obqN7mWXjFwt/dIWkuwA2yLeBhS9Bdz6cQTj 1KViY7A35rJcsefjhConz/SqSsw2W0vVxnsH7MqnBOvhA/d7Ud5KYrHXrlE+/MRN3BxS a+Xg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si14156551pgn.290.2019.09.03.02.41.30; Tue, 03 Sep 2019 02:41:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728918AbfICJkB (ORCPT + 99 others); Tue, 3 Sep 2019 05:40:01 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:47511 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728426AbfICJkB (ORCPT ); Tue, 3 Sep 2019 05:40:01 -0400 X-UUID: cb6a366d39bd4e8fa62f4b3972d6e544-20190903 X-UUID: cb6a366d39bd4e8fa62f4b3972d6e544-20190903 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 695586970; Tue, 03 Sep 2019 17:39:55 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 3 Sep 2019 17:39:55 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 3 Sep 2019 17:39:53 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , , Yongqiang Niu Subject: [PATCH v3 12/14] drm/mediatek: Add pm runtime support for ovl and rdma Date: Tue, 3 Sep 2019 17:37:34 +0800 Message-ID: <1567503456-24725-13-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> References: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yongqiang Niu Display use the dispsys device to call pm_rumtime_get_sync before. This patch add pm_runtime_xx with ovl and rdma device which has linked with larb0, then it will enable the correpsonding larb0 clock automatically by the device link. Signed-off-by: Yongqiang Niu Signed-off-by: Yong Wu --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 5 +++++ drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 5 +++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 9 +++++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index c4f07c2..51958cf 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "mtk_drm_crtc.h" #include "mtk_drm_ddp_comp.h" @@ -300,6 +301,8 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) return ret; } + pm_runtime_enable(dev); + ret = component_add(dev, &mtk_disp_ovl_component_ops); if (ret) dev_err(dev, "Failed to add component: %d\n", ret); @@ -311,6 +314,8 @@ static int mtk_disp_ovl_remove(struct platform_device *pdev) { component_del(&pdev->dev, &mtk_disp_ovl_component_ops); + pm_runtime_disable(&pdev->dev); + return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c index 9a6f0a2..15e5c3a 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "mtk_drm_crtc.h" #include "mtk_drm_ddp_comp.h" @@ -306,6 +307,8 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + pm_runtime_enable(dev); + ret = component_add(dev, &mtk_disp_rdma_component_ops); if (ret) dev_err(dev, "Failed to add component: %d\n", ret); @@ -317,6 +320,8 @@ static int mtk_disp_rdma_remove(struct platform_device *pdev) { component_del(&pdev->dev, &mtk_disp_rdma_component_ops); + pm_runtime_disable(&pdev->dev); + return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index c1e891e..daf002e 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -358,13 +358,21 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; int ret; DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); + ret = pm_runtime_get_sync(comp->dev); + if (ret < 0) + DRM_DEV_ERROR(comp->dev, "Failed to enable power domain: %d\n", + ret); + ret = mtk_crtc_ddp_hw_init(mtk_crtc); - if (ret) + if (ret) { + pm_runtime_put(comp->dev); return; + } drm_crtc_vblank_on(crtc); mtk_crtc->enabled = true; @@ -374,7 +382,8 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); - int i; + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; + int i, ret; DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); if (!mtk_crtc->enabled) @@ -398,6 +407,11 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, mtk_crtc_ddp_hw_fini(mtk_crtc); mtk_crtc->enabled = false; + + ret = pm_runtime_put(comp->dev); + if (ret < 0) + DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", + ret); } static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 7dc8496..c45e1f0 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -256,6 +256,8 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node, struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, const struct mtk_ddp_comp_funcs *funcs) { + struct platform_device *comp_pdev; + if (comp_id < 0 || comp_id >= DDP_COMPONENT_ID_MAX) return -EINVAL; @@ -282,6 +284,13 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node, if (IS_ERR(comp->clk)) return PTR_ERR(comp->clk); + comp_pdev = of_find_device_by_node(node); + if (!comp_pdev) { + dev_err(dev, "Waiting for device %s\n", node->full_name); + return -EPROBE_DEFER; + } + comp->dev = &comp_pdev->dev; + return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 108de60..d1838a8 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -83,6 +83,7 @@ struct mtk_ddp_comp { struct clk *clk; void __iomem *regs; int irq; + struct device *dev; enum mtk_ddp_comp_id id; const struct mtk_ddp_comp_funcs *funcs; }; -- 1.9.1