Sudhakar Rajashekhara <[EMAIL PROTECTED]> writes:

> Source: Texas Instruments Inc.
> Type: Enhancement
> Signed-off-by: Sudhakar Rajashekhara <[EMAIL PROTECTED]>
> Description:
> Adds the clock related changes for dm6467.
> ---
>  arch/arm/mach-davinci/clock.c        |   66 
> ++++++++++++++++++++++++++++++++--
>  include/asm-arm/arch-davinci/timex.h |   15 +++++++-
>  2 files changed, 77 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
> index 4826fcf..6ba8be0 100644
> --- a/arch/arm/mach-davinci/clock.c
> +++ b/arch/arm/mach-davinci/clock.c
> @@ -31,6 +31,9 @@ static DEFINE_MUTEX(clocks_mutex);
>  static DEFINE_SPINLOCK(clockfw_lock);
>  
>  static unsigned int commonrate;
> +static unsigned int div_by_four;
> +static unsigned int div_by_six;
> +static unsigned int div_by_eight;
>  static unsigned int armrate;
>  static unsigned int fixedrate = 27000000;    /* 27 MHZ */
>  
> @@ -247,6 +250,45 @@ static struct clk davinci_clks[] = {
>               .usecount = 1,
>       }
>  };
> +static struct clk davinci_dm6467_clks[] = {
> +     {
> +             .name = "ARMCLK",
> +             .rate = &armrate,
> +             .lpsc = -1,
> +             .flags = ALWAYS_ENABLED,
> +     },
> +     {
> +             .name = "UART0",
> +             .rate = &fixedrate,
> +             .lpsc = DAVINCI_DM646X_LPSC_UART0,
> +     },
> +     {
> +             .name = "UART1",
> +             .rate = &fixedrate,
> +             .lpsc = DAVINCI_DM646X_LPSC_UART1,
> +     },
> +     {
> +             .name = "UART2",
> +             .rate = &fixedrate,
> +             .lpsc = DAVINCI_DM646X_LPSC_UART2,
> +     },
> +     {
> +             .name = "I2CCLK",
> +             .rate = &div_by_four,
> +             .lpsc = DAVINCI_DM646X_LPSC_I2C,
> +     },
> +     {
> +             .name = "gpio",
> +             .rate = &commonrate,
> +             .lpsc = DAVINCI_DM646X_LPSC_GPIO,
> +     },
> +     {
> +             .name = "AEMIFCLK",
> +             .rate = &div_by_four,
> +             .lpsc = DAVINCI_DM646X_LPSC_AEMIF,
> +             .usecount = 1,
> +     },
> +};
>  
>  #ifdef CONFIG_DAVINCI_RESET_CLOCKS
>  /*
> @@ -275,15 +317,33 @@ late_initcall(clk_disable_unused);
>  int __init davinci_clk_init(void)
>  {
>       struct clk *clkp;
> -     int count = 0;
> +     static struct clk *board_clks;
> +     int count = 0, num_clks;
>       u32 pll_mult;
>  
>       pll_mult = davinci_readl(DAVINCI_PLL_CNTRL0_BASE + PLLM);
>       commonrate = ((pll_mult + 1) * 27000000) / 6;
>       armrate = ((pll_mult + 1) * 27000000) / 2;
>  
> -     for (clkp = davinci_clks; count < ARRAY_SIZE(davinci_clks);
> -          count++, clkp++) {
> +     if (cpu_is_davinci_dm6467()) {
> +             fixedrate = 24000000;
> +             div_by_four = ((pll_mult + 1) * 27000000) / 4;
> +             div_by_six = ((pll_mult + 1) * 27000000) / 6;
> +             div_by_eight = ((pll_mult + 1) * 27000000) / 8;
> +             armrate = ((pll_mult + 1) * 27000000) / 2;
> +
> +             board_clks = davinci_dm6467_clks;
> +             num_clks = ARRAY_SIZE(davinci_dm6467_clks);
> +     } else {
> +             fixedrate = 27000000;
> +             armrate = (pll_mult + 1) * (fixedrate / 2);
> +             commonrate = armrate / 3;
> +
> +             board_clks = davinci_clks;
> +             num_clks = ARRAY_SIZE(davinci_clks);
> +     }
> +
> +     for (clkp = board_clks; count < num_clks; count++, clkp++) {
>               clk_register(clkp);

Could you cleanup the use of 27000000 to use the #defines.  It's not
exactly clear why 27MHz is used for all the variants here.

>               /* Turn on clocks that have been enabled in the
> diff --git a/include/asm-arm/arch-davinci/timex.h 
> b/include/asm-arm/arch-davinci/timex.h
> index e4ec97f..1f69259 100644
> --- a/include/asm-arm/arch-davinci/timex.h
> +++ b/include/asm-arm/arch-davinci/timex.h
> @@ -11,7 +11,20 @@
>  #ifndef __ASM_ARCH_TIMEX_H
>  #define __ASM_ARCH_TIMEX_H
>  
> +#include <asm/arch/cpu.h>
> +
>  /* The source frequency for the timers is the 27MHz clock */
> -#define CLOCK_TICK_RATE              27000000
> +#ifdef CONFIG_MACH_DAVINCI_EVM
> +#define CLOCK_TICK_RATE                 24000000
> +#else
> +#define CLOCK_TICK_RATE                 148500000
> +#endif

I think it's time to get rid of this static CLOCK_TICK_RATE.  I don't
think this is used in generic code anymore.  Then, mach-davinci/time.c
can just be cleaned up to use DAVINCI_CLOCK_TICK_RATE.

> +#define DM644X_CLOCK_TICK_RATE               27000000
> +#define DM646X_CLOCK_TICK_RATE               148500000
> +#define DM355_CLOCK_TICK_RATE                24000000
> +
> +#define DAVINCI_CLOCK_TICK_RATE ((cpu_is_davinci_dm6467()) ?         \
> +             DM646X_CLOCK_TICK_RATE : ((cpu_is_davinci_dm644x()) ?   \
> +             DM644X_CLOCK_TICK_RATE : DM355_CLOCK_TICK_RATE))
>  
>  #endif                               /* __ASM_ARCH_TIMEX_H__ */
> -- 
> 1.5.4.1
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> [email protected]
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to