linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] clk: imx: scu and fracn pll update
@ 2024-10-14  9:11 Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2024-10-14  9:11 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Aisheng Dong
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan,
	Jacky Bai

Patch 1 is to resubmit [1] with comments addressed.
Patch 2 is for hdmi. Fix tag not needed.
Patch 3 and Patch 4 are for i.MX93 Fracn PLL fix.
In Patch 4:
fence_write is reusing the idea of fence_udelay in drivers/clk/tegra/clk.h

Detailed information is in commit log of each patch.

[1] https://lore.kernel.org/lkml/20240228082649.1633083-1-peng.fan@oss.nxp.com/

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (4):
      clk: imx: lpcg-scu: SW workaround for errata (e10858)
      clk: imx: lpcg-scu: Skip HDMI LPCG clock save/restore
      clk: imx: fracn-gppll: correct PLL initialization flow
      clk: imx: fracn-gppll: fix pll power up

 drivers/clk/imx/clk-fracn-gppll.c | 20 +++++++++++++-------
 drivers/clk/imx/clk-lpcg-scu.c    | 40 +++++++++++++++++++++++++++++++++++----
 2 files changed, 49 insertions(+), 11 deletions(-)
---
base-commit: d61a00525464bfc5fe92c6ad713350988e492b88
change-id: 20241014-imx-clk-v1-24c26cfa1d79

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858)
  2024-10-14  9:11 [PATCH 0/4] clk: imx: scu and fracn pll update Peng Fan (OSS)
@ 2024-10-14  9:11 ` Peng Fan (OSS)
  2024-10-14 14:20   ` Fabio Estevam
  2024-10-16 21:46   ` Stephen Boyd
  2024-10-14  9:11 ` [PATCH 2/4] clk: imx: lpcg-scu: Skip HDMI LPCG clock save/restore Peng Fan (OSS)
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2024-10-14  9:11 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Aisheng Dong
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Back-to-back LPCG writes can be ignored by the LPCG register due to
a HW bug. The writes need to be separated by at least 4 cycles of
the gated clock.

The workaround is implemented as follows:
1. For clocks running greater than or equal to 24MHz, a read
followed by the write will provide sufficient delay.
2. For clocks running below 24MHz, add a delay of 4 clock cylces
after the write to the LPCG register.

