Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2152280ybf; Mon, 2 Mar 2020 03:04:00 -0800 (PST) X-Google-Smtp-Source: ADFU+vv7IiKnqyGyWCK1zXcFsS7WVMU+38ZaQH4/NlwSpB4BJXWvcIn1LHGN+WQGv2xHld9R1vHn X-Received: by 2002:a05:6830:15c6:: with SMTP id j6mr2602121otr.348.1583147039719; Mon, 02 Mar 2020 03:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583147039; cv=none; d=google.com; s=arc-20160816; b=UT2Hr3XH1oq92NpblBPy/EzXH92OJHRHfbn1eQEGkqRbs3t+QjU8T3kAtRR2DjC88L eSf79T4k5W88bdOqHzyvDeVa4YoSLWDf+ILw6FTQbU/cbCMfXAMvlVCxvaSF0ynalm5H qacDt1vVtZKf0fr6gviZPHCXOcy1ib0Cac3pUMy3jIw8iInOxJVromqSPBt/cpmeBH5Y 7gIH75PD2vyStlYbHK0dKSAIjc7fzfDTwJA4qTcVsvC4/mJGKvWveJCEBWDFVOdth9yi fGPBKZdgN2pDgqu3c1uR9p/dYq5nr9NUz/AO0tZtWXTOChfvBcoQox31ZBglW+Kbt72p OM4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=A0qiMCdfISi5qQlx7Uo9SeMJag9JecxrUIXP+whfUqQ=; b=KKw6jWhB+CxcdcakdNK37qXwvEFKHJcPlU3t3WXVtJth2T//oPoZqvp5GuEtza5UKd 1wcpadDUvC+vNO7mWel95cq6BFf+ucijiRVokmzisy4RVDHv+Ku1en+Aep6hF0q4ayAm hu8WJO8j53EXJbshGqNPfbGYod3Q4RrH1X37aQb0jBeQ8epR5ueVh6LCz5izG66S56e2 T9rSX36Lqbl5ruzXAcoQzGvhB5UfqujtzQ0R+4YjuHTtEQTsHSmOYMZVVCcE/EfNzSjX CM6LsGwI2Z+s2n6oCrlkeNx4eOgZZfBiCC4UG64VacWj5yTQoXeq52fdJuDYMyxxxgHZ zHOQ== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si230444otq.159.2020.03.02.03.03.38; Mon, 02 Mar 2020 03:03:59 -0800 (PST) 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727967AbgCBLB4 (ORCPT + 99 others); Mon, 2 Mar 2020 06:01:56 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44600 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727896AbgCBLBx (ORCPT ); Mon, 2 Mar 2020 06:01:53 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 27F322949C5 From: Enric Balletbo i Serra To: robh+dt@kernel.org, mark.rutland@arm.com, ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, mturquette@baylibre.com, sboyd@kernel.org, ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com Cc: Mauro Carvalho Chehab , rdunlap@infradead.org, dri-devel@lists.freedesktop.org, Weiyi Lu , Seiya Wang , linux-clk@vger.kernel.org, Collabora Kernel ML , mtk01761 , Allison Randal , Thomas Gleixner , wens@csie.org, Kate Stewart , Greg Kroah-Hartman , Houlong Wei , Matthias Brugger , linux-media@vger.kernel.org, devicetree@vger.kernel.org, sean.wang@mediatek.com, frank-w@public-files.de, Minghsiu Tsai , Andrew-CT Chen , linux-mediatek@lists.infradead.org, hsinyi@chromium.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, Richard Fontana , linux-kernel@vger.kernel.org, matthias.bgg@kernel.org, Daniel Vetter Subject: [PATCH v11 5/5] soc / drm: mediatek: Fix mediatek-drm device probing Date: Mon, 2 Mar 2020 12:01:28 +0100 Message-Id: <20200302110128.2664251-6-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200302110128.2664251-1-enric.balletbo@collabora.com> References: <20200302110128.2664251-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the actual implementation the same compatible string "mediatek,-mmsys" is used to bind the clock drivers (drivers/soc/mediatek) as well as to the gpu driver (drivers/gpu/drm/mediatek/mtk_drm_drv.c). This ends with the problem that the only probed driver is the clock driver and there is no display at all. In any case having the same compatible string for two drivers is not correct and should be fixed. To fix this, and maintain backward compatibility, we can consider that the mmsys driver is the top-level entry point for the multimedia subsystem, so is not a pure clock controller but a system controller, and the drm driver is instantiated by that MMSYS driver. Signed-off-by: Enric Balletbo i Serra Reviewed-by: CK Hu --- Changes in v11: None Changes in v10: - Match driver data to get display routing. Changes in v9: - Do not move the display routing from the drm driver (CK) Changes in v8: - New patch introduced in this series. Changes in v7: None drivers/gpu/drm/mediatek/mtk_drm_drv.c | 31 ++++++++++++++++---------- drivers/soc/mediatek/mtk-mmsys.c | 6 +++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 208f9c5256ef..bb26e346750a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -422,9 +422,21 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = { { } }; +static const struct of_device_id mtk_drm_of_ids[] = { + { .compatible = "mediatek,mt2701-mmsys", + .data = &mt2701_mmsys_driver_data}, + { .compatible = "mediatek,mt2712-mmsys", + .data = &mt2712_mmsys_driver_data}, + { .compatible = "mediatek,mt8173-mmsys", + .data = &mt8173_mmsys_driver_data}, + { } +}; + static int mtk_drm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *phandle = dev->parent->of_node; + const struct of_device_id *of_id; struct mtk_drm_private *private; struct device_node *node; struct component_match *match = NULL; @@ -442,8 +454,14 @@ static int mtk_drm_probe(struct platform_device *pdev) return -ENODEV; } + of_id = of_match_node(mtk_drm_of_ids, phandle); + if (!of_id) + return -ENODEV; + + private->data = of_id->data; + /* Iterate over sibling DISP function blocks */ - for_each_child_of_node(dev->of_node->parent, node) { + for_each_child_of_node(phandle->parent, node) { const struct of_device_id *of_id; enum mtk_ddp_comp_type comp_type; int comp_id; @@ -575,22 +593,11 @@ static int mtk_drm_sys_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend, mtk_drm_sys_resume); -static const struct of_device_id mtk_drm_of_ids[] = { - { .compatible = "mediatek,mt2701-mmsys", - .data = &mt2701_mmsys_driver_data}, - { .compatible = "mediatek,mt2712-mmsys", - .data = &mt2712_mmsys_driver_data}, - { .compatible = "mediatek,mt8173-mmsys", - .data = &mt8173_mmsys_driver_data}, - { } -}; - static struct platform_driver mtk_drm_platform_driver = { .probe = mtk_drm_probe, .remove = mtk_drm_remove, .driver = { .name = "mediatek-drm", - .of_match_table = mtk_drm_of_ids, .pm = &mtk_drm_pm_ops, }, }; diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index bb99a05fb278..090dbab41160 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -379,6 +379,7 @@ static int mtk_mmsys_probe(struct platform_device *pdev) const struct mtk_mmsys_driver_data *data; struct clk_onecell_data *clk_data; struct device *dev = &pdev->dev; + struct platform_device *drm; void __iomem *config_regs; struct resource *mem; int ret; @@ -409,6 +410,11 @@ static int mtk_mmsys_probe(struct platform_device *pdev) if (ret) return ret; + drm = platform_device_register_data(&pdev->dev, "mediatek-drm", + PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(drm)) + return PTR_ERR(drm); + return 0; } -- 2.25.1