21 #include <linux/kernel.h>
22 #include <linux/sched.h>
36 #include <mach/regs-irq.h>
38 #include <mach/tick.h>
40 #include <plat/clock.h>
43 static unsigned long timer_startval;
44 static unsigned long timer_usec_ticks;
47 #define TICK_MAX (0xffff)
50 #define TIMER_USEC_SHIFT 16
69 static inline unsigned long
70 timer_mask_usec_ticks(
unsigned long scaler,
unsigned long pclk)
72 unsigned long den = pclk / 1000;
82 static inline unsigned long timer_ticks_to_usec(
unsigned long ticks)
86 res = ticks * timer_usec_ticks;
98 static unsigned long s3c2410_gettimeoffset (
void)
106 tdone = timer_startval - tval;
110 if (s3c24xx_ostimer_pending()) {
117 tdone = timer_startval - tval;
120 tdone += timer_startval;
123 return timer_ticks_to_usec(tdone);
131 s3c2410_timer_interrupt(
int irq,
void *
dev_id)
137 static struct irqaction s3c2410_timer_irq = {
138 .name =
"S3C2410 Timer Tick",
140 .handler = s3c2410_timer_interrupt,
143 #define use_tclk1_12() ( \
144 machine_is_bast() || \
145 machine_is_vr1000() || \
146 machine_is_anubis() || \
149 static struct clk *tin;
150 static struct clk *tdiv;
151 static struct clk *timerclk;
159 static void s3c2410_timer_setup (
void)
172 timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
173 tcnt = 12000000 /
HZ;
196 timer_usec_ticks = timer_mask_usec_ticks(6, pclk);
215 printk(
KERN_DEBUG "timer tcon=%08lx, tcnt %04lx, tcfg %08lx,%08lx, usec %08lx\n",
216 tcon, tcnt, tcfg0, tcfg1, timer_usec_ticks);
220 panic(
"setup_timer: HZ is too small, cannot configure timer!");
227 timer_startval = tcnt;
246 static void __init s3c2410_timer_resources(
void)
254 if (IS_ERR(timerclk))
255 panic(
"failed to get clock for system timer");
261 tmpdev.dev.init_name =
"s3c24xx-pwm.4";
262 tin =
clk_get(&tmpdev.dev,
"pwm-tin");
264 panic(
"failed to get pwm-tin clock for system timer");
266 tdiv =
clk_get(&tmpdev.dev,
"pwm-tdiv");
268 panic(
"failed to get pwm-tdiv clock for system timer");
274 static void __init s3c2410_timer_init(
void)
276 s3c2410_timer_resources();
277 s3c2410_timer_setup();
282 .init = s3c2410_timer_init,
283 .offset = s3c2410_gettimeoffset,
284 .resume = s3c2410_timer_setup