30 static struct clk *tin_event;
31 static struct clk *tin_source;
32 static struct clk *tdiv_event;
33 static struct clk *tdiv_source;
34 static struct clk *timerclk;
36 static unsigned long clock_count_per_tick;
37 static void s5p_timer_resume(
void);
73 static void s5p_time_setup(
enum s5p_timer_mode mode,
unsigned long tcnt)
93 tcon &= ~(0x0f << 12);
98 tcon &= ~(0x0f << 16);
103 tcon &= ~(0x07 << 20);
117 static void s5p_time_start(
enum s5p_timer_mode mode,
bool periodic)
181 static int s5p_set_next_event(
unsigned long cycles,
182 struct clock_event_device *
evt)
184 s5p_time_setup(timer_source.event_id, cycles);
190 static void s5p_set_mode(
enum clock_event_mode mode,
191 struct clock_event_device *
evt)
193 s5p_time_stop(timer_source.event_id);
196 case CLOCK_EVT_MODE_PERIODIC:
197 s5p_time_setup(timer_source.event_id, clock_count_per_tick);
198 s5p_time_start(timer_source.event_id,
PERIODIC);
201 case CLOCK_EVT_MODE_ONESHOT:
204 case CLOCK_EVT_MODE_UNUSED:
205 case CLOCK_EVT_MODE_SHUTDOWN:
208 case CLOCK_EVT_MODE_RESUME:
214 static void s5p_timer_resume(
void)
217 s5p_time_setup(timer_source.event_id, clock_count_per_tick);
218 s5p_time_start(timer_source.event_id,
PERIODIC);
221 s5p_time_setup(timer_source.source_id,
TCNT_MAX);
222 s5p_time_start(timer_source.source_id,
PERIODIC);
231 timer_source.event_id =
event;
232 timer_source.source_id =
source;
235 static struct clock_event_device time_event_device = {
236 .name =
"s5p_event_timer",
237 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
239 .set_next_event = s5p_set_next_event,
240 .set_mode = s5p_set_mode,
245 struct clock_event_device *evt =
dev_id;
247 evt->event_handler(evt);
252 static struct irqaction s5p_clock_event_irq = {
253 .name =
"s5p_time_irq",
255 .handler = s5p_clock_event_isr,
256 .dev_id = &time_event_device,
259 static void __init s5p_clockevent_init(
void)
263 unsigned int irq_number;
275 clock_count_per_tick = clock_rate /
HZ;
277 clockevents_calc_mult_shift(&time_event_device,
279 time_event_device.max_delta_ns =
281 time_event_device.min_delta_ns =
287 irq_number = timer_source.event_id +
IRQ_TIMER0;
288 setup_irq(irq_number, &s5p_clock_event_irq);
291 static void __iomem *s5p_timer_reg(
void)
295 switch (timer_source.source_id) {
300 offset = (timer_source.source_id * 0x0c) + 0x14;
332 static void __init s5p_clocksource_init(
void)
344 s5p_time_setup(timer_source.source_id,
TCNT_MAX);
345 s5p_time_start(timer_source.source_id,
PERIODIC);
351 panic(
"s5p_clocksource_timer: can't register clocksource\n");
354 static void __init s5p_timer_resources(
void)
357 unsigned long event_id = timer_source.event_id;
358 unsigned long source_id = timer_source.source_id;
362 if (IS_ERR(timerclk))
363 panic(
"failed to get timers clock for timer");
367 sprintf(devname,
"s3c24xx-pwm.%lu", event_id);
371 tin_event =
clk_get(&s3c_device_timer[event_id].
dev,
"pwm-tin");
372 if (IS_ERR(tin_event))
373 panic(
"failed to get pwm-tin clock for event timer");
375 tdiv_event =
clk_get(&s3c_device_timer[event_id].
dev,
"pwm-tdiv");
376 if (IS_ERR(tdiv_event))
377 panic(
"failed to get pwm-tdiv clock for event timer");
381 sprintf(devname,
"s3c24xx-pwm.%lu", source_id);
385 tin_source =
clk_get(&s3c_device_timer[source_id].
dev,
"pwm-tin");
386 if (IS_ERR(tin_source))
387 panic(
"failed to get pwm-tin clock for source timer");
389 tdiv_source =
clk_get(&s3c_device_timer[source_id].
dev,
"pwm-tdiv");
390 if (IS_ERR(tdiv_source))
391 panic(
"failed to get pwm-tdiv clock for source timer");
396 static void __init s5p_timer_init(
void)
398 s5p_timer_resources();
399 s5p_clockevent_init();
400 s5p_clocksource_init();
404 .init = s5p_timer_init,