From patchwork Tue Nov 20 14:33:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13006 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3B6E523FC2 for ; Tue, 20 Nov 2012 14:34:10 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id D268EA190BB for ; Tue, 20 Nov 2012 14:34:09 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so8234104iej.11 for ; Tue, 20 Nov 2012 06:34:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/UUEcn8KZQj1qcULiRoCZG+Cg5dByZ8rjOHYtZIHXxI=; b=nk6a8vNOKt9k7YAcKcEXfEVzPI+P2Mn4Rl3vQJ8B+9WtWNcSAoMj0IPuePvQDbY9vk 3ZHlvRn2NRg3XDge/SbvjJimcD7zVYVe7qdOZR4fxgdS8MCTERZn3gHLuZ5XvoFdmeGW fMZf1Jh9xKvFCCgR/jPkpPaEHFuDYqASVAYjle+KuEFnAib8kN9FJKpU7rv7/zBqnuBi eImWKgV5RizXWW/zy968YMRhAqq7k+J0PnQW+ViT076PyDRPy+5PaFnrg3fDyCtf3k97 2j4VVPwhotsBqGIKBG7UBbQLv3lfy2ipMZY92pVk5xQrX6ZIXNVHVa+z+dMgYBiRH0gw w/UA== Received: by 10.50.186.199 with SMTP id fm7mr9988622igc.62.1353422049507; Tue, 20 Nov 2012 06:34:09 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp326817igt; Tue, 20 Nov 2012 06:34:08 -0800 (PST) Received: by 10.216.195.206 with SMTP id p56mr556029wen.138.1353422048340; Tue, 20 Nov 2012 06:34:08 -0800 (PST) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by mx.google.com with ESMTPS id d5si5004377wef.71.2012.11.20.06.34.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 06:34:08 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.47 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.47; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.47 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f47.google.com with SMTP id ez12so926772wgb.4 for ; Tue, 20 Nov 2012 06:34:07 -0800 (PST) Received: by 10.180.76.203 with SMTP id m11mr14835663wiw.6.1353422047858; Tue, 20 Nov 2012 06:34:07 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id bn7sm20254052wib.8.2012.11.20.06.34.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 06:34:06 -0800 (PST) From: Lee Jones To: u-boot@lists.denx.de Cc: Lee Jones Subject: [PATCH 1/8] u8500: Correct unnecessary mathematical roll-over Date: Tue, 20 Nov 2012 14:33:47 +0000 Message-Id: <1353422034-28107-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353422034-28107-1-git-send-email-lee.jones@linaro.org> References: <1353422034-28107-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQn/d8Prj1/Cv1XDk0Ti2ihbuvosG0lV1wEeLCCkMV+hfVh/y72ZmF1liCNuaoCiyS7MqNJt If we attempt to take a 32bit timer value and multiply it by a significant number, the core will not be able to handle it. This gives the illusion that the timer is rolling over, when in fact this is not the case. If we ensure the division in this instance is carried out before the multiplication, the issue vanishes. Signed-off-by: Lee Jones --- arch/arm/cpu/armv7/u8500/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv7/u8500/timer.c b/arch/arm/cpu/armv7/u8500/timer.c index 79aad99..40326d8 100644 --- a/arch/arm/cpu/armv7/u8500/timer.c +++ b/arch/arm/cpu/armv7/u8500/timer.c @@ -70,7 +70,7 @@ struct u8500_mtu { * The MTU is clocked at 133 MHz by default. (V1 and later) */ #define TIMER_CLOCK (133 * 1000 * 1000 / 16) -#define COUNT_TO_USEC(x) ((x) * 16 / 133) +#define COUNT_TO_USEC(x) ((x) / 133 * 16) #define USEC_TO_COUNT(x) ((x) * 133 / 16) #define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ) #define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)