Skip to contentSkip to conversation

xtensa: fix wrong extern declaration renamed in code using it

PATCH New Oskar Schirmer 1 participant 3 messages Mar 26, 2009 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 xtensa: fix wrong extern declaration renamed in code using it

The variable ccount_nsec has been renamed to nsec_per_ccount in arch/xtensa/kernel/time.c in 2b8aea74 (2007-08-05), but the fix failed to rename the variable in arch/xtensa/include/asm/timex.h as well.

---
 arch/xtensa/include/asm/timex.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/include/asm/timex.h +2 -2
index b83a818..053bc42 100644
@@ -39,9 +39,9 @@
 
 #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
 extern unsigned long ccount_per_jiffy;
-extern unsigned long ccount_nsec;
+extern unsigned long nsec_per_ccount;
 #define CCOUNT_PER_JIFFY ccount_per_jiffy
-#define NSEC_PER_CCOUNT  ccount_nsec
+#define NSEC_PER_CCOUNT  nsec_per_ccount
 #else
 #define CCOUNT_PER_JIFFY (CONFIG_XTENSA_CPU_CLOCK*(1000000UL/HZ))
 #define NSEC_PER_CCOUNT (1000UL / CONFIG_XTENSA_CPU_CLOCK)
Signature · 1 line
1.6.2.107.ge47ee
#1 lore raw

PATCH 2/3 xtensa: implement ccount calibration for s6000

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.

---
 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
arch/xtensa/Kconfig +1 -0
index fa6dc4d..ac02f3c 100644
@@ -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
arch/xtensa/variants/s6000/Makefile +1 -0
index 408c4fe..16645a0 100644
@@ -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
arch/xtensa/variants/s6000/delay.c new file +27 -0
new file mode 100644
index 0000000..54b2b57
@@ -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));
+}
Signature · 1 line
1.6.2.107.ge47ee
#2 lore raw

PATCH 3/3 xtensa: update s6105_defconfig for ccount calibration

In reply to Oskar Schirmer

The previous patch enabled ccount calibration for the s6000 variant. This patch updates the defconfig for the s6105 platform to reflect this change.

---
 arch/xtensa/configs/s6105_defconfig |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
arch/xtensa/configs/s6105_defconfig +1 -2
index 6ced233..8eec578 100644
@@ -115,7 +115,7 @@ CONFIG_XTENSA_VARIANT_S6000=y
 CONFIG_PREEMPT=y
 # CONFIG_MATH_EMULATION is not set
 # CONFIG_HIGHMEM is not set
-# CONFIG_XTENSA_CALIBRATE_CCOUNT is not set
+CONFIG_XTENSA_CALIBRATE_CCOUNT=y
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_XTENSA_ISS_NETWORK is not set
 
@@ -131,7 +131,6 @@ CONFIG_SERIAL_CONSOLE=y
 # CONFIG_XTENSA_PLATFORM_ISS is not set
 # CONFIG_XTENSA_PLATFORM_XT2000 is not set
 CONFIG_XTENSA_PLATFORM_S6105=y
-CONFIG_XTENSA_CPU_CLOCK=300
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS1,38400 debug bootmem_debug loglevel=7"
Signature · 1 line
1.6.2.107.ge47ee