From: Johannes Weiner <jw@emlix.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Zankel <chris@zankel.net>,
linux-kernel@vger.kernel.org, Oskar Schirmer <os@emlix.com>
Subject: [patch 04/12] xtensa: implement ccount calibration for s6000
Date: Tue, 14 Apr 2009 11:41:12 +0200 [thread overview]
Message-ID: <1239702080-14355-5-git-send-email-jw@emlix.com> (raw)
In-Reply-To: <1239702080-14355-1-git-send-email-jw@emlix.com>
From: Oskar Schirmer <os@emlix.com>
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 <os@emlix.com>
---
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 03b3975..d83f380 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
+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 <asm/delay.h>
+#include <asm/timex.h>
+#include <asm/io.h>
+#include <variant/hardware.h>
+
+#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
next prev parent reply other threads:[~2009-04-14 9:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 9:41 Johannes Weiner
2009-04-14 9:41 ` [patch 01/12] xtensa: always use correct stack pointer for stack traces Johannes Weiner
2009-04-14 9:41 ` [patch 02/12] xtensa: register gpio chip before use Johannes Weiner
2009-04-14 9:41 ` [patch 03/12] xtensa: fix wrong extern declaration renamed in code using it Johannes Weiner
2009-04-14 9:41 ` Johannes Weiner [this message]
2009-04-14 9:41 ` [patch 05/12] xtensa: update s6105_defconfig for ccount calibration Johannes Weiner
2009-04-14 9:41 ` [patch 06/12] xtensa: implement CLK API Johannes Weiner
2009-04-14 9:41 ` [patch 07/12] xtensa: implement PTRACE_PEEKUSER addresses for nommu Johannes Weiner
2009-04-14 9:41 ` [patch 08/12] xtensa: s6000 dma engine support Johannes Weiner
2009-04-14 9:41 ` [patch 09/12] xtensa: allow platform and variant to initialize own irq chips Johannes Weiner
2009-04-23 7:19 ` Chris Zankel
2009-04-23 16:16 ` Daniel Glöckner
2009-04-14 9:41 ` [patch 10/12] xtensa: support s6000 gpio irqs and alternate function selection Johannes Weiner
2009-04-14 9:41 ` [patch 11/12] xtensa: s6105 specific configuration for s6gmac Johannes Weiner
2009-04-14 9:41 ` [patch 12/12] xtensa: enable s6gmac in s6105_defconfig Johannes Weiner
2009-04-16 7:42 ` Xtensa patches Chris Zankel
2009-04-16 8:24 ` Andrew Morton
2009-04-16 8:30 ` Paul Mundt
2009-04-16 8:56 ` Andrew Morton
2009-04-16 9:06 ` Paul Mundt
2009-04-16 8:35 ` Stephen Rothwell
2009-04-16 9:15 ` Chris Zankel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239702080-14355-5-git-send-email-jw@emlix.com \
--to=jw@emlix.com \
--cc=akpm@linux-foundation.org \
--cc=chris@zankel.net \
--cc=linux-kernel@vger.kernel.org \
--cc=os@emlix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®