Linux-Clk Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
@ 2019-08-27  8:17 Peng Fan
  2019-09-06 17:20 ` Stephen Boyd
  2019-09-09 11:44 ` Dong Aisheng
  0 siblings, 2 replies; 7+ messages in thread
From: Peng Fan @ 2019-08-27  8:17 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam, Aisheng Dong
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Peng Fan

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

There is hardware issue that:
The output clock the LPCG cell will not turn back on as expected,
even though a read of the IPG registers in the LPCG indicates that
the clock should be enabled.

The software workaround is to write twice to enable the LPCG clock
output.

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

diff --git a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-scu.c
index a73a799fb777..7391d0668ec4 100644
--- a/drivers/clk/imx/clk-lpcg-scu.c
+++ b/drivers/clk/imx/clk-lpcg-scu.c
@@ -54,6 +54,11 @@ static int clk_lpcg_scu_enable(struct clk_hw *hw)
 
 	reg |= val << clk->bit_idx;
 	writel(reg, clk->reg);
+	/*
+	 * There is hardware bug. When enabling the LPCG clock
+	 * output, SW can write the enabling value twice
+	 */
+	writel(reg, clk->reg);
 
 	spin_unlock_irqrestore(&imx_lpcg_scu_lock, flags);
 
@@ -71,6 +76,11 @@ 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);
+	/*
+	 * There is hardware bug. When enabling the LPCG clock
+	 * output, SW can write the enabling value twice
+	 */
+	writel(reg, clk->reg);
 
 	spin_unlock_irqrestore(&imx_lpcg_scu_lock, flags);
 }
-- 
2.16.4


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

* Re: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-08-27  8:17 [PATCH] clk: imx: lpcg: write twice when writing lpcg regs Peng Fan
@ 2019-09-06 17:20 ` Stephen Boyd
  2019-09-09 11:51   ` Dong Aisheng
  2019-09-09 11:44 ` Dong Aisheng
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Boyd @ 2019-09-06 17:20 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Aisheng Dong, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Peng Fan

Quoting Peng Fan (2019-08-27 01:17:50)
> From: Peng Fan <peng.fan@nxp.com>
> 
> There is hardware issue that:
> The output clock the LPCG cell will not turn back on as expected,
> even though a read of the IPG registers in the LPCG indicates that
> the clock should be enabled.
> 
> The software workaround is to write twice to enable the LPCG clock
> output.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Does this need a Fixes tag?


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

* Re: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-08-27  8:17 [PATCH] clk: imx: lpcg: write twice when writing lpcg regs Peng Fan
  2019-09-06 17:20 ` Stephen Boyd
@ 2019-09-09 11:44 ` Dong Aisheng
  1 sibling, 0 replies; 7+ messages in thread
From: Dong Aisheng @ 2019-09-09 11:44 UTC (permalink / raw)
  To: Peng Fan
  Cc: mturquette, sboyd, shawnguo, s.hauer, festevam, Aisheng Dong,
	kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel

On Tue, Aug 27, 2019 at 4:19 PM Peng Fan <peng.fan@nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> There is hardware issue that:
> The output clock the LPCG cell will not turn back on as expected,
> even though a read of the IPG registers in the LPCG indicates that
> the clock should be enabled.
>
> The software workaround is to write twice to enable the LPCG clock
> output.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>

Regards
Aisheng

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

* Re: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-09-06 17:20 ` Stephen Boyd
@ 2019-09-09 11:51   ` Dong Aisheng
  2019-09-10  2:47     ` Anson Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Dong Aisheng @ 2019-09-09 11:51 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: festevam, mturquette, s.hauer, shawnguo, Aisheng Dong, Peng Fan,
	kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel

On Sat, Sep 7, 2019 at 9:47 PM Stephen Boyd <sboyd@kernel.org> wrote:
>
> Quoting Peng Fan (2019-08-27 01:17:50)
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > There is hardware issue that:
> > The output clock the LPCG cell will not turn back on as expected,
> > even though a read of the IPG registers in the LPCG indicates that
> > the clock should be enabled.
> >
> > The software workaround is to write twice to enable the LPCG clock
> > output.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>
> Does this need a Fixes tag?

Not sure as it's not code logic issue but a hardware bug.
And 4.19 LTS still have not this driver support.

Regards
Aisheng

>

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

* RE: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-09-09 11:51   ` Dong Aisheng
@ 2019-09-10  2:47     ` Anson Huang
  2019-09-10 11:50       ` Daniel Baluta
  2019-09-13  3:42       ` Shawn Guo
  0 siblings, 2 replies; 7+ messages in thread
From: Anson Huang @ 2019-09-10  2:47 UTC (permalink / raw)
  To: Dong Aisheng, Stephen Boyd, Peng Fan
  Cc: festevam, mturquette, s.hauer, shawnguo, Aisheng Dong, Peng Fan,
	kernel, dl-linux-imx, Jacky Bai, Abel Vesa, linux-clk,
	linux-arm-kernel, linux-kernel



> On Sat, Sep 7, 2019 at 9:47 PM Stephen Boyd <sboyd@kernel.org> wrote:
> >
> > Quoting Peng Fan (2019-08-27 01:17:50)
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > There is hardware issue that:
> > > The output clock the LPCG cell will not turn back on as expected,
> > > even though a read of the IPG registers in the LPCG indicates that
> > > the clock should be enabled.
> > >
> > > The software workaround is to write twice to enable the LPCG clock
> > > output.
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> >
> > Does this need a Fixes tag?
> 
> Not sure as it's not code logic issue but a hardware bug.
> And 4.19 LTS still have not this driver support.

