From patchwork Fri Jun 10 10:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 581307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23CE5CCA480 for ; Fri, 10 Jun 2022 10:53:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348856AbiFJKw7 (ORCPT ); Fri, 10 Jun 2022 06:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346475AbiFJKwi (ORCPT ); Fri, 10 Jun 2022 06:52:38 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86E530AB4F for ; Fri, 10 Jun 2022 03:49:18 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id a15so42193218lfb.9 for ; Fri, 10 Jun 2022 03:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ly9q5MzbrlbdcUikNhTk9UKh8YRo0399T7xAGlulhbs=; b=qQ7dEWA1Nh+nSZcyR89nEkvc3VNGEmyLrd10VuNZ0P3oS/K12+GTM793sUhmqJeRzE bZjP+KdBEUe5iYoN8tFSQItsE2B50Ew9oxjYIakbd4dF2e6fH8RGwa80HIganSQJ48rY KgTuRxakqCRFHztVDV42/bd5yA93a/Ga0yvrARP3uRkJAjLFeZyOOw/QQgWbEvjS0r4c hX5JAaIGGuAZmC/7s/nTHLJcVT23qbHaNWHzj9nhsNftLUBwelquQ9/iJ4D+UUp6ATXI bT+RffP7BW9sPudT/aBrGUV6/QDta9V5C9BmOq1C20cYEbINmXhBwUASwqbNX/W+CtXB XdnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ly9q5MzbrlbdcUikNhTk9UKh8YRo0399T7xAGlulhbs=; b=f8c2rpl0sFGOPsU7iMLqgQEEzBpauWK+k0fxx1Hw5b2bvb7Hy7Jt2FxKOQIfDaXtZb WcgnFDDKkazYh6hCjBpwOP2hFLMAMgyVJKgkUoecsQ1kYGzYpm+k97xpeKQ4IV1xsbXm auYSDTw/ESXVt3XPaX2j4DcY2l/ULjBd79w6ARFp8mY3LHzb0XHh3jvodH0YoZq1v9Po 1hil5YegyjV6zFjYdczYJnF2JXSWmra0JBmc0wtWdDezHlALmEpcEThFchuSgSA0qmcg VjlpTUswQppdoOQ5/+m1WSChHG7LWJ11IxqDWFWgFZlG9pPWaGd2SHGwM3xqY3K+628Z YxrQ== X-Gm-Message-State: AOAM530k+NtUQ00AVe2UWQdAekOZXexw9vjDw7eyTqNdqzXlA/5p30aF mgRrvhMrBh7Tyic1C+T+gKY/0Q== X-Google-Smtp-Source: ABdhPJwzPEma/8t27CrbFO79u1PwunyeqedgBcWhAfU3hjkciEZneGBl7oHmPj1mFONxx3PRVXHlpw== X-Received: by 2002:ac2:4d82:0:b0:47d:b3c8:9e80 with SMTP id g2-20020ac24d82000000b0047db3c89e80mr1132324lfe.623.1654858156959; Fri, 10 Jun 2022 03:49:16 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id h11-20020ac24d2b000000b00477a287438csm4683468lfk.2.2022.06.10.03.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 03:49:16 -0700 (PDT) From: Vladimir Zapolskiy To: Bjorn Andersson Cc: Andy Gross , Rob Herring , Stephen Boyd , Michael Turquette , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v7 2/7] arm64: dts: qcom: sm8450: Add description of camera clock controller Date: Fri, 10 Jun 2022 13:49:11 +0300 Message-Id: <20220610104911.2296472-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> References: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change adds description of QCOm SM8450 camera clock controller. Signed-off-by: Vladimir Zapolskiy --- Changes from v6 to v7: * rebased on top of v5.19-rc1. Changes from v5 to v6: * rebased on top of linux-next. Changes from v3 to v5: * none. Changes from v2 to v3: * account a renamed header file. Changes from v1 to v2: * disabled camcc device tree node by default. arch/arm64/boot/dts/qcom/sm8450.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi index 7d08fad76371..fad813a21df5 100644 --- a/arch/arm64/boot/dts/qcom/sm8450.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -2288,6 +2289,25 @@ IPCC_MPROC_SIGNAL_GLINK_QMP }; }; + camcc: clock-controller@ade0000 { + compatible = "qcom,sm8450-camcc"; + reg = <0 0x0ade0000 0 0x20000>; + status = "disabled"; + clocks = <&gcc GCC_CAMERA_AHB_CLK>, + <&rpmhcc RPMH_CXO_CLK>, + <&rpmhcc RPMH_CXO_CLK_A>, + <&sleep_clk>; + clock-names = "iface", + "bi_tcxo", + "bi_tcxo_ao", + "sleep_clk"; + power-domains = <&rpmhpd SM8450_MMCX>; + required-opps = <&rpmhpd_opp_low_svs>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; + pdc: interrupt-controller@b220000 { compatible = "qcom,sm8450-pdc", "qcom,pdc"; reg = <0 0x0b220000 0 0x30000>, <0 0x174000f0 0 0x64>; From patchwork Fri Jun 10 10:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 581306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24857CCA47E for ; Fri, 10 Jun 2022 10:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346960AbiFJKy2 (ORCPT ); Fri, 10 Jun 2022 06:54:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349316AbiFJKxa (ORCPT ); Fri, 10 Jun 2022 06:53:30 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7CA248005 for ; Fri, 10 Jun 2022 03:49:55 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id w20so20546856lfa.11 for ; Fri, 10 Jun 2022 03:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DM/nIs/IKkNMeW47XBT24VkP7Vv3YRenARerqJeGNwk=; b=RCrqHNiDI0o3C8RVEGuaZH+tsOUtDUyWk30FEbhLgLRX9qX2hLxABgxvqYslGFy+gh 0mVWk9658k/fBTW0MDXfu25or2FNd3AUrTfHjiiPkRAY27OLocqZVX9BpMF804LL7xKH jZHxBIaZe5jzi5+HUNO2u+CyfU0tUUIP96JLZNXFBQM/VGTpoY4m7cKrCam5JKIqX14b GdAV2eMGrd0UJNezAwVzhnjpi7yr5gd5omTtjNgizg15TDTOIsbP1ebzWJ53yWQpl/8i qT1r3MH6ruiZzLOtD9Mw7Gk7EFp3Vl4g/ulPMTfihETv0QpH5EKVKVWDc/nPKWzc9Bqc ZkSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DM/nIs/IKkNMeW47XBT24VkP7Vv3YRenARerqJeGNwk=; b=nOv+o+DcucSPBfaodJMj2iIGHfPUqjPM7NDZUxF4PDTpZKa6cpOwu3+qCed+ulLFQQ twCekvPyiZtC54Ci3MIK/p4M9NSecnoGszglOhSNaZYLxeVBSiV8azIo0cXyts2ZB1wB eKxtXxziVcYtIq6iCPyXefCm8c9Vc/0l0Jl4X4E0B8y5yFnJdHKaLubFGlBULvO+hWt4 A201uI4jwmAYYEPZBL6iMWaO/CS3dcJf2M/CWit6rTM75oK5AFKl7qCjj2qiM0J+yHrS CuuIZGpaggwqjt4+PRT8NYCNNJsDZ/BfGU4GcQYUt2O2UoEEJZg07BCL9elRQW2AfsVU 7QIw== X-Gm-Message-State: AOAM530ne+9Cv6ici08tuN2hmZoIWc17U4AO8nKDi108r9c9yBXG72Mx ooc3gy9NErwoivl1Az/9o47vbA== X-Google-Smtp-Source: ABdhPJyVhq3bQ6XWWpN4PzRS+UB+ZuAVye1pvnY69WeuGkvBoCFEhMttjHZjCZ4C/D/rG/1KBHd0lQ== X-Received: by 2002:a19:7907:0:b0:479:165c:3842 with SMTP id u7-20020a197907000000b00479165c3842mr24838166lfc.552.1654858193387; Fri, 10 Jun 2022 03:49:53 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id c2-20020ac244a2000000b00478f2a09100sm4658945lfm.184.2022.06.10.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 03:49:53 -0700 (PDT) From: Vladimir Zapolskiy To: Bjorn Andersson Cc: Andy Gross , Stephen Boyd , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v7 5/7] clk: qcom: clk-alpha-pll: add Lucid EVO PLL configuration interfaces Date: Fri, 10 Jun 2022 13:49:51 +0300 Message-Id: <20220610104951.2296533-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> References: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change adds controls for Lucid EVO PLL configuration and exports control functions to clock controller drivers. Signed-off-by: Vladimir Zapolskiy --- Changes from v3 to v7: * none. Changes from v2 to v3: * improved commit subject and description per ask from Bjorn. drivers/clk/qcom/clk-alpha-pll.c | 65 ++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-alpha-pll.h | 5 ++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index 47879ee5a677..54bad5277802 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -191,8 +191,10 @@ EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); #define LUCID_5LPE_ENABLE_VOTE_RUN BIT(21) /* LUCID EVO PLL specific settings and offsets */ +#define LUCID_EVO_PCAL_NOT_DONE BIT(8) #define LUCID_EVO_ENABLE_VOTE_RUN BIT(25) #define LUCID_EVO_PLL_L_VAL_MASK GENMASK(15, 0) +#define LUCID_EVO_PLL_CAL_L_VAL_SHIFT 16 /* ZONDA PLL specific */ #define ZONDA_PLL_OUT_MASK 0xf @@ -1994,6 +1996,33 @@ const struct clk_ops clk_alpha_pll_zonda_ops = { }; EXPORT_SYMBOL_GPL(clk_alpha_pll_zonda_ops); +void clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, + const struct alpha_pll_config *config) +{ + clk_alpha_pll_write_config(regmap, PLL_L_VAL(pll), config->l | + (TRION_PLL_CAL_VAL << LUCID_EVO_PLL_CAL_L_VAL_SHIFT)); + + clk_alpha_pll_write_config(regmap, PLL_ALPHA_VAL(pll), config->alpha); + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL(pll), config->config_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U(pll), config->config_ctl_hi_val); + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U1(pll), config->config_ctl_hi1_val); + clk_alpha_pll_write_config(regmap, PLL_USER_CTL(pll), config->user_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_USER_CTL_U(pll), config->user_ctl_hi_val); + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL(pll), config->test_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL_U(pll), config->test_ctl_hi_val); + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL_U1(pll), config->test_ctl_hi1_val); + + /* Disable PLL output */ + regmap_update_bits(regmap, PLL_MODE(pll), PLL_OUTCTRL, 0); + + /* Set operation mode to STANDBY */ + regmap_write(regmap, PLL_OPMODE(pll), PLL_STANDBY); + + /* Place the PLL in STANDBY mode */ + regmap_update_bits(regmap, PLL_MODE(pll), PLL_RESET_N, PLL_RESET_N); +} +EXPORT_SYMBOL_GPL(clk_lucid_evo_pll_configure); + static int alpha_pll_lucid_evo_enable(struct clk_hw *hw) { struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); @@ -2079,6 +2108,31 @@ static void alpha_pll_lucid_evo_disable(struct clk_hw *hw) regmap_write(regmap, PLL_OPMODE(pll), PLL_STANDBY); } +static int alpha_pll_lucid_evo_prepare(struct clk_hw *hw) +{ + struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); + struct clk_hw *p; + u32 val = 0; + int ret; + + /* Return early if calibration is not needed. */ + regmap_read(pll->clkr.regmap, PLL_MODE(pll), &val); + if (!(val & LUCID_EVO_PCAL_NOT_DONE)) + return 0; + + p = clk_hw_get_parent(hw); + if (!p) + return -EINVAL; + + ret = alpha_pll_lucid_evo_enable(hw); + if (ret) + return ret; + + alpha_pll_lucid_evo_disable(hw); + + return 0; +} + static unsigned long alpha_pll_lucid_evo_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { @@ -2114,3 +2168,14 @@ const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops = { .set_rate = clk_lucid_evo_pll_postdiv_set_rate, }; EXPORT_SYMBOL_GPL(clk_alpha_pll_postdiv_lucid_evo_ops); + +const struct clk_ops clk_alpha_pll_lucid_evo_ops = { + .prepare = alpha_pll_lucid_evo_prepare, + .enable = alpha_pll_lucid_evo_enable, + .disable = alpha_pll_lucid_evo_disable, + .is_enabled = clk_trion_pll_is_enabled, + .recalc_rate = alpha_pll_lucid_evo_recalc_rate, + .round_rate = clk_alpha_pll_round_rate, + .set_rate = alpha_pll_lucid_5lpe_set_rate, +}; +EXPORT_SYMBOL_GPL(clk_alpha_pll_lucid_evo_ops); diff --git a/drivers/clk/qcom/clk-alpha-pll.h b/drivers/clk/qcom/clk-alpha-pll.h index 6e9907deaf30..0b7a6859ca2c 100644 --- a/drivers/clk/qcom/clk-alpha-pll.h +++ b/drivers/clk/qcom/clk-alpha-pll.h @@ -152,6 +152,8 @@ extern const struct clk_ops clk_alpha_pll_postdiv_lucid_5lpe_ops; extern const struct clk_ops clk_alpha_pll_zonda_ops; #define clk_alpha_pll_postdiv_zonda_ops clk_alpha_pll_postdiv_fabia_ops + +extern const struct clk_ops clk_alpha_pll_lucid_evo_ops; extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops; extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops; @@ -168,6 +170,7 @@ void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, void clk_zonda_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, const struct alpha_pll_config *config); - +void clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, + const struct alpha_pll_config *config); #endif From patchwork Fri Jun 10 10:49:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 581305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDE2DCCA47B for ; Fri, 10 Jun 2022 10:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348857AbiFJKyb (ORCPT ); Fri, 10 Jun 2022 06:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349342AbiFJKxc (ORCPT ); Fri, 10 Jun 2022 06:53:32 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 703B72EEBE8 for ; Fri, 10 Jun 2022 03:49:57 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id a2so36086348lfg.5 for ; Fri, 10 Jun 2022 03:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jw37sCbhRzE/9N5bfpDeLzXuyy9lXdNGSbRvzHjEYY0=; b=jWTqJNWN9R2jpKIf5zoxDd65DP0xtiqbP67dt3kcYTvQVEczBBXb0WDQw6JMhUpChu KW3bf5RoukqOYnUqRJPGpzfeeCGvzqLj70Wzw+fnKOfhFRfJO1PXRJgNk9+rcfY96E6W FHK+qXWm7S0P89IpQ05lg+WYTBx+ofFw+zPFGSQSArEaN3/Mem3x99jTFUIOXu3/7WFI bmOnt4Y96c9H15TjxlO6dz8y+c3Tr4SXnFpD0vTVLZw8/I92/0SoJvnIIYCRF817ExYK GghcW/8reN6W4vAE+XakffNYcqCRRXnXECblheNhAPmKAz80ki8NfCAMfqkGzLENihn8 0FTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jw37sCbhRzE/9N5bfpDeLzXuyy9lXdNGSbRvzHjEYY0=; b=iToFSm1cDgjhgRyOgeRQbJOvooX71/OXGCyG7bBvqGzt924drQ++94ffenkfWsRr6j XfwlCdEzm/0bUn7V1eG/dqLfbvTUS0AERbjS61eG1W0jN1tcW6fs1OPY4QtW59cUOsuL jACww24fDjIJpto0SkOEpOGznWo4zyWgKEqy2mvZu5mBCit8G0N3sgWB80v+pmF8G5jv RgaRBN3w5BM9a+0mCcGC3dAYAlJNKNcGdO+QLiWjTqRnkQLZ2HYtikSkYpJO3Zu3JhcF sf1SsK++e8cB1n4hHrp1EyEGwBq3QVq9t4ah6n5h2qR4DcS5+87dyQu0wRg8Wxgxx9NG M2eQ== X-Gm-Message-State: AOAM533QPJ9bkdLOeIskono/qEw62V1E+N3AquBI17Ey7Ks+aA9JmxkI ma1REfU7bYq4UHbQ+JLhYLIrag== X-Google-Smtp-Source: ABdhPJzR7JfRfvI/qKiBjWAhgTDx9t77Fs1D90Z9lvuoIB+jkET8JWpqkozYBu0ROeqWGVM6FM9Vjg== X-Received: by 2002:ac2:4a69:0:b0:479:7c24:c3e2 with SMTP id q9-20020ac24a69000000b004797c24c3e2mr7526366lfp.487.1654858195352; Fri, 10 Jun 2022 03:49:55 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id b34-20020a2ebc22000000b0025571a896ebsm2434935ljf.98.2022.06.10.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 03:49:55 -0700 (PDT) From: Vladimir Zapolskiy To: Bjorn Andersson Cc: Andy Gross , Stephen Boyd , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v7 6/7] clk: qcom: clk-alpha-pll: add Rivian EVO PLL configuration interfaces Date: Fri, 10 Jun 2022 13:49:53 +0300 Message-Id: <20220610104953.2296552-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> References: <20220610104911.2296472-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change adds and exports Rivian EVO PLL configuration and control functions to clock controller drivers. Signed-off-by: Vladimir Zapolskiy --- Changes from v1 to v7: * none. drivers/clk/qcom/clk-alpha-pll.c | 70 ++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-alpha-pll.h | 6 +++ 2 files changed, 76 insertions(+) diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index 54bad5277802..ab4f0fc15a48 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -154,6 +154,18 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = { [PLL_OFF_TEST_CTL_U] = 0x30, [PLL_OFF_TEST_CTL_U1] = 0x34, }, + [CLK_ALPHA_PLL_TYPE_RIVIAN_EVO] = { + [PLL_OFF_OPMODE] = 0x04, + [PLL_OFF_STATUS] = 0x0c, + [PLL_OFF_L_VAL] = 0x10, + [PLL_OFF_USER_CTL] = 0x14, + [PLL_OFF_USER_CTL_U] = 0x18, + [PLL_OFF_CONFIG_CTL] = 0x1c, + [PLL_OFF_CONFIG_CTL_U] = 0x20, + [PLL_OFF_CONFIG_CTL_U1] = 0x24, + [PLL_OFF_TEST_CTL] = 0x28, + [PLL_OFF_TEST_CTL_U] = 0x2c, + }, }; EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); @@ -2179,3 +2191,61 @@ const struct clk_ops clk_alpha_pll_lucid_evo_ops = { .set_rate = alpha_pll_lucid_5lpe_set_rate, }; EXPORT_SYMBOL_GPL(clk_alpha_pll_lucid_evo_ops); + +void clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, + const struct alpha_pll_config *config) +{ + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL(pll), config->config_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U(pll), config->config_ctl_hi_val); + clk_alpha_pll_write_config(regmap, PLL_CONFIG_CTL_U1(pll), config->config_ctl_hi1_val); + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL(pll), config->test_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_TEST_CTL_U(pll), config->test_ctl_hi_val); + clk_alpha_pll_write_config(regmap, PLL_L_VAL(pll), config->l); + clk_alpha_pll_write_config(regmap, PLL_USER_CTL(pll), config->user_ctl_val); + clk_alpha_pll_write_config(regmap, PLL_USER_CTL_U(pll), config->user_ctl_hi_val); + + regmap_write(regmap, PLL_OPMODE(pll), PLL_STANDBY); + + regmap_update_bits(regmap, PLL_MODE(pll), + PLL_RESET_N | PLL_BYPASSNL | PLL_OUTCTRL, + PLL_RESET_N | PLL_BYPASSNL); +} +EXPORT_SYMBOL_GPL(clk_rivian_evo_pll_configure); + +static unsigned long clk_rivian_evo_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); + u32 l; + + regmap_read(pll->clkr.regmap, PLL_L_VAL(pll), &l); + + return parent_rate * l; +} + +static long clk_rivian_evo_pll_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *prate) +{ + struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); + unsigned long min_freq, max_freq; + u32 l; + u64 a; + + rate = alpha_pll_round_rate(rate, *prate, &l, &a, 0); + if (!pll->vco_table || alpha_pll_find_vco(pll, rate)) + return rate; + + min_freq = pll->vco_table[0].min_freq; + max_freq = pll->vco_table[pll->num_vco - 1].max_freq; + + return clamp(rate, min_freq, max_freq); +} + +const struct clk_ops clk_alpha_pll_rivian_evo_ops = { + .enable = alpha_pll_lucid_5lpe_enable, + .disable = alpha_pll_lucid_5lpe_disable, + .is_enabled = clk_trion_pll_is_enabled, + .recalc_rate = clk_rivian_evo_pll_recalc_rate, + .round_rate = clk_rivian_evo_pll_round_rate, +}; +EXPORT_SYMBOL_GPL(clk_alpha_pll_rivian_evo_ops); diff --git a/drivers/clk/qcom/clk-alpha-pll.h b/drivers/clk/qcom/clk-alpha-pll.h index 0b7a6859ca2c..447efb82fe59 100644 --- a/drivers/clk/qcom/clk-alpha-pll.h +++ b/drivers/clk/qcom/clk-alpha-pll.h @@ -18,6 +18,7 @@ enum { CLK_ALPHA_PLL_TYPE_AGERA, CLK_ALPHA_PLL_TYPE_ZONDA, CLK_ALPHA_PLL_TYPE_LUCID_EVO, + CLK_ALPHA_PLL_TYPE_RIVIAN_EVO, CLK_ALPHA_PLL_TYPE_MAX, }; @@ -157,6 +158,9 @@ extern const struct clk_ops clk_alpha_pll_lucid_evo_ops; extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops; extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops; +extern const struct clk_ops clk_alpha_pll_rivian_evo_ops; +#define clk_alpha_pll_postdiv_rivian_evo_ops clk_alpha_pll_postdiv_fabia_ops + void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, const struct alpha_pll_config *config); void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, @@ -172,5 +176,7 @@ void clk_zonda_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, const struct alpha_pll_config *config); void clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, const struct alpha_pll_config *config); +void clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, + const struct alpha_pll_config *config); #endif