Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp937437ybv; Thu, 13 Feb 2020 12:22:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzORDh4xOyU5Qj+Losqv+dS9UaDhFsqaMdVxnYjM1TBvGu7VHDsJllAsogZbmcfYfFFQwKm X-Received: by 2002:a9d:65cf:: with SMTP id z15mr15300040oth.238.1581625327565; Thu, 13 Feb 2020 12:22:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581625327; cv=none; d=google.com; s=arc-20160816; b=sDyQVSKg6N6UvmtIuNCXum8nQ74VibVLezf+ozzPQn4dwIVepPrqD45BkjI6OpB2rg bFE/kCBHtU5pEDB0W84sIL9j/UymJv8kKZNJPPrkU1M4tmVcBO+O9vraJ7odXIoeaSoQ WIfNKiLNfkfQVPZPfwfc0mYbvAcUPx6+T2pzQzrnUIR5b5JBo0li3O4wzFRVQD0DwQCX 7oDViYD/dgwW0oYHYHQv/SJZcp2xnTlk65nPkBRLT+2Itm7kB2zwZkCOLSC68p6RonLJ om0pzg5wZpoaoJ+XJGba7x5J0LfTlNrBFUrchaS6Sn9jndEo5uRScIOlrnGTCTB5RxV0 B5Rg== 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=bwGuuK9Qbd/xUunOH1o5hLYUNmEt1kwHSqn2h5wvm7U=; b=eoYD8GKg5uY+D5D92xzrGRpP3bS7vXCn2+XXmjZ5VQLm58AXbFwUoIUxdoM6BULkTy D7awIgrdLNTveGt6yAounQkCaV5nLO8Tb5BZmUytDPB0JWoDT0c0kC78vLNcyuAgxmOp OlAAKoDREz2RYoXYhTH368YAZWCFLh1AYkh+tcvN7Ms6Akbb3zG6B8jZ63/gfrpAtowI 20jKw63WGa/PaqBCz4fB+ZPH8NbB7mnLgVN8bqhLWn7r4/I32zaO6sgD+JU4eVkfgV36 SVd3mMJuvX8RBJEInXztspEGfyWX+zcsURb6N4ApK1zofHNQ9Evb2XDaJH+Axa0MHHEp 5iqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aoQVPXYT; 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 200si1601536oii.156.2020.02.13.12.21.55; Thu, 13 Feb 2020 12:22:07 -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=aoQVPXYT; 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 S1727860AbgBMUVO (ORCPT + 99 others); Thu, 13 Feb 2020 15:21:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:35964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727910AbgBMUVM (ORCPT ); Thu, 13 Feb 2020 15:21:12 -0500 Received: from ziggy.cz (unknown [37.223.145.31]) (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 6EAFE246AF; Thu, 13 Feb 2020 20:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581625270; bh=DixFOO1GKT4exK4e47L4oEKto/snnxtafkHfLyzoRjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoQVPXYTBM5OOAECJE/bFoLv6kRxp2NCvyDhOWHJsrnOAbKQLbnfxHIZ8LjZtSCsC ApqfRu79GzpDKRUSbQbon2hwwIiZsGhBYUDMVYJGw4rD3SOCh7oWTlZxDV9B1WYhXo pLz5f5al64vrKwo51arNt5Ucl74Gm0bmXnKu+SJ0= 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: devicetree@vger.kernel.org, drinkcat@chromium.org, frank-w@public-files.de, sean.wang@mediatek.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, wens@csie.org, linux-mediatek@lists.infradead.org, rdunlap@infradead.org, matthias.bgg@kernel.org, hsinyi@chromium.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Matthias Brugger , Daniel Vetter , Matthias Brugger Subject: [PATCH v7 13/13] drm/mediatek: Add support for mmsys through a pdev Date: Thu, 13 Feb 2020 21:19:53 +0100 Message-Id: <20200213201953.15268-14-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213201953.15268-1-matthias.bgg@kernel.org> References: <20200213201953.15268-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 Reviewed-by: Enric Balletbo i Serra --- Changes in v7: - Add Rv-by from Enric Changes in v6: - re-arrange the patch order - generate platform_device for mmsys clock driver inside the DRM driver - fix DTS binding accordingly - switch all mmsys clock driver to platform probing - fix mt8173 platform driver remove function - fix probe defer path in HDMI driver - fix probe defer path in mtk_mdp_comp - fix identation of error messages Changes in v5: - fix missing regmap accessors in drm diver (patch 1) - omit probe deffered warning on all drivers (patch 5) - update drm and clk bindings (patch 6 and 7) - put mmsys clock part in dts child node of mmsys. Only done for HW where no dts backport compatible breakage is expected (either DRM driver not yet implemented or no HW available to the public) (patch 9 to 12) Changes in v4: - use platform device to probe clock driver - add Acked-by CK Hu for the probe deferred patch Changes in v3: - fix kconfig typo (shame on me) - delete __initconst from mm_clocks as converted to a platform driver Changes in v2: - add binding documentation - ddp: use regmap_update_bits - ddp: ignore EPROBE_DEFER on clock probing - mfd: delete mmsys_private - add Reviewed-by and Acked-by tags 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 b68837ea02b3..68605dedf997 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -125,6 +125,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 = { @@ -134,6 +135,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 = { @@ -141,6 +143,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) @@ -437,6 +440,24 @@ static int mtk_drm_probe(struct platform_device *pdev) 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); @@ -544,6 +565,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 03201080688d..15652264c233 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.1