Looks like there is an errata for this issue, and Ranjani just sent a patch for review internally,

Back-to-back LPCG writes can be ignored by the LPCG register due to a 
HW bug. The writes need to be separated by atleast 4 cycles of the gated clock.
The workaround is implemented as follows:
1. For clocks running greater than 50MHz no delay is required as the 
delay in accessing the LPCG register is sufficient.
2. For clocks running greater than 23MHz, a read followed by the write 
will provide the sufficient delay.
3. For clocks running below 23MHz, LPCG is not used.

Need double check?

Anson.

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

* Re: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-09-10  2:47     ` Anson Huang
@ 2019-09-10 11:50       ` Daniel Baluta
  2019-09-13  3:42       ` Shawn Guo
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Baluta @ 2019-09-10 11:50 UTC (permalink / raw)
  To: Anson Huang
  Cc: Dong Aisheng, Stephen Boyd, Peng Fan, festevam, mturquette,
	s.hauer, shawnguo, Aisheng Dong, kernel, dl-linux-imx, Jacky Bai,
	Abel Vesa, linux-clk, linux-arm-kernel, linux-kernel

On Tue, Sep 10, 2019 at 1:40 PM Anson Huang <anson.huang@nxp.com> wrote:
>
>
>
> > On Sat, Sep 7, 2019 at 9:47 PM Stephen Boyd <sboyd@kernel.org> wrote:
> > >
> > > Quoting Peng Fan (2019-08-27 01:17:50)
> > > > From: Peng Fan <peng.fan@nxp.com>
> > > >
> > > > There is hardware issue that:
> > > > The output clock the LPCG cell will not turn back on as expected,
> > > > even though a read of the IPG registers in the LPCG indicates that
> > > > the clock should be enabled.
> > > >
> > > > The software workaround is to write twice to enable the LPCG clock
> > > > output.
> > > >
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > >
> > > Does this need a Fixes tag?
> >
> > Not sure as it's not code logic issue but a hardware bug.
> > And 4.19 LTS still have not this driver support.
>
> Looks like there is an errata for this issue, and Ranjani just sent a patch for review internally,
>
> Back-to-back LPCG writes can be ignored by the LPCG register due to a
> HW bug. The writes need to be separated by atleast 4 cycles of the gated clock.
> The workaround is implemented as follows:
> 1. For clocks running greater than 50MHz no delay is required as the
> delay in accessing the LPCG register is sufficient.
> 2. For clocks running greater than 23MHz, a read followed by the write
> will provide the sufficient delay.
> 3. For clocks running below 23MHz, LPCG is not used.

Lets add this information in the commit message and also
enhance the comment before the double write.

Also, why can't we add a udelay after the first write and remove
the second write as having two writes for writing a value looks
very un-natural.

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

* Re: [PATCH] clk: imx: lpcg: write twice when writing lpcg regs
  2019-09-10  2:47     ` Anson Huang
  2019-09-10 11:50       ` Daniel Baluta
@ 2019-09-13  3:42       ` Shawn Guo
  1 sibling, 0 replies; 7+ messages in thread
From: Shawn Guo @ 2019-09-13  3:42 UTC (permalink / raw)
  To: Anson Huang
  Cc: Dong Aisheng, Stephen Boyd, Peng Fan, festevam, mturquette,
	s.hauer, Aisheng Dong, kernel, dl-linux-imx, Jacky Bai,
	Abel Vesa, linux-clk, linux-arm-kernel, linux-kernel

On Tue, Sep 10, 2019 at 02:47:59AM +0000, Anson Huang wrote:
> 
> 
> > On Sat, Sep 7, 2019 at 9:47 PM Stephen Boyd <sboyd@kernel.org> wrote:
> > >
> > > Quoting Peng Fan (2019-08-27 01:17:50)
> > > > From: Peng Fan <peng.fan@nxp.com>
> > > >
> > > > There is hardware issue that:
> > > > The output clock the LPCG cell will not turn back on as expected,
> > > > even though a read of the IPG registers in the LPCG indicates that
> > > > the clock should be enabled.
> > > >
> > > > The software workaround is to write twice to enable the LPCG clock
> > > > output.
> > > >
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > >
> > > Does this need a Fixes tag?
> > 
> > Not sure as it's not code logic issue but a hardware bug.
> > And 4.19 LTS still have not this driver support.
> 
> Looks like there is an errata for this issue, and Ranjani just sent a patch for review internally,

Having errata number in both commit log and code comment is generally
helpful.

Shawn

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  8:17 [PATCH] clk: imx: lpcg: write twice when writing lpcg regs Peng Fan
2019-09-06 17:20 ` Stephen Boyd
2019-09-09 11:51   ` Dong Aisheng
2019-09-10  2:47     ` Anson Huang
2019-09-10 11:50       ` Daniel Baluta
2019-09-13  3:42       ` Shawn Guo
2019-09-09 11:44 ` Dong Aisheng

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org linux-clk@archiver.kernel.org
	public-inbox-index linux-clk

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/ public-inbox