Message ID | 20230206100105.861720-8-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2150558wrn; Mon, 6 Feb 2023 02:09:54 -0800 (PST) X-Google-Smtp-Source: AK7set96J3D47SFElaSLJp1EUDnKlD9nV0nhhYshQX+QE1Vm0+vZlat+KBmgi0uvfQbgiuuf77Vi X-Received: by 2002:a50:f61a:0:b0:4aa:bb78:eeb5 with SMTP id c26-20020a50f61a000000b004aabb78eeb5mr1019547edn.15.1675678194392; Mon, 06 Feb 2023 02:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675678194; cv=none; d=google.com; s=arc-20160816; b=FIHKCWNw9+M/rUGzwiOdF4aS4pWAMpqHaTjvWm06qf6ZFakd0mLAiqrYMCIsjNOKE4 iTZFjEeKb+A2fziVGS7UI0jtRKTYlu+y8IgQSGk/hCCgDEfXOLgv61UaTLlXno/NjDhu Gu+cJ6J5wlhnRuYQN5APQxmcLgP9uOscp7hB8qkHUyyxoBaXRjSHk0N5rnb3fy5YL+3s WYgWUsbubG113CcGh5/TtB1V2Gr+3jhLNrwjT0dlN6fNLZKi+raoehhfX6HMsDvIcfDS nqbyNe3hiWasbFPwJm1AA9drYEdNgSHBz6mVS8zX7AHntpycpMXJ0DhGUZBp7lx3uPj6 nXIQ== 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=5xmVcO8j08igjTF0qT6XaCB3XcCA1MOZf1Rq2MH05Yg=; b=tDWmIrgSBzsz9OPzIUocMObjiFGuesY7fCeMMzZlRXiLSu3fRGuO0rJz57y61btoZU 1UtylFmV3BEPfKNHsXRRCPKAQtiB98v5Eyzi+UhIE2rXfuX6rILqHV9SjYsBKqoorFLh BP+/KysICSO5XpkdkSa3R2pWD1cC1Jx0+M7FJYyhnfmi2gLE4IEncwrZ6mZ9pehBu6kX 619ZI8W+zP0AZVt9xlcDCF4khe7qO4UNAvlsW10sIOPgZZ+7WRFXvg9xguF64oBln1/n sPb6JQUaO68J/YAkBEx9M68bWlnMEUwNf8N36Zy7DeewvYd1XVqaO1vNEWv1016bE2nZ Unxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PS6kLO5B; 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 t7-20020a056402240700b004a2687900absi13930971eda.351.2023.02.06.02.09.30; Mon, 06 Feb 2023 02:09:54 -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=PS6kLO5B; 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 S230052AbjBFKC2 (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Mon, 6 Feb 2023 05:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjBFKBZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Feb 2023 05:01:25 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DEE1353F; Mon, 6 Feb 2023 02:01:23 -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 D4967660302F; Mon, 6 Feb 2023 10:01:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1675677682; bh=Obi+vQT5xnaobAxtXIDP6ufWD0ahrxBt2y0sg2Yn4lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PS6kLO5BoOHCEh7QCx7k5NBBfdXTqFo0TCWhCsb19kjBClbMiS2KQYSeigzDbmqGR UT4yCtLQnDY32M64hpAP3otBPkJd2X5HHQzUeS4fkctwppbm2rBmGYGDkR9g82rcS5 SLgYXwC3fa8zNc/19L+ELDqwVNaGk6Az9NFc9rLvdRW6eQUDZjnftwCzAFA9NLW2qz Yxn8Xvw0dMff2E9MdLN2uaYZZZrGMiD82SHkFca+sruLMC2/ceQdUqrYlwGQzwU6xa 1XXt2TXVR8mtZN6CbcQhC1aNHMpDYTY6cPsKInPvft4iJFQ6oVMmRFBFNIO8MsqbEs kF37EFB3kzwfQ== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: sboyd@kernel.org Cc: mturquette@baylibre.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, edward-jw.yang@mediatek.com, johnson.wang@mediatek.com, wenst@chromium.org, miles.chen@mediatek.com, chun-jie.chen@mediatek.com, rex-bc.chen@mediatek.com, jose.exposito89@gmail.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v3 7/7] clk: mediatek: mt8195: Add support for frequency hopping through FHCTL Date: Mon, 6 Feb 2023 11:01:05 +0100 Message-Id: <20230206100105.861720-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206100105.861720-1-angelogioacchino.delregno@collabora.com> References: <20230206100105.861720-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757075938597780476?= X-GMAIL-MSGID: =?utf-8?q?1757075938597780476?= |
Series |
MediaTek Frequency Hopping: MT6795/8173/92/95
|
|
Commit Message
AngeloGioacchino Del Regno
Feb. 6, 2023, 10:01 a.m. UTC
Add FHCTL parameters and register PLLs through FHCTL to add support
for frequency hopping and SSC. FHCTL will be enabled only on PLLs
specified in devicetree.
This commit brings functional changes only upon addition of
devicetree configuration.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 69 +++++++++++++++++++-
1 file changed, 66 insertions(+), 3 deletions(-)
Comments
On Mon, Feb 6, 2023 at 6:01 PM AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: > > Add FHCTL parameters and register PLLs through FHCTL to add support > for frequency hopping and SSC. FHCTL will be enabled only on PLLs > specified in devicetree. > > This commit brings functional changes only upon addition of > devicetree configuration. > > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > --- > drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 69 +++++++++++++++++++- > 1 file changed, 66 insertions(+), 3 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > index 1bc917f2667e..c0db31ce0741 100644 > --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > @@ -3,9 +3,11 @@ > // Copyright (c) 2021 MediaTek Inc. > // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> > > +#include "clk-fhctl.h" > #include "clk-gate.h" > #include "clk-mtk.h" > #include "clk-pll.h" > +#include "clk-pllfh.h" > > #include <dt-bindings/clock/mt8195-clk.h> > #include <linux/of_device.h> > @@ -105,6 +107,61 @@ static const struct mtk_pll_data plls[] = { > 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), > }; > > +enum fh_pll_id { > + FH_ARMPLL_LL, > + FH_ARMPLL_BL, > + FH_MEMPLL, > + FH_ADSPPLL, > + FH_NNAPLL, > + FH_CCIPLL, > + FH_MFGPLL, > + FH_TVDPLL2, > + FH_MPLL, > + FH_MMPLL, > + FH_MAINPLL, > + FH_MSDCPLL, > + FH_IMGPLL, > + FH_VDECPLL, > + FH_TVDPLL1, > + FH_NR_FH, > +}; > + > +#define FH(_pllid, _fhid, _offset) { \ > + .data = { \ > + .pll_id = _pllid, \ > + .fh_id = _fhid, \ > + .fh_ver = FHCTL_PLLFH_V2, \ > + .fhx_offset = _offset, \ > + .dds_mask = GENMASK(21, 0), \ > + .slope0_value = 0x6003c97, \ > + .slope1_value = 0x6003c97, \ Are these > + .sfstrx_en = BIT(2), \ > + .frddsx_en = BIT(1), \ > + .fhctlx_en = BIT(0), \ > + .tgl_org = BIT(31), \ > + .dvfs_tri = BIT(31), \ > + .pcwchg = BIT(31), \ > + .dt_val = 0x0, \ > + .df_val = 0x9, \ and these just copied from MT8186? > + .updnlmt_shft = 16, \ > + .msk_frddsx_dys = GENMASK(23, 20), \ > + .msk_frddsx_dts = GENMASK(19, 16), \ > + }, \ > + } > + > +static struct mtk_pllfh_data pllfhs[] = { > + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), > + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), > + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), > + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), > + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), > + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), > + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), > + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), > + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), > + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), > +}; > + > static const struct of_device_id of_match_clk_mt8195_apmixed[] = { > { .compatible = "mediatek,mt8195-apmixedsys", }, > {} > @@ -114,13 +171,17 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) > { > struct clk_hw_onecell_data *clk_data; > struct device_node *node = pdev->dev.of_node; > + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; > int r; > > clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); > if (!clk_data) > return -ENOMEM; > > - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); > + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); > + > + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), > + pllfhs, ARRAY_SIZE(pllfhs), clk_data); > if (r) > goto free_apmixed_data; > > @@ -140,7 +201,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) > unregister_gates: > mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); > unregister_plls: > - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); > + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, > + ARRAY_SIZE(pllfhs), clk_data); Nit: I think this could be squeezed into one line. > free_apmixed_data: > mtk_free_clk_data(clk_data); > return r; > @@ -153,7 +215,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev) > > of_clk_del_provider(node); > mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); > - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); > + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, > + ARRAY_SIZE(pllfhs), clk_data); Same here. ChenYu > mtk_free_clk_data(clk_data); > > return 0; > -- > 2.39.1 >
Il 07/03/23 05:43, Chen-Yu Tsai ha scritto: > On Mon, Feb 6, 2023 at 6:01 PM AngeloGioacchino Del Regno > <angelogioacchino.delregno@collabora.com> wrote: >> >> Add FHCTL parameters and register PLLs through FHCTL to add support >> for frequency hopping and SSC. FHCTL will be enabled only on PLLs >> specified in devicetree. >> >> This commit brings functional changes only upon addition of >> devicetree configuration. >> >> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> >> --- >> drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 69 +++++++++++++++++++- >> 1 file changed, 66 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >> index 1bc917f2667e..c0db31ce0741 100644 >> --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >> +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >> @@ -3,9 +3,11 @@ >> // Copyright (c) 2021 MediaTek Inc. >> // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> >> >> +#include "clk-fhctl.h" >> #include "clk-gate.h" >> #include "clk-mtk.h" >> #include "clk-pll.h" >> +#include "clk-pllfh.h" >> >> #include <dt-bindings/clock/mt8195-clk.h> >> #include <linux/of_device.h> >> @@ -105,6 +107,61 @@ static const struct mtk_pll_data plls[] = { >> 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), >> }; >> >> +enum fh_pll_id { >> + FH_ARMPLL_LL, >> + FH_ARMPLL_BL, >> + FH_MEMPLL, >> + FH_ADSPPLL, >> + FH_NNAPLL, >> + FH_CCIPLL, >> + FH_MFGPLL, >> + FH_TVDPLL2, >> + FH_MPLL, >> + FH_MMPLL, >> + FH_MAINPLL, >> + FH_MSDCPLL, >> + FH_IMGPLL, >> + FH_VDECPLL, >> + FH_TVDPLL1, >> + FH_NR_FH, >> +}; >> + >> +#define FH(_pllid, _fhid, _offset) { \ >> + .data = { \ >> + .pll_id = _pllid, \ >> + .fh_id = _fhid, \ >> + .fh_ver = FHCTL_PLLFH_V2, \ >> + .fhx_offset = _offset, \ >> + .dds_mask = GENMASK(21, 0), \ > >> + .slope0_value = 0x6003c97, \ >> + .slope1_value = 0x6003c97, \ > > Are these > >> + .sfstrx_en = BIT(2), \ >> + .frddsx_en = BIT(1), \ >> + .fhctlx_en = BIT(0), \ >> + .tgl_org = BIT(31), \ >> + .dvfs_tri = BIT(31), \ >> + .pcwchg = BIT(31), \ > >> + .dt_val = 0x0, \ >> + .df_val = 0x9, \ > > and these just copied from MT8186? Yes, and that's because they're really the same. > >> + .updnlmt_shft = 16, \ >> + .msk_frddsx_dys = GENMASK(23, 20), \ >> + .msk_frddsx_dts = GENMASK(19, 16), \ >> + }, \ >> + } >> + >> +static struct mtk_pllfh_data pllfhs[] = { >> + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), >> + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), >> + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), >> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), >> + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), >> + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), >> + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), >> + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), >> + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), >> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), >> +}; >> + >> static const struct of_device_id of_match_clk_mt8195_apmixed[] = { >> { .compatible = "mediatek,mt8195-apmixedsys", }, >> {} >> @@ -114,13 +171,17 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) >> { >> struct clk_hw_onecell_data *clk_data; >> struct device_node *node = pdev->dev.of_node; >> + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; >> int r; >> >> clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); >> if (!clk_data) >> return -ENOMEM; >> >> - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); >> + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); >> + >> + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), >> + pllfhs, ARRAY_SIZE(pllfhs), clk_data); >> if (r) >> goto free_apmixed_data; >> >> @@ -140,7 +201,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) >> unregister_gates: >> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); >> unregister_plls: >> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); >> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, >> + ARRAY_SIZE(pllfhs), clk_data); > > Nit: I think this could be squeezed into one line. > >> free_apmixed_data: >> mtk_free_clk_data(clk_data); >> return r; >> @@ -153,7 +215,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev) >> >> of_clk_del_provider(node); >> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); >> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); >> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, >> + ARRAY_SIZE(pllfhs), clk_data); > > Same here. > That's the same on the others as well, but if I compress those lines I will have to rebase the clocks cleanup series again and send the 54 patches again.. I'd like to avoid that noise. If you really want though, I can do that... what should I do? Regards, Angelo
On Tue, Mar 7, 2023 at 5:27 PM AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: > > Il 07/03/23 05:43, Chen-Yu Tsai ha scritto: > > On Mon, Feb 6, 2023 at 6:01 PM AngeloGioacchino Del Regno > > <angelogioacchino.delregno@collabora.com> wrote: > >> > >> Add FHCTL parameters and register PLLs through FHCTL to add support > >> for frequency hopping and SSC. FHCTL will be enabled only on PLLs > >> specified in devicetree. > >> > >> This commit brings functional changes only upon addition of > >> devicetree configuration. > >> > >> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > >> --- > >> drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 69 +++++++++++++++++++- > >> 1 file changed, 66 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > >> index 1bc917f2667e..c0db31ce0741 100644 > >> --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > >> +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c > >> @@ -3,9 +3,11 @@ > >> // Copyright (c) 2021 MediaTek Inc. > >> // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> > >> > >> +#include "clk-fhctl.h" > >> #include "clk-gate.h" > >> #include "clk-mtk.h" > >> #include "clk-pll.h" > >> +#include "clk-pllfh.h" > >> > >> #include <dt-bindings/clock/mt8195-clk.h> > >> #include <linux/of_device.h> > >> @@ -105,6 +107,61 @@ static const struct mtk_pll_data plls[] = { > >> 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), > >> }; > >> > >> +enum fh_pll_id { > >> + FH_ARMPLL_LL, > >> + FH_ARMPLL_BL, > >> + FH_MEMPLL, > >> + FH_ADSPPLL, > >> + FH_NNAPLL, > >> + FH_CCIPLL, > >> + FH_MFGPLL, > >> + FH_TVDPLL2, > >> + FH_MPLL, > >> + FH_MMPLL, > >> + FH_MAINPLL, > >> + FH_MSDCPLL, > >> + FH_IMGPLL, > >> + FH_VDECPLL, > >> + FH_TVDPLL1, > >> + FH_NR_FH, > >> +}; > >> + > >> +#define FH(_pllid, _fhid, _offset) { \ > >> + .data = { \ > >> + .pll_id = _pllid, \ > >> + .fh_id = _fhid, \ > >> + .fh_ver = FHCTL_PLLFH_V2, \ > >> + .fhx_offset = _offset, \ > >> + .dds_mask = GENMASK(21, 0), \ > > > >> + .slope0_value = 0x6003c97, \ > >> + .slope1_value = 0x6003c97, \ > > > > Are these > > > >> + .sfstrx_en = BIT(2), \ > >> + .frddsx_en = BIT(1), \ > >> + .fhctlx_en = BIT(0), \ > >> + .tgl_org = BIT(31), \ > >> + .dvfs_tri = BIT(31), \ > >> + .pcwchg = BIT(31), \ > > > >> + .dt_val = 0x0, \ > >> + .df_val = 0x9, \ > > > > and these just copied from MT8186? > > Yes, and that's because they're really the same. Just to be safe, I asked MediaTek to take a look at the parameters. > > > >> + .updnlmt_shft = 16, \ > >> + .msk_frddsx_dys = GENMASK(23, 20), \ > >> + .msk_frddsx_dts = GENMASK(19, 16), \ > >> + }, \ > >> + } > >> + > >> +static struct mtk_pllfh_data pllfhs[] = { > >> + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), > >> + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), > >> + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), > >> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), > >> + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), > >> + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), > >> + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), > >> + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), > >> + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), > >> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), > >> +}; > >> + > >> static const struct of_device_id of_match_clk_mt8195_apmixed[] = { > >> { .compatible = "mediatek,mt8195-apmixedsys", }, > >> {} > >> @@ -114,13 +171,17 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) > >> { > >> struct clk_hw_onecell_data *clk_data; > >> struct device_node *node = pdev->dev.of_node; > >> + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; > >> int r; > >> > >> clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); > >> if (!clk_data) > >> return -ENOMEM; > >> > >> - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); > >> + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); > >> + > >> + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), > >> + pllfhs, ARRAY_SIZE(pllfhs), clk_data); > >> if (r) > >> goto free_apmixed_data; > >> > >> @@ -140,7 +201,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) > >> unregister_gates: > >> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); > >> unregister_plls: > >> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); > >> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, > >> + ARRAY_SIZE(pllfhs), clk_data); > > > > Nit: I think this could be squeezed into one line. > > > >> free_apmixed_data: > >> mtk_free_clk_data(clk_data); > >> return r; > >> @@ -153,7 +215,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev) > >> > >> of_clk_del_provider(node); > >> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); > >> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); > >> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, > >> + ARRAY_SIZE(pllfhs), clk_data); > > > > Same here. > > > > That's the same on the others as well, but if I compress those lines I will have > to rebase the clocks cleanup series again and send the 54 patches again.. I'd like > to avoid that noise. > > If you really want though, I can do that... what should I do? I see. Let's keep it the way it is then.
Il 07/03/23 10:29, Chen-Yu Tsai ha scritto: > On Tue, Mar 7, 2023 at 5:27 PM AngeloGioacchino Del Regno > <angelogioacchino.delregno@collabora.com> wrote: >> >> Il 07/03/23 05:43, Chen-Yu Tsai ha scritto: >>> On Mon, Feb 6, 2023 at 6:01 PM AngeloGioacchino Del Regno >>> <angelogioacchino.delregno@collabora.com> wrote: >>>> >>>> Add FHCTL parameters and register PLLs through FHCTL to add support >>>> for frequency hopping and SSC. FHCTL will be enabled only on PLLs >>>> specified in devicetree. >>>> >>>> This commit brings functional changes only upon addition of >>>> devicetree configuration. >>>> >>>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> >>>> --- >>>> drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 69 +++++++++++++++++++- >>>> 1 file changed, 66 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >>>> index 1bc917f2667e..c0db31ce0741 100644 >>>> --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >>>> +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c >>>> @@ -3,9 +3,11 @@ >>>> // Copyright (c) 2021 MediaTek Inc. >>>> // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> >>>> >>>> +#include "clk-fhctl.h" >>>> #include "clk-gate.h" >>>> #include "clk-mtk.h" >>>> #include "clk-pll.h" >>>> +#include "clk-pllfh.h" >>>> >>>> #include <dt-bindings/clock/mt8195-clk.h> >>>> #include <linux/of_device.h> >>>> @@ -105,6 +107,61 @@ static const struct mtk_pll_data plls[] = { >>>> 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), >>>> }; >>>> >>>> +enum fh_pll_id { >>>> + FH_ARMPLL_LL, >>>> + FH_ARMPLL_BL, >>>> + FH_MEMPLL, >>>> + FH_ADSPPLL, >>>> + FH_NNAPLL, >>>> + FH_CCIPLL, >>>> + FH_MFGPLL, >>>> + FH_TVDPLL2, >>>> + FH_MPLL, >>>> + FH_MMPLL, >>>> + FH_MAINPLL, >>>> + FH_MSDCPLL, >>>> + FH_IMGPLL, >>>> + FH_VDECPLL, >>>> + FH_TVDPLL1, >>>> + FH_NR_FH, >>>> +}; >>>> + >>>> +#define FH(_pllid, _fhid, _offset) { \ >>>> + .data = { \ >>>> + .pll_id = _pllid, \ >>>> + .fh_id = _fhid, \ >>>> + .fh_ver = FHCTL_PLLFH_V2, \ >>>> + .fhx_offset = _offset, \ >>>> + .dds_mask = GENMASK(21, 0), \ >>> >>>> + .slope0_value = 0x6003c97, \ >>>> + .slope1_value = 0x6003c97, \ >>> >>> Are these >>> >>>> + .sfstrx_en = BIT(2), \ >>>> + .frddsx_en = BIT(1), \ >>>> + .fhctlx_en = BIT(0), \ >>>> + .tgl_org = BIT(31), \ >>>> + .dvfs_tri = BIT(31), \ >>>> + .pcwchg = BIT(31), \ >>> >>>> + .dt_val = 0x0, \ >>>> + .df_val = 0x9, \ >>> >>> and these just copied from MT8186? >> >> Yes, and that's because they're really the same. > > Just to be safe, I asked MediaTek to take a look at the parameters. > Cool. Let's see what they say then! >>> >>>> + .updnlmt_shft = 16, \ >>>> + .msk_frddsx_dys = GENMASK(23, 20), \ >>>> + .msk_frddsx_dts = GENMASK(19, 16), \ >>>> + }, \ >>>> + } >>>> + >>>> +static struct mtk_pllfh_data pllfhs[] = { >>>> + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), >>>> + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), >>>> + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), >>>> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), >>>> + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), >>>> + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), >>>> + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), >>>> + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), >>>> + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), >>>> + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), >>>> +}; >>>> + >>>> static const struct of_device_id of_match_clk_mt8195_apmixed[] = { >>>> { .compatible = "mediatek,mt8195-apmixedsys", }, >>>> {} >>>> @@ -114,13 +171,17 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) >>>> { >>>> struct clk_hw_onecell_data *clk_data; >>>> struct device_node *node = pdev->dev.of_node; >>>> + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; >>>> int r; >>>> >>>> clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); >>>> if (!clk_data) >>>> return -ENOMEM; >>>> >>>> - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); >>>> + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); >>>> + >>>> + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), >>>> + pllfhs, ARRAY_SIZE(pllfhs), clk_data); >>>> if (r) >>>> goto free_apmixed_data; >>>> >>>> @@ -140,7 +201,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) >>>> unregister_gates: >>>> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); >>>> unregister_plls: >>>> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); >>>> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, >>>> + ARRAY_SIZE(pllfhs), clk_data); >>> >>> Nit: I think this could be squeezed into one line. >>> >>>> free_apmixed_data: >>>> mtk_free_clk_data(clk_data); >>>> return r; >>>> @@ -153,7 +215,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev) >>>> >>>> of_clk_del_provider(node); >>>> mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); >>>> - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); >>>> + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, >>>> + ARRAY_SIZE(pllfhs), clk_data); >>> >>> Same here. >>> >> >> That's the same on the others as well, but if I compress those lines I will have >> to rebase the clocks cleanup series again and send the 54 patches again.. I'd like >> to avoid that noise. >> >> If you really want though, I can do that... what should I do? > > I see. Let's keep it the way it is then. > Great. We can always do a small cleanup later, if needed. Angelo
Quoting AngeloGioacchino Del Regno (2023-02-06 02:01:05) > Add FHCTL parameters and register PLLs through FHCTL to add support > for frequency hopping and SSC. FHCTL will be enabled only on PLLs > specified in devicetree. > > This commit brings functional changes only upon addition of > devicetree configuration. > > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > --- Applied to clk-next
diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c index 1bc917f2667e..c0db31ce0741 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -3,9 +3,11 @@ // Copyright (c) 2021 MediaTek Inc. // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> +#include "clk-fhctl.h" #include "clk-gate.h" #include "clk-mtk.h" #include "clk-pll.h" +#include "clk-pllfh.h" #include <dt-bindings/clock/mt8195-clk.h> #include <linux/of_device.h> @@ -105,6 +107,61 @@ static const struct mtk_pll_data plls[] = { 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), }; +enum fh_pll_id { + FH_ARMPLL_LL, + FH_ARMPLL_BL, + FH_MEMPLL, + FH_ADSPPLL, + FH_NNAPLL, + FH_CCIPLL, + FH_MFGPLL, + FH_TVDPLL2, + FH_MPLL, + FH_MMPLL, + FH_MAINPLL, + FH_MSDCPLL, + FH_IMGPLL, + FH_VDECPLL, + FH_TVDPLL1, + FH_NR_FH, +}; + +#define FH(_pllid, _fhid, _offset) { \ + .data = { \ + .pll_id = _pllid, \ + .fh_id = _fhid, \ + .fh_ver = FHCTL_PLLFH_V2, \ + .fhx_offset = _offset, \ + .dds_mask = GENMASK(21, 0), \ + .slope0_value = 0x6003c97, \ + .slope1_value = 0x6003c97, \ + .sfstrx_en = BIT(2), \ + .frddsx_en = BIT(1), \ + .fhctlx_en = BIT(0), \ + .tgl_org = BIT(31), \ + .dvfs_tri = BIT(31), \ + .pcwchg = BIT(31), \ + .dt_val = 0x0, \ + .df_val = 0x9, \ + .updnlmt_shft = 16, \ + .msk_frddsx_dys = GENMASK(23, 20), \ + .msk_frddsx_dts = GENMASK(19, 16), \ + }, \ + } + +static struct mtk_pllfh_data pllfhs[] = { + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), +}; + static const struct of_device_id of_match_clk_mt8195_apmixed[] = { { .compatible = "mediatek,mt8195-apmixedsys", }, {} @@ -114,13 +171,17 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) { struct clk_hw_onecell_data *clk_data; struct device_node *node = pdev->dev.of_node; + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; int r; clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); if (!clk_data) return -ENOMEM; - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); + + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), + pllfhs, ARRAY_SIZE(pllfhs), clk_data); if (r) goto free_apmixed_data; @@ -140,7 +201,8 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev) unregister_gates: mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); unregister_plls: - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, + ARRAY_SIZE(pllfhs), clk_data); free_apmixed_data: mtk_free_clk_data(clk_data); return r; @@ -153,7 +215,8 @@ static int clk_mt8195_apmixed_remove(struct platform_device *pdev) of_clk_del_provider(node); mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, + ARRAY_SIZE(pllfhs), clk_data); mtk_free_clk_data(clk_data); return 0;