Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp139862pxb; Mon, 2 Nov 2020 16:39:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDBmyYUgrnAHQg4+XDI94OxsNU2D1Q37ysBkM+OuECB8eXku1KkKDdvw0+TeYg/mKcQBGq X-Received: by 2002:a50:a454:: with SMTP id v20mr18772391edb.98.1604363944495; Mon, 02 Nov 2020 16:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604363944; cv=none; d=google.com; s=arc-20160816; b=Jr590ulR5fzq8mUlYABDbt62Ds0tedHCSio29Tq+c9cltoKpJA+HRSIMcJP/mRZUD+ NA0lUg6QZDbOo48d7fZmZZS4/2b3FgGbID52Wl9zpiECTsaGbart/cBT2LR8BVeroK/K PdahxVB+KTrC/DPhUGkfxOsXUPDDgAdvCaB8/7XVUE0oVlNeYJ7IWaa5SAdqRd4reWNr pWN6uqdXKhMhCnMtpJHzBKp2g/e3ksBQPsCTF8efa+74o7hZE7/RkpJbvRgaxksvWq2/ xoUVRqB8rXMBPqWWNn5s4fpSD/16KmsKr2wEOv8/oRO6xyR3zvdsqw5Ne1kE1mxisHnX IENQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=TTh8I23rsT3JQM/U+4JI2YZxy2jJi59HmnccOSzKdYo=; b=OOqnOhLmG7kCQQs7Fb2L6fecW40AhlLN+zkvLNFwVfUO4f46K0DPty9NoyUJiYSsKN rJclddVhd5ZFRxwAJeDqXkyEhMKXkTmME2l/DiPN+OaTqUs9s9oxFGOEPh1va88gFMlJ O3F1rKmldhE8KBx6I6fQShSCIZbXVOvHMdQzBJMzZVgilqaPgslfNYP+VHfqRxSKN7nk a5gwApvBuO58+87u8VtEkfcT1Ocj5fBF1KGcFEIhu8Pc0Ap2AutUF7TSINS+VVE0mpxC s843K+MOpRnVdciOyu2gN20sahjt80wYnIIBIACJZKhU6iRJaoX5gbiTl9+BIjVTOUA9 mY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H8VfIx3Q; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h27si13567517ejd.478.2020.11.02.16.38.41; Mon, 02 Nov 2020 16:39:04 -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=@kernel.org header.s=default header.b=H8VfIx3Q; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727404AbgKCAes (ORCPT + 99 others); Mon, 2 Nov 2020 19:34:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:43542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbgKCAeq (ORCPT ); Mon, 2 Nov 2020 19:34:46 -0500 Received: from DESKTOP-GFFITBK.localdomain (218-161-90-76.HINET-IP.hinet.net [218.161.90.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 526EF22268; Tue, 3 Nov 2020 00:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604363685; bh=cZ+ihPXYHnIUGXvYZXzw6jQeEstXtmxMSgvykEOBwJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8VfIx3QlDpoNMSx8OV/lt3wO13ovVWEdQDPemOnShwakd2k97Mb+0hPF4fdBylRh c+IsLidywpx2S1Dx2bIWTrs3kIayCgYx9hYQOPgwrEanGpDc8OqpwRabkfw1njx2jV tAydiYlM3XKDXDufINktfMSf++JHEkc/DkkApKyY= From: Chun-Kuang Hu To: Philipp Zabel , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Chun-Kuang Hu Subject: [PATCH 02/11] drm/mediatek: Use correct device pointer to get CMDQ client register Date: Tue, 3 Nov 2020 08:34:13 +0800 Message-Id: <20201103003422.17838-3-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201103003422.17838-1-chunkuang.hu@kernel.org> References: <20201103003422.17838-1-chunkuang.hu@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some ddp component use mmsys device pointer to get CMDQ client register, this would get mmsys' CMDQ client register, so use each ddp component's device pointer to get. Signed-off-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_disp_color.c | 2 +- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 +- drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 2 +- drivers/gpu/drm/mediatek/mtk_dpi.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 14 +++++++++++--- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 5 ++--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 +- drivers/gpu/drm/mediatek/mtk_dsi.c | 2 +- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_color.c b/drivers/gpu/drm/mediatek/mtk_disp_color.c index 3ae9c810845b..461d96cb5cfa 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_color.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_color.c @@ -116,7 +116,7 @@ static int mtk_disp_color_probe(struct platform_device *pdev) return comp_id; } - ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id, + ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id, &mtk_disp_color_funcs); if (ret) { if (ret != -EPROBE_DEFER) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 28651bc579bc..f89a2b3e56f4 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -383,7 +383,7 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) return comp_id; } - ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id, + ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id, &mtk_disp_ovl_funcs); if (ret) { if (ret != -EPROBE_DEFER) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c index e04319fedf46..7a5dad4a2597 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c @@ -291,7 +291,7 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev) return comp_id; } - ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id, + ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id, &mtk_disp_rdma_funcs); if (ret) { if (ret != -EPROBE_DEFER) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index cf11c4850b40..6852b76fa583 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -784,7 +784,7 @@ static int mtk_dpi_probe(struct platform_device *pdev) return comp_id; } - ret = mtk_ddp_comp_init(dev, dev->of_node, &dpi->ddp_comp, comp_id, + ret = mtk_ddp_comp_init(dev->of_node, &dpi->ddp_comp, comp_id, &mtk_dpi_funcs); if (ret) { dev_err(dev, "Failed to initialize component: %d\n", ret); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index c17c0e4c030f..93a10550a147 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -465,10 +465,11 @@ unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, return ret; } -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) +int mtk_ddp_comp_init(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; + struct device *dev; enum mtk_ddp_comp_type type; struct device_node *larb_node; struct platform_device *larb_pdev; @@ -506,6 +507,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) { + DRM_INFO("Waiting for device %s\n", node->full_name); + return -EPROBE_DEFER; + } + dev = &comp_pdev->dev; + #if IS_REACHABLE(CONFIG_MTK_CMDQ) if (of_address_to_resource(node, 0, &res) != 0) { dev_err(dev, "Missing reg in %s node\n", node->full_name); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 1d9e00b69462..3bd6012d0746 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -204,9 +204,8 @@ int mtk_ddp_comp_get_id(struct device_node *node, enum mtk_ddp_comp_type comp_type); unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, struct mtk_ddp_comp ddp_comp); -int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node, - struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, - const struct mtk_ddp_comp_funcs *funcs); +int mtk_ddp_comp_init(struct device_node *comp_node, struct mtk_ddp_comp *comp, + enum mtk_ddp_comp_id comp_id, const struct mtk_ddp_comp_funcs *funcs); int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp); void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp); void mtk_dither_set(struct mtk_ddp_comp *comp, unsigned int bpc, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 59c85c63b7cc..e4a8769f200f 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -538,7 +538,7 @@ static int mtk_drm_probe(struct platform_device *pdev) goto err_node; } - ret = mtk_ddp_comp_init(dev->parent, node, comp, + ret = mtk_ddp_comp_init(node, comp, comp_id, NULL); if (ret) { of_node_put(node); diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 4a188a942c38..86109698f19c 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -1114,7 +1114,7 @@ static int mtk_dsi_probe(struct platform_device *pdev) goto err_unregister_host; } - ret = mtk_ddp_comp_init(dev, dev->of_node, &dsi->ddp_comp, comp_id, + ret = mtk_ddp_comp_init(dev->of_node, &dsi->ddp_comp, comp_id, &mtk_dsi_funcs); if (ret) { dev_err(dev, "Failed to initialize component: %d\n", ret); -- 2.17.1