No subject
Sun Jun 6 12:36:48 EDT 2010
> + =A0 =A0 =A0 struct clk *clk0;
> +
> + =A0 =A0 =A0 clk0 =3D clk_get_sys("mtu0", NULL);
> +
> + =A0 =A0 =A0 clk_enable(clk0);
> +
> + if (clk_get_rate(clk0) > (16 << 20))
> + cr |=3D MTU_CRn_PRESCALE_16;
> + else
> + cr |=3D MTU_CRn_PRESCALE_1;
To here can be removed actually.
We happen to know that this rate is not changing on the
MTU using systems.
And since we know the rate is not going to change...
Just save the rate and prescaler setting in a static local variable
and remove the other clock lookup and divisions.
(You still need to have a struct clk* pointer around for
enable/disable too.)
> (...)
> =A0void __init nmdk_timer_init(void)
> =A0{
> =A0 =A0 =A0 =A0unsigned long rate;
> =A0 =A0 =A0 =A0struct clk *clk0;
> - =A0 =A0 =A0 u32 cr;
>
> + =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0* On MTU block 0: timer0 is used as source,
> + =A0 =A0 =A0 =A0* timer1 is used for events.
> + =A0 =A0 =A0 =A0*/
> =A0 =A0 =A0 =A0clk0 =3D clk_get_sys("mtu0", NULL);
> =A0 =A0 =A0 =A0BUG_ON(IS_ERR(clk0));
>
> - =A0 =A0 =A0 clk_enable(clk0);
> -
> =A0 =A0 =A0 =A0/*
> - =A0 =A0 =A0 =A0* Tick rate is 2.4MHz for Nomadik and 110MHz for ux500:
> + =A0 =A0 =A0 =A0* Tick rate is 2.4MHz for Nomadik and 100 or 133MHz for =
ux500:
> =A0 =A0 =A0 =A0 * use a divide-by-16 counter if it's more than 16MHz
> =A0 =A0 =A0 =A0 */
> - =A0 =A0 =A0 cr =3D MTU_CRn_32BITS;;
> =A0 =A0 =A0 =A0rate =3D clk_get_rate(clk0);
> - =A0 =A0 =A0 if (rate > 16 << 20) {
> + =A0 =A0 =A0 if (rate > (16 << 20))
Whatever it is we're gonna look for check it agains
a #define like
#define PRESCALER_16_LIMIT (1 << 20)
(Or whatever we would come up with in this thread)
And:
if (rate > PRESCALER_16_LIMIT)
.. whatever that may be in the end...
Yours,
Linus Walleij
More information about the linux-arm-kernel
mailing list