linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] mx25: fix time accounting
Date: Wed, 12 May 2010 11:46:42 +0200	[thread overview]
Message-ID: <20100512094642.GB31199@pengutronix.de> (raw)
In-Reply-To: <20100512050627.GA19283@jasper.tkos.co.il>

On Wed, May 12, 2010 at 08:06:28AM +0300, Baruch Siach wrote:
> 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?

I just checked the fsl 2.6.31 source. They really pass the per_clk to
the timer, but they also change the timer source to MX3_TCTL_CLK_PER
(2<<6).
Here are the relevant bits from arch/arm/plat-mxc/time.c in the fsl
2.6.31 source:

/* MX31, MX35 */
#define MX3_TCTL_WAITEN		(1 << 3)
#define MX3_TCTL_CLK_IPG	(1 << 6)
#define MX3_TCTL_CLK_PER	(2 << 6)
#define MX3_TCTL_FRR		(1 << 9)
#define MX3_IR			0x0c
#define MX3_TSTAT		0x08
#define MX3_TSTAT_OF1		(1 << 0)
#define MX3_TCN			0x24
#define MX3_TCMP		0x10

#define timer_is_v2()	(!(cpu_is_mx1() || cpu_is_mx2()) || cpu_is_mx25())

void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
{
	...

	if (timer_is_v2())
		tctl_val = MX3_TCTL_CLK_PER | MX3_TCTL_FRR | MX3_TCTL_WAITEN | MXC_TCTL_TEN;
	else
		tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;

	...
}

I wonder what is going wrong here.

Sascha

-- 
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 |

  reply	other threads:[~2010-05-12  9:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-21 15:00 [PATCH 0/2] mx25: clock related fixes Baruch Siach
2010-01-21 15:00 ` [PATCH 1/2] mx25: remove unused mx25_clocks_init() argument Baruch Siach
2010-01-21 15:00 ` [PATCH 2/2] mx25: properly initialize clocks, fix time accounting Baruch Siach
2010-01-22  6:50   ` Baruch Siach
2010-01-22  7:57   ` Sascha Hauer
2010-01-25 10:54     ` Baruch Siach
2010-01-25 10:58       ` [PATCH 1/4] mx25: remove unused mx25_clocks_init() argument Baruch Siach
2010-01-25 10:58       ` [PATCH 2/4] mx25: properly initialize clocks Baruch Siach
2010-07-05  7:08         ` Uwe Kleine-König
2010-07-08 10:04           ` Baruch Siach
2010-01-25 10:58       ` [PATCH 3/4] mx25: fix time accounting Baruch Siach
2010-01-25 11:11         ` Lothar Waßmann
2010-01-25 15:01           ` Baruch Siach
2010-05-11 15:43         ` Sascha Hauer
2010-05-12  5:06           ` Baruch Siach
2010-05-12  9:46             ` Sascha Hauer [this message]
2010-05-12 10:45               ` Baruch Siach
2010-05-12 12:09                 ` Sascha Hauer
2010-07-06 15:28                 ` Rob Herring
2010-07-04  8:43               ` Baruch Siach
2010-07-04  8:47                 ` [PATCH] mx25: set GPT clock source to PER Baruch Siach
2010-07-05  8:21                   ` Sascha Hauer
2010-07-06  6:35                     ` Baruch Siach
2010-07-06  7:33                       ` Sascha Hauer
2010-07-06 14:06                         ` Rob Herring
2010-07-07  8:00                         ` Baruch Siach
2010-07-07 10:28                           ` Sascha Hauer
2010-07-07 13:04                             ` Baruch Siach
2010-07-05 11:18                 ` [PATCH 3/4] mx25: fix time accounting Martin Fuzzey
2010-01-25 10:58       ` [PATCH 4/4] mx25: make the FEC AHB clk secondary of the IPG Baruch Siach
2010-01-22  7:58   ` [PATCH 2/2] mx25: properly initialize clocks, fix time accounting Sascha Hauer
2010-01-22  7:59   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100512094642.GB31199@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).