From: Detlef Vollmann <dv@vollmann.ch>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] at91: change CONFIG_SYS_HZ to 1000
Date: Tue, 24 Feb 2009 15:51:10 +0100 [thread overview]
Message-ID: <49A4095E.7010502@vollmann.ch> (raw)
It seems that resistance is futile...
Nearly all boards now use a value of 1000 for CONFIG_SYS_HZ,
and a commit from Oct 1 last year in the net code breaks all
boards silently that have a different value.
So here's a patch for the at91 arm926ejs CPUs and boards
that changes get_timer and get_ticks to return milliseconds.
This will break boards that are not in the tree but use such CPUs,
but at least it'll break them loudly.
Detlef
CHANGELOG:
Change at91 CPUs based on arm926ejs to return milliseconds
from get_timer and get_ticks. Also changes in the value of
CONFIG_SYS_HZ to 1000 in all board configs using these CPUs.
This will not compile on boards using these CPUs with a
different value for CONFIG_SYS_HZ.
diff -Nrup u-boot-2009.03-rc1.orig/cpu/arm926ejs/at91/timer.c u-boot-2009.03-rc1/cpu/arm926ejs/at91/timer.c
--- u-boot-2009.03-rc1.orig/cpu/arm926ejs/at91/timer.c 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/cpu/arm926ejs/at91/timer.c 2009-02-24 14:58:47.000000000 +0100
@@ -30,6 +30,19 @@
#include <asm/arch/io.h>
/*
+ * This code essentially ignores the settings of AT91_MASTER_CLOCK
+ * and CONFIG_SYS_HZ, so we just bail out if they're not set to
+ * the canonical values.
+ */
+#if (CONFIG_SYS_HZ != 1000)
+#error "CONFIG_SYS_HZ must be set to 1000 for this CPU"
+#endif
+/* We leave some leeway for the master clock... */
+#if (AT91_MASTER_CLOCK < 85000000) || (AT91_MASTER_CLOCK > 115000000)
+#error "AT91_MASTER_CLOCK must be set to 100000000 for this CPU"
+#endif
+
+/*
* We're using the AT91CAP9/SAM9 PITC in 32 bit mode, by
* setting the 20 bit counter period to its maximum (0xfffff).
*/
@@ -38,6 +51,7 @@
#define READ_TIMER at91_sys_read(AT91_PIT_PIIR)
#define TIMER_FREQ (AT91C_MASTER_CLOCK << 4)
#define TICKS_TO_USEC(ticks) ((ticks) / 6)
+#define TICKS_TO_MSEC(ticks) ((ticks) / 6250)
ulong get_timer_masked(void);
ulong resettime;
@@ -73,6 +87,21 @@ static inline ulong get_timer_raw(void)
return 0xFFFFFFFFUL - (resettime - now) ;
}
+static inline ulong get_timer_masked_usec(void)
+{
+ return TICKS_TO_USEC(get_timer_raw());
+}
+
+static inline ulong get_timer_usec(ulong base)
+{
+ ulong now = get_timer_masked_usec();
+
+ if (now >= base)
+ return now - base;
+ else
+ return TICKS_TO_USEC(0xFFFFFFFFUL) - (base - now) ;
+}
+
void reset_timer_masked(void)
{
resettime = READ_TIMER;
@@ -80,7 +109,7 @@ void reset_timer_masked(void)
ulong get_timer_masked(void)
{
- return TICKS_TO_USEC(get_timer_raw());
+ return TICKS_TO_MSEC(get_timer_raw());
}
@@ -88,8 +117,8 @@ void udelay_masked(unsigned long usec)
{
ulong tmp;
- tmp = get_timer(0);
- while (get_timer(tmp) < usec) /* our timer works in usecs */
+ tmp = get_timer_usec(0);
+ while (get_timer_usec(tmp) < usec)
; /* NOP */
}
@@ -105,7 +134,7 @@ ulong get_timer(ulong base)
if (now >= base)
return now - base;
else
- return TICKS_TO_USEC(0xFFFFFFFFUL) - (base - now) ;
+ return TICKS_TO_MSEC(0xFFFFFFFFUL) - (base - now) ;
}
void udelay(unsigned long usec)
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/afeb9260.h u-boot-2009.03-rc1/include/configs/afeb9260.h
--- u-boot-2009.03-rc1.orig/include/configs/afeb9260.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/afeb9260.h 2009-02-24 15:00:19.000000000 +0100
@@ -30,7 +30,7 @@
#define AT91_MAIN_CLOCK 18429952 /* from 18.432 MHz crystal */
#define AT91_MASTER_CLOCK 89999598 /* peripheral = main / 2 */
#define CONFIG_SYS_AT91_PLLB 0x107c3e18 /* PLLB settings for USB */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/at91cap9adk.h u-boot-2009.03-rc1/include/configs/at91cap9adk.h
--- u-boot-2009.03-rc1.orig/include/configs/at91cap9adk.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/at91cap9adk.h 2009-02-24 15:00:07.000000000 +0100
@@ -33,7 +33,7 @@
#define AT91_MASTER_CLOCK 100000000 /* peripheral */
#define AT91_CPU_CLOCK 200000000 /* cpu */
#define CONFIG_SYS_AT91_PLLB 0x10073e01 /* PLLB settings for USB */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/at91sam9260ek.h u-boot-2009.03-rc1/include/configs/at91sam9260ek.h
--- u-boot-2009.03-rc1.orig/include/configs/at91sam9260ek.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/at91sam9260ek.h 2009-02-24 15:01:22.000000000 +0100
@@ -33,7 +33,7 @@
#define AT91_MASTER_CLOCK 100000000 /* peripheral */
#define AT91_CPU_CLOCK 200000000 /* cpu */
#define CONFIG_SYS_AT91_PLLB 0x107c3e18 /* PLLB settings for USB */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/at91sam9261ek.h u-boot-2009.03-rc1/include/configs/at91sam9261ek.h
--- u-boot-2009.03-rc1.orig/include/configs/at91sam9261ek.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/at91sam9261ek.h 2009-02-24 15:02:55.000000000 +0100
@@ -32,7 +32,7 @@
#define AT91_MAIN_CLOCK 18432000 /* 18.432 MHz crystal */
#define AT91_MASTER_CLOCK 100000000 /* peripheral */
#define AT91_CPU_CLOCK 200000000 /* cpu */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/at91sam9263ek.h u-boot-2009.03-rc1/include/configs/at91sam9263ek.h
--- u-boot-2009.03-rc1.orig/include/configs/at91sam9263ek.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/at91sam9263ek.h 2009-02-24 15:03:09.000000000 +0100
@@ -33,7 +33,7 @@
#define AT91_MASTER_CLOCK 100000000 /* peripheral */
#define AT91_CPU_CLOCK 200000000 /* cpu */
#define CONFIG_SYS_AT91_PLLB 0x133a3e8d /* PLLB settings for USB */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
diff -Nrup u-boot-2009.03-rc1.orig/include/configs/at91sam9rlek.h u-boot-2009.03-rc1/include/configs/at91sam9rlek.h
--- u-boot-2009.03-rc1.orig/include/configs/at91sam9rlek.h 2009-02-23 00:22:21.000000000 +0100
+++ u-boot-2009.03-rc1/include/configs/at91sam9rlek.h 2009-02-24 15:03:20.000000000 +0100
@@ -32,7 +32,7 @@
#define AT91_MAIN_CLOCK 12000000 /* 12 MHz crystal */
#define AT91_MASTER_CLOCK 100000000 /* peripheral */
#define AT91_CPU_CLOCK 200000000 /* cpu */
-#define CONFIG_SYS_HZ 1000000 /* 1us resolution */
+#define CONFIG_SYS_HZ 1000 /* 1ms resolution */
#define AT91_SLOW_CLOCK 32768 /* slow clock */
--
Detlef Vollmann vollmann engineering gmbh
Linux and C++ for Embedded Systems http://www.vollmann.ch/
next reply other threads:[~2009-02-24 14:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 14:51 Detlef Vollmann [this message]
2009-02-24 21:42 ` [U-Boot] [PATCH] at91: change CONFIG_SYS_HZ to 1000 Wolfgang Denk
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=49A4095E.7010502@vollmann.ch \
--to=dv@vollmann.ch \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.