From patchwork Fri Jan 20 09:20:49 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: 46251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp98295wrn; Fri, 20 Jan 2023 01:24:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXtIBZLbLQ5156gP80ma2CQJPgHWmWyOM6+vkGOIXH5Xpm/d10ea30acbRr5cHODRxFV7PIM X-Received: by 2002:a17:906:f49:b0:864:8c78:e7ff with SMTP id h9-20020a1709060f4900b008648c78e7ffmr10102168ejj.23.1674206660973; Fri, 20 Jan 2023 01:24:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674206660; cv=none; d=google.com; s=arc-20160816; b=K7FfjUz09J/MXz7Vjdkjbd0B/9h6/oD+dV9kyq8GqDfh25a5B6SDgjXA08hk19Hreb N04hEXI3OnK+dXtnCzIVETKWa7eIKwy3M9oA95cF5JSp6CZtH1TcKqvUn4sXUCalX0Vb 9I9RKYWtU62l1Nah1j2A2s8W3SczyWP7PNL11DqvfWno4vY3rikKgd00bSPT1jl91ZEH y+dFUZqTE2By3FRbPz+0MmLZvTfVv3iQzxtC5TFGyKYZCuu1Cqulyk0BO/M2DBdtlhDb TvPXD6kMc/1aUekP7athvEJIvN7SSbhg6OBTKKlQ0kD4q5WUs/1CvdhpoC9oftkTO011 f+GA== 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=n5QstG+e/RJC3BZTflTjLQ3D6yBy6EGIQXVUxUm4iX4=; b=rJZENH7PzzXtx+NMRbmgPkFPiHcCRIP/YAsslC4tWR1mP1V2MJusWgKeMrH7luWjL9 1jCF0c4wTaBSInO9OUdwq96ZUjd0nFeqY6vUDoPOt3J5bniBoI5V+uFIyRpMmVtOpltb HzekMJF+b7pFY06+wKeN6tF9okshhVLSC9O9tES/8Xy1Id4AZzLZCWEsm9KvXFjrgflh mgXYHBKXdlTTea+EQDBNYak1M37DUtbK4T/kHETNC1GIuG9hGjI8/IhOTfAZYAhmM7Da r1uCL5nbXH7qEBETUcCGnBO1HEgHUeMX8iW30G80HDgBoLBY2vexvFDRxHIxgwgVgjLe Ti7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Rz5/ikVQ"; 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=NONE sp=NONE 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 js8-20020a17090797c800b00877a7bcc8d7si166486ejc.468.2023.01.20.01.23.57; Fri, 20 Jan 2023 01:24:20 -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="Rz5/ikVQ"; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjATJXP (ORCPT + 99 others); Fri, 20 Jan 2023 04:23:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbjATJWj (ORCPT ); Fri, 20 Jan 2023 04:22:39 -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 388149EE11; Fri, 20 Jan 2023 01:21:47 -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 E696A6602DE9; Fri, 20 Jan 2023 09:21:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1674206491; bh=IVNkSTL1Ac045C8DuqPAkVteL1MrOc/053CjcEkcRrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rz5/ikVQnL5QbH1r0zchI4XE43l6EhtMlMG8k4lihf0zT6jIQ8n/Yb7VpNktwMA7N e8aCC8TCV82D3eBU0NpVQTdK0uwWAJpL2wNGzTt1RI+O97TS8qtJotSvBIZlllooOk l4zjH4mY9Z3j97e2+jE9o/M4xa29Ca8hfL6kWOKA2sL8hG12pGjhiTZPO7/GtxzVWX +eksj7h4Rdd1R8oEUspIzfceHff+HPW7BFYEhUBtsOwSKzsd1hGkxztJdFPdQ/Q/z1 /qmAZy2wOyW/wfeQPJ1ADlJbTyPDmTjLopkpZgDf0F4g1NeS8RGqL0GAjvHH9fOIgt UsgXZOW9l9ygw== From: AngeloGioacchino Del Regno To: mturquette@baylibre.com Cc: sboyd@kernel.org, matthias.bgg@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, angelogioacchino.delregno@collabora.com, wenst@chromium.org, johnson.wang@mediatek.com, miles.chen@mediatek.com, fparent@baylibre.com, chun-jie.chen@mediatek.com, sam.shih@mediatek.com, y.oudjana@protonmail.com, nfraprado@collabora.com, rex-bc.chen@mediatek.com, ryder.lee@kernel.org, daniel@makrotopia.org, jose.exposito89@gmail.com, yangyingliang@huawei.com, pablo.sun@mediatek.com, msp@baylibre.com, weiyi.lu@mediatek.com, ikjn@chromium.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, kernel@collabora.com Subject: [PATCH v4 19/23] clk: mediatek: clk-mt8192: Migrate topckgen to mtk_clk_simple_probe() Date: Fri, 20 Jan 2023 10:20:49 +0100 Message-Id: <20230120092053.182923-20-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120092053.182923-1-angelogioacchino.delregno@collabora.com> References: <20230120092053.182923-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?1755532923537838489?= X-GMAIL-MSGID: =?utf-8?q?1755532923537838489?= Since the common simple probe function for MediaTek clock drivers can now register the MFG MUX notifier, it's possible to migrate MT8192's topckgen to that, allowing for some code size reduction. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai Tested-by: Miles Chen --- drivers/clk/mediatek/clk-mt8192.c | 85 +++++++------------------------ 1 file changed, 17 insertions(+), 68 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-mt8192.c index 1ffff53bbe90..61299960d28a 100644 --- a/drivers/clk/mediatek/clk-mt8192.c +++ b/drivers/clk/mediatek/clk-mt8192.c @@ -1064,71 +1064,6 @@ static int clk_mt8192_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb); } -static int clk_mt8192_top_probe(struct platform_device *pdev) -{ - struct device_node *node = pdev->dev.of_node; - struct clk_hw_onecell_data *top_clk_data; - int r; - void __iomem *base; - - base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); - - top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); - if (!top_clk_data) - return -ENOMEM; - - r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); - if (r) - return r; - - r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); - if (r) - goto unregister_fixed_clks; - - r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes, - ARRAY_SIZE(top_mtk_muxes), node, - &mt8192_clk_lock, top_clk_data); - if (r) - goto unregister_factors; - - r = mtk_clk_register_composites(&pdev->dev, top_muxes, - ARRAY_SIZE(top_muxes), base, - &mt8192_clk_lock, top_clk_data); - if (r) - goto unregister_muxes; - - r = mtk_clk_register_gates(&pdev->dev, node, top_clks, - ARRAY_SIZE(top_clks), top_clk_data); - if (r) - goto unregister_top_composites; - - r = clk_mt8192_reg_mfg_mux_notifier(&pdev->dev, - top_clk_data->hws[CLK_TOP_MFG_PLL_SEL]->clk); - if (r) - goto unregister_gates; - - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data); - if (r) - goto unregister_gates; - - return 0; - -unregister_gates: - mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); -unregister_top_composites: - mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_data); -unregister_muxes: - mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); -unregister_factors: - mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); -unregister_fixed_clks: - mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), - top_clk_data); - return r; -} - static int clk_mt8192_apmixed_probe(struct platform_device *pdev) { struct clk_hw_onecell_data *clk_data; @@ -1162,9 +1097,6 @@ static const struct of_device_id of_match_clk_mt8192[] = { { .compatible = "mediatek,mt8192-apmixedsys", .data = clk_mt8192_apmixed_probe, - }, { - .compatible = "mediatek,mt8192-topckgen", - .data = clk_mt8192_top_probe, }, { /* sentinel */ } @@ -1197,9 +1129,26 @@ static const struct mtk_clk_desc peri_desc = { .num_clks = ARRAY_SIZE(peri_clks), }; +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_mtk_muxes, + .num_mux_clks = ARRAY_SIZE(top_mtk_muxes), + .composite_clks = top_muxes, + .num_composite_clks = ARRAY_SIZE(top_muxes), + .clks = top_clks, + .num_clks = ARRAY_SIZE(top_clks), + .clk_lock = &mt8192_clk_lock, + .clk_notifier_func = clk_mt8192_reg_mfg_mux_notifier, + .mfg_clk_idx = CLK_TOP_MFG_PLL_SEL, +}; + static const struct of_device_id of_match_clk_mt8192_simple[] = { { .compatible = "mediatek,mt8192-infracfg", .data = &infra_desc }, { .compatible = "mediatek,mt8192-pericfg", .data = &peri_desc }, + { .compatible = "mediatek,mt8192-topckgen", .data = &topck_desc }, { /* sentinel */ } };