unsigned long flags;
unsigned int rate;
unsigned int tcora;
- struct clk *pclk;
};
static unsigned long timer8_get_counter(struct timer8_priv *p)
static int timer8_enable(struct timer8_priv *p)
{
- p->rate = clk_get_rate(p->pclk) / SCALE;
ctrl_outw(0xffff, p->mapbase + TCORA);
ctrl_outw(0x0000, p->mapbase + _8TCNT);
ctrl_outw(0x0c02, p->mapbase + _8TCR);
static int timer8_start(struct timer8_priv *p)
{
- int ret = 0;
+ int ret;
- if (!(p->flags & FLAG_STARTED))
- ret = timer8_enable(p);
+ if ((p->flags & FLAG_STARTED))
+ return 0;
- if (ret)
- goto out;
- p->flags |= FLAG_STARTED;
+ ret = timer8_enable(p);
+ if (!ret)
+ p->flags |= FLAG_STARTED;
- out:
return ret;
}
}
timer8_priv.mapbase = (unsigned long)base;
- timer8_priv.pclk = clk;
+
+ rate = clk_get_rate(clk) / SCALE;
+ if (!rate) {
+ pr_err("Failed to get rate for the clocksource\n");
+ goto unmap_reg;
+ }
ret = request_irq(irq, timer8_interrupt,
IRQF_TIMER, timer8_priv.ced.name, &timer8_priv);
pr_err("failed to request irq %d for clockevent\n", irq);
goto unmap_reg;
}
- rate = clk_get_rate(clk) / SCALE;
+
clockevents_config_and_register(&timer8_priv.ced, rate, 1, 0x0000ffff);
- return;
+ return;
unmap_reg:
iounmap(base);
free_clk: