From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/9] ARM: mx27: convert to common timer code
Date: Sun, 8 Sep 2013 15:12:51 -0500 [thread overview]
Message-ID: <1378671174-18535-7-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1378671174-18535-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Convert mx27 to use the commmon timer code.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
arch/arm/cpu/arm926ejs/mx27/timer.c | 110 ------------------------------------
include/configs/imx27lite-common.h | 3 +
2 files changed, 3 insertions(+), 110 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
index 40fe2aa..b64875a 100644
--- a/arch/arm/cpu/arm926ejs/mx27/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
@@ -17,7 +17,6 @@
*/
#include <common.h>
-#include <div64.h>
#include <asm/io.h>
#include <asm/arch/imx-regs.h>
@@ -27,62 +26,6 @@
#define GPTCR_CLKSOURCE_32 (4 << 1) /* Clock source */
#define GPTCR_TEN 1 /* Timer enable */
-DECLARE_GLOBAL_DATA_PTR;
-
-#define timestamp (gd->arch.tbl)
-#define lastinc (gd->arch.lastinc)
-
-/*
- * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
- * "tick" is internal timer period
- */
-#ifdef CONFIG_MX27_TIMER_HIGH_PRECISION
-/* ~0.4% error - measured with stop-watch on 100s boot-delay */
-static inline unsigned long long tick_to_time(unsigned long long tick)
-{
- tick *= CONFIG_SYS_HZ;
- do_div(tick, CONFIG_MX27_CLK32);
- return tick;
-}
-
-static inline unsigned long long time_to_tick(unsigned long long time)
-{
- time *= CONFIG_MX27_CLK32;
- do_div(time, CONFIG_SYS_HZ);
- return time;
-}
-
-static inline unsigned long long us_to_tick(unsigned long long us)
-{
- us = us * CONFIG_MX27_CLK32 + 999999;
- do_div(us, 1000000);
- return us;
-}
-#else
-/* ~2% error */
-#define TICK_PER_TIME ((CONFIG_MX27_CLK32 + CONFIG_SYS_HZ / 2) / \
- CONFIG_SYS_HZ)
-#define US_PER_TICK (1000000 / CONFIG_MX27_CLK32)
-
-static inline unsigned long long tick_to_time(unsigned long long tick)
-{
- do_div(tick, TICK_PER_TIME);
- return tick;
-}
-
-static inline unsigned long long time_to_tick(unsigned long long time)
-{
- return time * TICK_PER_TIME;
-}
-
-static inline unsigned long long us_to_tick(unsigned long long us)
-{
- us += US_PER_TICK - 1;
- do_div(us, US_PER_TICK);
- return us;
-}
-#endif
-
/* nothing really to do with interrupts, just starts up a counter. */
/* The 32768Hz 32-bit timer overruns in 131072 seconds */
int timer_init(void)
@@ -107,56 +50,3 @@ int timer_init(void)
return 0;
}
-
-unsigned long long get_ticks(void)
-{
- struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE;
- ulong now = readl(®s->gpt_tcn); /* current tick value */
-
- if (now >= lastinc) {
- /*
- * normal mode (non roll)
- * move stamp forward with absolut diff ticks
- */
- timestamp += (now - lastinc);
- } else {
- /* we have rollover of incrementer */
- timestamp += (0xFFFFFFFF - lastinc) + now;
- }
- lastinc = now;
- return timestamp;
-}
-
-ulong get_timer_masked(void)
-{
- /*
- * get_ticks() returns a long long (64 bit), it wraps in
- * 2^64 / CONFIG_MX27_CLK32 = 2^64 / 2^15 = 2^49 ~ 5 * 10^14 (s) ~
- * 5 * 10^9 days... and get_ticks() * CONFIG_SYS_HZ wraps in
- * 5 * 10^6 days - long enough.
- */
- return tick_to_time(get_ticks());
-}
-
-ulong get_timer(ulong base)
-{
- return get_timer_masked() - base;
-}
-
-/* delay x useconds AND preserve advance timstamp value */
-void __udelay(unsigned long usec)
-{
- unsigned long long tmp;
- ulong tmo;
-
- tmo = us_to_tick(usec);
- tmp = get_ticks() + tmo; /* get current timestamp */
-
- while (get_ticks() < tmp) /* loop till event */
- /*NOP*/;
-}
-
-ulong get_tbclk(void)
-{
- return CONFIG_MX27_CLK32;
-}
diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
index 8236133..3c825df 100644
--- a/include/configs/imx27lite-common.h
+++ b/include/configs/imx27lite-common.h
@@ -17,6 +17,9 @@
#define CONFIG_MX27
#define CONFIG_MX27_CLK32 32768 /* OSC32K frequency */
+#define CONFIG_SYS_TIMER_RATE CONFIG_MX27_CLK32
+#define CONFIG_SYS_TIMER_COUNTER (0x10003000 + 0x10)
+
#define CONFIG_DISPLAY_BOARDINFO
#define CONFIG_DISPLAY_CPUINFO
--
1.8.1.2
next prev parent reply other threads:[~2013-09-08 20:12 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-08 20:12 [U-Boot] [PATCH 0/9] Consolidate ARM timer code Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 1/9] ARM: add common timer functions Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 2/9] examples: enable gc-sections option Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 3/9] time: create default __udelay Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 4/9] ARM: highbank: convert to common timer code Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 5/9] ARM: mx25: " Rob Herring
2013-09-08 23:56 ` Benoît Thébaudeau
2013-09-09 21:00 ` Rob Herring
2013-09-10 10:25 ` Benoît Thébaudeau
2013-09-10 16:20 ` Rob Herring
2013-09-08 20:12 ` Rob Herring [this message]
2013-09-08 20:12 ` [U-Boot] [PATCH 7/9] ARM: vexpress: " Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 8/9] ARM: socfpga: " Rob Herring
2013-09-08 20:12 ` [U-Boot] [PATCH 9/9] ARM: tegra: " Rob Herring
2013-09-09 5:53 ` [U-Boot] [PATCH 0/9] Consolidate ARM " Wolfgang Denk
2013-09-09 14:52 ` Rob Herring
2013-09-09 15:37 ` Wolfgang Denk
2013-09-09 7:13 ` Lukasz Majewski
2013-09-09 18:55 ` Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 0/9] Consolidate " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 1/9] examples: enable gc-sections option Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 2/9] Introduce common timer functions Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 3/9] sh: convert to common timer code Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 4/9] ARM: highbank: " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 5/9] ARM: mx25: " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 6/9] ARM: vexpress: " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 7/9] ARM: socfpga: " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 8/9] ARM: tegra: " Rob Herring
2013-10-04 15:22 ` [U-Boot] [PATCH v2 9/9] ARM: versatile: " Rob Herring
2013-11-04 21:31 ` [U-Boot] [PATCH v2 0/9] Consolidate " Tom Rini
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=1378671174-18535-7-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox