1 /* ASB2305 timer specifcations
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #ifndef _ASM_UNIT_TIMEX_H
12 #define _ASM_UNIT_TIMEX_H
15 #include <linux/irq.h>
16 #endif /* __ASSEMBLY__ */
18 #include <asm/timer-regs.h>
19 #include <unit/clock.h>
22 * jiffies counter specifications
25 #define TMJCBR_MAX 0xffff
30 #define TMJCIRQ TM1IRQ
31 #define TMJCICR TM1ICR
32 #define TMJCICR_LEVEL GxICR_LEVEL_5
36 static inline void startup_jiffies_counter(void)
41 /* use as little prescaling as possible to avoid losing accuracy */
43 rate = MN10300_JCCLK / HZ;
45 if (rate > TMJCBR_MAX) {
46 md = TM0MD_SRC_IOCLK_8;
47 rate = MN10300_JCCLK / 8 / HZ;
49 if (rate > TMJCBR_MAX) {
50 md = TM0MD_SRC_IOCLK_32;
51 rate = MN10300_JCCLK / 32 / HZ;
53 BUG_ON(rate > TMJCBR_MAX);
62 TM1MD_SRC_TM0CASCADE << 8 |
64 TM1MD_INIT_COUNTER << 8;
68 TM1MD_SRC_TM0CASCADE << 8 |
70 TM1MD_COUNT_ENABLE << 8;
74 TMJCICR |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
78 static inline void shutdown_jiffies_counter(void)
82 #endif /* !__ASSEMBLY__ */
86 * timestamp counter specifications
89 #define TMTSCBR_MAX 0xffffffff
90 #define TMTSCBC TM45BC
94 static inline void startup_timestamp_counter(void)
96 /* set up timer 4 & 5 cascaded as a 32-bit counter to count real time
97 * - count down from 4Gig-1 to 0 and wrap at IOCLK rate
101 TM4MD = TM4MD_SRC_IOCLK;
102 TM4MD |= TM4MD_INIT_COUNTER;
103 TM4MD &= ~TM4MD_INIT_COUNTER;
106 TM5MD = TM5MD_SRC_TM4CASCADE;
107 TM5MD |= TM5MD_INIT_COUNTER;
108 TM5MD &= ~TM5MD_INIT_COUNTER;
111 TM5MD |= TM5MD_COUNT_ENABLE;
112 TM4MD |= TM4MD_COUNT_ENABLE;
115 static inline void shutdown_timestamp_counter(void)
122 * we use a cascaded pair of 16-bit down-counting timers to count I/O
123 * clock cycles for the purposes of time keeping
125 typedef unsigned long cycles_t;
127 static inline cycles_t read_timestamp_counter(void)
129 return (cycles_t) TMTSCBC;
132 #endif /* !__ASSEMBLY__ */
134 #endif /* _ASM_UNIT_TIMEX_H */