[PATCH 06/15] ARM: mxs: Add timer support
Shawn Guo
shawn.gsc at gmail.com
Thu Dec 2 09:44:06 EST 2010
Hi Uwe,
2010/12/1 Uwe Kleine-König <u.kleine-koenig at pengutronix.de>:
> Hello Shawn,
>
[...]
>> +
>> + /* Disable interrupt in timer module */
>> + timrot_irq_disable();
>> +
>> + if (mode != clockevent_mode) {
>> + /* Set event time into far-far future */
>> + __raw_writel(__raw_readl(timer_base +
>> + HW_TIMROT_RUNNING_COUNTn(0)) + 3,
>> + timer_base + HW_TIMROT_MATCH_COUNTn(0));
> I don't know if this is needed, maybe there cannot be a pending event
> when set_mode is called? Thomas?
>
Freescale BSP works well without this. It's probably not needed.
>> +
>> +static struct clocksource clocksource_mxs = {
>> + .name = "mxs_timer",
>> + .rating = 200,
>> + .read = timrot_get_cycles,
>> + .mask = CLOCKSOURCE_MASK(32),
>> + .shift = 10,
>> + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
>> +};
>> +
>> +static int __init mxs_clocksource_init(struct clk *timer_clk)
>> +{
>> + unsigned int c = clk_get_rate(timer_clk);
>> +
>> + if (timrot_is_v1())
>> + clocksource_mxs.mask = CLOCKSOURCE_MASK(16);
> I wonder if a shift of 10 is a bit heavy for a 16 bit timer.
>
I do not understand that. The shift is used in clocksource_hz2mult() as below.
static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
{
/* hz = cyc/(Billion ns)
* mult/2^shift = ns/cyc
* mult = ns/cyc * 2^shift
* mult = 1Billion/hz * 2^shift
* mult = 1000000000 * 2^shift / hz
* mult = (1000000000<<shift) / hz
*/
u64 tmp = ((u64)1000000000) << shift_constant;
tmp += hz/2; /* round for do_div */
do_div(tmp, hz);
return (u32)tmp;
}
The shift is working against the timers frequency (hz). Should hz be
the thing concerned here instead of timer bit width? Since both MX23
and MX28 timer are running at 32K, so shift value 10 is picked here.
--
Regards,
Shawn
More information about the linux-arm-kernel
mailing list