diff mbox

[v3,1/3] ARM: shmobile: sh73a0: wait for completion when kicking the clock

Message ID 1362054120-8600-2-git-send-email-g.liakhovetski@gmx.de (mailing list archive)
State Superseded
Commit 92140169bd1b9c192ddc6d5d439d07e6f783a5dd
Headers show

Commit Message

Guennadi Liakhovetski Feb. 28, 2013, 12:21 p.m. UTC
To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to
be set and to make sure the setting has taken effect, it has to be read
back repeatedly until it is cleared by the hardware. This patch adds the
waiting part, that was missing until now.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

As noted in patch 0/3, this patch affects existing systems, but AFAICS 
only theoretically - so far nobody is changing clock rates of any of the 
FRQCRA and FRQCRB clocks. Still, please, handle with care.

 arch/arm/mach-shmobile/clock-sh73a0.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

Comments

Simon Horman March 1, 2013, 2:52 a.m. UTC | #1
On Thu, Feb 28, 2013 at 01:21:58PM +0100, Guennadi Liakhovetski wrote:
> To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to
> be set and to make sure the setting has taken effect, it has to be read
> back repeatedly until it is cleared by the hardware. This patch adds the
> waiting part, that was missing until now.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

This patch seems to be ready to be applied.

Magnus, could I get a review from you?

> ---
> 
> As noted in patch 0/3, this patch affects existing systems, but AFAICS 
> only theoretically - so far nobody is changing clock rates of any of the 
> FRQCRA and FRQCRB clocks. Still, please, handle with care.
> 
>  arch/arm/mach-shmobile/clock-sh73a0.c |   23 +++++++++++++++++------
>  1 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
> index 71843dd..34b5c5a 100644
> --- a/arch/arm/mach-shmobile/clock-sh73a0.c
> +++ b/arch/arm/mach-shmobile/clock-sh73a0.c
> @@ -21,6 +21,7 @@
>  #include <linux/io.h>
>  #include <linux/sh_clk.h>
>  #include <linux/clkdev.h>
> +#include <asm/processor.h>
>  #include <mach/common.h>
>  
>  #define FRQCRA		IOMEM(0xe6150000)
> @@ -234,14 +235,24 @@ static struct clk *main_clks[] = {
>  	&sh73a0_extalr_clk,
>  };
>  
> -static void div4_kick(struct clk *clk)
> +static int frqcr_kick(void)
>  {
> -	unsigned long value;
> +	int i;
> +
> +	/* set KICK bit in FRQCRB to update hardware setting, check success */
> +	__raw_writel(__raw_readl(FRQCRB) | (1 << 31), FRQCRB);
> +	for (i = 1000; i; i--)
> +		if (__raw_readl(FRQCRB) & (1 << 31))
> +			cpu_relax();
> +		else
> +			return i;
> +
> +	return -ETIMEDOUT;
> +}
>  
> -	/* set KICK bit in FRQCRB to update hardware setting */
> -	value = __raw_readl(FRQCRB);
> -	value |= (1 << 31);
> -	__raw_writel(value, FRQCRB);
> +static void div4_kick(struct clk *clk)
> +{
> +	frqcr_kick();
>  }
>  
>  static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
> -- 
> 1.7.2.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Horman March 19, 2013, 3:42 a.m. UTC | #2
On Fri, Mar 01, 2013 at 11:52:25AM +0900, Simon Horman wrote:
> On Thu, Feb 28, 2013 at 01:21:58PM +0100, Guennadi Liakhovetski wrote:
> > To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to
> > be set and to make sure the setting has taken effect, it has to be read
> > back repeatedly until it is cleared by the hardware. This patch adds the
> > waiting part, that was missing until now.
> > 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> 
> This patch seems to be ready to be applied.
> 
> Magnus, could I get a review from you?

Magnus, ping.

