Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp112123imm; Tue, 17 Jul 2018 15:04:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpefwzTPEXxMjbzkjEfAsgqba/PQyQQAdcdxgOW8P605gRVbYFKq2mprp4cJ9pdvm1CRi6oB X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr3186910pgv.79.1531865095281; Tue, 17 Jul 2018 15:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531865095; cv=none; d=google.com; s=arc-20160816; b=KIqAPIHRfHg5VO++RXr1cuFmt5cW/uKIN8Xelz/3WULgFhdeFMle9RpL1BTebkCqUA 5c6lYbW3689N49kLE13mZ89jEOrM7GLcvKZlXoGDg2yvGFtvoWUKbQkYlvgUtkuOa+HA 4zFOH7t1FNEHY9H0tmHHLdQNv2kK32cquIJG40x+ouaSRN8OewcbwLX1ZLmDq4sbnkgr 3BOCEZYDuwloHcOihL1zY8AkhXpNoYvX63IEqocjH6i1HYmzJ/MmxlAJTH+Wk3OAlDV2 HTaV4cIT/elPgu4o1UPG9QzPep2/dg7vYY8QVsRApk9i8gW1OXAx03HG9tVfqeY4nijQ Ggkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=n68ztOfHlUrcW9qhnx5UzQk6BCcfy5pXCysI6z3sr7s=; b=HtJsWk7z6lb/pkOw6+qBGcs0L0jl8udW4qeAlI1uyktUgmCICrEF5tma6lHmLjAaPN r2umGN/u5U9V3S3k16HIg3+aSd1UacAi7MbSHLDMWC3Hcfy7fEHcGzTW2bosSpD3lyG3 mqAMtt1GCISomJOafZarSwaEhRiPt6eSeukPryRR8LHHjwRNaPXhkI/Ek8v6OIfmUBNj 4RhbNHnZV5DUtWCL4YYC1FNVPemr9Hk+QMg8gnUp+EYcDHRV5MMOVj96FSTLpNtbQ9Dq InUS1fEdLnVJPmTdzZrC0mhrHMRxNigMGDZ082TrcvEpRXBMLQwPnJQdkxuHjVSY+0Wx hekA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="imFHgyW/"; 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 e17-v6si1832532pgm.671.2018.07.17.15.04.40; Tue, 17 Jul 2018 15:04:55 -0700 (PDT) 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="imFHgyW/"; 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 S1731374AbeGQWih (ORCPT + 99 others); Tue, 17 Jul 2018 18:38:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:45754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbeGQWig (ORCPT ); Tue, 17 Jul 2018 18:38:36 -0400 Received: from ziggy.de (144.pool85-56-49.dynamic.orange.es [85.56.49.144]) (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 6732D20839; Tue, 17 Jul 2018 22:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531865035; bh=U0ilIxN8f7Iu4VX226MDd/I68fU+92CDuDprBIA7res=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imFHgyW/x1HLMHbH57UziCZQbgKDWaI0nkuy3ZiuhyCD7FmowpowUZih6zpeCekU/ JToNnWLt+VyUp/Iwu7WAyKxwRVQEtu5DRpWwHm+Eu5BnQNXiGawxXSlRj0nPKbkf2T NclZdF0a68YptvnxaOaPSpR91njXpfkDws3dUvY0= From: matthias.bgg@kernel.org To: ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com, ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, robh+dt@kernel.org, mark.rutland@arm.com, mturquette@baylibre.com, sboyd@codeaurora.org, lee.jones@linaro.org Cc: davem@davemloft.net, gregkh@linuxfoundation.org, mchehab@kernel.org, rdunlap@infradead.org, pi-cheng.chen@linaro.org, sean.wang@mediatek.com, linux-clk@vger.kernel.org, linux@armlinux.org.uk, matthias.bgg@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger Subject: [resend PATCH v4 3/5] clk: mediatek: mt8173: switch mmsys to platform device probing Date: Wed, 18 Jul 2018 00:03:26 +0200 Message-Id: <20180717220328.792-4-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180717220328.792-1-matthias.bgg@kernel.org> References: <20180717220328.792-1-matthias.bgg@kernel.org> 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 96c292c3e440..10b6a0251123 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -13,8 +13,11 @@ */ #include +#include #include #include +#include +#include #include "clk-mtk.h" #include "clk-gate.h" @@ -791,7 +794,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), @@ -1152,22 +1155,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 = platform_get_drvdata(pdev); + + kfree(private->clk_data); + kfree(private); + + 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, + .probe = 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.17.1