/*
- * Copyright (C) 2010 Albert ARIBAUD <albert.aribaud@free.fr>
+ * Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net>
*
* Based on original Kirkwood support which is
* Copyright (C) Marvell International Ltd. and its affiliates
*/
#include <common.h>
-#include <asm/arch/orion5x.h>
+#include <asm/io.h>
#define UBOOT_CNTR 0 /* counter to use for uboot timer */
/ (CONFIG_SYS_TCLK / 1000);
}
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
-void reset_timer_masked(void)
-{
- /* reset time */
- lastdec = read_timer();
- timestamp = 0;
-}
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
ulong get_timer_masked(void)
{
return timestamp;
}
-void reset_timer(void)
-{
- reset_timer_masked();
-}
-
ulong get_timer(ulong base)
{
return get_timer_masked() - base;
}
-void set_timer(ulong t)
-{
- timestamp = t;
-}
-
static inline ulong uboot_cntr_val(void)
{
return readl(CNTMR_VAL_REG(UBOOT_CNTR));
cntmrctrl |= CTCR_ARM_TIMER_EN(UBOOT_CNTR);
cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR);
writel(cntmrctrl, CNTMR_CTRL_REG);
+ return 0;
+}
+void timer_init_r(void)
+{
/* init the timestamp and lastdec value */
- reset_timer_masked();
+ lastdec = read_timer();
+ timestamp = 0;
+}
- return 0;
+/*
+ * This function is derived from PowerPC code (read timebase as long long).
+ * On ARM it just returns the timer value.
+ */
+unsigned long long get_ticks(void)
+{
+ return get_timer(0);
+}
+
+/*
+ * 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)
+{
+ return (ulong)CONFIG_SYS_HZ;
}