> > ---
> > 
> > As noted in patch 0/3, this patch affects existing systems, but AFAICS 
> > only theoretically - so far nobody is changing clock rates of any of the 
> > FRQCRA and FRQCRB clocks. Still, please, handle with care.
> > 
> >  arch/arm/mach-shmobile/clock-sh73a0.c |   23 +++++++++++++++++------
> >  1 files changed, 17 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
> > index 71843dd..34b5c5a 100644
> > --- a/arch/arm/mach-shmobile/clock-sh73a0.c
> > +++ b/arch/arm/mach-shmobile/clock-sh73a0.c
> > @@ -21,6 +21,7 @@
> >  #include <linux/io.h>
> >  #include <linux/sh_clk.h>
> >  #include <linux/clkdev.h>
> > +#include <asm/processor.h>
> >  #include <mach/common.h>
> >  
> >  #define FRQCRA		IOMEM(0xe6150000)
> > @@ -234,14 +235,24 @@ static struct clk *main_clks[] = {
> >  	&sh73a0_extalr_clk,
> >  };
> >  
> > -static void div4_kick(struct clk *clk)
> > +static int frqcr_kick(void)
> >  {
> > -	unsigned long value;
> > +	int i;
> > +
> > +	/* set KICK bit in FRQCRB to update hardware setting, check success */
> > +	__raw_writel(__raw_readl(FRQCRB) | (1 << 31), FRQCRB);
> > +	for (i = 1000; i; i--)
> > +		if (__raw_readl(FRQCRB) & (1 << 31))
> > +			cpu_relax();
> > +		else
> > +			return i;
> > +
> > +	return -ETIMEDOUT;
> > +}
> >  
> > -	/* set KICK bit in FRQCRB to update hardware setting */
> > -	value = __raw_readl(FRQCRB);
> > -	value |= (1 << 31);
> > -	__raw_writel(value, FRQCRB);
> > +static void div4_kick(struct clk *clk)
> > +{
> > +	frqcr_kick();
> >  }
> >  
> >  static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
> > -- 
> > 1.7.2.5
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Magnus Damm March 19, 2013, 5:15 a.m. UTC | #3
On Tue, Mar 19, 2013 at 12:42 PM, Simon Horman <horms@verge.net.au> wrote:
> On Fri, Mar 01, 2013 at 11:52:25AM +0900, Simon Horman wrote:
>> On Thu, Feb 28, 2013 at 01:21:58PM +0100, Guennadi Liakhovetski wrote:
>> > To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to
>> > be set and to make sure the setting has taken effect, it has to be read
>> > back repeatedly until it is cleared by the hardware. This patch adds the
>> > waiting part, that was missing until now.
>> >
>> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>>
>> This patch seems to be ready to be applied.
>>
>> Magnus, could I get a review from you?
>
> Magnus, ping.

Thanks for the ping. This patch looks good to me.

Acked-by: Magnus Damm <damm@opensource.se>

Now if we could do the same thing for the MSTP bits too then that
would be excellent...

/ magnus
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Horman March 21, 2013, 1:25 p.m. UTC | #4
On Tue, Mar 19, 2013 at 02:15:29PM +0900, Magnus Damm wrote:
> On Tue, Mar 19, 2013 at 12:42 PM, Simon Horman <horms@verge.net.au> wrote:
> > On Fri, Mar 01, 2013 at 11:52:25AM +0900, Simon Horman wrote:
> >> On Thu, Feb 28, 2013 at 01:21:58PM +0100, Guennadi Liakhovetski wrote:
> >> > To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to
> >> > be set and to make sure the setting has taken effect, it has to be read
> >> > back repeatedly until it is cleared by the hardware. This patch adds the
> >> > waiting part, that was missing until now.
> >> >
> >> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> >>
> >> This patch seems to be ready to be applied.
> >>
> >> Magnus, could I get a review from you?
> >
> > Magnus, ping.
> 
> Thanks for the ping. This patch looks good to me.
> 
> Acked-by: Magnus Damm <damm@opensource.se>

Thanks, applied to the soc branch.

> Now if we could do the same thing for the MSTP bits too then that
> would be excellent...
> 
> / magnus
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 71843dd..34b5c5a 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -21,6 +21,7 @@ 
 #include <linux/io.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
+#include <asm/processor.h>
 #include <mach/common.h>
 
 #define FRQCRA		IOMEM(0xe6150000)
@@ -234,14 +235,24 @@  static struct clk *main_clks[] = {
 	&sh73a0_extalr_clk,
 };
 
-static void div4_kick(struct clk *clk)
+static int frqcr_kick(void)
 {
-	unsigned long value;
+	int i;
+
+	/* set KICK bit in FRQCRB to update hardware setting, check success */
+	__raw_writel(__raw_readl(FRQCRB) | (1 << 31), FRQCRB);
+	for (i = 1000; i; i--)
+		if (__raw_readl(FRQCRB) & (1 << 31))
+			cpu_relax();
+		else
+			return i;
+
+	return -ETIMEDOUT;
+}
 
-	/* set KICK bit in FRQCRB to update hardware setting */
-	value = __raw_readl(FRQCRB);
-	value |= (1 << 31);
-	__raw_writel(value, FRQCRB);
+static void div4_kick(struct clk *clk)
+{
+	frqcr_kick();
 }
 
 static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,