11 #ifndef _ASM_UNIT_TIMEX_H
12 #define _ASM_UNIT_TIMEX_H
14 #include <asm/timer-regs.h>
15 #include <unit/clock.h>
16 #include <asm/param.h>
22 #define TMJCBR_MAX 0xffff
23 #define TMJCIRQ TM1IRQ
24 #define TMJCICR TM1ICR
28 #define MN10300_SRC_IOCLK MN10300_IOCLK
31 # error HZ undeclared.
34 #if (MN10300_SRC_IOCLK + HZ / 2) / HZ - 1 <= TMJCBR_MAX
35 # define IOCLK_PRESCALE 1
36 # define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK
37 # define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK
38 #elif (MN10300_SRC_IOCLK / 8 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
39 # define IOCLK_PRESCALE 8
40 # define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_8
41 # define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_8
42 #elif (MN10300_SRC_IOCLK / 32 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
43 # define IOCLK_PRESCALE 32
44 # define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_32
45 # define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_32
50 #define MN10300_JCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
51 #define MN10300_TSCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
53 #define MN10300_JC_PER_HZ ((MN10300_JCCLK + HZ / 2) / HZ)
54 #define MN10300_TSC_PER_HZ ((MN10300_TSCCLK + HZ / 2) / HZ)
56 static inline void stop_jiffies_counter(
void)
63 static inline void reload_jiffies_counter(
u32 cnt)
71 TM1MD_SRC_TM0CASCADE << 8 | \
72 TM0MD_INIT_COUNTER | \
73 TM1MD_INIT_COUNTER << 8;
77 TM1MD_SRC_TM0CASCADE << 8 | \
78 TM0MD_COUNT_ENABLE | \
79 TM1MD_COUNT_ENABLE << 8;
91 #define TMTSCBR_MAX 0xffffffff
92 #define TMTSCBC TM45BC
96 static inline void startup_timestamp_counter(
void)
107 TM4MD |= TM4MD_INIT_COUNTER;
108 TM4MD &= ~TM4MD_INIT_COUNTER;
112 TM5MD = TM5MD_SRC_TM4CASCADE;
113 TM5MD |= TM5MD_INIT_COUNTER;
114 TM5MD &= ~TM5MD_INIT_COUNTER;
118 TM5MD |= TM5MD_COUNT_ENABLE;
119 TM4MD |= TM4MD_COUNT_ENABLE;
124 static inline void shutdown_timestamp_counter(
void)
139 static inline cycles_t read_timestamp_counter(
void)