aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/clkt2xxx_dpllcore.c')
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_dpllcore.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/arch/arm/mach-omap2/clkt2xxx_dpllcore.c b/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
index 0d2f14c2dcce..d8620105c42a 100644
--- a/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
+++ b/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
@@ -28,16 +28,22 @@
28#include "clock.h" 28#include "clock.h"
29#include "clock2xxx.h" 29#include "clock2xxx.h"
30#include "opp2xxx.h" 30#include "opp2xxx.h"
31#include "cm2xxx_3xxx.h" 31#include "cm2xxx.h"
32#include "cm-regbits-24xx.h" 32#include "cm-regbits-24xx.h"
33#include "sdrc.h" 33#include "sdrc.h"
34#include "sram.h" 34#include "sram.h"
35 35
36/* #define DOWN_VARIABLE_DPLL 1 */ /* Experimental */ 36/* #define DOWN_VARIABLE_DPLL 1 */ /* Experimental */
37 37
38/*
39 * dpll_core_ck: pointer to the combined dpll_ck + core_ck on OMAP2xxx
40 * (currently defined as "dpll_ck" in the OMAP2xxx clock tree). Set
41 * during dpll_ck init and used later by omap2xxx_clk_get_core_rate().
42 */
43static struct clk_hw_omap *dpll_core_ck;
44
38/** 45/**
39 * omap2xxx_clk_get_core_rate - return the CORE_CLK rate 46 * omap2xxx_clk_get_core_rate - return the CORE_CLK rate
40 * @clk: pointer to the combined dpll_ck + core_ck (currently "dpll_ck")
41 * 47 *
42 * Returns the CORE_CLK rate. CORE_CLK can have one of three rate 48 * Returns the CORE_CLK rate. CORE_CLK can have one of three rate
43 * sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz 49 * sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz
@@ -45,12 +51,14 @@
45 * struct clk *dpll_ck, which is a composite clock of dpll_ck and 51 * struct clk *dpll_ck, which is a composite clock of dpll_ck and
46 * core_ck. 52 * core_ck.
47 */ 53 */
48unsigned long omap2xxx_clk_get_core_rate(struct clk *clk) 54unsigned long omap2xxx_clk_get_core_rate(void)
49{ 55{
50 long long core_clk; 56 long long core_clk;
51 u32 v; 57 u32 v;
52 58
53 core_clk = omap2_get_dpll_rate(clk); 59 WARN_ON(!dpll_core_ck);
60
61 core_clk = omap2_get_dpll_rate(dpll_core_ck);
54 62
55 v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 63 v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
56 v &= OMAP24XX_CORE_CLK_SRC_MASK; 64 v &= OMAP24XX_CORE_CLK_SRC_MASK;
@@ -96,19 +104,22 @@ static long omap2_dpllcore_round_rate(unsigned long target_rate)
96 104
97} 105}
98 106
99unsigned long omap2_dpllcore_recalc(struct clk *clk) 107unsigned long omap2_dpllcore_recalc(struct clk_hw *hw,
108 unsigned long parent_rate)
100{ 109{
101 return omap2xxx_clk_get_core_rate(clk); 110 return omap2xxx_clk_get_core_rate();
102} 111}
103 112
104int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate) 113int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate,
114 unsigned long parent_rate)
105{ 115{
116 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
106 u32 cur_rate, low, mult, div, valid_rate, done_rate; 117 u32 cur_rate, low, mult, div, valid_rate, done_rate;
107 u32 bypass = 0; 118 u32 bypass = 0;
108 struct prcm_config tmpset; 119 struct prcm_config tmpset;
109 const struct dpll_data *dd; 120 const struct dpll_data *dd;
110 121
111 cur_rate = omap2xxx_clk_get_core_rate(dclk); 122 cur_rate = omap2xxx_clk_get_core_rate();
112 mult = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 123 mult = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
113 mult &= OMAP24XX_CORE_CLK_SRC_MASK; 124 mult &= OMAP24XX_CORE_CLK_SRC_MASK;
114 125
@@ -169,3 +180,19 @@ int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
169 return 0; 180 return 0;
170} 181}
171 182
183/**
184 * omap2xxx_clkt_dpllcore_init - clk init function for dpll_ck
185 * @clk: struct clk *dpll_ck
186 *
187 * Store a local copy of @clk in dpll_core_ck so other code can query
188 * the core rate without having to clk_get(), which can sleep. Must
189 * only be called once. No return value. XXX If the clock
190 * registration process is ever changed such that dpll_ck is no longer
191 * statically defined, this code may need to change to increment some
192 * kind of use count on dpll_ck.
193 */
194void omap2xxx_clkt_dpllcore_init(struct clk_hw *hw)
195{
196 WARN(dpll_core_ck, "dpll_core_ck already set - should never happen");
197 dpll_core_ck = to_clk_hw_omap(hw);
198}