From patchwork Sat Dec 7 22:23:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 11277863 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 D92B317EF for ; Sat, 7 Dec 2019 22:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7F2E24681 for ; Sat, 7 Dec 2019 22:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575757514; bh=TiW6KdtW/ar4YbEgXwuzvM2malWSh9JMEZcRb2LrTeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YPI/TTELSPpKdLskI+Lacxx20u96cp/4no1CJruhEsS2Amo0/wyPh/hUfksXDCdfJ odYtBdfpUjYSmb/nIUEdEj1CuwzHlYhVvKrOgVFerJB/i21FjlF0OLGor5Ieh8Oh0f TIAUo7D3ggsnwvhDGzxKdo+NbuAPFJCUbZRSPPSw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbfLGWZJ (ORCPT ); Sat, 7 Dec 2019 17:25:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:37486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfLGWZJ (ORCPT ); Sat, 7 Dec 2019 17:25:09 -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 0DA2E24684; Sat, 7 Dec 2019 22:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575757507; bh=TiW6KdtW/ar4YbEgXwuzvM2malWSh9JMEZcRb2LrTeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EIy223GfLfJ1Jh2RMn4ZaTBhUU3ruVrxeM/rHhKeyeyTaIr56xDav0PYUmGBorz/C +v+DBS/1RiUGCyCRpCDgdYuYqKvC7Zl9EI/HcM/KEAG/ceYkSjfipc95esttNamXlu VAboNB0fCb8FXoeyWxmSrmROjjjAS3cc3m3nTG1g= 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 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 Subject: [PATCH v6 08/12] clk: mediatek: mt6779: switch mmsys to platform device probing Date: Sat, 7 Dec 2019 23:23:45 +0100 Message-Id: <20191207222349.23161-9-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 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org 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-mt6779-mm.c | 41 +++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt6779-mm.c b/drivers/clk/mediatek/clk-mt6779-mm.c index fb5fbb8e3e41..439ec460c166 100644 --- a/drivers/clk/mediatek/clk-mt6779-mm.c +++ b/drivers/clk/mediatek/clk-mt6779-mm.c @@ -4,13 +4,19 @@ * Author: Wendell Lin */ +#include #include #include #include +#include #include "clk-mtk.h" #include "clk-gate.h" +struct clk_mt6779_mm_priv { + struct clk_onecell_data *clk_data; +}; + static const struct mtk_gate_regs mm0_cg_regs = { .set_ofs = 0x0104, .clr_ofs = 0x0108, @@ -84,30 +90,39 @@ static const struct mtk_gate mm_clks[] = { GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16), }; -static const struct of_device_id of_match_clk_mt6779_mm[] = { - { .compatible = "mediatek,mt6779-mmsys", }, - {} -}; - static int clk_mt6779_mm_probe(struct platform_device *pdev) { - struct clk_onecell_data *clk_data; - struct device_node *node = pdev->dev.of_node; + struct clk_mt6779_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 int clk_mt6779_mm_remove(struct platform_device *pdev) +{ + struct clk_mt6779_mm_priv *private = platform_get_drvdata(pdev); + + kfree(private->clk_data); + + return 0; } static struct platform_driver clk_mt6779_mm_drv = { .probe = clk_mt6779_mm_probe, + .remove = clk_mt6779_mm_remove, .driver = { .name = "clk-mt6779-mm", - .of_match_table = of_match_clk_mt6779_mm, }, }; - -builtin_platform_driver(clk_mt6779_mm_drv); +module_platform_driver(clk_mt6779_mm_drv);