Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp431059imu; Fri, 16 Nov 2018 04:56:38 -0800 (PST) X-Google-Smtp-Source: AJdET5eMfTpJ9PDBWojm7nDJqgdRM0z4e4RjMQTSeHVEeRoSXY4a5ps979TZSWHWTXPK6AH67A4R X-Received: by 2002:aa7:8254:: with SMTP id e20-v6mr11074049pfn.164.1542372998268; Fri, 16 Nov 2018 04:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542372998; cv=none; d=google.com; s=arc-20160816; b=mkw1EMTfOZRAGM2N2M3665F2xceKkEJ6XW7rxjUTTzDwUXjBGGmixQriRiMybP1is7 Ekabtcg5xKWOnLSr/zr60jjbwS98pbcMnE9MhwaIm+x9ighDAb0NtofW7jBO1q10pMZi ObmTo4AOLHGvku05oNGPNF4q9y2OS33l5CbddxJfwHxjoHafrtdU+m6i0cqvfhcidiCX QRL0FkTylYsjneOjHMqzjtkHodMBd3OKOBRIDiRa4IMkgGXyRxi822q1VfTzcyikLGOK u/CSj2nD/2s8k+8YwmdRWLlcR3/m24avBiNmaVZsfJfQzvUyvB/yfuv53MRUr5TFAxwN sBxw== 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=t4vRb7vej7pA0poaDyESDl1Tk8levWPv2saLjPFHGIg=; b=MrdoiLlSZ099NbN5J4FAOpuWEGpaq/AjHk+dy6K4OafoNYLrn7hq/PpQx1BPpkQu7v 5o+iL8wGQGMazrWN0H0XCWpADh/NOHtL1k4o1B46CKYxqJ0qNJ1UCU8uw0++2do5eSrD LDcF4lEogZkkfyXZcWYnDOUy661zRKP0P3vFvRudY7U2KfKP4HdMbvsR1CUdDNT2n6XX dqCfVkKnY9WAU8AaSo0cBYS/qGVnYdvy5S0RVVO31c1ITy/11SDDNNAhORzL4/8ozzzF Ht4xweg5evYT1IJXQqHOQp/cRb3f7lh00CLd7aEfFAfe67Qfpt2waLWuWNE/gZrsVcvZ 15bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dYpdYAGR; 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 p1-v6si24753953plb.290.2018.11.16.04.56.23; Fri, 16 Nov 2018 04:56:38 -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=dYpdYAGR; 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 S2389804AbeKPXHy (ORCPT + 99 others); Fri, 16 Nov 2018 18:07:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:33442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbeKPXHy (ORCPT ); Fri, 16 Nov 2018 18:07:54 -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 66F2520989; Fri, 16 Nov 2018 12:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542372936; bh=YWa3oRPVlT/S63uQvThApqIKb9DzRSCSP+OAynmBwf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dYpdYAGREL8rC/98+2atoSVHhmJBzkuuyZym5BrQ+pp92C8+ukAY045+yTqhYkGek oqBXxhgzlRS2e3pV1G7S673+hUKXsaXhMzhLOpEvwvPUIJyKisoCYplQciqqX2Dc7v zV5Sxq2+QlEWFW4funxYFx8SyS/FaNYAU3lLwk2s= 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 02/12] clk: mediatek: mt2701-mmsys: switch to platform device probing Date: Fri, 16 Nov 2018 13:54:39 +0100 Message-Id: <20181116125449.23581-3-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-mt2701-mm.c | 42 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt2701-mm.c b/drivers/clk/mediatek/clk-mt2701-mm.c index fe1f85072fc5..200b1842b94b 100644 --- a/drivers/clk/mediatek/clk-mt2701-mm.c +++ b/drivers/clk/mediatek/clk-mt2701-mm.c @@ -12,14 +12,20 @@ * GNU General Public License for more details. */ +#include #include #include +#include #include "clk-mtk.h" #include "clk-gate.h" #include +struct clk_mt2701_mm_priv { + struct clk_onecell_data *clk_data; +}; + static const struct mtk_gate_regs disp0_cg_regs = { .set_ofs = 0x0104, .clr_ofs = 0x0108, @@ -87,23 +93,25 @@ static const struct mtk_gate mm_clks[] = { GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14), }; -static const struct of_device_id of_match_clk_mt2701_mm[] = { - { .compatible = "mediatek,mt2701-mmsys", }, - {} -}; - static int clk_mt2701_mm_probe(struct platform_device *pdev) { - struct clk_onecell_data *clk_data; int r; - struct device_node *node = pdev->dev.of_node; + struct device_node *node = pdev->dev.parent->of_node; + struct clk_mt2701_mm_priv *private; + + private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL); + if (!private) + return -ENOMEM; - clk_data = mtk_alloc_clk_data(CLK_MM_NR); + private->clk_data = mtk_alloc_clk_data(CLK_MM_NR); + + 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) dev_err(&pdev->dev, "could not register clock provider: %s: %d\n", @@ -112,12 +120,22 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev) return r; } +static int clk_mt2701_mm_remove(struct platform_device *pdev) +{ + struct clk_mt2701_mm_priv *private = platform_get_drvdata(pdev); + + kfree(private->clk_data); + kfree(private); + + return 0; +} + static struct platform_driver clk_mt2701_mm_drv = { .probe = clk_mt2701_mm_probe, + .remove = clk_mt2701_mm_remove, .driver = { .name = "clk-mt2701-mm", - .of_match_table = of_match_clk_mt2701_mm, }, }; -builtin_platform_driver(clk_mt2701_mm_drv); +module_platform_driver(clk_mt2701_mm_drv); -- 2.19.1