[PATCH 3/4] mx25: fix time accounting

Baruch Siach baruch at tkos.co.il
Wed May 12 01:06:28 EDT 2010


Hi Sascha,

On Tue, May 11, 2010 at 05:43:49PM +0200, Sascha Hauer wrote:
> On Mon, Jan 25, 2010 at 12:58:21PM +0200, Baruch Siach wrote:
> > The gpt_clk rate function doesn't consider the PER divider. This causes a
> > significant drift in time accounting. Fix this by introducing the correct rate
> > calculation function.
> 
> Should have tested this one. In fact with this patch applied my clock
> goes wrong.
> 
> The i.MX Timer code makes sure the gpt clock is sourced from the ipg
> clock (GPTCR[6:8] = 1), so the behaviour should be correct the way it
> was before this patch. Any idea why it was wrong on your hardware? Have
> you changed the GPTCR bits?

No. My current platform is the i.MX25 PDK. I've added the following to my 
mx25pdk_init():

debugfs_create_x32("gptcr", 0444, NULL,
    (u32*)MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR));

When the system is running I get:

# cat /debugfs/gptcr 
0x00000249

That is GPTCR[6:8] = 1.

The same clock calculation is being done in the platform code of the Freescale 
supplied kernel (now based on 2.6.31).  Can you get this one running on your 
platform?

baruch

> > 
> > Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> > ---
> >  arch/arm/mach-mx25/clock.c |    7 ++++++-
> >  1 files changed, 6 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
> > index 08aaa38..c003ac4 100644
> > --- a/arch/arm/mach-mx25/clock.c
> > +++ b/arch/arm/mach-mx25/clock.c
> > @@ -119,6 +119,11 @@ static unsigned long get_rate_nfc(struct clk *clk)
> >  	return get_rate_per(8);
> >  }
> >  
> > +static unsigned long get_rate_gpt(struct clk *clk)
> > +{
> > +	return get_rate_per(5);
> > +}
> > +
> >  static unsigned long get_rate_otg(struct clk *clk)
> >  {
> >  	return 48000000; /* FIXME */
> > @@ -156,7 +161,7 @@ static void clk_cgcr_disable(struct clk *clk)
> >  		.secondary	= s,			\
> >  	}
> >  
> > -DEFINE_CLOCK(gpt_clk,    0, CCM_CGCR0,  5, get_rate_ipg, NULL, NULL);
> > +DEFINE_CLOCK(gpt_clk,    0, CCM_CGCR0,  5, get_rate_gpt, NULL, NULL);
> >  DEFINE_CLOCK(uart_per_clk, 0, CCM_CGCR0, 15, get_rate_uart, NULL, NULL);
> >  DEFINE_CLOCK(cspi1_clk,  0, CCM_CGCR1,  5, get_rate_ipg, NULL, NULL);
> >  DEFINE_CLOCK(cspi2_clk,  0, CCM_CGCR1,  6, get_rate_ipg, NULL, NULL);
> > -- 
> > 1.6.5
> > 
> > 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -



More information about the linux-arm-kernel mailing list