diff options
author | Paul Walmsley <paul@pwsan.com> | 2010-01-26 22:13:08 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2010-01-28 20:13:49 -0500 |
commit | 44da0a51032f3d90a441bd80c2efe68532104980 (patch) | |
tree | 25f119597684c1d7ce2a2525d6f3c3c2c0fc4053 /arch | |
parent | 87a1b26c2d31dce62758b78c077ff5a1b5a52ab8 (diff) |
OMAP2xxx clock: move sys_clk code into mach-omap2/clkt2xxx_sys.c
Move the sys_clk clock functions from clock2xxx.c to
mach-omap2/clkt2xxx_sys.c. This is intended to make the clock code
easier to understand, since all of the functions needed to manage the
sys_clk are now located in their own file, rather than being mixed
with other, unrelated functions.
Clock debugging is also now more finely-grained, since the DEBUG
macro can now be defined for the sys_clk clock alone. This
should reduce unnecessary console noise when debugging.
Also, if at some future point the mach-omap2/ directory is split into
OMAP2/3/4 variants, this clkt file can be placed in the mach-omap2xxx/
directory, rather than shared with other chip types that don't use
this clock type.
Thanks to Alexander Shishkin <virtuoso@slind.org> for his comments to
improve the patch description.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Alexander Shishkin <virtuoso@slind.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-omap2/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clkt2xxx_sys.c | 50 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2xxx.c | 30 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2xxx.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2xxx_data.c | 4 |
5 files changed, 55 insertions, 35 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 51178bff698c..7ce5fea7f2bc 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile | |||
@@ -13,7 +13,8 @@ clock-common = clock.o clock_common_data.o \ | |||
13 | clkt_clksel.o | 13 | clkt_clksel.o |
14 | clock-omap2xxx = clkt2xxx_dpllcore.o \ | 14 | clock-omap2xxx = clkt2xxx_dpllcore.o \ |
15 | clkt2xxx_virt_prcm_set.o \ | 15 | clkt2xxx_virt_prcm_set.o \ |
16 | clkt2xxx_apll.o clkt2xxx_osc.o | 16 | clkt2xxx_apll.o clkt2xxx_osc.o \ |
17 | clkt2xxx_sys.o | ||
17 | 18 | ||
18 | obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) $(clock-common) \ | 19 | obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) $(clock-common) \ |
19 | $(clock-omap2xxx) | 20 | $(clock-omap2xxx) |
diff --git a/arch/arm/mach-omap2/clkt2xxx_sys.c b/arch/arm/mach-omap2/clkt2xxx_sys.c new file mode 100644 index 000000000000..822b5a79f457 --- /dev/null +++ b/arch/arm/mach-omap2/clkt2xxx_sys.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * OMAP2xxx sys_clk-specific clock code | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 Texas Instruments, Inc. | ||
5 | * Copyright (C) 2004-2010 Nokia Corporation | ||
6 | * | ||
7 | * Contacts: | ||
8 | * Richard Woodruff <r-woodruff2@ti.com> | ||
9 | * Paul Walmsley | ||
10 | * | ||
11 | * Based on earlier work by Tuukka Tikkanen, Tony Lindgren, | ||
12 | * Gordon McNutt and RidgeRun, Inc. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | #undef DEBUG | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/io.h> | ||
24 | |||
25 | #include <plat/clock.h> | ||
26 | |||
27 | #include "clock.h" | ||
28 | #include "clock2xxx.h" | ||
29 | #include "prm.h" | ||
30 | #include "prm-regbits-24xx.h" | ||
31 | |||
32 | void __iomem *prcm_clksrc_ctrl; | ||
33 | |||
34 | u32 omap2xxx_get_sysclkdiv(void) | ||
35 | { | ||
36 | u32 div; | ||
37 | |||
38 | div = __raw_readl(prcm_clksrc_ctrl); | ||
39 | div &= OMAP_SYSCLKDIV_MASK; | ||
40 | div >>= OMAP_SYSCLKDIV_SHIFT; | ||
41 | |||
42 | return div; | ||
43 | } | ||
44 | |||
45 | unsigned long omap2xxx_sys_clk_recalc(struct clk *clk) | ||
46 | { | ||
47 | return clk->parent->rate / omap2xxx_get_sysclkdiv(); | ||
48 | } | ||
49 | |||
50 | |||
diff --git a/arch/arm/mach-omap2/clock2xxx.c b/arch/arm/mach-omap2/clock2xxx.c index 62c3b022a1e9..b59cb1d2bf55 100644 --- a/arch/arm/mach-omap2/clock2xxx.c +++ b/arch/arm/mach-omap2/clock2xxx.c | |||
@@ -46,8 +46,6 @@ | |||
46 | 46 | ||
47 | struct clk *vclk, *sclk, *dclk; | 47 | struct clk *vclk, *sclk, *dclk; |
48 | 48 | ||
49 | void __iomem *prcm_clksrc_ctrl; | ||
50 | |||
51 | /*------------------------------------------------------------------------- | 49 | /*------------------------------------------------------------------------- |
52 | * Omap24xx specific clock functions | 50 | * Omap24xx specific clock functions |
53 | *-------------------------------------------------------------------------*/ | 51 | *-------------------------------------------------------------------------*/ |
@@ -79,34 +77,6 @@ const struct clkops clkops_omap2430_i2chs_wait = { | |||
79 | .find_companion = omap2_clk_dflt_find_companion, | 77 | .find_companion = omap2_clk_dflt_find_companion, |
80 | }; | 78 | }; |
81 | 79 | ||
82 | #ifdef OLD_CK | ||
83 | /* Recalculate SYST_CLK */ | ||
84 | static void omap2_sys_clk_recalc(struct clk *clk) | ||
85 | { | ||
86 | u32 div = PRCM_CLKSRC_CTRL; | ||
87 | div &= (1 << 7) | (1 << 6); /* Test if ext clk divided by 1 or 2 */ | ||
88 | div >>= clk->rate_offset; | ||
89 | clk->rate = (clk->parent->rate / div); | ||
90 | propagate_rate(clk); | ||
91 | } | ||
92 | #endif /* OLD_CK */ | ||
93 | |||
94 | u32 omap2xxx_get_sysclkdiv(void) | ||
95 | { | ||
96 | u32 div; | ||
97 | |||
98 | div = __raw_readl(prcm_clksrc_ctrl); | ||
99 | div &= OMAP_SYSCLKDIV_MASK; | ||
100 | div >>= OMAP_SYSCLKDIV_SHIFT; | ||
101 | |||
102 | return div; | ||
103 | } | ||
104 | |||
105 | unsigned long omap2_sys_clk_recalc(struct clk *clk) | ||
106 | { | ||
107 | return clk->parent->rate / omap2xxx_get_sysclkdiv(); | ||
108 | } | ||
109 | |||
110 | /* | 80 | /* |
111 | * Set clocks for bypass mode for reboot to work. | 81 | * Set clocks for bypass mode for reboot to work. |
112 | */ | 82 | */ |
diff --git a/arch/arm/mach-omap2/clock2xxx.h b/arch/arm/mach-omap2/clock2xxx.h index 3b0610dbbd37..c14061b2b9f1 100644 --- a/arch/arm/mach-omap2/clock2xxx.h +++ b/arch/arm/mach-omap2/clock2xxx.h | |||
@@ -11,9 +11,8 @@ | |||
11 | unsigned long omap2_table_mpu_recalc(struct clk *clk); | 11 | unsigned long omap2_table_mpu_recalc(struct clk *clk); |
12 | int omap2_select_table_rate(struct clk *clk, unsigned long rate); | 12 | int omap2_select_table_rate(struct clk *clk, unsigned long rate); |
13 | long omap2_round_to_table_rate(struct clk *clk, unsigned long rate); | 13 | long omap2_round_to_table_rate(struct clk *clk, unsigned long rate); |
14 | unsigned long omap2_sys_clk_recalc(struct clk *clk); | 14 | unsigned long omap2xxx_sys_clk_recalc(struct clk *clk); |
15 | unsigned long omap2_osc_clk_recalc(struct clk *clk); | 15 | unsigned long omap2_osc_clk_recalc(struct clk *clk); |
16 | unsigned long omap2_sys_clk_recalc(struct clk *clk); | ||
17 | unsigned long omap2_dpllcore_recalc(struct clk *clk); | 16 | unsigned long omap2_dpllcore_recalc(struct clk *clk); |
18 | int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate); | 17 | int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate); |
19 | unsigned long omap2xxx_clk_get_core_rate(struct clk *clk); | 18 | unsigned long omap2xxx_clk_get_core_rate(struct clk *clk); |
diff --git a/arch/arm/mach-omap2/clock2xxx_data.c b/arch/arm/mach-omap2/clock2xxx_data.c index 402115fa9c12..3a435bb8f029 100644 --- a/arch/arm/mach-omap2/clock2xxx_data.c +++ b/arch/arm/mach-omap2/clock2xxx_data.c | |||
@@ -79,7 +79,7 @@ static struct clk sys_ck = { /* (*12, *13, 19.2, 26, 38.4)MHz */ | |||
79 | .ops = &clkops_null, | 79 | .ops = &clkops_null, |
80 | .parent = &osc_ck, | 80 | .parent = &osc_ck, |
81 | .clkdm_name = "wkup_clkdm", | 81 | .clkdm_name = "wkup_clkdm", |
82 | .recalc = &omap2_sys_clk_recalc, | 82 | .recalc = &omap2xxx_sys_clk_recalc, |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static struct clk alt_ck = { /* Typical 54M or 48M, may not exist */ | 85 | static struct clk alt_ck = { /* Typical 54M or 48M, may not exist */ |
@@ -2264,7 +2264,7 @@ int __init omap2_clk_init(void) | |||
2264 | 2264 | ||
2265 | osc_ck.rate = omap2_osc_clk_recalc(&osc_ck); | 2265 | osc_ck.rate = omap2_osc_clk_recalc(&osc_ck); |
2266 | propagate_rate(&osc_ck); | 2266 | propagate_rate(&osc_ck); |
2267 | sys_ck.rate = omap2_sys_clk_recalc(&sys_ck); | 2267 | sys_ck.rate = omap2xxx_sys_clk_recalc(&sys_ck); |
2268 | propagate_rate(&sys_ck); | 2268 | propagate_rate(&sys_ck); |
2269 | 2269 | ||
2270 | for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++) | 2270 | for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++) |