From patchwork Sat Dec 7 22:23:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 11277871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D696513B6 for ; Sat, 7 Dec 2019 22:25:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEDFB2467A for ; Sat, 7 Dec 2019 22:25:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEDFB2467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1ED1A6E26C; Sat, 7 Dec 2019 22:25:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id B47276E267 for ; Sat, 7 Dec 2019 22:25:17 +0000 (UTC) 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 119172467D; Sat, 7 Dec 2019 22:25:12 +0000 (UTC) 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@codeaurora.org, ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com, enric.balletbo@collabora.com Subject: [PATCH v6 10/12] clk: mediatek: mt8183: switch mmsys to platform device probing Date: Sat, 7 Dec 2019 23:23:47 +0100 Message-Id: <20191207222349.23161-11-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191207222349.23161-1-matthias.bgg@kernel.org> References: <20191207222349.23161-1-matthias.bgg@kernel.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575757517; bh=q7YR4HMuFuPvR0RHWH0ycHC5MCSJKPZtTtyErowzU74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHJd7SdyDsbnvS03itu1WhPFsk4qurb84v+sPFd/yCQrRsses75DkrsP4CqtSwZ4r h66S1OXeCi9jHDllgCSigCY1JNe0ZQTl1dTJ2O36tflUPF9hsdq+woH8SpI+Q5glTP 0LUv3CeTPapswzJXohRsOc4+LD5TmKNERxpzgPKg= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, rdunlap@infradead.org, frank-w@public-files.de, sean.wang@mediatek.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, sean.wang@kernel.org, wens@csie.org, drinkcat@chromium.org, linux-mediatek@lists.infradead.org, mbrugger@suse.com, hsinyi@chromium.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Matthias Brugger Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem. Singed-off-by: Matthias Brugger --- drivers/clk/mediatek/clk-mt8183-mm.c | 39 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8183-mm.c b/drivers/clk/mediatek/clk-mt8183-mm.c index 720c696b506d..e6dcad18d81a 100644 --- a/drivers/clk/mediatek/clk-mt8183-mm.c +++ b/drivers/clk/mediatek/clk-mt8183-mm.c @@ -3,14 +3,20 @@ // Copyright (c) 2018 MediaTek Inc. // Author: Weiyi Lu +#include #include #include +#include #include "clk-mtk.h" #include "clk-gate.h" #include +struct clk_mt8183_mm_priv { + struct clk_onecell_data *clk_data; +}; + static const struct mtk_gate_regs mm0_cg_regs = { .set_ofs = 0x104, .clr_ofs = 0x108, @@ -84,28 +90,37 @@ static const struct mtk_gate mm_clks[] = { static int clk_mt8183_mm_probe(struct platform_device *pdev) { - struct clk_onecell_data *clk_data; - struct device_node *node = pdev->dev.of_node; + struct clk_mt8183_mm_priv *private; + struct device_node *node = pdev->dev.parent->of_node; + + private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL); + if (!private) + return -ENOMEM; - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); + private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); + platform_set_drvdata(pdev, private); mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), - clk_data); + private->clk_data); - return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + return of_clk_add_provider(node, of_clk_src_onecell_get, + private->clk_data); } -static const struct of_device_id of_match_clk_mt8183_mm[] = { - { .compatible = "mediatek,mt8183-mmsys", }, - {} -}; +static int clk_mt8183_mm_remove(struct platform_device *pdev) +{ + struct clk_mt8183_mm_priv *private = platform_get_drvdata(pdev); + + kfree(private->clk_data); + + return 0; +} static struct platform_driver clk_mt8183_mm_drv = { .probe = clk_mt8183_mm_probe, + .remove = clk_mt8183_mm_remove, .driver = { .name = "clk-mt8183-mm", - .of_match_table = of_match_clk_mt8183_mm, }, }; - -builtin_platform_driver(clk_mt8183_mm_drv); +module_platform_driver(clk_mt8183_mm_drv);