Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp431152imu; Fri, 16 Nov 2018 04:56:43 -0800 (PST) X-Google-Smtp-Source: AJdET5eauDwnottCJSQ9wEZJOlBYOoErLI/ubY1FcJwAfCDdT53AHvpVPZGQeG10l4kzlXp6YS8l X-Received: by 2002:a63:181c:: with SMTP id y28mr9548308pgl.75.1542373003767; Fri, 16 Nov 2018 04:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542373003; cv=none; d=google.com; s=arc-20160816; b=vNyr74QPCBA5AjqfNiUFoSxrvxYCoBVaRz6xqsJz93iT1bR+zI+gQv63PhbrQSr8JX 2JU7+P35nrDxcnuV8HHJIVQWo8Gz7jIBvJd3mkHr+fBj8V5V1NZQcGb/am/AJC8kEQGb f6EGqWRQpPVo+GZuZvm/Pyq7FczC4n4gjtWhnQQVc3Nkphv9SYF1tDbKQnWnGJcumTDX 6L3AhqTtKWFi6Ys9kDrYsk8oWpvLGwT2wHvHY3f9i7wYhWUwokuQ4b/olGiD9fHFZkbZ kJvcNFgvdEYIp6o502UepnSY80brySF4oJ/e+6jFI23AYPwPV1hqyd32e9YkuxHal8sw VBBQ== 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=p1JXbiyMV8QEBZfNCCOCJZXZBIv5a4/r1hWyIOd1bwI=; b=jxl6VLPukhBjil9VPsMyfkY5xnIna/6+rKMdyKgccISUNgOG8QsinHsUCEoJVfo5wi 61N3YBhjIwKv3oqqRs0qEv4BVN5wMfjFcYaD4yS7TzMqOjfZr9SO/D2fqxy5ug0W0HB0 YNaAgb0cCcYz9A1nS1fBDIaB/E6YL2axLUNJdvn4gIe+l8aucp2DiixAXWl4Kso+OipK dhaoHT5ICy3gHWsQXWUgI9MxP9TC5XHkR8EaWB52ERGQbLaOllZs22LrNafBNkXDYF+O umkyThEMFfdBJ9EEdEsUTBpW5Wio//IUceDfoynVwEvzHi2+72J60i+I4P3Va4B3fvOW avrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TcSRYdkn; 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 o9-v6si33401621pfe.283.2018.11.16.04.56.29; Fri, 16 Nov 2018 04:56:43 -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=TcSRYdkn; 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 S2389830AbeKPXH7 (ORCPT + 99 others); Fri, 16 Nov 2018 18:07:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:33546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbeKPXH6 (ORCPT ); Fri, 16 Nov 2018 18:07:58 -0500 Received: from ziggy.de (unknown [93.176.133.217]) (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 AEF0C208E7; Fri, 16 Nov 2018 12:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542372940; bh=J2OCMnIzgBP1xvJrW/wc62tgqU2n8Ltez8hvwJRyV7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TcSRYdkn1JBa5TvCekARCRnLoINIPuj6B4Cxb1GqqfupwoKz3wlUxn4X/fEGs8heS RQEKsoNFMx5LOAHczD2K2Ahtjd1IrZhoiiSlc6mXE3LDipmSWu1K/s94WtVHqyCVQ/ MZ0X6r1qXIt4IlFkl+iqwDi6Ac1MSahMt62v+Ohk= 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, matthias.bgg@gmail.com Cc: sean.wang@mediatek.com, sean.wang@kernel.org, rdunlap@infradead.org, wens@csie.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, Matthias Brugger Subject: [PATCH v5 03/12] clk: mediatek: mt8173: switch mmsys to platform device probing Date: Fri, 16 Nov 2018 13:54:40 +0100 Message-Id: <20181116125449.23581-4-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116125449.23581-1-matthias.bgg@kernel.org> References: <20181116125449.23581-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 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.19.1