From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/9] ARM: mx25: convert to common timer code
Date: Sun, 8 Sep 2013 15:12:50 -0500 [thread overview]
Message-ID: <1378671174-18535-6-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 mx25 to use the commmon timer code.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
arch/arm/cpu/arm926ejs/mx25/timer.c | 117 ------------------------------------
include/configs/mx25pdk.h | 3 +
include/configs/tx25.h | 2 +
include/configs/zmx25.h | 3 +
4 files changed, 8 insertions(+), 117 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
index 42b6076..7f19791 100644
--- a/arch/arm/cpu/arm926ejs/mx25/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
@@ -21,65 +21,8 @@
*/
#include <common.h>
-#include <div64.h>
#include <asm/io.h>
#include <asm/arch/imx-regs.h>
-#include <asm/arch/clock.h>
-
-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_MX25_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, MXC_CLK32);
- return tick;
-}
-
-static inline unsigned long long time_to_tick(unsigned long long time)
-{
- time *= MXC_CLK32;
- do_div(time, CONFIG_SYS_HZ);
- return time;
-}
-
-static inline unsigned long long us_to_tick(unsigned long long us)
-{
- us = us * MXC_CLK32 + 999999;
- do_div(us, 1000000);
- return us;
-}
-#else
-/* ~2% error */
-#define TICK_PER_TIME ((MXC_CLK32 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ)
-#define US_PER_TICK (1000000 / MXC_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 32KHz 32-bit timer overruns in 134217 seconds */
@@ -104,63 +47,3 @@ int timer_init(void)
return 0;
}
-
-unsigned long long get_ticks(void)
-{
- struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE;
- ulong now = readl(&gpt->counter); /* 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 / MXC_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*/;
-}
-
-/*
- * This function is derived from PowerPC code (timebase clock frequency).
- * On ARM it returns the number of timer ticks per second.
- */
-ulong get_tbclk(void)
-{
- ulong tbclk;
-
- tbclk = MXC_CLK32;
- return tbclk;
-}
diff --git a/include/configs/mx25pdk.h b/include/configs/mx25pdk.h
index ccd3b6c..568ed6c 100644
--- a/include/configs/mx25pdk.h
+++ b/include/configs/mx25pdk.h
@@ -15,6 +15,9 @@
#define CONFIG_SYS_TEXT_BASE 0x81200000
#define CONFIG_MXC_GPIO
+#define CONFIG_SYS_TIMER_RATE 32768
+#define CONFIG_SYS_TIMER_COUNTER (IMX_GPT1_BASE + 0x24)
+
#define CONFIG_DISPLAY_CPUINFO
#define CONFIG_DISPLAY_BOARDINFO
diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index 2d7479b..f879441 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -15,6 +15,8 @@
*/
#define CONFIG_MX25
#define CONFIG_MX25_CLK32 32000 /* OSC32K frequency */
+#define CONFIG_SYS_TIMER_RATE CONFIG_MX25_CLK32
+#define CONFIG_SYS_TIMER_COUNTER (IMX_GPT1_BASE + 0x24)
#define CONFIG_SYS_MONITOR_LEN (256 << 10) /* 256 kB for U-Boot */
diff --git a/include/configs/zmx25.h b/include/configs/zmx25.h
index 2e7f145..deaadfa 100644
--- a/include/configs/zmx25.h
+++ b/include/configs/zmx25.h
@@ -14,6 +14,9 @@
#define CONFIG_MX25
#define CONFIG_SYS_TEXT_BASE 0xA0000000
+#define CONFIG_SYS_TIMER_RATE 32768
+#define CONFIG_SYS_TIMER_COUNTER (IMX_GPT1_BASE + 0x24)
+
#define CONFIG_MACH_TYPE MACH_TYPE_ZMX25
/*
* Environment settings
--
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 ` Rob Herring [this message]
2013-09-08 23:56 ` [U-Boot] [PATCH 5/9] ARM: mx25: " 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 ` [U-Boot] [PATCH 6/9] ARM: mx27: " Rob Herring
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-6-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