Fixes: 2f77296d3df9 ("clk: imx: add lpcg clock support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-lpcg-scu.c | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-scu.c
index dd5abd09f3e206a5073767561b517d5b3320b28c..2cffec0c42dccc256e8dc5e9181952e250870a76 100644
--- a/drivers/clk/imx/clk-lpcg-scu.c
+++ b/drivers/clk/imx/clk-lpcg-scu.c
@@ -6,6 +6,7 @@
 
 #include <linux/bits.h>
 #include <linux/clk-provider.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/slab.h>
@@ -41,6 +42,31 @@ struct clk_lpcg_scu {
 
 #define to_clk_lpcg_scu(_hw) container_of(_hw, struct clk_lpcg_scu, hw)
 
+/* e10858 -LPCG clock gating register synchronization errata */
+static void lpcg_e10858_writel(ulong rate, void __iomem *reg, u32 val)
+{
+	u32 reg1;
+
+	writel(val, reg);
+
+	if (rate >= 24000000 || rate == 0) {
+		/*
+		 * The time taken to access the LPCG registers from the AP core
+		 * through the interconnect is longer than the minimum delay
+		 * of 4 clock cycles required by the errata.
+		 * Adding a readl will provide sufficient delay to prevent
+		 * back-to-back writes.
+		 */
+		reg1 = readl(reg);
+	} else {
+		/*
+		 * For clocks running below 24MHz, wait a minimum of
+		 * 4 clock cycles.
+		 */
+		ndelay(4 * (DIV_ROUND_UP(1000000000, rate)));
+	}
+}
+
 static int clk_lpcg_scu_enable(struct clk_hw *hw)
 {
 	struct clk_lpcg_scu *clk = to_clk_lpcg_scu(hw);
@@ -57,7 +83,8 @@ static int clk_lpcg_scu_enable(struct clk_hw *hw)
 		val |= CLK_GATE_SCU_LPCG_HW_SEL;
 
 	reg |= val << clk->bit_idx;
-	writel(reg, clk->reg);
+
+	lpcg_e10858_writel(clk_hw_get_rate(hw), clk->reg, reg);
 
 	spin_unlock_irqrestore(&imx_lpcg_scu_lock, flags);
 
@@ -74,7 +101,7 @@ static void clk_lpcg_scu_disable(struct clk_hw *hw)
 
 	reg = readl_relaxed(clk->reg);
 	reg &= ~(CLK_GATE_SCU_LPCG_MASK << clk->bit_idx);
-	writel(reg, clk->reg);
+	lpcg_e10858_writel(clk_hw_get_rate(hw), clk->reg, reg);
 
 	spin_unlock_irqrestore(&imx_lpcg_scu_lock, flags);
 }
@@ -149,9 +176,8 @@ static int __maybe_unused imx_clk_lpcg_scu_resume(struct device *dev)
 	 * FIXME: Sometimes writes don't work unless the CPU issues
 	 * them twice
 	 */
-
-	writel(clk->state, clk->reg);
 	writel(clk->state, clk->reg);
+	lpcg_e10858_writel(0, clk->reg, clk->state);
 	dev_dbg(dev, "restore lpcg state 0x%x\n", clk->state);
 
 	return 0;

-- 
2.37.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] clk: imx: lpcg-scu: Skip HDMI LPCG clock save/restore
  2024-10-14  9:11 [PATCH 0/4] clk: imx: scu and fracn pll update Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
@ 2024-10-14  9:11 ` Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 3/4] clk: imx: fracn-gppll: correct PLL initialization flow Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up Peng Fan (OSS)
  3 siblings, 0 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2024-10-14  9:11 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Aisheng Dong
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

On i.MX8QM, HDMI LPCG clocks operation needs SCU clock "hdmi_ipg_clk"
to be ON. While during noirq suspend phase, "hdmi_ipg_clk" is disabled
by HDMI IRQ STEER driver, so SError will be triggered when accessing
the HDMI LPCG registers.

Skip all HDMI LPCG clocks save/restore to avoid SError during
system suspend/resume, it will NOT introduce additional power consumption
as their parent clock is disabled when suspend.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-lpcg-scu.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-scu.c
index 2cffec0c42dccc256e8dc5e9181952e250870a76..466c0de11ca7d5af42a5ec34fb197dc90b1742b1 100644
--- a/drivers/clk/imx/clk-lpcg-scu.c
+++ b/drivers/clk/imx/clk-lpcg-scu.c
@@ -162,6 +162,9 @@ static int __maybe_unused imx_clk_lpcg_scu_suspend(struct device *dev)
 {
 	struct clk_lpcg_scu *clk = dev_get_drvdata(dev);
 
+	if (!strncmp("hdmi_lpcg", clk_hw_get_name(&clk->hw), strlen("hdmi_lpcg")))
+		return 0;
+
 	clk->state = readl_relaxed(clk->reg);
 	dev_dbg(dev, "save lpcg state 0x%x\n", clk->state);
 
@@ -172,6 +175,9 @@ static int __maybe_unused imx_clk_lpcg_scu_resume(struct device *dev)
 {
 	struct clk_lpcg_scu *clk = dev_get_drvdata(dev);
 
+	if (!strncmp("hdmi_lpcg", clk_hw_get_name(&clk->hw), strlen("hdmi_lpcg")))
+		return 0;
+
 	/*
 	 * FIXME: Sometimes writes don't work unless the CPU issues
 	 * them twice

-- 
2.37.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] clk: imx: fracn-gppll: correct PLL initialization flow
  2024-10-14  9:11 [PATCH 0/4] clk: imx: scu and fracn pll update Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 2/4] clk: imx: lpcg-scu: Skip HDMI LPCG clock save/restore Peng Fan (OSS)
@ 2024-10-14  9:11 ` Peng Fan (OSS)
  2024-10-14  9:11 ` [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up Peng Fan (OSS)
  3 siblings, 0 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2024-10-14  9:11 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Aisheng Dong
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan,
	Jacky Bai

From: Peng Fan <peng.fan@nxp.com>

Per i.MX93 Reference Mannual 22.4 Initialization information
1. Program appropriate value of DIV[ODIV], DIV[RDIV] and DIV[MFI]
   as per Integer mode.
2. Wait for 5 μs.
3. Program the following field in CTRL register.
   Set CTRL[POWERUP] to 1'b1 to enable PLL block.
4. Poll PLL_STATUS[PLL_LOCK] register, and wait till PLL_STATUS[PLL_LOCK]
   is 1'b1 and pll_lock output signal is 1'b1.
5. Set CTRL[CLKMUX_EN] to 1'b1 to enable PLL output clock.

So move the CLKMUX_EN operation after PLL locked.

Fixes: 1b26cb8a77a4 ("clk: imx: support fracn gppll")
Co-developed-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-fracn-gppll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/imx/clk-fracn-gppll.c b/drivers/clk/imx/clk-fracn-gppll.c
index 591e0364ee5c113859a7b6271c8c11e98a0e0ffc..4749c3e0b7051cf53876664808aa28742f6861f7 100644
--- a/drivers/clk/imx/clk-fracn-gppll.c
+++ b/drivers/clk/imx/clk-fracn-gppll.c
@@ -303,13 +303,13 @@ static int clk_fracn_gppll_prepare(struct clk_hw *hw)
 	val |= POWERUP_MASK;
 	writel_relaxed(val, pll->base + PLL_CTRL);
 
-	val |= CLKMUX_EN;
-	writel_relaxed(val, pll->base + PLL_CTRL);
-
 	ret = clk_fracn_gppll_wait_lock(pll);
 	if (ret)
 		return ret;
 
+	val |= CLKMUX_EN;
+	writel_relaxed(val, pll->base + PLL_CTRL);
+
 	val &= ~CLKMUX_BYPASS;
 	writel_relaxed(val, pll->base + PLL_CTRL);
 

-- 
2.37.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up
  2024-10-14  9:11 [PATCH 0/4] clk: imx: scu and fracn pll update Peng Fan (OSS)
                   ` (2 preceding siblings ...)
  2024-10-14  9:11 ` [PATCH 3/4] clk: imx: fracn-gppll: correct PLL initialization flow Peng Fan (OSS)
@ 2024-10-14  9:11 ` Peng Fan (OSS)
  2024-10-16 21:49   ` Stephen Boyd
  3 siblings, 1 reply; 9+ messages in thread
From: Peng Fan (OSS) @ 2024-10-14  9:11 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Aisheng Dong
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan,
	Jacky Bai

From: Peng Fan <peng.fan@nxp.com>

To i.MX93 which features dual Cortex-A55 cores and DSU, when using
writel_relaxed to write value to PLL registers, the value might be
buffered. To make sure the value has been written into the hardware,
using readl to read back the register could make sure the value
written into hardware.

current PLL power up flow can be simplified as below:
  1. writel_relaxed to set the PLL POWERUP bit;
  2. readl_poll_timeout to check the PLL lock bit:
     a). timeout = ktime_add_us(ktime_get(), timeout_us);
     b). readl the pll the lock reg;
     c). check if the pll lock bit ready
     d). check if timeout

But in some corner cases, both the write in step 1 and read in
step 2 will be blocked by other bus transaction in the SoC for a
long time, saying the value into real hardware is just before step b).
That means the timeout counting has begins for quite sometime since
step a), but value still not written into real hardware until bus
released just at a point before step b).

Then there maybe chances that the pll lock bit is not ready
when readl done but the timeout happens. readl_poll_timeout will
err return due to timeout. To avoid such unexpected failure,
read back the reg to make sure the write has been done in HW
reg.

Introduce fence_write for this purpose.

Since we are here, to avoid udelay to run before writel_relaxed, use
fence_write before udelay.

Fixes: 1b26cb8a77a4 ("clk: imx: support fracn gppll")
Co-developed-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-fracn-gppll.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/imx/clk-fracn-gppll.c b/drivers/clk/imx/clk-fracn-gppll.c
index 4749c3e0b7051cf53876664808aa28742f6861f7..6a4b3745d3d9aa1b583c9bd390c884bcb689e4c7 100644
--- a/drivers/clk/imx/clk-fracn-gppll.c
+++ b/drivers/clk/imx/clk-fracn-gppll.c
@@ -63,6 +63,12 @@
 		.odiv	=	(_odiv),			\
 	}
 
+#define fence_write(val, reg)			\
+	do {					\
+		writel_relaxed(val, reg);	\
+		readl(reg);			\
+	} while (0)
+
 struct clk_fracn_gppll {
 	struct clk_hw			hw;
 	void __iomem			*base;
@@ -253,10 +259,10 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate,
 
 	pll_div = FIELD_PREP(PLL_RDIV_MASK, rate->rdiv) | rate->odiv |
 		FIELD_PREP(PLL_MFI_MASK, rate->mfi);
-	writel_relaxed(pll_div, pll->base + PLL_DIV);
+	fence_write(pll_div, pll->base + PLL_DIV);
 	if (pll->flags & CLK_FRACN_GPPLL_FRACN) {
 		writel_relaxed(rate->mfd, pll->base + PLL_DENOMINATOR);
-		writel_relaxed(FIELD_PREP(PLL_MFN_MASK, rate->mfn), pll->base + PLL_NUMERATOR);
+		fence_write(FIELD_PREP(PLL_MFN_MASK, rate->mfn), pll->base + PLL_NUMERATOR);
 	}
 
 	/* Wait for 5us according to fracn mode pll doc */
@@ -264,7 +270,7 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate,
 
 	/* Enable Powerup */
 	tmp |= POWERUP_MASK;
-	writel_relaxed(tmp, pll->base + PLL_CTRL);
+	fence_write(tmp, pll->base + PLL_CTRL);
 
 	/* Wait Lock */
 	ret = clk_fracn_gppll_wait_lock(pll);
@@ -301,7 +307,7 @@ static int clk_fracn_gppll_prepare(struct clk_hw *hw)
 	writel_relaxed(val, pll->base + PLL_CTRL);
 
 	val |= POWERUP_MASK;
-	writel_relaxed(val, pll->base + PLL_CTRL);
+	fence_write(val, pll->base + PLL_CTRL);
 
 	ret = clk_fracn_gppll_wait_lock(pll);
 	if (ret)

-- 
2.37.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858)
  2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
@ 2024-10-14 14:20   ` Fabio Estevam
  2024-10-15  2:25     ` Peng Fan
  2024-10-16 21:46   ` Stephen Boyd
  1 sibling, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2024-10-14 14:20 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Aisheng Dong, linux-clk,
	imx, linux-arm-kernel, linux-kernel, Peng Fan

On Mon, Oct 14, 2024 at 6:03 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:

> +/* e10858 -LPCG clock gating register synchronization errata */

Please share the link to the errata doc that contains this e10858.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858)
  2024-10-14 14:20   ` Fabio Estevam
@ 2024-10-15  2:25     ` Peng Fan
  0 siblings, 0 replies; 9+ messages in thread
