aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorSekhar Nori <nsekhar@ti.com>2011-06-14 11:33:20 -0400
committerSekhar Nori <nsekhar@ti.com>2011-07-06 07:18:45 -0400
commit56e580d7783ba49a50ccc1b1f3130e5ed2dc52e7 (patch)
tree89ae7f1de834df5fd7425c40e6a7697d0a696401 /arch/arm
parent0c6fce5eb6a9866674dcf6c26913d0908a119ba3 (diff)
davinci: dm6467/T EVM: fix setting up of reference clock rate
The DM6467 and DM6467T EVMs use different reference clock frequencies. This difference is currently supported by having the SoC code call a public board routine which sets up the reference clock frequency. This does not scale as more boards are added. Instead, use the clk_set_rate() API to setup the reference clock frequency to a different value from the board file. Suggested-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com> Acked-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c17
-rw-r--r--arch/arm/mach-davinci/clock.c38
-rw-r--r--arch/arm/mach-davinci/clock.h2
-rw-r--r--arch/arm/mach-davinci/dm646x.c4
-rw-r--r--arch/arm/mach-davinci/include/mach/dm646x.h2
5 files changed, 49 insertions, 14 deletions
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index f6ac9ba7487..9db9838bd16 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -719,9 +719,15 @@ static void __init cdce_clk_init(void)
719 } 719 }
720} 720}
721 721
722#define DM6467T_EVM_REF_FREQ 33000000
723
722static void __init davinci_map_io(void) 724static void __init davinci_map_io(void)
723{ 725{
724 dm646x_init(); 726 dm646x_init();
727
728 if (machine_is_davinci_dm6467tevm())
729 davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
730
725 cdce_clk_init(); 731 cdce_clk_init();
726} 732}
727 733
@@ -785,17 +791,6 @@ static __init void evm_init(void)
785 soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID; 791 soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
786} 792}
787 793
788#define DM646X_EVM_REF_FREQ 27000000
789#define DM6467T_EVM_REF_FREQ 33000000
790
791void __init dm646x_board_setup_refclk(struct clk *clk)
792{
793 if (machine_is_davinci_dm6467tevm())
794 clk->rate = DM6467T_EVM_REF_FREQ;
795 else
796 clk->rate = DM646X_EVM_REF_FREQ;
797}
798
799MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM") 794MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
800 .boot_params = (0x80000100), 795 .boot_params = (0x80000100),
801 .map_io = davinci_map_io, 796 .map_io = davinci_map_io,
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index e4e3af179f0..ae653194b64 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -368,6 +368,12 @@ static unsigned long clk_leafclk_recalc(struct clk *clk)
368 return clk->parent->rate; 368 return clk->parent->rate;
369} 369}
370 370
371int davinci_simple_set_rate(struct clk *clk, unsigned long rate)
372{
373 clk->rate = rate;
374 return 0;
375}
376
371static unsigned long clk_pllclk_recalc(struct clk *clk) 377static unsigned long clk_pllclk_recalc(struct clk *clk)
372{ 378{
373 u32 ctrl, mult = 1, prediv = 1, postdiv = 1; 379 u32 ctrl, mult = 1, prediv = 1, postdiv = 1;
@@ -506,6 +512,38 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
506} 512}
507EXPORT_SYMBOL(davinci_set_pllrate); 513EXPORT_SYMBOL(davinci_set_pllrate);
508 514
515/**
516 * davinci_set_refclk_rate() - Set the reference clock rate
517 * @rate: The new rate.
518 *
519 * Sets the reference clock rate to a given value. This will most likely
520 * result in the entire clock tree getting updated.
521 *
522 * This is used to support boards which use a reference clock different
523 * than that used by default in <soc>.c file. The reference clock rate
524 * should be updated early in the boot process; ideally soon after the
525 * clock tree has been initialized once with the default reference clock
526 * rate (davinci_common_init()).
527 *
528 * Returns 0 on success, error otherwise.
529 */
530int davinci_set_refclk_rate(unsigned long rate)
531{
532 struct clk *refclk;
533
534 refclk = clk_get(NULL, "ref");
535 if (IS_ERR(refclk)) {
536 pr_err("%s: failed to get reference clock.\n", __func__);
537 return PTR_ERR(refclk);
538 }
539
540 clk_set_rate(refclk, rate);
541
542 clk_put(refclk);
543
544 return 0;
545}
546
509int __init davinci_clk_init(struct clk_lookup *clocks) 547int __init davinci_clk_init(struct clk_lookup *clocks)
510 { 548 {
511 struct clk_lookup *c; 549 struct clk_lookup *c;
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 0dd22031ec6..50b2482e0ba 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -123,6 +123,8 @@ int davinci_clk_init(struct clk_lookup *clocks);
123int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, 123int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
124 unsigned int mult, unsigned int postdiv); 124 unsigned int mult, unsigned int postdiv);
125int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); 125int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
126int davinci_set_refclk_rate(unsigned long rate);
127int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
126 128
127extern struct platform_device davinci_wdt_device; 129extern struct platform_device davinci_wdt_device;
128extern void davinci_watchdog_reset(struct platform_device *); 130extern void davinci_watchdog_reset(struct platform_device *);
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 1e0f809644b..46739c96cd3 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -42,6 +42,7 @@
42/* 42/*
43 * Device specific clocks 43 * Device specific clocks
44 */ 44 */
45#define DM646X_REF_FREQ 27000000
45#define DM646X_AUX_FREQ 24000000 46#define DM646X_AUX_FREQ 24000000
46 47
47static struct pll_data pll1_data = { 48static struct pll_data pll1_data = {
@@ -56,6 +57,8 @@ static struct pll_data pll2_data = {
56 57
57static struct clk ref_clk = { 58static struct clk ref_clk = {
58 .name = "ref_clk", 59 .name = "ref_clk",
60 .rate = DM646X_REF_FREQ,
61 .set_rate = davinci_simple_set_rate,
59}; 62};
60 63
61static struct clk aux_clkin = { 64static struct clk aux_clkin = {
@@ -901,7 +904,6 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)
901 904
902void __init dm646x_init(void) 905void __init dm646x_init(void)
903{ 906{
904 dm646x_board_setup_refclk(&ref_clk);
905 davinci_common_init(&davinci_soc_info_dm646x); 907 davinci_common_init(&davinci_soc_info_dm646x);
906} 908}
907 909
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h
index 7a27f3f1391..2a00fe5ac25 100644
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ b/arch/arm/mach-davinci/include/mach/dm646x.h
@@ -15,7 +15,6 @@
15#include <mach/asp.h> 15#include <mach/asp.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <linux/clk.h>
19#include <linux/davinci_emac.h> 18#include <linux/davinci_emac.h>
20 19
21#define DM646X_EMAC_BASE (0x01C80000) 20#define DM646X_EMAC_BASE (0x01C80000)
@@ -31,7 +30,6 @@
31void __init dm646x_init(void); 30void __init dm646x_init(void);
32void __init dm646x_init_mcasp0(struct snd_platform_data *pdata); 31void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
33void __init dm646x_init_mcasp1(struct snd_platform_data *pdata); 32void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
34void __init dm646x_board_setup_refclk(struct clk *clk);
35int __init dm646x_init_edma(struct edma_rsv_info *rsv); 33int __init dm646x_init_edma(struct edma_rsv_info *rsv);
36 34
37void dm646x_video_init(void); 35void dm646x_video_init(void);