aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel
diff options
context:
space:
mode:
authorMike Frysinger <vapier.adi@gmail.com>2009-01-07 10:14:39 -0500
committerBryan Wu <cooloney@kernel.org>2009-01-07 10:14:39 -0500
commite32f55d9dbffd2ca16e0bb4ea7156b56741b78cd (patch)
treea6f3605022c6ccf3f6a5e649b38364f4b28b139b /arch/blackfin/kernel
parentc250bfb93c046a789989af475ae18d08c61b4cfa (diff)
Blackfin arch: rewrite get_sclk()/get_vco()
rewrite get_sclk()/get_vco() based on the assumption sclk/vco never changes (since today it cannot) Signed-off-by: Mike Frysinger <vapier.adi@gmail.com> Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r--arch/blackfin/kernel/setup.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 20d04a1bc861..b2a811347b65 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -956,17 +956,18 @@ static int __init early_init_clkin_hz(char *buf)
956early_param("clkin_hz=", early_init_clkin_hz); 956early_param("clkin_hz=", early_init_clkin_hz);
957 957
958/* Get the voltage input multiplier */ 958/* Get the voltage input multiplier */
959static u_long cached_vco_pll_ctl, cached_vco;
960static u_long get_vco(void) 959static u_long get_vco(void)
961{ 960{
962 u_long msel; 961 static u_long cached_vco;
962 u_long msel, pll_ctl;
963 963
964 u_long pll_ctl = bfin_read_PLL_CTL(); 964 /* The assumption here is that VCO never changes at runtime.
965 if (pll_ctl == cached_vco_pll_ctl) 965 * If, someday, we support that, then we'll have to change this.
966 */
967 if (cached_vco)
966 return cached_vco; 968 return cached_vco;
967 else
968 cached_vco_pll_ctl = pll_ctl;
969 969
970 pll_ctl = bfin_read_PLL_CTL();
970 msel = (pll_ctl >> 9) & 0x3F; 971 msel = (pll_ctl >> 9) & 0x3F;
971 if (0 == msel) 972 if (0 == msel)
972 msel = 64; 973 msel = 64;
@@ -978,9 +979,9 @@ static u_long get_vco(void)
978} 979}
979 980
980/* Get the Core clock */ 981/* Get the Core clock */
981static u_long cached_cclk_pll_div, cached_cclk;
982u_long get_cclk(void) 982u_long get_cclk(void)
983{ 983{
984 static u_long cached_cclk_pll_div, cached_cclk;
984 u_long csel, ssel; 985 u_long csel, ssel;
985 986
986 if (bfin_read_PLL_STAT() & 0x1) 987 if (bfin_read_PLL_STAT() & 0x1)
@@ -1003,21 +1004,21 @@ u_long get_cclk(void)
1003EXPORT_SYMBOL(get_cclk); 1004EXPORT_SYMBOL(get_cclk);
1004 1005
1005/* Get the System clock */ 1006/* Get the System clock */
1006static u_long cached_sclk_pll_div, cached_sclk;
1007u_long get_sclk(void) 1007u_long get_sclk(void)
1008{ 1008{
1009 static u_long cached_sclk;
1009 u_long ssel; 1010 u_long ssel;
1010 1011
1012 /* The assumption here is that SCLK never changes at runtime.
1013 * If, someday, we support that, then we'll have to change this.
1014 */
1015 if (cached_sclk)
1016 return cached_sclk;
1017
1011 if (bfin_read_PLL_STAT() & 0x1) 1018 if (bfin_read_PLL_STAT() & 0x1)
1012 return get_clkin_hz(); 1019 return get_clkin_hz();
1013 1020
1014 ssel = bfin_read_PLL_DIV(); 1021 ssel = bfin_read_PLL_DIV() & 0xf;
1015 if (ssel == cached_sclk_pll_div)
1016 return cached_sclk;
1017 else
1018 cached_sclk_pll_div = ssel;
1019
1020 ssel &= 0xf;
1021 if (0 == ssel) { 1022 if (0 == ssel) {
1022 printk(KERN_WARNING "Invalid System Clock\n"); 1023 printk(KERN_WARNING "Invalid System Clock\n");
1023 ssel = 1; 1024 ssel = 1;