Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2407241ybl; Sat, 7 Dec 2019 14:50:36 -0800 (PST) X-Google-Smtp-Source: APXvYqy6TZ5Pw5MzHQhIe+pvgndtlYm0pXPMVP7zrOvZTHYo86eUovhGJ/4Rll1enPQaN0rUVIW5 X-Received: by 2002:a05:6830:2157:: with SMTP id r23mr16968108otd.143.1575759036921; Sat, 07 Dec 2019 14:50:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575759036; cv=none; d=google.com; s=arc-20160816; b=fzBR3NOCboPbnJQSX0fgmQQiVdBnW2UfSuJb5MnHkQDdSVzKautXYfmc23Bgz/KcYY CDRhhbJzECYTwRqOSrkgXg26xQQpXII/8iS7syRtGzj5VNb2VsiD45p0E4e2araVzHk2 C6rXhOeySiOjoNwaBZEZ++oPvvEdWUoih0mZrsN4sOzSjOPgMXN3yzfzYpjgKh5d/+De q8C0quBSc4QBpPvvILOQR7Hdqxc9mjaQTkdO1k1noEbWEMSLzJAseyPs9zis7CWvkkUR FSpcQ+l8Tj9rSZJsN8ymJb6sjpPHiUdgAzeR7VJj3ZBNi0+xLITqdigvNtcios7SoPfe NT/w== 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=wO1A09hs8M8Tn5cqLa6aZQR9auWTMpgT7L1AIAAEfOg=; b=T1pLTRQb71UX3os3/gz1CdmgrsrteDyt4XAIP5GEDSezhvNlR9hXQL0FBvZYaymT3P /9nrcjH2vxKBVb7uWkHdzrug/gnv7kt4Wm5LaKKjMl1TpKLJ3uultRu50hN+FV0C95Vz igxJ065R7cjmr9ZIbi0HTt3QUq5XSEP3dYgen2/JDtsolwpOXnPa2JAPuaawh3SfJ4R9 109c/QbKUBHNXuLdIFWqCQUhEYORv4AWVYPJ3WAmihodjeXfrK7E8HuVKFmi+Imxzeep 0R5YzDdk/Zuvb9dBgrgERPcrtIWdqm+E09t0OBtfXA7lRdcogCq6eaqycf/075fNF9KB gveg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xRNWDRcr; 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 y129si9530857oig.143.2019.12.07.14.50.26; Sat, 07 Dec 2019 14:50:36 -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=xRNWDRcr; 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 S1727163AbfLGWtA (ORCPT + 99 others); Sat, 7 Dec 2019 17:49:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:44672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfLGWs7 (ORCPT ); Sat, 7 Dec 2019 17:48:59 -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 E7D402467B; Sat, 7 Dec 2019 22:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575758938; bh=JSPEnmIDkobd2bvgU/0fVPQfLB35GOvh84DoJ03YQtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xRNWDRcrxBWatU0mYCZ/bQCA2Sx1J9ELv0b+8QQIDYu/2iRklhA6BHVCwFCkLtABm f4U9Ni/4irWC2wton2yVqNXQnWFuJptWlKr2+j4HOVO0UymtSMpQEBPRHsxpxEAVki 0QZ36lLj/pSLZzpmE5y1sKBhQQt0zxeQJm+M1p7A= 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 11/12] clk: mediatek: mt8173: switch mmsys to platform device probing Date: Sat, 7 Dec 2019 23:47:39 +0100 Message-Id: <20191207224740.24536-12-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 Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem. Signed-off-by: Matthias Brugger --- drivers/clk/mediatek/clk-mt8173.c | 51 ++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c index 537a7f49b0f7..1e6a390534e4 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -5,8 +5,11 @@ */ #include +#include #include #include +#include +#include #include "clk-mtk.h" #include "clk-gate.h" @@ -783,7 +786,7 @@ static const struct mtk_gate_regs mm1_cg_regs __initconst = { .ops = &mtk_clk_gate_ops_setclr, \ } -static const struct mtk_gate mm_clks[] __initconst = { +static const struct mtk_gate mm_clks[] = { /* MM0 */ GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1), @@ -1144,22 +1147,56 @@ static void __init mtk_imgsys_init(struct device_node *node) } CLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8173-imgsys", mtk_imgsys_init); -static void __init mtk_mmsys_init(struct device_node *node) -{ +struct mtk_mmsys_priv { struct clk_onecell_data *clk_data; +}; + +static int mtk_mmsys_probe(struct platform_device *pdev) +{ int r; + struct device_node *node; + struct mtk_mmsys_priv *private; + + node = pdev->dev.parent->of_node; - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); + private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL); + if (!private) + return -ENOMEM; + + 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); - r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + r = of_clk_add_provider(node, of_clk_src_onecell_get, + private->clk_data); if (r) pr_err("%s(): could not register clock provider: %d\n", __func__, r); + + return r; +} + +static int mtk_mmsys_remove(struct platform_device *pdev) +{ + struct mtk_mmsys_priv *private; + private = platform_get_drvdata(pdev); + + kfree(private->clk_data); + + return 0; } -CLK_OF_DECLARE(mtk_mmsys, "mediatek,mt8173-mmsys", mtk_mmsys_init); + +static struct platform_driver clk_mt8173_mm_drv = { + .probe = mtk_mmsys_probe, + .remove = mtk_mmsys_remove, + .driver = { + .name = "clk-mt8173-mm", + }, +}; +module_platform_driver(clk_mt8173_mm_drv); static void __init mtk_vdecsys_init(struct device_node *node) { -- 2.24.0