From patchwork Mon Mar 6 14:04:53 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: 64681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1866379wrd; Mon, 6 Mar 2023 06:18:22 -0800 (PST) X-Google-Smtp-Source: AK7set+BqRASdBxyalORnagoQEeU54VmAMPEdwcawJjBcoxtQiD6AoJPlA6FOe5FW71Z5204iJFK X-Received: by 2002:a05:6a21:78a1:b0:cc:2ed0:e1e5 with SMTP id bf33-20020a056a2178a100b000cc2ed0e1e5mr17031154pzc.13.1678112302560; Mon, 06 Mar 2023 06:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678112302; cv=none; d=google.com; s=arc-20160816; b=EtH0FtgpnUabZO3OLUdERz+h1dQs0fUn/st+X2IPJ6MwQVn5F64hxpg7LeEQqFilWY qec8dSPSM4BmGMStSI50xl4n0BPRrfmnevNf6wM0SvAkW1qUu1IvkuJScDWDf3BP4GZe 8Igco1MRWqwXhyVnBxE16JDJUJv2GClKK4qgWSEG4LGPjkMA5AMgc6SqTmGSfjBZzro0 MoXoz0XE6m/15WKKmR80Mi67mX41Bs8EfR4T6jysdhqtoOolt0yzQ9wdiXHUpkTQJ2fp oGRGzWVFez74jWIvgWfB2yGrqsTE6qXempHNKVwsEin6EP+R3zQoLsPTrqjggJjYApY7 12eQ== 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=NaUOyyuWw6OAxCWcMLq2vhLC0wwPgkHM5n0VdLB0UpQ=; b=dViXKo0BIFb/I4U2FiPKWk+/2t0UykrXrzCWqdRtjrzfFUgCcM833NGoqsvvlTWAAN +vNG73gCxDiAPZ4KhEwo+ZDi9o8TU+191kctKtBYBp9zDORpE7KIEIOdIIaCOCC3x3Nv n33FN3ZrzfwoHHK19tB5nIoZzQAR5rnYT30eR3+fWJPqcNsQHOlwKEPNz+hgNp0bDZ6T 26XYDB/CFoLoDym2yFFFjPuvUiFb2E7AxoJJ9iWBnS0SqVNVG6mC6Z2SXgjg/WOq8sCj j2JWWn19N4XbzlnjZ+YXpfDbk67lxWmVnESh/uGHs1g1diOLkXYNls4mzOBETFDQnFzE 1lbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CLDbFnLR; 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 w8-20020a63f508000000b004e8529ae3eesi9380270pgh.294.2023.03.06.06.18.08; Mon, 06 Mar 2023 06:18:22 -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=CLDbFnLR; 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 S230317AbjCFOGb (ORCPT + 99 others); Mon, 6 Mar 2023 09:06:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjCFOGW (ORCPT ); Mon, 6 Mar 2023 09:06:22 -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 4A8A526CCB; Mon, 6 Mar 2023 06:05:56 -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 A0A3E6602EDC; Mon, 6 Mar 2023 14:05:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678111555; bh=2q4R6Jj0wfJKPJ+fgyMaXPc0tFWxhnOsQQvuKEQkDuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLDbFnLRkqvbVWBn1v0fho/bVdFtDS0n8WxwkpjwFGxWjzFd2SLOed0sYJRQ3w6T1 ztQifom4AkCY2d7+JtJyCdhNHT+SRAtsCXoGZxZVQln9xrUtYQPlrBStE2XYHIwsdp KUr+8NjeGIcncOOTQmWnZaaNx/aCTYhcRLaTUFCyKnEQjJWYQ0zKtNNBNuWMT/kGEj W+oqjla3FBKObdXao7aVUJQMw7R4oFsfavR98WMpNCjue/2OVtlGoNzkECXG49O3JB iXePud7iXqkKD8jvAm1NIQQzmfOhikIkZ0WtgexM/pR4USbvBYl28QSfiNL1CCsdUT tOHbKfbaxFi5Q== 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 04/54] clk: mediatek: Add divider clocks to mtk_clk_simple_{probe,remove}() Date: Mon, 6 Mar 2023 15:04:53 +0100 Message-Id: <20230306140543.1813621-5-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?1759628285550365063?= X-GMAIL-MSGID: =?utf-8?q?1759628285550365063?= Add support for divider clocks register/unregister in the common mtk_clk_simple_probe() and mtk_clk_simple_remove() functions. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai Tested-by: Miles Chen Tested-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 19 +++++++++++++++++-- drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 990be3d62db2..01224cfbcc79 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -496,7 +496,7 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev, /* Calculate how many clk_hw_onecell_data entries to allocate */ num_clks = mcd->num_clks + mcd->num_composite_clks; num_clks += mcd->num_fixed_clks + mcd->num_factor_clks; - num_clks += mcd->num_mux_clks; + num_clks += mcd->num_mux_clks + mcd->num_divider_clks; clk_data = mtk_alloc_clk_data(num_clks); if (!clk_data) @@ -534,11 +534,19 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev, goto unregister_muxes; } + if (mcd->divider_clks) { + r = mtk_clk_register_dividers(mcd->divider_clks, + mcd->num_divider_clks, + base, mcd->clk_lock, clk_data); + if (r) + goto unregister_composites; + } + if (mcd->clks) { r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks, mcd->num_clks, clk_data); if (r) - goto unregister_composites; + goto unregister_dividers; } if (mcd->clk_notifier_func) { @@ -567,6 +575,10 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev, unregister_clks: if (mcd->clks) mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); +unregister_dividers: + if (mcd->divider_clks) + mtk_clk_unregister_dividers(mcd->divider_clks, + mcd->num_divider_clks, clk_data); unregister_composites: if (mcd->composite_clks) mtk_clk_unregister_composites(mcd->composite_clks, @@ -599,6 +611,9 @@ static int __mtk_clk_simple_remove(struct platform_device *pdev, of_clk_del_provider(node); if (mcd->clks) mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); + if (mcd->divider_clks) + mtk_clk_unregister_dividers(mcd->divider_clks, + mcd->num_divider_clks, clk_data); if (mcd->composite_clks) mtk_clk_unregister_composites(mcd->composite_clks, mcd->num_composite_clks, clk_data); diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index b8e0ff8f52fa..554aecdc1015 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -222,6 +222,8 @@ struct mtk_clk_desc { size_t num_clks; const struct mtk_composite *composite_clks; size_t num_composite_clks; + const struct mtk_clk_divider *divider_clks; + size_t num_divider_clks; const struct mtk_fixed_clk *fixed_clks; size_t num_fixed_clks; const struct mtk_fixed_factor *factor_clks;