Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp346839rdb; Thu, 19 Oct 2023 06:22:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXQ+Vv1Mh0mmOUt370+zlwWY7xG5Hdn8oaFGm6iV0HYlF4GIADv0GFEHZ1OI+XOlDoy3bL X-Received: by 2002:a05:6a00:1995:b0:6be:2991:d878 with SMTP id d21-20020a056a00199500b006be2991d878mr1923490pfl.15.1697721753888; Thu, 19 Oct 2023 06:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697721753; cv=none; d=google.com; s=arc-20160816; b=VQkfkO3xpn2RqeGeZ/qg5toYlUEQpZlJxi9RZsKx/8aJAI0kB8a/XcRbKMgsUnyIPC LKfQvfjdbcUuSce9C2Zm2y0Mu7kCa/Y0w0O01gxIYVXn+XS3fexPKMZdbb7dxfFcFe0B z4ZAN/om6kbiTeEAzSR6XXuQRNFPrjY+EP7p/AqEFItzrL8rzNxDSNUZVQJ8gAH/Y4OM Yf4JqNf7u/xJBYI3fjKIk8EcYwOwtTYyimdHOZp8izAe8QWjnOQVvuDaVZGto4LNvYHc ruwORD0pZ50FNUb3d1Zgf13rNXvXzhSCswd5K+sZ0lhI3QFhtpvmH7Lg9/zNPKsuCc3M 3B+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LK/A8QLl6mmZsiIVExfW0sdngxXHRyvJR8+2rskOKXw=; fh=xl2RlKdu+G8wuKrdg4B8HmIIWwR4G+fzkFrAAsU8m0c=; b=FpAIT5FbmBN5JmTk8IbJyvuPAQ/MyWXYZX0oKok4a4TNrRUT8Z8aFmzuxE6x4fj1+p SOGec0cwpvBrqqSrYLBo80Pw57R2VEATADYA8/7FeRQ9r6t+8c/9wPiu2rpVu9cx0uQi mikP5k4kOUHmvT+4wucuywV5Zykza3IahClPyWxQ4y+b8BnzGbr8JchXI1y7oN55C2Ue Z6Hmu+DQb4IadQCHmsq6kp1IRUjIrvQ+fyrgifvUqHWPl0P1E/sgf6HeemLh+CUP3XNW vEB5gffYl6/2xe7uTi9XtUl55F6nLQIZTbpDohIXf3Zx3Z+sDwWY7XCGAzXkNYp58TE2 u70Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y2EbQdSu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id w8-20020a63f508000000b0059c36d79520si4490516pgh.772.2023.10.19.06.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 06:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y2EbQdSu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EFA2582F9153; Thu, 19 Oct 2023 06:22:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345889AbjJSNWO (ORCPT + 99 others); Thu, 19 Oct 2023 09:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235390AbjJSNWJ (ORCPT ); Thu, 19 Oct 2023 09:22:09 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026BD130 for ; Thu, 19 Oct 2023 06:22:06 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5a87ac9d245so55135977b3.3 for ; Thu, 19 Oct 2023 06:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697721726; x=1698326526; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LK/A8QLl6mmZsiIVExfW0sdngxXHRyvJR8+2rskOKXw=; b=y2EbQdSuBPfoN7iHvMzb7Eehk+7o1FyEgcUZGm3n4YjsSBbqvyuGTQjwulKDSIst3g VEufAFVA4Oq+ACDcflmvrFUc7RGdRAwXl1/Qmc7c26S1YDHznIt+9A542K42kRAycz97 JNoOJ9TkP5bh4kEhvcnO6rqA3E268DPOgmqpoRTnY6NyljsweBQGOmmsrKwEmy3K+pua seGiEfihIEHmrZtNqJHNzNPymzbFmWd15AnOUOgY+dpr2lSpgqFIBZiY+6154Rz+MhDv 0Qre5tLtGJU3DnXWJBTtSYk0n1GTsk9A70udMS8XSiAvx55Sz7bN7f7dt+ZGb9HPxv6l ibig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697721726; x=1698326526; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LK/A8QLl6mmZsiIVExfW0sdngxXHRyvJR8+2rskOKXw=; b=YrPx7OqZIbHTh2Xk/AmgMNr6ibbyNgKyn9s6lW89KGOJDp5yNgN9H+L/247JBNSXn0 JPuOhSAETQLZmMVcPJfdFtOhshNR0W8gt3POwpq6UViJChh7YJ3Ejxwj5W6ZgDQz4PHY d7Q2/MwMDaXBktNw6dWFL0PNSY255MThfj3z3vqbK9JAvSOAqZNAqtoGonuTle2Aj2Lh TjwC9EEYvlsSGfEgdt5ufPRoWBk0In8H823GSAXh/NvrMJCLtNnAMKKy/TeztN+nUE5F hJ13Inxte4sFKm4r/+lSwd8lz2gEBxk6i2D8Ne/hXpxdCsLivGk5mwlMJJvsPiN5XzsS 1cnw== X-Gm-Message-State: AOJu0YxU9p64oFpyetzgD7mGaM3OQPq0FivUzKGtet+d6BMQdhzlYokf aHuk9MSw+BzGrGXBs1FUfkBpFPQFIfVO0bR5A/z18w== X-Received: by 2002:a0d:d8cc:0:b0:5a7:afc9:3579 with SMTP id a195-20020a0dd8cc000000b005a7afc93579mr2270939ywe.18.1697721726120; Thu, 19 Oct 2023 06:22:06 -0700 (PDT) MIME-Version: 1.0 References: <9ebae0e9780745091274562a2b9afd856241dbdc.1697694811.git.quic_varada@quicinc.com> In-Reply-To: <9ebae0e9780745091274562a2b9afd856241dbdc.1697694811.git.quic_varada@quicinc.com> From: Dmitry Baryshkov Date: Thu, 19 Oct 2023 16:21:55 +0300 Message-ID: Subject: Re: [PATCH v4 5/9] clk: qcom: apss-ipq6018: ipq5332: add safe source switch for a53pll To: Varadarajan Narayanan Cc: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, ilia.lin@kernel.org, sivaprak@codeaurora.org, quic_kathirav@quicinc.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 06:22:31 -0700 (PDT) On Thu, 19 Oct 2023 at 11:42, Varadarajan Narayanan wrote: > > Stromer Plus PLL found on IPQ53xx doesn't support dynamic > frequency scaling. To achieve the same, we need to park the APPS > PLL source to GPLL0, re configure the PLL and then switch the > source to APSS_PLL_EARLY. > > To support this, register a clock notifier to get the PRE_RATE > and POST_RATE notification. Change the APSS PLL source to GPLL0 > when PRE_RATE notification is received, then configure the PLL > and then change back the source to APSS_PLL_EARLY. > > Additionally, not all SKUs of IPQ53xx support scaling. Hence, > do the above to the SKUs that support scaling. > > Signed-off-by: Kathiravan T > Signed-off-by: Varadarajan Narayanan > --- > v3: devm_kzalloc for cpu_clk_notifier instead of global static > v2: Handle ABORT_RATE_CHANGE > Use local variable for apcs_alias0_clk_src.clkr.hw > Use single line comment instead of multi line style > --- > drivers/clk/qcom/apss-ipq6018.c | 58 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/qcom/apss-ipq6018.c b/drivers/clk/qcom/apss-ipq6018.c > index 4e13a08..db65b0d 100644 > --- a/drivers/clk/qcom/apss-ipq6018.c > +++ b/drivers/clk/qcom/apss-ipq6018.c > @@ -9,8 +9,11 @@ > #include > #include > #include > +#include > +#include > > #include > +#include > > #include "common.h" > #include "clk-regmap.h" > @@ -84,15 +87,68 @@ static const struct qcom_cc_desc apss_ipq6018_desc = { > .num_clks = ARRAY_SIZE(apss_ipq6018_clks), > }; > > +static int cpu_clk_notifier_fn(struct notifier_block *nb, unsigned long action, > + void *data) > +{ > + struct clk_hw *hw; > + u8 index; > + int err; > + > + if (action == PRE_RATE_CHANGE) > + index = P_GPLL0; > + else if (action == POST_RATE_CHANGE || action == ABORT_RATE_CHANGE) > + index = P_APSS_PLL_EARLY; > + else > + return NOTIFY_OK; > + > + hw = &apcs_alias0_clk_src.clkr.hw; > + err = clk_rcg2_mux_closest_ops.set_parent(hw, index); > + > + return notifier_from_errno(err); > +} > + > static int apss_ipq6018_probe(struct platform_device *pdev) > { > + struct notifier_block *cpu_clk_notifier; > struct regmap *regmap; > + u32 soc_id; > + int ret; > + > + ret = qcom_smem_get_soc_id(&soc_id); > + if (ret) > + return ret; > > regmap = dev_get_regmap(pdev->dev.parent, NULL); > if (!regmap) > return -ENODEV; > > - return qcom_cc_really_probe(pdev, &apss_ipq6018_desc, regmap); > + ret = qcom_cc_really_probe(pdev, &apss_ipq6018_desc, regmap); > + if (ret) > + return ret; > + > + switch (soc_id) { > + /* Only below variants of IPQ53xx support scaling */ > + case QCOM_ID_IPQ5332: > + case QCOM_ID_IPQ5322: > + case QCOM_ID_IPQ5300: > + cpu_clk_notifier = devm_kzalloc(&pdev->dev, > + sizeof(*cpu_clk_notifier), > + GFP_KERNEL); > + if (!cpu_clk_notifier) > + return -ENOMEM; > + > + cpu_clk_notifier->notifier_call = cpu_clk_notifier_fn; > + > + ret = clk_notifier_register(apcs_alias0_clk_src.clkr.hw.clk, > + cpu_clk_notifier); devm_clk_notifier_register sounds more future-proof. Other than that: Reviewed-by: Dmitry Baryshkov > + if (ret) > + return ret; > + break; > + default: > + break; > + } > + > + return 0; > } > > static struct platform_driver apss_ipq6018_driver = { > -- > 2.7.4 > -- With best wishes Dmitry