From patchwork Thu Jan 26 08:53:20 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: 48531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp171384wrn; Thu, 26 Jan 2023 00:55:54 -0800 (PST) X-Google-Smtp-Source: AK7set8ZFl0ac/hVMXyhKM0yz3kyzgp3NGTe9QA5xmKAxjvGYpo5N4LbhY9pHcygJTHHtaXPN6PU X-Received: by 2002:a17:906:13c6:b0:878:605e:dbe7 with SMTP id g6-20020a17090613c600b00878605edbe7mr1665563ejc.3.1674723353884; Thu, 26 Jan 2023 00:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674723353; cv=none; d=google.com; s=arc-20160816; b=RD65F3NLzgOtdaL92YDPvLnvGaI/FN67k8PrxRBHqp2c2TQDrsj2HgCepkNyBcJOt9 FRnd+txmGJnvs006eZIYXkw2Cd8LBZ0MRA6MwkeGGqY5PLK3WJ84OAJ3fZo/9OpNRWCL CPNR3Ck9LfIlUwTlevCTLT4bH86dYKeDtXZGn9TX69TJN1WYbh39kLReN3DBqGFNHwOJ 8T3z3Ii6ACgBuclKL6YIe5M0kovVdJcxcrdB4P0D1X0WDxkYQVo7IFEoJWy1IVkBWZOV z81dw+wUGFMCWSCvMpPxF11tQJAH2El/x+z3f9zLt8e4DqfO+cS19vhSgSzr5i+82EaQ 9X/w== 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=MqmGbvtohrr9AwXpIavOukLiaH9UsuX6IGvABUv/8JA=; b=AMGGgmyHPmxwEHfmgr/kQYOe15Akjr+FhcefYzx+IDXadoZ9ZizH4hm+vIYbFwjP67 FFcI3zfX6cpon5F5QHBDVh3UdQBawZMK3WSx5HW3oDniD44hnnO/XkI8ndNUFp03EOrK yv2gzaive4zuYBVasvk86dHq+X1fXfuE2GP8ZOW8Q99bd+yOYnymFdG+JGNccgJNnyqQ jkr/uqAEQh9LKpoQhnnQGBKhUpMZwKkx0F7YtXORVw/AaH15uy89/sDwCgzCXtum1Nj+ m973MatRo8Yeont5+ohUcaYuU/3I2qcr2x2+ITaLQazhpdT8pJToKCrk4lqHuGFw3ltf ivkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Tv34dzq8; 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 p16-20020a170906935000b0084d7c8a4bdfsi643176ejw.276.2023.01.26.00.55.26; Thu, 26 Jan 2023 00:55:53 -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=Tv34dzq8; 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 S236609AbjAZIyA (ORCPT + 99 others); Thu, 26 Jan 2023 03:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236557AbjAZIxt (ORCPT ); Thu, 26 Jan 2023 03:53:49 -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 DB9CF402FD; Thu, 26 Jan 2023 00:53:43 -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 E46286602E78; Thu, 26 Jan 2023 08:53:30 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1674723211; bh=oWl0cctAa7ZwmyC5Ywb+4z1cuC9Q0pBS1rdEG+qBoHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tv34dzq8/zvQ56rn+b98dM0W2HBHbbfENlA/yBM/c27HTXvKFKJROC1HKERVK8OAY 2ugvW8zPmlxB5KM9iOJXjetrnUPpP+ZDIWWHDByOl3owirn4X8KooRmOAyKS5XVWzp R2zrW5lDFe/7ay/o48jV6qUe+RhzApriqZR9EsNs+FHEKr/p+FTL1kNvMqMfzY8Cni RHyN3VzmxjNpCYXhKXVVahrppctr5XcHrS7IAPryA0HDz0hrhFEisRQa1gOU2AMb0x iLYKIU/hEyi5jvdzWdosdJJFGFywu7vpeXgHTz72lqRDf/oDgiheNhbLgxbeeo2+4O 8QHdRvQ1Usyng== From: AngeloGioacchino Del Regno 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 v2 5/6] clk: mediatek: mt8192: Add support for frequency hopping through FHCTL Date: Thu, 26 Jan 2023 09:53:20 +0100 Message-Id: <20230126085321.87267-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126085321.87267-1-angelogioacchino.delregno@collabora.com> References: <20230126085321.87267-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?1756074715706766750?= X-GMAIL-MSGID: =?utf-8?q?1756074715706766750?= 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 --- drivers/clk/mediatek/clk-mt8192.c | 67 ++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-mt8192.c index 61299960d28a..0f9f10172148 100644 --- a/drivers/clk/mediatek/clk-mt8192.c +++ b/drivers/clk/mediatek/clk-mt8192.c @@ -12,10 +12,12 @@ #include #include +#include "clk-fhctl.h" #include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" #include "clk-pll.h" +#include "clk-pllfh.h" #include #include @@ -1042,6 +1044,57 @@ static const struct mtk_pll_data plls[] = { 0, 0, 32, 0x0330, 24, 0, 0, 0, 0x0334, 0), }; +enum fh_pll_id { + FH_ARMPLL_LL, + FH_ARMPLL_BL0, + FH_ARMPLL_BL1, + FH_ARMPLL_BL2, + FH_ARMPLL_BL3, + FH_CCIPLL, + FH_MFGPLL, + FH_MEMPLL, + FH_MPLL, + FH_MMPLL, + FH_MAINPLL, + FH_MSDCPLL, + FH_ADSPPLL, + FH_APUPLL, + FH_TVDPLL, + 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_MFGPLL, FH_MFGPLL, 0xb4), + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x12c), + FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0x154), +}; + /* Register mux notifier for MFG mux */ static int clk_mt8192_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) { @@ -1068,17 +1121,24 @@ static int clk_mt8192_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,mt8192-fhctl"; int r; clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); if (!clk_data) return -ENOMEM; - 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_clk_data; + r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); if (r) - goto free_clk_data; + goto unregister_plls; r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); if (r) @@ -1088,6 +1148,9 @@ static int clk_mt8192_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_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, + ARRAY_SIZE(pllfhs), clk_data); free_clk_data: mtk_free_clk_data(clk_data); return r;