From patchwork Tue Mar 29 14:24:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Joye X-Patchwork-Id: 88787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 71351B6F12 for ; Wed, 30 Mar 2011 01:25:23 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E1DDB28082; Tue, 29 Mar 2011 16:25:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fHiOGRU4aqJ8; Tue, 29 Mar 2011 16:25:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 631BC28091; Tue, 29 Mar 2011 16:25:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7301328091 for ; Tue, 29 Mar 2011 16:25:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VBiaGj3cqLj0 for ; Tue, 29 Mar 2011 16:25:15 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.haslerrail.com (mail.haslerrail.com [212.103.73.117]) by theia.denx.de (Postfix) with ESMTP id 062EC28090 for ; Tue, 29 Mar 2011 16:25:13 +0200 (CEST) Received: from 212.103.73.117 ([212.103.73.117]) by hrsrv03.haslerrail.net ([192.168.99.4]) with Microsoft Exchange Server HTTP-DAV ; Tue, 29 Mar 2011 14:25:29 +0000 Received: from hrwks7001-l by mail.haslerrail.com; 29 Mar 2011 16:24:59 +0200 From: Laurent Joye To: u-boot@lists.denx.de Organization: HaslerRail AG Date: Tue, 29 Mar 2011 16:24:59 +0200 Message-ID: <1301408699.3605.24.camel@hrwks7001-l.haslerrail.net> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 X-Content-Filtered-By: Mailman/MimeDel 2.1.9 Subject: [U-Boot] arm imx35 timer failure X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Hello, I'm developing a product based on the imx35 cpu with NOR and NAND flash. The SBC I use is the pcm-043 from Phytec. I use the FEC to communicate over the ethernet. I've made my own BSP for Das U-boot based on the release tagged v2011.03-rc2 on the git://git.denx.de/u-boot.git master repository. I've encountered one problem in uboot so that my board can work properly: This concerns the FEC autonegotiation timeout. I had some MDIO read an write and autonegotiation wait timeout failures. By debugging the problem I've found that the changes I've brought to the timer.c file (see patch below for arch/arm/cpu/arm1136/timer.c) of the imx35 cpu solves the problem. It seems that the return value of the "get_timer_masked" function is not given with the same unit as the input value for the "get_timer" function. It seems also to me that this value should be dependent of the "CONFIG_SYS_HZ" macro. Did anybody encountered this problem? Could you please tell me if there is really something wrong in timer.c file? Laurent Joye HaslerRail AG Bern, Switzerland Related patch: diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index db1e2c9..00ca3e6 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -70,7 +70,7 @@ inline ulong get_timer_masked(void) struct gpt_regs *gpt = (struct gpt_regs *)GPT1_BASE_ADDR; ulong val = readl(&gpt->counter); - return val; + return val / CONFIG_SYS_HZ; } void reset_timer(void) @@ -84,12 +84,14 @@ ulong get_timer(ulong base) tmp = get_timer_masked(); - if (tmp <= (base * 1000)) { + if (tmp < base) { /* Overflow */ - tmp += (0xffffffff - base); + tmp = (0xffffffff - (base - tmp)); + } else { + tmp = tmp -base; } - return (tmp / 1000) - base; + return tmp; } void set_timer(ulong t) @@ -103,6 +105,7 @@ void set_timer(ulong t) void __udelay(unsigned long usec) { ulong tmp; + usec /= CONFIG_SYS_HZ; tmp = get_timer_masked(); /* get current timestamp */