All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@nxp.com>
To: Jacky Bai <ping.bai@nxp.com>
Cc: shawnguo@kernel.org, robh+dt@kernel.org, sboyd@kernel.org,
	s.hauer@pengutronix.de, p.zabel@pengutronix.de,
	kernel@pengutronix.de, linux-imx@nxp.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v3 4/9] clk: imx: disable i.mx7ulp composite clock during initialization
Date: Tue, 14 Sep 2021 14:32:42 +0300	[thread overview]
Message-ID: <YUCIWg2e/inua6GB@ryzen> (raw)
In-Reply-To: <20210914065208.3582128-5-ping.bai@nxp.com>

On 21-09-14 14:52:03, Jacky Bai wrote:
> From: Anson Huang <Anson.Huang@nxp.com>
> 
> i.MX7ULP peripheral clock ONLY allow parent/rate to be changed
> with clock gated, however, during clock tree initialization, the
> peripheral clock could be enabled by bootloader, but the prepare
> count in clock tree is still zero, so clock core driver will allow
> parent/rate changed even with CLK_SET_RATE_GATE/CLK_SET_PARENT_GATE
> set, but the change will fail due to HW NOT allow parent/rate change
> with clock enabled. It will cause clock HW status mismatch with
> clock tree info and lead to function issue. Below is an example:
> 
> usdhc0's pcc clock value is 0xC5000000 during kernel boot up, it
> means usdhc0 clock is enabled, its parent is APLL_PFD1. In DT file,
> the usdhc0 clock settings are as below:
> 
> assigned-clocks = <&pcc2 IMX7ULP_CLK_USDHC0>;
> assigned-clock-parents = <&scg1 IMX7ULP_CLK_NIC1_DIV>;
> 
> when kernel boot up, the clock tree info is as below, but the usdhc0
> PCC register is still 0xC5000000, which means its parent is still
> from APLL_PFD1, which is incorrect and cause usdhc0 NOT work.
> 
> nic1_clk       2        2        0   176000000          0     0  50000
>     usdhc0       0        0        0   176000000          0     0  50000
> 
> After making sure the peripheral clock is disabled during clock tree
> initialization, the usdhc0 is working, and this change is necessary
> for all i.MX7ULP peripheral clocks.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>

Reviewed-by: Abel Vesa <abel.vesa@nxp.com>

> ---
>   v3 changes: no
> ---
>  drivers/clk/imx/clk-composite-7ulp.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c
> index 50ed383320bf..92908ee4509d 100644
> --- a/drivers/clk/imx/clk-composite-7ulp.c
> +++ b/drivers/clk/imx/clk-composite-7ulp.c
> @@ -8,6 +8,7 @@
>  #include <linux/bits.h>
>  #include <linux/clk-provider.h>
>  #include <linux/err.h>
> +#include <linux/io.h>
>  #include <linux/slab.h>
>  
>  #include "../clk-fractional-divider.h"
> @@ -73,6 +74,7 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,
>  	struct clk_gate *gate = NULL;
>  	struct clk_mux *mux = NULL;
>  	struct clk_hw *hw;
> +	u32 val;
>  
>  	if (mux_present) {
>  		mux = kzalloc(sizeof(*mux), GFP_KERNEL);
> @@ -111,6 +113,18 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name,
>  		gate_hw = &gate->hw;
>  		gate->reg = reg;
>  		gate->bit_idx = PCG_CGC_SHIFT;
> +		/*
> +		 * make sure clock is gated during clock tree initialization,
> +		 * the HW ONLY allow clock parent/rate changed with clock gated,
> +		 * during clock tree initialization, clocks could be enabled
> +		 * by bootloader, so the HW status will mismatch with clock tree
> +		 * prepare count, then clock core driver will allow parent/rate
> +		 * change since the prepare count is zero, but HW actually
> +		 * prevent the parent/rate change due to the clock is enabled.
> +		 */
> +		val = readl_relaxed(reg);
> +		val &= ~(1 << PCG_CGC_SHIFT);
> +		writel_relaxed(val, reg);
>  	}
>  
>  	hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
> -- 
> 2.26.2
> 

  reply	other threads:[~2021-09-14 11:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  6:51 [PATCH v3 0/9] Add imx8ulp clock & reset driver support Jacky Bai
2021-09-14  6:52 ` [PATCH v3 1/9] dt-bindings: clock: Add imx8ulp clock support Jacky Bai
2021-09-14 11:25   ` Abel Vesa
2021-09-14 13:11     ` Jacky Bai
2021-09-14 15:30       ` Abel Vesa
2021-09-20 21:44         ` Rob Herring
2021-09-14  6:52 ` [PATCH v3 2/9] clk: imx: Update the pllv4 to support imx8ulp Jacky Bai
2021-09-14 11:29   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 3/9] clk: imx: Update the compsite driver " Jacky Bai
2021-09-14 11:30   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 4/9] clk: imx: disable i.mx7ulp composite clock during initialization Jacky Bai
2021-09-14 11:32   ` Abel Vesa [this message]
2021-09-14  6:52 ` [PATCH v3 5/9] clk: imx: Add 'CLK_SET_RATE_NO_REPARENT' for composite-7ulp Jacky Bai
2021-09-14 11:33   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 6/9] clk: imx: disable the pfd when set pfdv2 clock rate Jacky Bai
2021-09-14 11:34   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 7/9] clk: imx: Update the pfdv2 for 8ulp specific support Jacky Bai
2021-09-14 11:35   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 8/9] clk: imx: Add clock driver for imx8ulp Jacky Bai
2021-09-14 11:55   ` Abel Vesa
2021-09-14  6:52 ` [PATCH v3 9/9] clk: imx: Add the pcc reset controller support on imx8ulp Jacky Bai
2021-09-14 12:09   ` Abel Vesa
2021-09-14 13:07     ` Jacky Bai
2021-09-14 15:19       ` Abel Vesa
2021-09-14 11:17 ` [PATCH v3 0/9] Add imx8ulp clock & reset driver support Abel Vesa
2021-09-16  6:46 ` Abel Vesa

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=YUCIWg2e/inua6GB@ryzen \
    --to=abel.vesa@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=p.zabel@pengutronix.de \
    --cc=ping.bai@nxp.com \
    --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.