From patchwork Tue Feb 21 11:55:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 59946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1823329wrn; Tue, 21 Feb 2023 04:04:33 -0800 (PST) X-Google-Smtp-Source: AK7set9TbRX83OLrfddYHt/bTw3FbcxWqVSqYUq6X7G/RzBm00ALe4pBh+5OhMjUUtlrcK9EoM0n X-Received: by 2002:aa7:cfd1:0:b0:4ab:2555:408a with SMTP id r17-20020aa7cfd1000000b004ab2555408amr4955103edy.22.1676981073666; Tue, 21 Feb 2023 04:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676981073; cv=none; d=google.com; s=arc-20160816; b=VbhXHsWYUp7x1AlWWKlXpV57BpkbxilzPZyHAwaKYIDHVHXszUn4SPZ7k1OZr3v/z5 f782bTwgfrikQUgAPHHQ3+ikIj8TOHjt7qGhccd1URwH5O4g/EfFh5DtcvIZhkk1mpRV 7v2ZwXOqrnyQ2lC6DYarG6lxhTgfNSMeujGaykmIjbckTtCN6IJ/lDWoXbpbpT5PCDIi bbNOUIoBx1fv2KzQwiPSa0P+2CcJlBfR8mVdirZxo0clXAmN8ByjVPPIfuP3tSASS98U IjvVspTx0bMY8aEbhU3TztLUNkIDBKxnwGlq6I5jR+uOlpePjp2aQ9IHpDz4FqBl4oH7 SjFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WDpv9hD7zokJRVzSpAYM5tyE/PL/+ZojBGjT2//dGJY=; b=Bnppr9ViUbwbrhh3w9zkWFFzfgjeEII9J4u1Jb4jUnh9JdXO5MEwjxjA01UL6Rh1XU C1+zGIGVYZc48I8ofc+LXa6EoNmygZdosIaSNjL9yob6wT+pDhnpUgLjhsTHXoJHOsRj hEfdxWQvEOYF93CoxxyTbzQ0bSV9IR2VCp4fcAlBRFthIUqKmR1xa4iapynsykIoBUvY NrXz6semktLE+FosdkFywSB26fAjDXAfwece7Gqu/GGzBxG8ElB20mqeIPZBJyWIVrDq I158BgVIRFvD43ly0LVIYsQzz3hMH0E+EiW55NLPu7jUopVAjXLRJFPN15VLh/ZxVCdB 0JxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R+WkmBjf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a50ed08000000b0048e82d753a3si796527eds.227.2023.02.21.04.04.09; Tue, 21 Feb 2023 04:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R+WkmBjf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234784AbjBUMA4 (ORCPT + 99 others); Tue, 21 Feb 2023 07:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234703AbjBUMAN (ORCPT ); Tue, 21 Feb 2023 07:00:13 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04FF0298D0; Tue, 21 Feb 2023 03:59:21 -0800 (PST) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7BB3766021D2; Tue, 21 Feb 2023 11:57:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676980623; bh=0Y27t3R6zvpg0EqaXE0oMVd4qikZ3fYziMJKJIURiLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+WkmBjfdsuyMCgPJpZffNA3nj85TLSmpumZLqNMcO9dBrcsSug7tM+YAiKcrvttM BsdXtQwxg+5k4kd5yi6agE9yKuy15nV/u9Vv9JHE0oXAc6StCL8geFXhOB52QK0quh DWd1CD/jhBKoemo9rQ5qXOkl9T9qpg6ZG73ag3zy3f5krxgLJqCuZkNtoNkrzdzxJM 1/FsMyGAFGNc38y1KOAB43IOePMwPBNYvbOMDLpfy8Eack/+kPns/z67H/2JihdrdX lCcwfpb48QnX8YaukbTEFj7Sf7HSsK0BDpQDy6jQbPBKktr489nUriA9n34X4Ed4rL 4lV14pYU2gXHQ== From: AngeloGioacchino Del Regno To: mturquette@baylibre.com Cc: sboyd@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, wenst@chromium.org, johnson.wang@mediatek.com, miles.chen@mediatek.com, chun-jie.chen@mediatek.com, daniel@makrotopia.org, fparent@baylibre.com, msp@baylibre.com, nfraprado@collabora.com, rex-bc.chen@mediatek.com, zhaojh329@gmail.com, sam.shih@mediatek.com, edward-jw.yang@mediatek.com, yangyingliang@huawei.com, granquet@baylibre.com, pablo.sun@mediatek.com, sean.wang@mediatek.com, chen.zhong@mediatek.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 52/54] clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module Date: Tue, 21 Feb 2023 12:55:47 +0100 Message-Id: <20230221115549.360132-53-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221115549.360132-1-angelogioacchino.delregno@collabora.com> References: <20230221115549.360132-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758442106289201028?= X-GMAIL-MSGID: =?utf-8?q?1758442106289201028?= Convert apmixedsys clocks to be a platform driver; while at it, also add necessary error handling to the probe function, add a remove callback and provide a MODULE_DESCRIPTION(). This driver is now compatible with an eventual module build. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8135-apmixedsys.c | 53 ++++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8135-apmixedsys.c b/drivers/clk/mediatek/clk-mt8135-apmixedsys.c index 2b4d379300fc..744aae092281 100644 --- a/drivers/clk/mediatek/clk-mt8135-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8135-apmixedsys.c @@ -47,16 +47,59 @@ static const struct mtk_pll_data plls[] = { PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0), }; -static void __init mtk_apmixedsys_init(struct device_node *node) +static int clk_mt8135_apmixed_probe(struct platform_device *pdev) { struct clk_hw_onecell_data *clk_data; + struct device_node *node = pdev->dev.of_node; + int ret; clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); if (!clk_data) - return; + return -ENOMEM; - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); + if (ret) + return ret; + + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); + if (ret) + goto unregister_plls; + + return 0; + +unregister_plls: + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + + return ret; +} + +static int clk_mt8135_apmixed_remove(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + mtk_free_clk_data(clk_data); + + return 0; } -CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8135-apmixedsys", - mtk_apmixedsys_init); + +static const struct of_device_id of_match_clk_mt8135_apmixed[] = { + { .compatible = "mediatek,mt8135-apmixedsys" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, of_match_clk_mt8135_apmixed); + +static struct platform_driver clk_mt8135_apmixed_drv = { + .probe = clk_mt8135_apmixed_probe, + .remove = clk_mt8135_apmixed_remove, + .driver = { + .name = "clk-mt8135-apmixed", + .of_match_table = of_match_clk_mt8135_apmixed, + }, +}; +module_platform_driver(clk_mt8135_apmixed_drv) + +MODULE_DESCRIPTION("MediaTek MT8135 apmixedsys clocks driver"); MODULE_LICENSE("GPL");