From patchwork Mon Feb 20 15:01:08 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: 59528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1365308wrn; Mon, 20 Feb 2023 07:24:00 -0800 (PST) X-Google-Smtp-Source: AK7set+kqu9TgHLLO50fXhOOeYYh8iLnig9NdBMADU4/QvAchNLdycgdjb9i9wbsR0Rmq+X+youz X-Received: by 2002:a17:90b:1e4d:b0:233:bc5a:92fc with SMTP id pi13-20020a17090b1e4d00b00233bc5a92fcmr3696914pjb.16.1676906640411; Mon, 20 Feb 2023 07:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676906640; cv=none; d=google.com; s=arc-20160816; b=sXZuFHkfWrg0j9aPd4JyE6QY5Wb13GE1JOUHwgQqQsG3rLS4fYWWfg4oinL4A1iN78 m6Almufmfopz39DmWWu0RQ7naLEkmPZG0itmWhAi74NzhNy6mbLf/lDFcZnJt9ypPL2g qdt+9qGwKsfNFzFqCk9aNecOdBMSx1fR2huHhQhPyaZU8rEGUt+vETAJ0KAmw65fVcEp wWMvh8HKzETJXXPKmY3soZTuUwZiT/FKzfqvPV+V/ei2jj0yrsT+t2EV5jyz1DxJnQGZ R5HHYPS73LlG9p7zjeIEk8E3ZhvIhoHkfXHZMp5mFwK1QvayJkQSyLHd2pQgN3mR5X0g TUlg== 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=Vr0rSHj74FJCEU+LN+qZ1nHPrwauM15rNLf68zVlLzA=; b=ucGTY5cdr50bYlyLTuluw+D66S09JvHGQNvV9P/t0QECF+Ui2JBnzHUGA8Lf7CFhzN AuvagdQuk3yD+sAnm1EeAvwA3dtt6RG9jNC8I7CepWikaqPjRq11tUuphdVAA+Zvphdx P7wMbFu7X2WmXFJRcGa5BIrvKSGOCv086/YLBrWp+JB1tx/SzYYUapMrD6mHErYhwXbB lN7iDhwsucsz2pEKZFn+YqWXdnrXA+efGTT7RgvNEXTcntpoWSVddDoksVUM+PlYZu4e BCForVhjMQzHRlX0DQ7/ej1z4WBhYGW+lttxQpqUp8kT2wz+vNEF5UX/7pZTjbUE4DMz 3sLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aaVL1z4+; 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 r83-20020a632b56000000b005021cf73d48si2615531pgr.190.2023.02.20.07.23.47; Mon, 20 Feb 2023 07:24:00 -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=aaVL1z4+; 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 S232369AbjBTPGJ (ORCPT + 99 others); Mon, 20 Feb 2023 10:06:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232969AbjBTPFw (ORCPT ); Mon, 20 Feb 2023 10:05:52 -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 E04C81DB9F; Mon, 20 Feb 2023 07:04:11 -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 1D52A6602169; Mon, 20 Feb 2023 15:02:28 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676905349; bh=M5hdGMuzmKCUIv2g12dDgcyuK136Nce3uLfpDQsboOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aaVL1z4+bFi5k5Pm92LtPA2oZYmKSVXIi3EpYw3kN79tgEJDKZQpUPOZMXcx/gGFe QrxLcIQqhx+lUCUjuA4FYxZT5+sUJjV76Ydum6eJOXq7xNCXInW04Go9fZDJmIUuxK MI2i4Wg+35RAQ9aDRns6YEC2T1n+JH/xjybUtH78yuDtMWRLf3F3NimAk6/Pg88PX4 2nDq4p0k8jhdpkGZwyRVupxsZZpFaVRHkz4PNLyn76mrOG3o2jqzWihjmY5Lh01KdS cvQFE447RQXMyaf1zDnKPv/Sja6+JIz3YeGWFdBu2H+rFx4tKoJC344SNSMwEshH44 ggLC9Nmgl5VIQ== 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 v3 52/55] clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module Date: Mon, 20 Feb 2023 16:01:08 +0100 Message-Id: <20230220150111.77897-53-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230220150111.77897-1-angelogioacchino.delregno@collabora.com> References: <20230220150111.77897-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?1758364057722344020?= X-GMAIL-MSGID: =?utf-8?q?1758364057722344020?= 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");