mx25 gpt-clock issue, waits are too long

Mehnert, Torsten T.Mehnert at eckelmann.de
Mon Jul 4 11:24:25 EDT 2011


Hi,

i am using barebox and standard linux (2.6.39.1) on my mx25 board. Under linux i now have the problem
that a sleepwait or busywait results in a factor 1.8 too long waiting time. So sleep(10) results in ~18 seconds
of waiting.

I see through the clock registers
and found that the clock source of the general purpose timer is set to UPLL(240MHz), divided by 2 its 120MHz.
So when 120Mhz is factor 1.8 too much, then the correct value should be 66MHz. As this value can't be divided from
UPLL i changed the clock source to AHB_DIV(133MHz), get the 66MHz and my sleep(10) are the proper 10 seconds.
I think that the clock-mx25.c expected the CCM_MCR register to be cleared completely, which it's not in my case.

I tested this issue again on the mx25-3stack evaluation board, with the same result.

Old Kernel message: sched_clock: 32 bits at 120MHz, resolution 8ns, wraps every 35791ms
New Kernel message: sched_clock: 32 bits at 66MHz, resolution 15ns, wraps every 64585ms


This patch fixes this issue:

Request for comment and feedback.

From: T. Mehnert <t.mehnert at eckelmann.de>
Date: Mon, 4 Jul 2011 15:53:30 +0200
Subject: [PATCH] GPT clock fix: corrected the clock source

This patch changes the clock source for the general purpose timer
of the arm/mx25 from UPLL to AHB_DIV. This fixes the problem,
that sleep/busy wating waits factor 1.8 too long.

Signed-off-by: Torsten Mehnert <t.mehnert at eckelmann.de>
---
 arch/arm/mach-imx/clock-imx25.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clock-imx25.c b/arch/arm/mach-imx/clock-imx25.c
index a65838f..bf1ecda 100644
--- a/arch/arm/mach-imx/clock-imx25.c
+++ b/arch/arm/mach-imx/clock-imx25.c
@@ -328,6 +328,10 @@ int __init mx25_clocks_init(void)
        __raw_writel(__raw_readl(CRM_BASE+0x64) | (1 << 7) | (1 << 0),
                        CRM_BASE + 0x64);

+       /* Clock source for gpt is ahb_div */
+       __raw_writel(__raw_readl(CRM_BASE+0x64) & ~(1 << 5),
+                       CRM_BASE + 0x64);
+
        mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);

        return 0;
--
1.7.0.4
ECKELMANN AG
Vorstand: Dr.-Ing. Gerd Eckelmann (Vorsitzender), Dr.-Ing. Peter Cordes, Dr.-Ing. Frank-Thomas Mellert
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Sitz der Gesellschaft: Wiesbaden
Amtsgericht Wiesbaden, HRB 12636



More information about the linux-arm-kernel mailing list