12 #include <linux/time.h>
13 #include <linux/timex.h>
16 #include <linux/types.h>
22 #include <mach/hardware.h>
23 #include <mach/irqs.h>
42 #define U300_TIMER_APP_ROST (0x0000)
43 #define U300_TIMER_APP_ROST_TIMER_RESET (0x00000000)
45 #define U300_TIMER_APP_EOST (0x0004)
46 #define U300_TIMER_APP_EOST_TIMER_ENABLE (0x00000000)
48 #define U300_TIMER_APP_DOST (0x0008)
49 #define U300_TIMER_APP_DOST_TIMER_DISABLE (0x00000000)
51 #define U300_TIMER_APP_SOSTM (0x000c)
52 #define U300_TIMER_APP_SOSTM_MODE_CONTINUOUS (0x00000000)
53 #define U300_TIMER_APP_SOSTM_MODE_ONE_SHOT (0x00000001)
55 #define U300_TIMER_APP_OSTS (0x0010)
56 #define U300_TIMER_APP_OSTS_TIMER_STATE_MASK (0x0000000F)
57 #define U300_TIMER_APP_OSTS_TIMER_STATE_IDLE (0x00000001)
58 #define U300_TIMER_APP_OSTS_TIMER_STATE_ACTIVE (0x00000002)
59 #define U300_TIMER_APP_OSTS_ENABLE_IND (0x00000010)
60 #define U300_TIMER_APP_OSTS_MODE_MASK (0x00000020)
61 #define U300_TIMER_APP_OSTS_MODE_CONTINUOUS (0x00000000)
62 #define U300_TIMER_APP_OSTS_MODE_ONE_SHOT (0x00000020)
63 #define U300_TIMER_APP_OSTS_IRQ_ENABLED_IND (0x00000040)
64 #define U300_TIMER_APP_OSTS_IRQ_PENDING_IND (0x00000080)
66 #define U300_TIMER_APP_OSTCC (0x0014)
68 #define U300_TIMER_APP_OSTTC (0x0018)
70 #define U300_TIMER_APP_OSTIE (0x001c)
71 #define U300_TIMER_APP_OSTIE_IRQ_DISABLE (0x00000000)
72 #define U300_TIMER_APP_OSTIE_IRQ_ENABLE (0x00000001)
74 #define U300_TIMER_APP_OSTIA (0x0020)
75 #define U300_TIMER_APP_OSTIA_IRQ_ACK (0x00000080)
78 #define U300_TIMER_APP_RDDT (0x0040)
79 #define U300_TIMER_APP_RDDT_TIMER_RESET (0x00000000)
81 #define U300_TIMER_APP_EDDT (0x0044)
82 #define U300_TIMER_APP_EDDT_TIMER_ENABLE (0x00000000)
84 #define U300_TIMER_APP_DDDT (0x0048)
85 #define U300_TIMER_APP_DDDT_TIMER_DISABLE (0x00000000)
87 #define U300_TIMER_APP_SDDTM (0x004c)
88 #define U300_TIMER_APP_SDDTM_MODE_CONTINUOUS (0x00000000)
89 #define U300_TIMER_APP_SDDTM_MODE_ONE_SHOT (0x00000001)
91 #define U300_TIMER_APP_DDTS (0x0050)
92 #define U300_TIMER_APP_DDTS_TIMER_STATE_MASK (0x0000000F)
93 #define U300_TIMER_APP_DDTS_TIMER_STATE_IDLE (0x00000001)
94 #define U300_TIMER_APP_DDTS_TIMER_STATE_ACTIVE (0x00000002)
95 #define U300_TIMER_APP_DDTS_ENABLE_IND (0x00000010)
96 #define U300_TIMER_APP_DDTS_MODE_MASK (0x00000020)
97 #define U300_TIMER_APP_DDTS_MODE_CONTINUOUS (0x00000000)
98 #define U300_TIMER_APP_DDTS_MODE_ONE_SHOT (0x00000020)
99 #define U300_TIMER_APP_DDTS_IRQ_ENABLED_IND (0x00000040)
100 #define U300_TIMER_APP_DDTS_IRQ_PENDING_IND (0x00000080)
102 #define U300_TIMER_APP_DDTCC (0x0054)
104 #define U300_TIMER_APP_DDTTC (0x0058)
106 #define U300_TIMER_APP_DDTIE (0x005c)
107 #define U300_TIMER_APP_DDTIE_IRQ_DISABLE (0x00000000)
108 #define U300_TIMER_APP_DDTIE_IRQ_ENABLE (0x00000001)
110 #define U300_TIMER_APP_DDTIA (0x0060)
111 #define U300_TIMER_APP_DDTIA_IRQ_ACK (0x00000080)
114 #define U300_TIMER_APP_RGPT1 (0x0080)
115 #define U300_TIMER_APP_RGPT1_TIMER_RESET (0x00000000)
117 #define U300_TIMER_APP_EGPT1 (0x0084)
118 #define U300_TIMER_APP_EGPT1_TIMER_ENABLE (0x00000000)
120 #define U300_TIMER_APP_DGPT1 (0x0088)
121 #define U300_TIMER_APP_DGPT1_TIMER_DISABLE (0x00000000)
123 #define U300_TIMER_APP_SGPT1M (0x008c)
124 #define U300_TIMER_APP_SGPT1M_MODE_CONTINUOUS (0x00000000)
125 #define U300_TIMER_APP_SGPT1M_MODE_ONE_SHOT (0x00000001)
127 #define U300_TIMER_APP_GPT1S (0x0090)
128 #define U300_TIMER_APP_GPT1S_TIMER_STATE_MASK (0x0000000F)
129 #define U300_TIMER_APP_GPT1S_TIMER_STATE_IDLE (0x00000001)
130 #define U300_TIMER_APP_GPT1S_TIMER_STATE_ACTIVE (0x00000002)
131 #define U300_TIMER_APP_GPT1S_ENABLE_IND (0x00000010)
132 #define U300_TIMER_APP_GPT1S_MODE_MASK (0x00000020)
133 #define U300_TIMER_APP_GPT1S_MODE_CONTINUOUS (0x00000000)
134 #define U300_TIMER_APP_GPT1S_MODE_ONE_SHOT (0x00000020)
135 #define U300_TIMER_APP_GPT1S_IRQ_ENABLED_IND (0x00000040)
136 #define U300_TIMER_APP_GPT1S_IRQ_PENDING_IND (0x00000080)
138 #define U300_TIMER_APP_GPT1CC (0x0094)
140 #define U300_TIMER_APP_GPT1TC (0x0098)
142 #define U300_TIMER_APP_GPT1IE (0x009c)
143 #define U300_TIMER_APP_GPT1IE_IRQ_DISABLE (0x00000000)
144 #define U300_TIMER_APP_GPT1IE_IRQ_ENABLE (0x00000001)
146 #define U300_TIMER_APP_GPT1IA (0x00a0)
147 #define U300_TIMER_APP_GPT1IA_IRQ_ACK (0x00000080)
150 #define U300_TIMER_APP_RGPT2 (0x00c0)
151 #define U300_TIMER_APP_RGPT2_TIMER_RESET (0x00000000)
153 #define U300_TIMER_APP_EGPT2 (0x00c4)
154 #define U300_TIMER_APP_EGPT2_TIMER_ENABLE (0x00000000)
156 #define U300_TIMER_APP_DGPT2 (0x00c8)
157 #define U300_TIMER_APP_DGPT2_TIMER_DISABLE (0x00000000)
159 #define U300_TIMER_APP_SGPT2M (0x00cc)
160 #define U300_TIMER_APP_SGPT2M_MODE_CONTINUOUS (0x00000000)
161 #define U300_TIMER_APP_SGPT2M_MODE_ONE_SHOT (0x00000001)
163 #define U300_TIMER_APP_GPT2S (0x00d0)
164 #define U300_TIMER_APP_GPT2S_TIMER_STATE_MASK (0x0000000F)
165 #define U300_TIMER_APP_GPT2S_TIMER_STATE_IDLE (0x00000001)
166 #define U300_TIMER_APP_GPT2S_TIMER_STATE_ACTIVE (0x00000002)
167 #define U300_TIMER_APP_GPT2S_ENABLE_IND (0x00000010)
168 #define U300_TIMER_APP_GPT2S_MODE_MASK (0x00000020)
169 #define U300_TIMER_APP_GPT2S_MODE_CONTINUOUS (0x00000000)
170 #define U300_TIMER_APP_GPT2S_MODE_ONE_SHOT (0x00000020)
171 #define U300_TIMER_APP_GPT2S_IRQ_ENABLED_IND (0x00000040)
172 #define U300_TIMER_APP_GPT2S_IRQ_PENDING_IND (0x00000080)
174 #define U300_TIMER_APP_GPT2CC (0x00d4)
176 #define U300_TIMER_APP_GPT2TC (0x00d8)
178 #define U300_TIMER_APP_GPT2IE (0x00dc)
179 #define U300_TIMER_APP_GPT2IE_IRQ_DISABLE (0x00000000)
180 #define U300_TIMER_APP_GPT2IE_IRQ_ENABLE (0x00000001)
182 #define U300_TIMER_APP_GPT2IA (0x00e0)
183 #define U300_TIMER_APP_GPT2IA_IRQ_ACK (0x00000080)
186 #define U300_TIMER_APP_CRC (0x100)
187 #define U300_TIMER_APP_CRC_CLOCK_REQUEST_ENABLE (0x00000001)
189 #define TICKS_PER_JIFFY ((CLOCK_TICK_RATE + (HZ/2)) / HZ)
190 #define US_PER_TICK ((1000000 + (HZ/2)) / HZ)
197 static void u300_set_mode(
enum clock_event_mode
mode,
198 struct clock_event_device *
evt)
201 case CLOCK_EVT_MODE_PERIODIC:
227 case CLOCK_EVT_MODE_ONESHOT:
255 case CLOCK_EVT_MODE_UNUSED:
256 case CLOCK_EVT_MODE_SHUTDOWN:
264 case CLOCK_EVT_MODE_RESUME:
278 static int u300_set_next_event(
unsigned long cycles,
279 struct clock_event_device *
evt)
310 static struct clock_event_device clockevent_u300_1mhz = {
313 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
314 .set_next_event = u300_set_next_event,
315 .set_mode = u300_set_mode,
321 struct clock_event_device *
evt = &clockevent_u300_1mhz;
325 evt->event_handler(evt);
329 static struct irqaction u300_timer_irq = {
330 .name =
"U300 Timer Tick",
332 .handler = u300_timer_interrupt,
343 static u32 notrace u300_read_sched_clock(
void)
352 static void __init u300_timer_init(
void)
360 clk_prepare_enable(clk);
405 pr_err(
"timer: failed to initialize U300 clock source\n");
422 .init = u300_timer_init,