From: Peng Fan @ 2024-10-15  2:25 UTC (permalink / raw)
  To: Fabio Estevam, Peng Fan (OSS)
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Aisheng Dong,
	linux-clk@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

> Subject: Re: [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata
> (e10858)
> 
> On Mon, Oct 14, 2024 at 6:03 AM Peng Fan (OSS)
> <peng.fan@oss.nxp.com> wrote:
> 
> > +/* e10858 -LPCG clock gating register synchronization errata */
> 
> Please share the link to the errata doc that contains this e10858.

https://www.nxp.com.cn/docs/en/errata/IMX8_1N94W.pdf

Thanks,
Peng.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858)
  2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
  2024-10-14 14:20   ` Fabio Estevam
@ 2024-10-16 21:46   ` Stephen Boyd
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2024-10-16 21:46 UTC (permalink / raw)
  To: Abel Vesa, Aisheng Dong, Fabio Estevam, Michael Turquette,
	Peng Fan, Pengutronix Kernel Team, Sascha Hauer, Shawn Guo
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan

Quoting Peng Fan (OSS) (2024-10-14 02:11:22)
> diff --git a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-scu.c
> index dd5abd09f3e206a5073767561b517d5b3320b28c..2cffec0c42dccc256e8dc5e9181952e250870a76 100644
> --- a/drivers/clk/imx/clk-lpcg-scu.c
> +++ b/drivers/clk/imx/clk-lpcg-scu.c
> @@ -6,6 +6,7 @@
>  
>  #include <linux/bits.h>
>  #include <linux/clk-provider.h>
> +#include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> @@ -41,6 +42,31 @@ struct clk_lpcg_scu {
>  
>  #define to_clk_lpcg_scu(_hw) container_of(_hw, struct clk_lpcg_scu, hw)
>  
> +/* e10858 -LPCG clock gating register synchronization errata */
> +static void lpcg_e10858_writel(ulong rate, void __iomem *reg, u32 val)

