From patchwork Mon Jul 8 06:29:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 257465 X-Patchwork-Delegate: macpaul@andestech.com 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 3211E2C016A for ; Mon, 8 Jul 2013 16:30:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CE6EB4A09B; Mon, 8 Jul 2013 08:30: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 nKebZpMPmuhm; Mon, 8 Jul 2013 08:30:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7F9A84A051; Mon, 8 Jul 2013 08:30:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 73BCD4A050 for ; Mon, 8 Jul 2013 08:30:10 +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 DL9hrpewOuXU for ; Mon, 8 Jul 2013 08:30:04 +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-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by theia.denx.de (Postfix) with ESMTPS id 1B4EA4A04B for ; Mon, 8 Jul 2013 08:29:57 +0200 (CEST) Received: by mail-pa0-f52.google.com with SMTP id kq13so4005396pab.25 for ; Sun, 07 Jul 2013 23:29:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=QMajSuyVPvaDXg3LoK1tRNrrJnROOmuuEWcc3RaWHSA=; b=bVgUqCARgaoVJXpMU6lErF45zgOWIChUvagHOWYwKZwcuILNVno0rgDB2/ikPs7LZH E9G2leutXV0yRAD5vIvuiJrY8Sd6Gu+oFZ2YFlOdKDlxQEmqWF6oEEW9GVvqQWTAxMA7 Pg0oVumLUjKoTgWMZL37WI5IaC8EnkrgP7zOyI3JrWOgjk8/WroQzzSg12mPBF92TQFC YWYDlBpwAgvcsfCuimGSZjXIcpQzyIcVvfN7zuw/lybbnyAnOmF14w7Gq1F74Q2ZBBEs EKxjvD6wTWxid4jFhtHYXPKMYanpKAUXKVRyZmmZcVL58R2FjINJ+PxdGUydz5zBXioT EVvA== X-Received: by 10.66.50.104 with SMTP id b8mr21746323pao.39.1373264996323; Sun, 07 Jul 2013 23:29:56 -0700 (PDT) Received: from [192.168.1.103] (111-240-58-17.dynamic.hinet.net. [111.240.58.17]) by mx.google.com with ESMTPSA id te9sm6127530pab.6.2013.07.07.23.29.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Jul 2013 23:29:55 -0700 (PDT) Message-ID: <1373264992.5000.1.camel@phoenix> From: Axel Lin To: Macpaul Lin Date: Mon, 08 Jul 2013 14:29:52 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkR5ErKbHCwGUuixXEG/sURdqMAIm0ei6bOWKi8h+dQq9q9XX/+DLwVIupPiTfQ7FYlHEFs Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] nds32: ag101/ag102: Fix setting lastdec and now values X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The timer3 counter unit for lastdesc and now values are inconsistent in current code. The unit of "readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2)" is second. However, CONFIG_SYS_HZ is defined as 1000 in board config file. This means the accuracy of "lastdec" and "now" should be in millisecond, thus fix the equation to set lastdec and now variables accordingly. Signed-off-by: Axel Lin --- Hi Kuan-Yu, This change is based on your suggestion. I don't have this hardware, can you test if this patch works? Thanks, Axel arch/nds32/cpu/n1213/ag101/timer.c | 7 ++++--- arch/nds32/cpu/n1213/ag102/timer.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/nds32/cpu/n1213/ag101/timer.c b/arch/nds32/cpu/n1213/ag101/timer.c index caa36b8..926091f 100644 --- a/arch/nds32/cpu/n1213/ag101/timer.c +++ b/arch/nds32/cpu/n1213/ag101/timer.c @@ -86,7 +86,8 @@ void reset_timer_masked(void) #ifdef CONFIG_FTTMR010_EXT_CLK lastdec = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ); #else - lastdec = readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2); + lastdec = readl(&tmr->timer3_counter) / + (CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ); #endif timestamp = 0; /* start "advancing" time stamp from 0 */ @@ -110,8 +111,8 @@ ulong get_timer_masked(void) #ifdef CONFIG_FTTMR010_EXT_CLK ulong now = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ); #else - ulong now = readl(&tmr->timer3_counter) / \ - (CONFIG_SYS_CLK_FREQ / 2 / 1024); + ulong now = readl(&tmr->timer3_counter) / + (CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ); #endif debug("%s(): now = %lx, lastdec = %lx\n", __func__, now, lastdec); diff --git a/arch/nds32/cpu/n1213/ag102/timer.c b/arch/nds32/cpu/n1213/ag102/timer.c index caa36b8..926091f 100644 --- a/arch/nds32/cpu/n1213/ag102/timer.c +++ b/arch/nds32/cpu/n1213/ag102/timer.c @@ -86,7 +86,8 @@ void reset_timer_masked(void) #ifdef CONFIG_FTTMR010_EXT_CLK lastdec = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ); #else - lastdec = readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2); + lastdec = readl(&tmr->timer3_counter) / + (CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ); #endif timestamp = 0; /* start "advancing" time stamp from 0 */ @@ -110,8 +111,8 @@ ulong get_timer_masked(void) #ifdef CONFIG_FTTMR010_EXT_CLK ulong now = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ); #else - ulong now = readl(&tmr->timer3_counter) / \ - (CONFIG_SYS_CLK_FREQ / 2 / 1024); + ulong now = readl(&tmr->timer3_counter) / + (CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ); #endif debug("%s(): now = %lx, lastdec = %lx\n", __func__, now, lastdec);