All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacky Bai <ping.bai@nxp.com>
To: shawnguo@kernel.org, robh+dt@kernel.org, sboyd@kernel.org,
	abel.vesa@nxp.com, s.hauer@pengutronix.de,
	p.zabel@pengutronix.de
Cc: kernel@pengutronix.de, linux-imx@nxp.com,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org
Subject: [PATCH 6/9] clk: imx: disable the pfd when set pfdv2 clock rate
Date: Mon, 19 Jul 2021 13:34:27 +0800	[thread overview]
Message-ID: <20210719053430.1442505-7-ping.bai@nxp.com> (raw)
In-Reply-To: <20210719053430.1442505-1-ping.bai@nxp.com>

It is possible that a PFD is enabled in HW but not in SW. That
means the enable count & prepare count of the PFD clock is '0',
so the 'CLK_SET_RATE' flag can do nothing when the rate is changed
while the PFD is hw enabled. In order to safely change the pfd
rate, we can disable the PFD directly if it is hw enabled but not
used by SW end user.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
---
 drivers/clk/imx/clk-pfdv2.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/imx/clk-pfdv2.c b/drivers/clk/imx/clk-pfdv2.c
index 6b744c84278e..9cba83521988 100644
--- a/drivers/clk/imx/clk-pfdv2.c
+++ b/drivers/clk/imx/clk-pfdv2.c
@@ -161,8 +161,17 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (!rate)
 		return -EINVAL;
 
-	/* PFD can NOT change rate without gating */
-	WARN_ON(clk_pfdv2_is_enabled(hw));
+	/*
+	 * PFD can NOT change rate without gating.
+	 * as the PFDs may enabled in HW by default but no
+	 * consumer used it, the enable count is '0', so the
+	 * 'SET_RATE_GATE' can NOT help on blocking the set_rate
+	 * ops especially for 'assigned-clock-xxx'. In order
+	 * to simplify the case, just disable the PFD if it is
+	 * enabled in HW but not in SW.
+	 */
+	if (clk_pfdv2_is_enabled(hw))
+		clk_pfdv2_disable(hw);
 
 	tmp = tmp * 18 + rate / 2;
 	do_div(tmp, rate);
-- 
2.26.2


  parent reply	other threads:[~2021-07-19  5:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  5:34 [PATCH 0/9] Add imx8ulp clock & reset driver support Jacky Bai
2021-07-19  5:34 ` [PATCH 1/9] dt-bindings: clock: Add imx8ulp clock support Jacky Bai
2021-07-29 18:55   ` Rob Herring
2021-07-30 10:05     ` Jacky Bai
2021-07-19  5:34 ` [PATCH 2/9] clk: imx: Update the pllv4 to support imx8ulp Jacky Bai
2021-07-19  5:34 ` [PATCH 3/9] clk: imx: Update the compsite driver " Jacky Bai
2021-07-19  5:34 ` [PATCH 4/9] clk: imx: disable i.mx7ulp composite clock during initialization Jacky Bai
2021-07-19  5:34 ` [PATCH 5/9] clk: imx: Add 'CLK_SET_RATE_NO_REPARENT' for composite-7ulp Jacky Bai
2021-07-19  5:34 ` Jacky Bai [this message]
2021-07-19  5:34 ` [PATCH 7/9] clk: imx: Update the pfdv2 for 8ulp specific support Jacky Bai
2021-07-19  5:34 ` [PATCH 8/9] clk: imx: Add clock driver for imx8ulp Jacky Bai
2021-07-19  5:34 ` [PATCH 9/9] clk: imx: Add the pcc reset controller support on imx8ulp Jacky Bai
2021-07-19  6:23   ` Liu Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210719053430.1442505-7-ping.bai@nxp.com \
    --to=ping.bai@nxp.com \
    --cc=abel.vesa@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.