Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp111974imm; Tue, 17 Jul 2018 15:04:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWhprpmlqW1LCpJIq6MwMybtbQHSC2cq/QIPehYiX/Kh/cQMKq9SH1apdKrCDX3rij2PKu X-Received: by 2002:a62:225d:: with SMTP id i90-v6mr2424775pfi.246.1531865086079; Tue, 17 Jul 2018 15:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531865086; cv=none; d=google.com; s=arc-20160816; b=yiiuTH/VhQvD/hhS2l5Qon9eHDedoDBseU2Sw8dfcIzQ14yXB+9mwqejzm9jM+lF7k h8lsS8HkKBtX8ALUNXb13IJN/aZBoeOFTDHtq0JXKwUDmky7lc/yeF/4uOox9Xs+W2fV bLracC4UQtJjTnz4edDXHLLXukDLsAz2jo8hUlw/OCXXybPRXII99RhzY2XOIDPIowS4 /xifKhYLV4RWhUIpfQX5fKFFy/doD53tAfE6dAKyxtk/wcjQO9LPDiqr8aUL6SOt6s4n 75UMER0VDOEGbHzNVfp1Q+/pT0DmhPMrz16tUZ7nSLdOyc2/56E2jZLpFgEhjridwuVl bfSA== 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=s8RCurzsYy1LTOzRfp8y3gwbvytCuOdRf0wzeaTd46A=; b=mODrheNBkry/icDjjM0/jAFpsndgVfsfy107H9RalN3V2elrsWZLk0ZixL+/2xRIrU IqNRR/M1+QMKv3ep6xm4GghITLdVRRgHebEc5GNKh0wCQk2qlnxVK0pEFn+jLH6P5Kij 8KSy7dXDROfXjoRzlh+ww1H9+asF/2F68NHpruVODy2NS/0SSS2ONpJDme3Byt74AUhS uaHUU9r0AAyoByVbmM+mgAHojCQ2aevBlnjMx55+f39dZF8U6eVuMHqTDKJr6W0CoE/q GsrDrTxsZGf0aCqmQsC/uqV6PAwg995S12SdQNwnUFlTG2udaE2QRfUOk8T4xfMsksnG /FIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MA9DTbnU; 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 s8-v6si1651432plq.327.2018.07.17.15.04.30; Tue, 17 Jul 2018 15:04:46 -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=MA9DTbnU; 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 S1731304AbeGQWib (ORCPT + 99 others); Tue, 17 Jul 2018 18:38:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:45614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbeGQWib (ORCPT ); Tue, 17 Jul 2018 18:38:31 -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 9D0BE20835; Tue, 17 Jul 2018 22:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531865029; bh=totdlQGjZC0xH4Bv4jG2HvOFf3a91b0+KWpmIUhORts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MA9DTbnUwSuRy/BIHFmG03ahgOqUxRgbqFmZm4eEqf0VRHaCZrdNVbxHvkQHa0/vb /4mNtc6gEN0DmJOxsci5231EFChGoYl1FJzcnASYIONmyfKx68FyUwAZn9o6cKagzz K/ACfKG36/cPwMVye6DeKkoCT0Q20PCAU6Ny5b60= 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 2/5] clk: mediatek: mt2701-mmsys: switch to platform device probing Date: Wed, 18 Jul 2018 00:03:25 +0200 Message-Id: <20180717220328.792-3-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-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.17.1