]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
davinci: dm6467/T EVM: fix setting up of reference clock rate
authorSekhar Nori <nsekhar@ti.com>
Tue, 14 Jun 2011 15:33:20 +0000 (15:33 +0000)
committerSekhar Nori <nsekhar@ti.com>
Wed, 6 Jul 2011 11:18:45 +0000 (16:48 +0530)
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>
arch/arm/mach-davinci/board-dm646x-evm.c
arch/arm/mach-davinci/clock.c
arch/arm/mach-davinci/clock.h
arch/arm/mach-davinci/dm646x.c
arch/arm/mach-davinci/include/mach/dm646x.h

index f6ac9ba74878066afdfcde05e3630108ff86f6c1..9db9838bd1636b6da5a43fe58194f8024f09e9da 100644 (file)
@@ -719,9 +719,15 @@ static void __init cdce_clk_init(void)
        }
 }
 
+#define DM6467T_EVM_REF_FREQ           33000000
+
 static void __init davinci_map_io(void)
 {
        dm646x_init();
+
+       if (machine_is_davinci_dm6467tevm())
+               davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
+
        cdce_clk_init();
 }
 
@@ -785,17 +791,6 @@ static __init void evm_init(void)
        soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
 }
 
-#define DM646X_EVM_REF_FREQ            27000000
-#define DM6467T_EVM_REF_FREQ           33000000
-
-void __init dm646x_board_setup_refclk(struct clk *clk)
-{
-       if (machine_is_davinci_dm6467tevm())
-               clk->rate = DM6467T_EVM_REF_FREQ;
-       else
-               clk->rate = DM646X_EVM_REF_FREQ;
-}
-
 MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
        .boot_params  = (0x80000100),
        .map_io       = davinci_map_io,
index e4e3af179f0270e0c60698b66ed27eb321023b82..ae653194b64551a4051f2e05e23f823e2cfdb970 100644 (file)
@@ -368,6 +368,12 @@ static unsigned long clk_leafclk_recalc(struct clk *clk)
        return clk->parent->rate;
 }
 
+int davinci_simple_set_rate(struct clk *clk, unsigned long rate)
+{
+       clk->rate = rate;
+       return 0;
+}
+
 static unsigned long clk_pllclk_recalc(struct clk *clk)
 {
        u32 ctrl, mult = 1, prediv = 1, postdiv = 1;
@@ -506,6 +512,38 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
 }
 EXPORT_SYMBOL(davinci_set_pllrate);
 
+/**
+ * davinci_set_refclk_rate() - Set the reference clock rate
+ * @rate:      The new rate.
+ *
+ * Sets the reference clock rate to a given value. This will most likely
+ * result in the entire clock tree getting updated.
+ *
+ * This is used to support boards which use a reference clock different
+ * than that used by default in <soc>.c file. The reference clock rate
+ * should be updated early in the boot process; ideally soon after the
+ * clock tree has been initialized once with the default reference clock
+ * rate (davinci_common_init()).
+ *
+ * Returns 0 on success, error otherwise.
+ */
+int davinci_set_refclk_rate(unsigned long rate)
+{
+       struct clk *refclk;
+
+       refclk = clk_get(NULL, "ref");
+       if (IS_ERR(refclk)) {
+               pr_err("%s: failed to get reference clock.\n", __func__);
+               return PTR_ERR(refclk);
+       }
+
+       clk_set_rate(refclk, rate);
+
+       clk_put(refclk);
+
+       return 0;
+}
+
 int __init davinci_clk_init(struct clk_lookup *clocks)
   {
        struct clk_lookup *c;
index 0dd22031ec6222467a4a3a5ccb0eb27405e1d510..50b2482e0ba23e090e603f86ad64f0592007a886 100644 (file)
@@ -123,6 +123,8 @@ int davinci_clk_init(struct clk_lookup *clocks);
 int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
                                unsigned int mult, unsigned int postdiv);
 int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
+int davinci_set_refclk_rate(unsigned long rate);
+int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
 
 extern struct platform_device davinci_wdt_device;
 extern void davinci_watchdog_reset(struct platform_device *);
index 1e0f809644bbfd1df1dcda646ea968e6f5e71a29..46739c96cd381dbd554dbc3513158a162aad7e0b 100644 (file)
@@ -42,6 +42,7 @@
 /*
  * Device specific clocks
  */
+#define DM646X_REF_FREQ                27000000
 #define DM646X_AUX_FREQ                24000000
 
 static struct pll_data pll1_data = {
@@ -56,6 +57,8 @@ static struct pll_data pll2_data = {
 
 static struct clk ref_clk = {
        .name = "ref_clk",
+       .rate = DM646X_REF_FREQ,
+       .set_rate = davinci_simple_set_rate,
 };
 
 static struct clk aux_clkin = {
@@ -901,7 +904,6 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)
 
 void __init dm646x_init(void)
 {
-       dm646x_board_setup_refclk(&ref_clk);
        davinci_common_init(&davinci_soc_info_dm646x);
 }
 
index 7a27f3f139137258b517d589606041e275f5cf13..2a00fe5ac253dc7a3f810cbeb4d58553bb51ad21 100644 (file)
@@ -15,7 +15,6 @@
 #include <mach/asp.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
-#include <linux/clk.h>
 #include <linux/davinci_emac.h>
 
 #define DM646X_EMAC_BASE               (0x01C80000)
@@ -31,7 +30,6 @@
 void __init dm646x_init(void);
 void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
 void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
-void __init dm646x_board_setup_refclk(struct clk *clk);
 int __init dm646x_init_edma(struct edma_rsv_info *rsv);
 
 void dm646x_video_init(void);