diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-03-07 15:01:28 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-04-25 11:03:46 -0400 |
commit | 6c7b06850c5a1615cc9e660e0d24ce2025bb9bcf (patch) | |
tree | 985229601193226b294602a7a1c19337607d2300 /arch/arm | |
parent | eb92044eb3d59d29c9812e85e3a4bf41f6f38e3a (diff) |
ARM i.MX: prepare for common clock framework
- Add necessary #ifdefs for CONFIG_COMMON_CLOCK
- Add a global spinlock to protect the CCM registers
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-imx/clk.h | 44 | ||||
-rw-r--r-- | arch/arm/plat-mxc/clock.c | 11 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/clock.h | 4 |
3 files changed, 59 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h new file mode 100644 index 000000000000..00f2590e0b38 --- /dev/null +++ b/arch/arm/mach-imx/clk.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __MACH_IMX_CLK_H | ||
2 | #define __MACH_IMX_CLK_H | ||
3 | |||
4 | #include <linux/spinlock.h> | ||
5 | #include <linux/clk-provider.h> | ||
6 | #include <mach/clock.h> | ||
7 | |||
8 | struct clk *imx_clk_pllv1(const char *name, char *parent, | ||
9 | void __iomem *base); | ||
10 | |||
11 | static inline struct clk *imx_clk_fixed(const char *name, int rate) | ||
12 | { | ||
13 | return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate); | ||
14 | } | ||
15 | |||
16 | static inline struct clk *imx_clk_divider(const char *name, const char *parent, | ||
17 | void __iomem *reg, u8 shift, u8 width) | ||
18 | { | ||
19 | return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT, | ||
20 | reg, shift, width, 0, &imx_ccm_lock); | ||
21 | } | ||
22 | |||
23 | static inline struct clk *imx_clk_gate(const char *name, const char *parent, | ||
24 | void __iomem *reg, u8 shift) | ||
25 | { | ||
26 | return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg, | ||
27 | shift, 0, &imx_ccm_lock); | ||
28 | } | ||
29 | |||
30 | static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg, | ||
31 | u8 shift, u8 width, const char **parents, int num_parents) | ||
32 | { | ||
33 | return clk_register_mux(NULL, name, parents, num_parents, 0, reg, shift, | ||
34 | width, 0, &imx_ccm_lock); | ||
35 | } | ||
36 | |||
37 | static inline struct clk *imx_clk_fixed_factor(const char *name, | ||
38 | const char *parent, unsigned int mult, unsigned int div) | ||
39 | { | ||
40 | return clk_register_fixed_factor(NULL, name, parent, | ||
41 | CLK_SET_RATE_PARENT, mult, div); | ||
42 | } | ||
43 | |||
44 | #endif | ||
diff --git a/arch/arm/plat-mxc/clock.c b/arch/arm/plat-mxc/clock.c index 2ed3ab173add..5079787273d2 100644 --- a/arch/arm/plat-mxc/clock.c +++ b/arch/arm/plat-mxc/clock.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <mach/clock.h> | 41 | #include <mach/clock.h> |
42 | #include <mach/hardware.h> | 42 | #include <mach/hardware.h> |
43 | 43 | ||
44 | #ifndef CONFIG_COMMON_CLK | ||
44 | static LIST_HEAD(clocks); | 45 | static LIST_HEAD(clocks); |
45 | static DEFINE_MUTEX(clocks_mutex); | 46 | static DEFINE_MUTEX(clocks_mutex); |
46 | 47 | ||
@@ -200,6 +201,16 @@ struct clk *clk_get_parent(struct clk *clk) | |||
200 | } | 201 | } |
201 | EXPORT_SYMBOL(clk_get_parent); | 202 | EXPORT_SYMBOL(clk_get_parent); |
202 | 203 | ||
204 | #else | ||
205 | |||
206 | /* | ||
207 | * Lock to protect the clock module (ccm) registers. Used | ||
208 | * on all i.MXs | ||
209 | */ | ||
210 | DEFINE_SPINLOCK(imx_ccm_lock); | ||
211 | |||
212 | #endif /* CONFIG_COMMON_CLK */ | ||
213 | |||
203 | /* | 214 | /* |
204 | * Get the resulting clock rate from a PLL register value and the input | 215 | * Get the resulting clock rate from a PLL register value and the input |
205 | * frequency. PLLs with this register layout can at least be found on | 216 | * frequency. PLLs with this register layout can at least be found on |
diff --git a/arch/arm/plat-mxc/include/mach/clock.h b/arch/arm/plat-mxc/include/mach/clock.h index 753a5988d85c..bd940c795cbb 100644 --- a/arch/arm/plat-mxc/include/mach/clock.h +++ b/arch/arm/plat-mxc/include/mach/clock.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | 25 | ||
26 | #ifndef CONFIG_COMMON_CLK | ||
26 | struct module; | 27 | struct module; |
27 | 28 | ||
28 | struct clk { | 29 | struct clk { |
@@ -59,6 +60,9 @@ struct clk { | |||
59 | 60 | ||
60 | int clk_register(struct clk *clk); | 61 | int clk_register(struct clk *clk); |
61 | void clk_unregister(struct clk *clk); | 62 | void clk_unregister(struct clk *clk); |
63 | #endif /* CONFIG_COMMON_CLK */ | ||
64 | |||
65 | extern spinlock_t imx_ccm_lock; | ||
62 | 66 | ||
63 | unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref); | 67 | unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref); |
64 | 68 | ||