Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758423AbZCZNjc (ORCPT ); Thu, 26 Mar 2009 09:39:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757601AbZCZNil (ORCPT ); Thu, 26 Mar 2009 09:38:41 -0400 Received: from mx1.emlix.com ([193.175.82.87]:56789 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758060AbZCZNij (ORCPT ); Thu, 26 Mar 2009 09:38:39 -0400 From: Oskar Schirmer To: Chris Zankel Cc: linux-kernel@vger.kernel.org, linux-xtensa@linux-xtensa.org, Oskar Schirmer Subject: [patch 2/3] xtensa: implement ccount calibration for s6000 Date: Thu, 26 Mar 2009 14:39:44 +0100 Message-Id: <1238074785-24810-2-git-send-email-os@emlix.com> In-Reply-To: <1238074785-24810-1-git-send-email-os@emlix.com> References: <1238074785-24810-1-git-send-email-os@emlix.com> Organization: emlix gmbh, Goettingen, Germany" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2286 Lines: 75 Calculate core frequency from timers at boot time instead of assuming a fixed frequency. This is useful as the true frequency is set up by the boot loader, thus variable. Signed-off-by: Oskar Schirmer --- arch/xtensa/Kconfig | 1 + arch/xtensa/variants/s6000/Makefile | 1 + arch/xtensa/variants/s6000/delay.c | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 0 deletions(-) create mode 100644 arch/xtensa/variants/s6000/delay.c diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index fa6dc4d..ac02f3c 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -80,6 +80,7 @@ config XTENSA_VARIANT_S6000 bool "s6000 - Stretch software configurable processor" select VARIANT_IRQ_SWITCH select ARCH_REQUIRE_GPIOLIB + select XTENSA_CALIBRATE_CCOUNT endchoice config XTENSA_UNALIGNED_USER diff --git a/arch/xtensa/variants/s6000/Makefile b/arch/xtensa/variants/s6000/Makefile index 408c4fe..16645a0 100644 --- a/arch/xtensa/variants/s6000/Makefile +++ b/arch/xtensa/variants/s6000/Makefile @@ -1,3 +1,4 @@ # s6000 Makefile obj-y += irq.o gpio.o dmac.o isef.o uncached-mapping.o +obj-$(CONFIG_XTENSA_CALIBRATE_CCOUNT) += delay.o diff --git a/arch/xtensa/variants/s6000/delay.c b/arch/xtensa/variants/s6000/delay.c new file mode 100644 index 0000000..54b2b57 --- /dev/null +++ b/arch/xtensa/variants/s6000/delay.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +#define LOOPS 10 +void platform_calibrate_ccount(void) +{ + u32 uninitialized_var(a); + u32 uninitialized_var(u); + u32 b; + u32 tstamp = S6_REG_GREG1 + S6_GREG1_GLOBAL_TIMER; + int i = LOOPS+1; + do { + u32 t = u; + asm volatile( + "1: l32i %0, %2, 0 ;" + " beq %0, %1, 1b ;" + : "=&a"(u) : "a"(t), "a"(tstamp)); + b = xtensa_get_ccount(); + if (i == LOOPS) + a = b; + } while (--i >= 0); + b -= a; + nsec_per_ccount = (LOOPS * 10000) / b; + ccount_per_jiffy = b * (100000UL / (LOOPS * HZ)); +} -- 1.6.2.107.ge47ee -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/