* [PATCH 2/2] ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate
@ 2013-05-22 22:10 Guennadi Liakhovetski
2013-05-25 0:58 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Guennadi Liakhovetski @ 2013-05-22 22:10 UTC (permalink / raw)
To: linux-sh
According to the datasheet, it is not allowed to change div4 clock rates
if an earlier rate change operation is still in progress, as indicated by
a set kick bit.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
arch/arm/mach-shmobile/clock-sh73a0.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 8cb6738..2ef27a6 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -257,7 +257,7 @@ static struct clk twd_clk = {
.ops = &twd_clk_ops,
};
-static struct sh_clk_ops zclk_ops;
+static struct sh_clk_ops zclk_ops, kicker_ops;
static const struct sh_clk_ops *div4_clk_ops;
static int zclk_set_rate(struct clk *clk, unsigned long rate)
@@ -326,18 +326,32 @@ static unsigned long zclk_recalc(struct clk *clk)
return clk_get_rate(clk->parent);
}
-static void zclk_extend(void)
+static int kicker_set_rate(struct clk *clk, unsigned long rate)
{
- div4_clk_ops = div4_clks[DIV4_Z].ops;
+ if (__raw_readl(FRQCRB) & (1 << 31))
+ return -EBUSY;
+ return div4_clk_ops->set_rate(clk, rate);
+}
+
+static void div4_clk_extend(void)
+{
+ int i;
+
+ div4_clk_ops = div4_clks[0].ops;
+
+ /* Add a kicker-busy check before changing the rate */
+ kicker_ops = *div4_clk_ops;
/* We extend the DIV4 clock with a 1:1 pass-through case */
zclk_ops = *div4_clk_ops;
+ kicker_ops.set_rate = kicker_set_rate;
zclk_ops.set_rate = zclk_set_rate;
zclk_ops.round_rate = zclk_round_rate;
zclk_ops.recalc = zclk_recalc;
- div4_clks[DIV4_Z].ops = &zclk_ops;
+ for (i = 0; i < DIV4_NR; i++)
+ div4_clks[i].ops = i = DIV4_Z ? &zclk_ops : &kicker_ops;
}
enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_ZB1,
@@ -702,7 +716,7 @@ void __init sh73a0_clock_init(void)
if (!ret) {
ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
if (!ret)
- zclk_extend();
+ div4_clk_extend();
}
if (!ret)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate
2013-05-22 22:10 [PATCH 2/2] ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate Guennadi Liakhovetski
@ 2013-05-25 0:58 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2013-05-25 0:58 UTC (permalink / raw)
To: linux-sh
On Thu, May 23, 2013 at 12:10:00AM +0200, Guennadi Liakhovetski wrote:
> According to the datasheet, it is not allowed to change div4 clock rates
> if an earlier rate change operation is still in progress, as indicated by
> a set kick bit.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> ---
> arch/arm/mach-shmobile/clock-sh73a0.c | 24 +++++++++++++++++++-----
> 1 files changed, 19 insertions(+), 5 deletions(-)
Thanks Guennadi,
I will queue this up in the soc-sh73a0 branch for v3.11.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-25 0:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22 22:10 [PATCH 2/2] ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate Guennadi Liakhovetski
2013-05-25 0:58 ` Simon Horman
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).