From patchwork Mon Mar 6 14:05:41 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: 64685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1867066wrd; Mon, 6 Mar 2023 06:19:45 -0800 (PST) X-Google-Smtp-Source: AK7set+3iiFORYsXUy808L7TlzWRz8LIIOyMqbPYyk3p2W0YVSPdAyWQlRsqq2AYr6CU0IZ0TFdR X-Received: by 2002:a17:906:80c1:b0:87b:d62c:d87 with SMTP id a1-20020a17090680c100b0087bd62c0d87mr11030294ejx.1.1678112385502; Mon, 06 Mar 2023 06:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678112385; cv=none; d=google.com; s=arc-20160816; b=OnfDyR2L7mWMHj0/B/maBBqzuf/Qfk709p7SZJE7iMbCwb/cchluiHr8gwJHFs8q5o sFTnA7768rLSKVJvxHwapKeZYI5L/skddD1QcBc18IFGA+0FoqC6ODvJ2WsMWKcaghjT mcChBCX9ZMcR9OpcK4alGAn7oCfsCCXx1ntUaCoth4GiiPUEDgRmOmIQbfcrBRhLDsHE tjhDkL3FPbp6qYVSPD2vE58T8xsVYtL1kdGKyvC+2m4NwSUjVt5rFrlZ3JRX61QGTuTz CV8MI6lplFPAyr1twqhTvpKoTu7jfObP9ritfg/rz1PiSkEioPysE68jmiQ1Q5J5/8V4 3fUA== 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=azsVNssM4YVIgJkjBhfB+0RW4YebySD+ilpX5G6kaO0=; b=0EUhRley3yn1Qiq+/4fdR5xfmYoZkUjIfB+HyrSWF0etHJQ4rQxa59f/5MHoQuWbh+ xbRb8b45D+J5ohTAGn+yP2U5LFwohdfebqdvHxp7P4f4dJwp1Nk/pcuuHg47/DzTJIdL iMqooGZpfWcpKHg+nJirelfPsnslAM6yqbIevTUY8oqmym6RInBqFbab5oakFzbmcCMm ifyokLDuanLH1K+QHuiVe+4lrnauzTsyFF5Xho3bw7lNolf2/ETzTJtzzbaWEmMoQLgu zXPdtGrVdmbkG8WEDzSx8qmRdTGdF7gokR8xiTa4eWPn+kdP9QU9qp4LgX8cVtV6CV9w vCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UqzU9FO+; 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=QUARANTINE sp=QUARANTINE 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 b15-20020a17090636cf00b008d92efb7984si9460407ejc.999.2023.03.06.06.19.21; Mon, 06 Mar 2023 06:19:45 -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=UqzU9FO+; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjCFOLm (ORCPT + 99 others); Mon, 6 Mar 2023 09:11:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbjCFOLE (ORCPT ); Mon, 6 Mar 2023 09:11:04 -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 9CD602D69; Mon, 6 Mar 2023 06:09:08 -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 B58726603006; Mon, 6 Mar 2023 14:07:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678111631; bh=G39BkrHiy8UDI2+jdX1lg0zn/2dAssLXNfESAl+XYlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UqzU9FO+BQkxwKP30fVYNYeLm8JDdCS8rNUj08L9I+vAPRT4C4H2+31aJWjKx21jL +XESMgURqQ0Auav1c3VKbWnl7yFJXB3mm5P/4Y8/7i9LQ3WLV1A4M7SuVA9zVjmHfe cLubYutgJsp+jvjOgaR+w4DuAblcbSAtla+EwDMB7f3p0oQzbNVTAEp7KpGcyIutTL FD0b1lnlpP9Xp2W09fd9Z4EgQzjy8vsSRuCnjTE/95RdgIZe8h1Op8cHrwijUsWYBz O6ch2TalnomG/jJIzSr6/Vb6PYrIElzxZ3U+zMYSSrONS66xp+T3TTe+rbBAOC59Ob /PGaPDs6thNXA== 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, kernel@collabora.com Subject: [PATCH v6 52/54] clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module Date: Mon, 6 Mar 2023 15:05:41 +0100 Message-Id: <20230306140543.1813621-53-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306140543.1813621-1-angelogioacchino.delregno@collabora.com> References: <20230306140543.1813621-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?1759628372325580304?= X-GMAIL-MSGID: =?utf-8?q?1759628372325580304?= 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");