From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EF26C55182 for ; Mon, 3 Aug 2026 14:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sBoJSR+t4o6rLEYzXc6evi5ADYig1EhmcESvsg7Klw8=; b=AQh1QS0Qgg/8OapwvnqP56z4Aj GZzMsLjNeZUIXU3LLZF582jXQzHjVQ3AKG/zFMP4Dqp8IS8sg0IermqOqRVSS3gmwZCVr9ohRg9sm 9z7TvQF26ZrX2E0YjjOtWOEGuvJL7+hTHDEHltDyRLLeqAxKSqZSWnQK+Hs/Fb96nxot3z4f5Fkn0 bUoT/jGxgSBKcYL84VpvAA+XKS2B/WrRDKgBoB33/Y6eUNxbFVFXFNljq5MuSqalv9PllnYFXDYKP JTjGWv0tyy3Wa75zxGKFgCo56GyU3aMiXoEM7XxFZHXRoCoCYDM4nk6ra+vV9JXDhCZAG+ChdLbqi P+9YeYbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wqtV6-0000000HL9a-3YrN; Mon, 03 Aug 2026 14:18:44 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wqtV2-0000000HL3q-1U3r for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2026 14:18:43 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-38e42560ebcso2557116a91.1 for ; Mon, 03 Aug 2026 07:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785766720; x=1786371520; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sBoJSR+t4o6rLEYzXc6evi5ADYig1EhmcESvsg7Klw8=; b=Y+yfZj8Q5r3i5UesB7SBnyZOeeefz8L0RbWQJyv/PJMgNXmJ8RI5KCgWo3GgiXPYrP N2cynqOI27iY+vJ7khHnrwnAUICDjrb0RrXQhCGuFSt+tsDB7Bf6DG1oM9wJrvryqMqn 90bfdiyYA9QbdW9fXjQOaxJKFy6Kzy12SS9vXkkGS8isqElphqb+OL2VteaXXIZ/rwZd mflzNRi7QuDAnAES6CAY4kseAmWVQQzivfMUN51EjFqwUYjn5lujt3VFRw8Z3+m7A2p2 BGEycB9pLurEGHBlTPnrmB2UM40zGf24TMrI9VtmQazi4P4M1EwsLqd9D385WFUN4Y6+ 8ZtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785766720; x=1786371520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sBoJSR+t4o6rLEYzXc6evi5ADYig1EhmcESvsg7Klw8=; b=D0RuKZVSeyhD5Xv7udutBbfoqhcCIC0mzBWOMYPKpTLQKb1UQ/i8OAu35VNYxxGYLi AV14bmmT60DKsT2NsxRBbiwBh6PdIuy9aI9b1bPyLnaxgzb/+r4grOkhhPwMtm+qz+e1 uPa931KUluxpKpOXwV5q43Z5KJ1nOTILAKeQNY/EMcEe8gpN6Te2XCCy04MfKSC0q3tj 1x5827e1WmiMhYfjNSu4J56loxgVR64tLnI5EH/0y5Ahs1Zy6tKxxwdjiawnxx0oQHi4 BOmNV/q3xxsxf7syrAztoK9/h0IX/Fi7oG9NDji08AIPjS7rzIqiT1U2voCfKi1Pbj1b 3Npg== X-Forwarded-Encrypted: i=1; AHgh+RoAp94IWuztWwUjbiJh6i7pbvt7aznCaGjwYYWnowsAYo17QbFgCv2KNEWA+agkJEfX7IiJCqtjU2OJx8dFlT8U@lists.infradead.org X-Gm-Message-State: AOJu0YzAPIjSFhqPN/yiOJD7jU0gM0ZzcmVrKmgxPw6sdETf1jvpDK9x HdFo78uoj5GKdsIvhjLzEL49CKXU5KV4LfeErZjSdOVWxRxL07nuV0Ha X-Gm-Gg: AR+sD12GVNMm7BqbJc8ZqqwcjYXkFXyHxRd5ltMiNYw5mW9JFgn1GWq2EGdGvYD5kX9 lGgdP+0Zcz+eK5WVrYZflG4miSkMHJe8MfpsBtrsMFN95u/VYeJiFscTUhuelr5PhgKIFzGi/47 7J7f+L/85Msqo4UK4UaYJnDB8asijdg5haFH6s3+QqpzqfpCEmWygP3MsPWI95m59x67RjG/gHi SqjZViQRMJCGh2EoWaAVUu8JqzrHquvs7Yh+uaBMAsLOuohHcQTpstC4UXz+OIgtK5MKyPb25zn fNLmihscAjqUTT/DeMhl6/jF46XWRjEY69X2uGklVsK96ujAJIgGj5NlUluqepslQG9cJ8olrby llSaz20lrBKqHys9VKlHqjU9k+iTz1h8P4aZCjaJD9017Cylvnkc2cGRpTX2vWhe/nTnGik28lW YMHSm6nVf4eYqujUKPhDHFZtattvisACS2AVJAIkUSJwOAGGTX6/kszkbwYyFI3iySBmn8XsKjV vZ9ZXN8c4NbFesx8GOlvlzBxEnSDtw= X-Received: by 2002:a17:90b:57cd:b0:38f:1a80:d1e7 with SMTP id 98e67ed59e1d1-38fbc437c4cmr9229318a91.13.1785766719653; Mon, 03 Aug 2026 07:18:39 -0700 (PDT) Received: from buffalo-ssd (M014013071096.v4.enabler.ne.jp. [14.13.71.96]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38fb30dff2esm4078462a91.13.2026.08.03.07.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 07:18:39 -0700 (PDT) From: Akari Tsuyukusa To: Michael Turquette , Stephen Boyd , Brian Masney , Matthias Brugger , AngeloGioacchino Del Regno , Yassine Oudjana , Richard Cochran Cc: Laura Nao , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Chen-Yu Tsai , Akari Tsuyukusa , Bartosz Golaszewski , Danilo Krummrich , Bjorn Helgaas , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= , Nicolas Frattaroli , Takashi Sakamoto , Haotian Zhang , Kees Cook , Miles Chen , Daniel Golle , Sam Shih , linux-clk@vger.kernel.org (open list:COMMON CLK FRAMEWORK), linux-kernel@vger.kernel.org (open list), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support), netdev@vger.kernel.org (open list:PTP HARDWARE CLOCK SUPPORT:Keyword:(?:\b|_)ptp(?:\b|_)), stable@vger.kernel.org Subject: [PATCH 16/32] clk: mediatek: mt6779: Switch to common probe/remove helpers Date: Mon, 3 Aug 2026 23:16:43 +0900 Message-ID: <20260803141659.559129-17-akkun11.open@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260803141659.559129-1-akkun11.open@gmail.com> References: <20260803141659.559129-1-akkun11.open@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260803_071840_399796_1B751538 X-CRM114-Status: GOOD ( 17.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The MT6779 main clock driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Additionally, merge the separate infracfg and other drivers into a single platform driver, and add support for the apmixed and topckgen clock controllers using the consolidated of_match_table. Finally, replace the custom arch_initcall() initialization loop with the module_platform_driver() macro. Signed-off-by: Akari Tsuyukusa --- drivers/clk/mediatek/clk-mt6779.c | 124 ++++++------------------------ 1 file changed, 22 insertions(+), 102 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt6779.c b/drivers/clk/mediatek/clk-mt6779.c index 4b9dcb910b03..a806789ae27c 100644 --- a/drivers/clk/mediatek/clk-mt6779.c +++ b/drivers/clk/mediatek/clk-mt6779.c @@ -808,7 +808,7 @@ static const char * const i2s5_m_ck_parents[] = { "aud_2_sel" }; -static const struct mtk_composite top_aud_muxes[] = { +static const struct mtk_composite top_aud_muxes_divs[] = { MUX(CLK_TOP_I2S0_M_SEL, "i2s0_m_ck_sel", i2s0_m_ck_parents, 0x320, 8, 1), MUX(CLK_TOP_I2S1_M_SEL, "i2s1_m_ck_sel", i2s1_m_ck_parents, @@ -821,9 +821,7 @@ static const struct mtk_composite top_aud_muxes[] = { 0x320, 12, 1), MUX(CLK_TOP_I2S5_M_SEL, "i2s5_m_ck_sel", i2s5_m_ck_parents, 0x328, 20, 1), -}; -static struct mtk_composite top_aud_divs[] = { DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "i2s0_m_ck_sel", 0x320, 2, 0x324, 8, 0), DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "i2s1_m_ck_sel", @@ -1211,125 +1209,47 @@ static const struct mtk_pll_data plls[] = { 0, 0, 32, 8, 0x02D4, 1, 0, 0x14, 1, 0x02D8, 0, 0x02D4), }; -static int clk_mt6779_apmixed_probe(struct platform_device *pdev) -{ - struct clk_hw_onecell_data *clk_data; - struct device_node *node = pdev->dev.of_node; - - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); - if (!clk_data) - return -ENOMEM; - - mtk_clk_register_plls(&pdev->dev, plls, ARRAY_SIZE(plls), clk_data); - - mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, - ARRAY_SIZE(apmixed_clks), clk_data); - - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); -} - -static int clk_mt6779_top_probe(struct platform_device *pdev) -{ - void __iomem *base; - struct clk_hw_onecell_data *clk_data; - struct device_node *node = pdev->dev.of_node; - - base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); - - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); - if (!clk_data) - return -ENOMEM; - - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), - clk_data); - - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); - - mtk_clk_register_muxes(&pdev->dev, top_muxes, - ARRAY_SIZE(top_muxes), node, - &mt6779_clk_lock, clk_data); - - mtk_clk_register_composites(&pdev->dev, top_aud_muxes, - ARRAY_SIZE(top_aud_muxes), base, - &mt6779_clk_lock, clk_data); - - mtk_clk_register_composites(&pdev->dev, top_aud_divs, - ARRAY_SIZE(top_aud_divs), base, - &mt6779_clk_lock, clk_data); - - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); -} - -static const struct of_device_id of_match_clk_mt6779[] = { - { - .compatible = "mediatek,mt6779-apmixed", - .data = clk_mt6779_apmixed_probe, - }, { - .compatible = "mediatek,mt6779-topckgen", - .data = clk_mt6779_top_probe, - }, { - /* sentinel */ - } +static const struct mtk_clk_desc apmixed_desc = { + .clks = apmixed_clks, + .num_clks = ARRAY_SIZE(apmixed_clks), + .plls = plls, + .num_plls = ARRAY_SIZE(plls), }; -static int clk_mt6779_probe(struct platform_device *pdev) -{ - int (*clk_probe)(struct platform_device *pdev); - int r; - - clk_probe = of_device_get_match_data(&pdev->dev); - if (!clk_probe) - return -EINVAL; - - r = clk_probe(pdev); - if (r) - dev_err(&pdev->dev, - "could not register clock provider: %s: %d\n", - pdev->name, r); - - return r; -} +static const struct mtk_clk_desc topck_desc = { + .fixed_clks = top_fixed_clks, + .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), + .factor_clks = top_divs, + .num_factor_clks = ARRAY_SIZE(top_divs), + .mux_clks = top_muxes, + .num_mux_clks = ARRAY_SIZE(top_muxes), + .composite_clks = top_aud_muxes_divs, + .num_composite_clks = ARRAY_SIZE(top_aud_muxes_divs), + .clk_lock = &mt6779_clk_lock, +}; static const struct mtk_clk_desc infra_desc = { .clks = infra_clks, .num_clks = ARRAY_SIZE(infra_clks), }; -static const struct of_device_id of_match_clk_mt6779_infra[] = { +static const struct of_device_id of_match_clk_mt6779[] = { + { .compatible = "mediatek,mt6779-apmixed", .data = &apmixed_desc }, + { .compatible = "mediatek,mt6779-topckgen", .data = &topck_desc }, { .compatible = "mediatek,mt6779-infracfg_ao", .data = &infra_desc }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, of_match_clk_mt6779); -static struct platform_driver clk_mt6779_infra_drv = { +static struct platform_driver clk_mt6779_drv = { .probe = mtk_clk_simple_probe, .remove = mtk_clk_simple_remove, - .driver = { - .name = "clk-mt6779-infra", - .of_match_table = of_match_clk_mt6779_infra, - }, -}; - -static struct platform_driver clk_mt6779_drv = { - .probe = clk_mt6779_probe, .driver = { .name = "clk-mt6779", .of_match_table = of_match_clk_mt6779, }, }; - -static int __init clk_mt6779_init(void) -{ - int ret = platform_driver_register(&clk_mt6779_drv); - - if (ret) - return ret; - return platform_driver_register(&clk_mt6779_infra_drv); -} - -arch_initcall(clk_mt6779_init); +module_platform_driver(clk_mt6779_drv); MODULE_DESCRIPTION("MediaTek MT6779 main clocks driver"); MODULE_LICENSE("GPL"); -- 2.55.0