From patchwork Mon Feb 6 15:28:47 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: 53350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2298690wrn; Mon, 6 Feb 2023 07:31:38 -0800 (PST) X-Google-Smtp-Source: AK7set+qAliTSryrIqbw+mfELfXK3B3AGAd4YiLmn0Eb1BiYOTrVejTqWQryNP/gOEBSclDZLrmk X-Received: by 2002:a05:6a20:8405:b0:bc:fb05:3c3f with SMTP id c5-20020a056a20840500b000bcfb053c3fmr26556964pzd.43.1675697497744; Mon, 06 Feb 2023 07:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675697497; cv=none; d=google.com; s=arc-20160816; b=ToWFOiZLcIF/QRUui3YBgH8Z9xtn8j1TekmthIoFiSJ4/I4Pun5b95FzeBxKmViQcS KGfkmD8cm53tTtOpFnjyTcGIgRyyDDd1eM7O2Ti4Hb+mtEW+bslpcKESEW+OAx6CVN1y sMFOSQH0pd9tltR0NZ8nIUd8HWMMJS5NG99esVPkCNyZYGLr3JdeHB/ZrlvR6sh0A4bN GaFDVsDa8y/2Sp9Tfrf9szUg8Au8YfdtJ0LkFSxRzPpmq2L7mCLRKniDm8An6QHKSxL1 H+0Vrfc0klDRmzF7z9GKPxS+EaJRHQtdalxZRdZOIS4P1VdP3uEZUcqqfqjkK5uDIAU3 h3nQ== 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=cLm8/4kt0g3mdIhaMRmDWeK/3S0jl3hpdGtxdh4EtII=; b=IOXfgJG4u9WRVVc/FyJGRLPTCBdswXVOPXTqtyX0xppMT5imrjqEoRi1ftw1KK94mD uEAxicCjUVlG0GC4KUVZKJajP3iYkrzhmSn0cZEMSeq1obdYG4aUgsUCeVZd2KT57BDD zCetu7XPLbysotZnaehQiCfTRF3nC2S3CJUKaej6ofxkT2Xe6e4fNB5M4tHm8u9+Whpw jlgIrDqMoqGAb3wt3kKcf4Rjkt3NdqDFiNyqII7c+zOSAP5KrwpaPKh65+nEdzdM1bI7 JbrVjarsEifOfxwupZADXvGmbpk4DyGMdSu/+RJERk1f2Yp6ZrucDXTZpcIPJNJjHHK3 cv1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TGRDyum1; 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 f18-20020a637552000000b004785d1e2b7bsi12829979pgn.514.2023.02.06.07.31.24; Mon, 06 Feb 2023 07:31:37 -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=TGRDyum1; 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 S231207AbjBFPaM (ORCPT + 99 others); Mon, 6 Feb 2023 10:30:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbjBFP3y (ORCPT ); Mon, 6 Feb 2023 10:29:54 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F0BADBFA; Mon, 6 Feb 2023 07:29:53 -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 E14486602F95; Mon, 6 Feb 2023 15:29:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675697392; bh=VUavP0qYk/wKIn4zeMlnEGssDqB/rSJrf27scQBcgnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TGRDyum1g6ftrAjjkSy3xWe/f1YxeCUQlpp7jDY4FUTLP4RaF/SBSj+1p6OXysXPN tRqalaAJoGBlfmH0tCmUTwM/UPK9R2qF98vKy79miQ45v0dJT0PlWNlDZentdBxmpk RYdp16XcjhzcZKuGl9WHcW8GcQH7nbDz+sud0IrKCoirY79N9MAmlsPqdtyJ8XeTKH b9s537IeHNLp8SdTmd5gKI2sH5d5iCkTyULQCxaN6oetuQ9MtC2smo5/I0+Ywd/jTv gA8QcUVBqc40hOMMxFV03UoqZ7NPPE8Ec+94IrkqYdBGjdKKB+Pay7ab9ltLZ/srTo 8QLjVgw6rmwAg== 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 v1 04/45] clk: mediatek: Add divider clocks to mtk_clk_simple_{probe,remove}() Date: Mon, 6 Feb 2023 16:28:47 +0100 Message-Id: <20230206152928.918562-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206152928.918562-1-angelogioacchino.delregno@collabora.com> References: <20230206152928.918562-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?1757096179502670036?= X-GMAIL-MSGID: =?utf-8?q?1757096179502670036?= 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 --- 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 a69d3f0a38c7..39bd360aa0c9 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;