Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3767670pxb; Sun, 24 Oct 2021 10:34:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKCAyA9BAaF8kUrFXb1yDTifoSyF50Lgl+5NSogZhn0hQyTvyjxeTyqtsyQGaH9E5My6cq X-Received: by 2002:a05:6402:1644:: with SMTP id s4mr18016051edx.181.1635096845626; Sun, 24 Oct 2021 10:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635096845; cv=none; d=google.com; s=arc-20160816; b=wyscebUk6NNQIGBmPZk9YUEcGRuzoaVbBdOysG7TlQ/Ik1q7TT0KCfzxvgbSu8eQO9 suPcnzl5n3q+OQqhGF8qmvhaGCAFCD0fjuPdr+Cep6ky0EO391XYjh/TJdcMQ/E5HSao ZoZIGWc6ndQ0Q1YGEAqsO865/rQru/whQkIwQ7ek74d72bHQcUgoRnQUQaXc+H89dh/6 BoBFlHj0dNCRpLP01RBjn7/AfLJOHkSHjH0czDIA65i3xipI9xQBeRmenLygu7y9tDtc Y5WuYup5Oibk2lm5HE8LfhRgV+PAZNLzVB3xSBMVE+h6GEGikg6h5e3wjJKgPGTc1pqg vBOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HgGS/TvUDMG3fQx9yKOzke/c5Xu6vKp0j7mW0xSrxIs=; b=gkWyHH7kSHN25KMFeWbhE57U21B61VKnZcUU3BieLLpjLlbt4ItigWoIEBXKhtoKgO aRhTVsv3z3+XlodFw04i3f22rQPR/nr3Hfi9dvX/wf///mFvAnETvXI1vMDadAPMc9Zq 5Bl6yeT9AfIrTHOr/kadRBxbQnuN99uJJvEIU4ROuQp0OIGhAlffsU62w2PG4T2iSz/O hiTUSkdq7/RcGEY3MzvvAsWRNtjMtprEDLzgnz2E+hfhoJlTTKSbDRJtA93qw3KXXIlR MydB1xCjHf9ugFY2w0PVD2NWEJ6r84aEWBCqusjiY8pQXTycKVFtu7iDM5m7Csds2H/U Fhtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPX33eA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt9si27677493ejc.675.2021.10.24.10.33.41; Sun, 24 Oct 2021 10:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPX33eA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231836AbhJXRcj (ORCPT + 99 others); Sun, 24 Oct 2021 13:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbhJXRcg (ORCPT ); Sun, 24 Oct 2021 13:32:36 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53421C061225 for ; Sun, 24 Oct 2021 10:30:13 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 34-20020a9d0325000000b00552cae0decbso11692418otv.0 for ; Sun, 24 Oct 2021 10:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HgGS/TvUDMG3fQx9yKOzke/c5Xu6vKp0j7mW0xSrxIs=; b=WPX33eA6Cus/C/DS/Fhqhv1hc2HIccKxAURkdetkilrRWi6UoMsB6jaqZRJbgt9LFY Nfw8nDbrrZBq9eRLTq60RRF3UMB8VwCcmng6GFRmr+brEOcI4plthFaWgSb6dSpfeRB5 UPG8r6EAw7qO7mTyVah6oLD8VrhqeJ7sL6oXHKfJQ2ZB1jv24bsrtYY5Fw3Cly1Iwr4r Daypsu1akqHI1GKVnh32oCy+ihigTykW/XOYd9cjCiAIKqwEkkFIdIwGn5N/Yxh3rIbS Y9eW9F5uUztm8mg8H4PmbAhOHwt03vNSUd2fZQbZ+UV5SKVRNQvi87FgnYo2g7Wou5dM 0OiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HgGS/TvUDMG3fQx9yKOzke/c5Xu6vKp0j7mW0xSrxIs=; b=UVXGLh1KCodo9a898eEbNWQEhxsspPQeg9hW+aMQksJ3TVG3b/tbFPmAnR9wFffcWE D8f+b/tOTkefcjXxXFdMwyY+fdTfasQ3vDCrWVNDfOLNSHKHIX9AXeWSGAaw1KI+dj1Q MDHrViNQAtUWXzVt6aReVU308YOKXBWI6AMoF5eX/KnYJ2v78/X88pdR/TBb73wG3Ysk GTQQGnIUQ1PJPvfgW90Y+UVNVcjenxQcrIK2ScVGTCZ6UMVYIRiIHv1hoU5cYBauo6vW MG39PwxeDUtcH0BWN/1FbBBZgzzAnyv0C30pyy3SIqbJzVrIsxBt3VzIWF4h60//nkD9 /9pw== X-Gm-Message-State: AOAM532+8NJqNDs6J7k5yujclsTm6DWMSw9ALDejBnEmgnX/k31cWsT9 mEday6w2WDPP8MMeVjFD/D1M/A== X-Received: by 2002:a9d:19e3:: with SMTP id k90mr9508712otk.99.1635096612490; Sun, 24 Oct 2021 10:30:12 -0700 (PDT) Received: from builder.lan ([2600:1700:a0:3dc8:3697:f6ff:fe85:aac9]) by smtp.gmail.com with ESMTPSA id r22sm2955520otq.5.2021.10.24.10.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Oct 2021 10:30:11 -0700 (PDT) Date: Sun, 24 Oct 2021 12:30:09 -0500 From: Bjorn Andersson To: Yassine Oudjana Cc: Andy Gross , Michael Turquette , Stephen Boyd , Rob Herring , Ilia Lin , Viresh Kumar , Nishanth Menon , "Rafael J. Wysocki" , Loic Poulain , Konrad Dybcio , AngeloGioacchino Del Regno , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org Subject: Re: [PATCH 3/8] clk: qcom: msm8996-cpu: Add MSM8996 Pro CBF support Message-ID: References: <20211014083016.137441-1-y.oudjana@protonmail.com> <20211014083016.137441-4-y.oudjana@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211014083016.137441-4-y.oudjana@protonmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 14 Oct 03:32 CDT 2021, Yassine Oudjana wrote: > MSM8996 Pro (MSM8996SG) has a few differences in the CBF clock. > I think it would be nice if you described what those differences are. Regards, Bjorn > Signed-off-by: Yassine Oudjana > --- > Dependencies: > - clk: qcom: msm8996-cpu: Add CBF support > https://lore.kernel.org/linux-arm-msm/20210528192541.1120703-1-konrad.dybcio@somainline.org/ > > drivers/clk/qcom/clk-cpu-8996.c | 61 +++++++++++++++++++++------------ > 1 file changed, 40 insertions(+), 21 deletions(-) > > diff --git a/drivers/clk/qcom/clk-cpu-8996.c b/drivers/clk/qcom/clk-cpu-8996.c > index 8afc271f92d0..ab2acbe74f0f 100644 > --- a/drivers/clk/qcom/clk-cpu-8996.c > +++ b/drivers/clk/qcom/clk-cpu-8996.c > @@ -70,11 +70,11 @@ enum _pmux_input { > > enum { > CBF_PLL_INDEX = 1, > - CBF_DIV_2_INDEX, > + CBF_DIV_INDEX, > CBF_SAFE_INDEX > }; > > -#define DIV_2_THRESHOLD 600000000 > +#define DIV_THRESHOLD 600000000 > #define PWRCL_REG_OFFSET 0x0 > #define PERFCL_REG_OFFSET 0x80000 > #define MUX_OFFSET 0x40 > @@ -142,6 +142,17 @@ static const struct alpha_pll_config cbfpll_config = { > .early_output_mask = BIT(3), > }; > > +static const struct alpha_pll_config cbfpll_config_pro = { > + .l = 72, > + .config_ctl_val = 0x200d4aa8, > + .config_ctl_hi_val = 0x006, > + .pre_div_mask = BIT(12), > + .post_div_mask = 0x3 << 8, > + .post_div_val = 0x3 << 8, > + .main_output_mask = BIT(0), > + .early_output_mask = BIT(3), > +}; > + > static struct clk_alpha_pll perfcl_pll = { > .offset = PERFCL_REG_OFFSET, > .regs = prim_pll_regs, > @@ -230,7 +241,8 @@ struct clk_cpu_8996_mux { > u8 width; > struct notifier_block nb; > struct clk_hw *pll; > - struct clk_hw *pll_div_2; > + struct clk_hw *pll_div; > + u8 div; > struct clk_regmap clkr; > }; > > @@ -280,11 +292,11 @@ static int clk_cpu_8996_mux_determine_rate(struct clk_hw *hw, > struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_hw(hw); > struct clk_hw *parent = cpuclk->pll; > > - if (cpuclk->pll_div_2 && req->rate < DIV_2_THRESHOLD) { > - if (req->rate < (DIV_2_THRESHOLD / 2)) > + if (cpuclk->pll_div &&req->rate < DIV_THRESHOLD) { > + if (req->rate < (DIV_THRESHOLD / cpuclk->div)) > return -EINVAL; > > - parent = cpuclk->pll_div_2; > + parent = cpuclk->pll_div; > } > > req->best_parent_rate = clk_hw_round_rate(parent, req->rate); > @@ -336,7 +348,8 @@ static struct clk_cpu_8996_mux pwrcl_pmux = { > .shift = 0, > .width = 2, > .pll = &pwrcl_pll.clkr.hw, > - .pll_div_2 = &pwrcl_smux.clkr.hw, > + .pll_div = &pwrcl_smux.clkr.hw, > + .div = 2, > .nb.notifier_call = cpu_clk_notifier_cb, > .clkr.hw.init = &(struct clk_init_data) { > .name = "pwrcl_pmux", > @@ -358,7 +371,8 @@ static struct clk_cpu_8996_mux perfcl_pmux = { > .shift = 0, > .width = 2, > .pll = &perfcl_pll.clkr.hw, > - .pll_div_2 = &perfcl_smux.clkr.hw, > + .pll_div = &perfcl_smux.clkr.hw, > + .div = 2, > .nb.notifier_call = cpu_clk_notifier_cb, > .clkr.hw.init = &(struct clk_init_data) { > .name = "perfcl_pmux", > @@ -481,19 +495,23 @@ static int qcom_cbf_clk_msm8996_register_clks(struct device *dev, > struct regmap *regmap) > { > int ret; > + bool is_pro = of_device_is_compatible(dev->of_node, "qcom,msm8996pro-apcc"); > > - cbf_mux.pll_div_2 = clk_hw_register_fixed_factor(dev, "cbf_pll_main", > - "cbf_pll", CLK_SET_RATE_PARENT, > - 1, 2); > - if (IS_ERR(cbf_mux.pll_div_2)) { > + cbf_mux.div = is_pro ? 4 : 2; > + cbf_mux.pll_div = clk_hw_register_fixed_factor(dev, "cbf_pll_main", > + "cbf_pll", CLK_SET_RATE_PARENT, > + 1, cbf_mux.div); > + > + if (IS_ERR(cbf_mux.pll_div)) { > dev_err(dev, "Failed to initialize cbf_pll_main\n"); > - return PTR_ERR(cbf_mux.pll_div_2); > + return PTR_ERR(cbf_mux.pll_div); > } > > ret = devm_clk_register_regmap(dev, cbf_msm8996_clks[0]); > ret = devm_clk_register_regmap(dev, cbf_msm8996_clks[1]); > > - clk_alpha_pll_configure(&cbf_pll, regmap, &cbfpll_config); > + clk_alpha_pll_configure(&cbf_pll, regmap, is_pro ? > + &cbfpll_config_pro : &cbfpll_config); > clk_set_rate(cbf_pll.clkr.hw.clk, 614400000); > clk_prepare_enable(cbf_pll.clkr.hw.clk); > clk_notifier_register(cbf_mux.clkr.hw.clk, &cbf_mux.nb); > @@ -575,7 +593,7 @@ static int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, > qcom_cpu_clk_msm8996_acd_init(base); > break; > case POST_RATE_CHANGE: > - if (cnd->new_rate < DIV_2_THRESHOLD) > + if (cnd->new_rate < DIV_THRESHOLD) > ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, > DIV_2_INDEX); > else > @@ -600,15 +618,15 @@ static int cbf_clk_notifier_cb(struct notifier_block *nb, unsigned long event, > > switch (event) { > case PRE_RATE_CHANGE: > - parent = clk_hw_get_parent_by_index(&cbfclk->clkr.hw, CBF_DIV_2_INDEX); > - ret = clk_cpu_8996_mux_set_parent(&cbfclk->clkr.hw, CBF_DIV_2_INDEX); > + parent = clk_hw_get_parent_by_index(&cbfclk->clkr.hw, CBF_DIV_INDEX); > + ret = clk_cpu_8996_mux_set_parent(&cbfclk->clkr.hw, CBF_DIV_INDEX); > > - if (cnd->old_rate > DIV_2_THRESHOLD && cnd->new_rate < DIV_2_THRESHOLD) > - ret = clk_set_rate(parent->clk, cnd->old_rate / 2); > + if (cnd->old_rate > DIV_THRESHOLD && cnd->new_rate < DIV_THRESHOLD) > + ret = clk_set_rate(parent->clk, cnd->old_rate / cbfclk->div); > break; > case POST_RATE_CHANGE: > - if (cnd->new_rate < DIV_2_THRESHOLD) > - ret = clk_cpu_8996_mux_set_parent(&cbfclk->clkr.hw, CBF_DIV_2_INDEX); > + if (cnd->new_rate < DIV_THRESHOLD) > + ret = clk_cpu_8996_mux_set_parent(&cbfclk->clkr.hw, CBF_DIV_INDEX); > else { > parent = clk_hw_get_parent_by_index(&cbfclk->clkr.hw, CBF_PLL_INDEX); > ret = clk_set_rate(parent->clk, cnd->new_rate); > @@ -676,6 +694,7 @@ static int qcom_cpu_clk_msm8996_driver_remove(struct platform_device *pdev) > > static const struct of_device_id qcom_cpu_clk_msm8996_match_table[] = { > { .compatible = "qcom,msm8996-apcc" }, > + { .compatible = "qcom,msm8996pro-apcc" }, > {} > }; > MODULE_DEVICE_TABLE(of, qcom_cpu_clk_msm8996_match_table); > -- > 2.33.0 > >