Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2407938ybl; Sat, 7 Dec 2019 14:51:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyMD1Ng9qtcYZCQECrP5zErrFMePQYex8nAkWiFFfvKjTS37RXj1qXxrpOUHz3H8J1c3bYF X-Received: by 2002:aca:52c7:: with SMTP id g190mr17920901oib.84.1575759115944; Sat, 07 Dec 2019 14:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575759115; cv=none; d=google.com; s=arc-20160816; b=s74WU7t65iTECyj4p/XFCzgozeEse2oih1X1D2R8htG12xqtCe4XdO8YGdUKR3Kvcc Vi6u/0HJjcwXWwLCfjOvPjQqSIQTkZxN9K8TH/stY7l06rhj2TEL6mOflkC3CV4vLN11 RodyfVrFN5H39HmGbzlf0GT3eyXrRGmOB2eOYCX2eOA9lzJ8OWkc3qMoSUOYHNE/pR8n tlbdnL64eIs5IwensgoSC+QllGUuiyLOdvXkpcjhPJKtBE80asb19ql7qAZb/ZbKK9yA JGdZk3xUMuxe2lU45njH9sM3HR8TGluPsDfFj9HzuRwQ4b1g+TyPbMhdeoXufhf3ZTO1 F2JQ== 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 :dkim-signature; bh=3P17HKtPMMGqTlotUSAPFDe3LOLUr92n2OHUVUKmKQA=; b=he84YIuDkN1gcdZKGANk68Fd4qq5OkuT7u4i9N+7cWzIktp/dPmP6DoYSOnci/yRVC BM1ZE06r9e5vvGm0z6iKcw3115jZjFFNjfzQMDkPtE1a2uH9X7YBxDceI0NVCi3h7s+S v7LdPLXLWFrZWB5jwlmBFGwWM36cbB2cEXuWp84UDf19b3YIPnqOjzNR3ukPtG7AwqCq sVXO1t3jHM5ozA1dg73IdhRpOTjtvOug2TdGRbTrGrTZ73XCthmFs7xnEhcNb+Xv0D/9 /zX1Oq99tZSKZjLWT2nxbxdlFidna24cpkKCl36BJpWx3YWko1J3CohC33z0ZkxVm1OF rZzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ex+aJfRs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si9721899otq.31.2019.12.07.14.51.44; Sat, 07 Dec 2019 14:51:55 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ex+aJfRs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727184AbfLGWtF (ORCPT + 99 others); Sat, 7 Dec 2019 17:49:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:44836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfLGWtE (ORCPT ); Sat, 7 Dec 2019 17:49:04 -0500 Received: from ziggy.de (unknown [95.169.229.25]) (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 105EB2467E; Sat, 7 Dec 2019 22:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575758943; bh=2c1gUv8XKvS1eMqQrdyjBwQRMHyDf9x2WLP/L/N/oYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ex+aJfRsACjZ28NTdSFjpsnEX8XGNmUrxtA8psb1ayWYzB3TuieejguY2nD2Roc2F G6kC8Ox+SbgCLvviz1viCFs0nmHzWSfR8Ay8XHFq9B4CjOP9/gbN2zjTyRHbss9zB3 DbBUR8OiMXk4Q4QZ1Hale5vP6GR60CkbihW9mY4M= From: matthias.bgg@kernel.org 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, enric.balletbo@collabora.com Cc: sean.wang@mediatek.com, sean.wang@kernel.org, rdunlap@infradead.org, wens@csie.org, hsinyi@chromium.org, frank-w@public-files.de, drinkcat@chromium.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, mbrugger@suse.com, matthias.bgg@kernel.org Subject: [resend PATCH v6 12/12] drm/mediatek: Add support for mmsys through a pdev Date: Sat, 7 Dec 2019 23:47:40 +0100 Message-Id: <20191207224740.24536-13-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191207224740.24536-1-matthias.bgg@kernel.org> References: <20191207224740.24536-1-matthias.bgg@kernel.org> 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 From: Matthias Brugger The MMSYS subsystem includes clocks and drm components. This patch adds an initailization path through a platform device for the clock part, so that both drivers get probed from the same device tree compatible. Signed-off-by: Matthias Brugger --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 210455e9f46c..5ada74d8d0c9 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -186,6 +186,7 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = { .ext_path = mt2701_mtk_ddp_ext, .ext_len = ARRAY_SIZE(mt2701_mtk_ddp_ext), .shadow_register = true, + .clk_drv_name = "clk-mt2701-mm", }; static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = { @@ -195,6 +196,7 @@ static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = { .ext_len = ARRAY_SIZE(mt2712_mtk_ddp_ext), .third_path = mt2712_mtk_ddp_third, .third_len = ARRAY_SIZE(mt2712_mtk_ddp_third), + .clk_drv_name = "clk-mt2712-mm", }; static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = { @@ -202,6 +204,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = { .main_len = ARRAY_SIZE(mt8173_mtk_ddp_main), .ext_path = mt8173_mtk_ddp_ext, .ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext), + .clk_drv_name = "clk-mt8173-mm", }; static int mtk_drm_kms_init(struct drm_device *drm) @@ -499,6 +502,24 @@ static int mtk_drm_probe(struct platform_device *pdev) INIT_WORK(&private->commit.work, mtk_atomic_work); private->data = of_device_get_match_data(dev); + /* + * MMSYS includes apart from components management a block providing + * clocks for the subsystem. We probe this clock driver via a platform + * device. + */ + if (private->data->clk_drv_name) { + private->clk_dev = platform_device_register_data(dev, + private->data->clk_drv_name, -1, + NULL, 0); + + if (IS_ERR(private->clk_dev)) { + dev_err(dev, "failed to register %s platform device\n", + private->data->clk_drv_name); + + return PTR_ERR(private->clk_dev); + } + } + private->config_regs = syscon_node_to_regmap(dev->of_node); if (IS_ERR(private->config_regs)) return PTR_ERR(private->config_regs); @@ -605,6 +626,9 @@ static int mtk_drm_remove(struct platform_device *pdev) for (i = 0; i < DDP_COMPONENT_ID_MAX; i++) of_node_put(private->comp_node[i]); + if (private->clk_dev) + platform_device_unregister(private->clk_dev); + return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h index 63a121577dcb..8fe9136adc38 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h @@ -29,11 +29,13 @@ struct mtk_mmsys_driver_data { unsigned int third_len; bool shadow_register; + const char *clk_drv_name; }; struct mtk_drm_private { struct drm_device *drm; struct device *dma_dev; + struct platform_device *clk_dev; unsigned int num_pipes; -- 2.24.0