s/ulong/unsigned long/

> +{
> +       u32 reg1;
> +
> +       writel(val, reg);
> +
> +       if (rate >= 24000000 || rate == 0) {

Can be '24 * HZ_PER_MHZ'

> +               /*
> +                * The time taken to access the LPCG registers from the AP core
> +                * through the interconnect is longer than the minimum delay
> +                * of 4 clock cycles required by the errata.
> +                * Adding a readl will provide sufficient delay to prevent
> +                * back-to-back writes.
> +                */
> +               reg1 = readl(reg);
> +       } else {
> +               /*
> +                * For clocks running below 24MHz, wait a minimum of
> +                * 4 clock cycles.
> +                */
> +               ndelay(4 * (DIV_ROUND_UP(1000000000, rate)));

Can be '1000 * HZ_PER_MHZ'


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up
  2024-10-14  9:11 ` [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up Peng Fan (OSS)
@ 2024-10-16 21:49   ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2024-10-16 21:49 UTC (permalink / raw)
  To: Abel Vesa, Aisheng Dong, Fabio Estevam, Michael Turquette,
	Peng Fan, Pengutronix Kernel Team, Sascha Hauer, Shawn Guo
  Cc: linux-clk, imx, linux-arm-kernel, linux-kernel, Peng Fan,
	Jacky Bai

Quoting Peng Fan (OSS) (2024-10-14 02:11:25)
> From: Peng Fan <peng.fan@nxp.com>
> 
> To i.MX93 which features dual Cortex-A55 cores and DSU, when using
> writel_relaxed to write value to PLL registers, the value might be
> buffered. To make sure the value has been written into the hardware,
> using readl to read back the register could make sure the value
> written into hardware.
> 
> current PLL power up flow can be simplified as below:
>   1. writel_relaxed to set the PLL POWERUP bit;
>   2. readl_poll_timeout to check the PLL lock bit:
>      a). timeout = ktime_add_us(ktime_get(), timeout_us);
>      b). readl the pll the lock reg;
>      c). check if the pll lock bit ready
>      d). check if timeout
> 
> But in some corner cases, both the write in step 1 and read in
> step 2 will be blocked by other bus transaction in the SoC for a
> long time, saying the value into real hardware is just before step b).
> That means the timeout counting has begins for quite sometime since
> step a), but value still not written into real hardware until bus
> released just at a point before step b).
> 
> Then there maybe chances that the pll lock bit is not ready
> when readl done but the timeout happens. readl_poll_timeout will
> err return due to timeout. To avoid such unexpected failure,
> read back the reg to make sure the write has been done in HW
> reg.
> 
> Introduce fence_write for this purpose.

Please just write out the readl() instead of introducing a bespoke macro
that isn't generic for all architectures.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-10-16 21:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14  9:11 [PATCH 0/4] clk: imx: scu and fracn pll update Peng Fan (OSS)
2024-10-14  9:11 ` [PATCH 1/4] clk: imx: lpcg-scu: SW workaround for errata (e10858) Peng Fan (OSS)
2024-10-14 14:20   ` Fabio Estevam
2024-10-15  2:25     ` Peng Fan
2024-10-16 21:46   ` Stephen Boyd
2024-10-14  9:11 ` [PATCH 2/4] clk: imx: lpcg-scu: Skip HDMI LPCG clock save/restore Peng Fan (OSS)
2024-10-14  9:11 ` [PATCH 3/4] clk: imx: fracn-gppll: correct PLL initialization flow Peng Fan (OSS)
2024-10-14  9:11 ` [PATCH 4/4] clk: imx: fracn-gppll: fix pll power up Peng Fan (OSS)
2024-10-16 21:49   ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).